From 54db504ef43c2245d200ed0b9e27d55da8f41ce5 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 4 Jun 2024 22:34:55 +0200 Subject: [PATCH 01/75] refactor: better typing for handleSnapRequest --- ui/store/actions.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ui/store/actions.ts b/ui/store/actions.ts index dfdae2ddb02f..63281643c970 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -10,7 +10,7 @@ import { capitalize, isEqual } from 'lodash'; import { ThunkAction } from 'redux-thunk'; import { Action, AnyAction } from 'redux'; import { ethErrors, serializeError } from 'eth-rpc-errors'; -import { Hex, Json } from '@metamask/utils'; +import { Hex, Json, JsonRpcRequest } from '@metamask/utils'; import { AssetsContractController, BalanceMap, @@ -1242,15 +1242,8 @@ export async function handleSnapRequest(args: { snapId: string; origin: string; handler: string; - request: { - id?: string; - jsonrpc: '2.0'; - method: string; - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - params?: Record; - }; -}): Promise { + request: JsonRpcRequest; +}): Promise { return submitRequestToBackground('handleSnapRequest', [args]); } From 448b28e3df92d518a4ba1cb6635240ff41edf4ad Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 4 Jun 2024 22:35:40 +0200 Subject: [PATCH 02/75] feat(btc): add CreateBtcAccount component --- app/_locales/en/messages.json | 5 +- .../lib/snap-keyring/bitcoin-manager-snap.ts | 21 +++++++ shared/constants/bitcoin-manager-snap.ts | 8 +++ .../account-list-menu/account-list-menu.js | 63 +++++++++++++++++-- .../create-btc-account.stories.js | 10 +++ .../create-btc-account.test.tsx | 57 +++++++++++++++++ .../create-btc-account/create-btc-account.tsx | 55 ++++++++++++++++ .../multichain/create-btc-account/index.ts | 1 + ui/components/multichain/index.js | 1 + ui/pages/home/home.container.js | 2 + 10 files changed, 216 insertions(+), 7 deletions(-) create mode 100644 app/scripts/lib/snap-keyring/bitcoin-manager-snap.ts create mode 100644 shared/constants/bitcoin-manager-snap.ts create mode 100644 ui/components/multichain/create-btc-account/create-btc-account.stories.js create mode 100644 ui/components/multichain/create-btc-account/create-btc-account.test.tsx create mode 100644 ui/components/multichain/create-btc-account/create-btc-account.tsx create mode 100644 ui/components/multichain/create-btc-account/index.ts diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index b3ee9ef98b53..34d576d8e2db 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -278,7 +278,10 @@ "description": "$1 is Learn more link" }, "addNewAccount": { - "message": "Add a new account" + "message": "Add a new Ethereum account" + }, + "addNewBitcoinAccount": { + "message": "Add a new Bitcoin account" }, "addNewToken": { "message": "Add new token" diff --git a/app/scripts/lib/snap-keyring/bitcoin-manager-snap.ts b/app/scripts/lib/snap-keyring/bitcoin-manager-snap.ts new file mode 100644 index 000000000000..9ce906f4a368 --- /dev/null +++ b/app/scripts/lib/snap-keyring/bitcoin-manager-snap.ts @@ -0,0 +1,21 @@ +import { SnapId } from '@metamask/snaps-sdk'; +import { Sender } from '@metamask/keyring-api'; +import { HandlerType } from '@metamask/snaps-utils'; +import { Json, JsonRpcRequest } from '@metamask/utils'; +import { handleSnapRequest } from '../../../../ui/store/actions'; + +export const BITCOIN_MANAGER_SNAP_ID: SnapId = + 'npm:@consensys/bitcoin-manager-snap' as SnapId; +// Local snap: +// 'local:http://localhost:8080' as SnapId; + +export class BitcoinManagerSnapSender implements Sender { + send = async (request: JsonRpcRequest): Promise => { + return (await handleSnapRequest({ + origin: 'metamask', + snapId: BITCOIN_MANAGER_SNAP_ID, + handler: HandlerType.OnKeyringRequest, + request, + })) as Json; + }; +} diff --git a/shared/constants/bitcoin-manager-snap.ts b/shared/constants/bitcoin-manager-snap.ts new file mode 100644 index 000000000000..821f54ae6ea0 --- /dev/null +++ b/shared/constants/bitcoin-manager-snap.ts @@ -0,0 +1,8 @@ +import { SnapId } from '@metamask/snaps-sdk'; + +export const BITCOIN_MANAGER_SNAP_ID: SnapId = + 'local:http://localhost:8080' as SnapId; + +// FIXME: This one should probably somewhere else with other CAIP-2 chain ID identifiers! +export const BITCOIN_MANAGER_SCOPE_MAINNET = + 'bip122:000000000019d6689c085ae165831e93'; diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index 8c909e72da46..91807d53ba1a 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -22,6 +22,7 @@ import { CreateEthAccount, ImportAccount, AccountListItemMenuTypes, + CreateBtcAccount, } from '..'; import { AlignItems, @@ -68,10 +69,32 @@ const ACTION_MODES = { MENU: 'menu', // Displays the add account form controls ADD: 'add', + // Displays the add account form controls (for bitcoin account) + ADD_BITCOIN: 'add-bitcoin', // Displays the import account form controls IMPORT: 'import', }; +/** + * Gets the title for a given action mode. + * + * @param t - Function to translate text. + * @param actionMode - An action mode. + * @returns The title for this action mode. + */ +export const getActionTitle = (t, actionMode) => { + switch (actionMode) { + case ACTION_MODES.ADD: + case ACTION_MODES.ADD_BITCOIN: + case ACTION_MODES.MENU: + return t('addAccount'); + case ACTION_MODES.IMPORT: + return t('importAccount'); + default: + return t('selectAnAccount'); + } +}; + /** * Merges ordered accounts with balances with each corresponding account data from internal accounts * @@ -136,12 +159,7 @@ export const AccountListMenu = ({ } searchResults = mergeAccounts(searchResults, accounts); - let title = t('selectAnAccount'); - if (actionMode === ACTION_MODES.ADD || actionMode === ACTION_MODES.MENU) { - title = t('addAccount'); - } else if (actionMode === ACTION_MODES.IMPORT) { - title = t('importAccount'); - } + const title = getActionTitle(t, actionMode); let onBack = null; if (actionMode !== ACTION_MODES.LIST) { @@ -180,6 +198,19 @@ export const AccountListMenu = ({ /> ) : null} + {actionMode === ACTION_MODES.ADD_BITCOIN ? ( + + { + if (confirmed) { + onClose(); + } else { + setActionMode(ACTION_MODES.LIST); + } + }} + /> + + ) : null} {actionMode === ACTION_MODES.IMPORT ? ( + + { + trackEvent({ + category: MetaMetricsEventCategory.Navigation, + event: MetaMetricsEventName.AccountAddSelected, + properties: { + account_type: MetaMetricsEventAccountType.Default, + location: 'Main Menu', + }, + }); + setActionMode(ACTION_MODES.ADD_BITCOIN); + }} + data-testid="multichain-account-menu-popover-add-account" + > + {t('addNewBitcoinAccount')} + + ; +DefaultStory.storyName = 'Default'; diff --git a/ui/components/multichain/create-btc-account/create-btc-account.test.tsx b/ui/components/multichain/create-btc-account/create-btc-account.test.tsx new file mode 100644 index 000000000000..75fe1dbac1fc --- /dev/null +++ b/ui/components/multichain/create-btc-account/create-btc-account.test.tsx @@ -0,0 +1,57 @@ +/* eslint-disable jest/require-top-level-describe */ +import React from 'react'; +import { fireEvent, renderWithProvider } from '../../../../test/jest'; +import configureStore from '../../../store/store'; +import mockState from '../../../../test/data/mock-state.json'; +import { CreateBtcAccount } from '.'; + +const render = (props = { onActionComplete: jest.fn() }) => { + const store = configureStore(mockState); + return renderWithProvider(, store); +}; + +const ACCOUNT_NAME = 'Bitcoin Account'; + +describe('CreateBtcAccount', () => { + afterEach(() => { + jest.clearAllMocks(); + }); + + it('displays account name input and suggests name', () => { + const { getByPlaceholderText } = render(); + + expect(getByPlaceholderText(ACCOUNT_NAME)).toBeInTheDocument(); + }); + + it('fires onActionComplete when clicked', async () => { + const onActionComplete = jest.fn(); + const { getByText, getByPlaceholderText } = render({ onActionComplete }); + + const input = getByPlaceholderText(ACCOUNT_NAME); + const newAccountName = 'New Account Name'; + + fireEvent.change(input, { + target: { value: newAccountName }, + }); + fireEvent.click(getByText('Create')); + + // TODO: Add logic to rename account + }); + + it(`doesn't allow duplicate account names`, async () => { + const { getByText, getByPlaceholderText } = render(); + + const input = getByPlaceholderText(ACCOUNT_NAME); + const usedAccountName = + mockState.metamask.internalAccounts.accounts[ + '07c2cfec-36c9-46c4-8115-3836d3ac9047' + ].metadata.name; + + fireEvent.change(input, { + target: { value: usedAccountName }, + }); + + const submitButton = getByText('Create'); + expect(submitButton).toHaveAttribute('disabled'); + }); +}); diff --git a/ui/components/multichain/create-btc-account/create-btc-account.tsx b/ui/components/multichain/create-btc-account/create-btc-account.tsx new file mode 100644 index 000000000000..386487d43ccd --- /dev/null +++ b/ui/components/multichain/create-btc-account/create-btc-account.tsx @@ -0,0 +1,55 @@ +import React from 'react'; +import { InternalAccount, KeyringClient } from '@metamask/keyring-api'; +import { useDispatch } from 'react-redux'; +import { CreateAccount } from '..'; +import { MultichainNetworks } from '../../../../shared/constants/multichain/networks'; +import { BitcoinManagerSnapSender } from '../../../../app/scripts/lib/snap-keyring/bitcoin-manager-snap'; +import { setAccountLabel } from '../../../store/actions'; + +type CreateBtcAccountOptions = { + /** + * Callback called once the account has been created + */ + onActionComplete: (completed: boolean) => Promise; +}; + +export const CreateBtcAccount = ({ + onActionComplete, +}: CreateBtcAccountOptions) => { + const dispatch = useDispatch(); + + const onCreateAccount = async (name: string) => { + // We finish the current action to close the popup before starting the account creation. + // + // NOTE: We asssume that at this stage, name validation has already been validated so we + // can safely proceed with the account Snap flow. + await onActionComplete(true); + + // Trigger the Snap account creation flow + const client = new KeyringClient(new BitcoinManagerSnapSender()); + const account = await client.createAccount({ + scope: MultichainNetworks.BITCOIN, + }); + + // TODO: Use the new Snap account creation flow that also include account renaming + // For now, we just use the AccountsController to rename the account after being created + if (name) { + dispatch(setAccountLabel(account.address, name)); + } + + // NOTE: If the renaming part of this flow fail, the account might still be created, but it + // will be named according the Snap keyring naming logic (Snap Account N). + }; + + const getNextAvailableAccountName = async (_accounts: InternalAccount[]) => { + return 'Bitcoin Account'; + }; + + return ( + + ); +}; diff --git a/ui/components/multichain/create-btc-account/index.ts b/ui/components/multichain/create-btc-account/index.ts new file mode 100644 index 000000000000..99f761103277 --- /dev/null +++ b/ui/components/multichain/create-btc-account/index.ts @@ -0,0 +1 @@ +export { CreateBtcAccount } from './create-btc-account'; diff --git a/ui/components/multichain/index.js b/ui/components/multichain/index.js index 4f4ca9468bac..2c606081c861 100644 --- a/ui/components/multichain/index.js +++ b/ui/components/multichain/index.js @@ -18,6 +18,7 @@ export { ProductTour } from './product-tour-popover'; export { AccountDetails } from './account-details'; export { CreateAccount } from './create-account'; export { CreateEthAccount } from './create-eth-account'; +export { CreateBtcAccount } from './create-btc-account'; export { ConnectedAccountsMenu } from './connected-accounts-menu'; export { ImportAccount } from './import-account'; export { ImportNftsModal } from './import-nfts-modal'; diff --git a/ui/pages/home/home.container.js b/ui/pages/home/home.container.js index 07cfcbdff912..2ecda44ab56e 100644 --- a/ui/pages/home/home.container.js +++ b/ui/pages/home/home.container.js @@ -157,6 +157,8 @@ const mapStateToProps = (state) => { const hasAllowedPopupRedirectApprovals = hasPendingApprovals(state, [ ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) + SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.confirmAccountCreation, + SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.confirmAccountRemoval, SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showSnapAccountRedirect, ///: END:ONLY_INCLUDE_IF ]); From ab68a06ab630c92d21715f6d64b13af21b410a7b Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 11:15:53 +0200 Subject: [PATCH 03/75] feat(btc): add bitcoin-amanger-snap@1.0.4-rc4 as a preinstalled snap --- .../bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json | 1 + app/scripts/snaps/preinstalled-snaps.ts | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json diff --git a/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json b/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json new file mode 100644 index 000000000000..238392b18ab7 --- /dev/null +++ b/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json @@ -0,0 +1 @@ +{"snapId":"npm:@consensys/bitcoin-manager-snap","manifest":{"version":"0.1.4-rc4","description":"A MetaMask snap to manage Bitcoin","proposedName":"Bitcoin Manager","repository":{"type":"git","url":"https://github.com/MetaMask/bitcoin.git"},"source":{"shasum":"QOQ8JIPH6mEZUppVP94GxVdmReCCNGTwwl2wAnLLQaI=","location":{"npm":{"filePath":"dist/bundle.js","iconPath":"images/icon.svg","packageName":"@consensys/bitcoin-manager-snap","registry":"https://registry.npmjs.org/"}}},"initialConnections":{"http://localhost:3000":{},"https://ramps-dev.portfolio.metamask.io":{},"https://portfolio.metamask.io":{},"https://portfolio-builds.metafi-dev.codefi.network":{},"https://dev.portfolio.metamask.io":{}},"initialPermissions":{"endowment:rpc":{"dapps":true,"snaps":false},"endowment:keyring":{"allowedOrigins":["http://localhost:3000","https://ramps-dev.portfolio.metamask.io","https://portfolio.metamask.io","https://portfolio-builds.metafi-dev.codefi.network","https://dev.portfolio.metamask.io"]},"snap_getBip32Entropy":[{"path":["m","84'","0'"],"curve":"secp256k1"},{"path":["m","84'","1'"],"curve":"secp256k1"}],"endowment:network-access":{},"snap_manageAccounts":{},"snap_manageState":{},"snap_dialog":{}},"manifestVersion":"0.1"},"files":[{"path":"images/icon.svg","value":"\n\n\n\n\n\n\n\n\n\n"},{"path":"dist/bundle.js","value":"(()=>{var t={242:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer,i=r(4261),o=r(4347),s=r(7651);var a,c,u=(a=i,c=Object.create(null),a&&Object.keys(a).forEach((function(t){if(\"default\"!==t){var e=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(c,t,e.get?e:{enumerable:!0,get:function(){return a[t]}})}})),c.default=a,Object.freeze(c));const f=\"Expected Private\",h=\"Expected Point\",l=\"Expected Tweak\",p=\"Expected Signature\",d=\"Expected Extra Data (32 bytes)\",y=\"Expected Scalar\";u.utils.hmacSha256Sync=(t,...e)=>o.hmac(s.sha256,t,u.utils.concatBytes(...e)),u.utils.sha256Sync=(...t)=>s.sha256(u.utils.concatBytes(...t));const g=u.utils._normalizePrivateKey,b=32,w=32,m=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),v=32,E=new Uint8Array(32),_=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function S(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]=0)}function T(t){return t instanceof Uint8Array&&64===t.length&&S(t.subarray(0,32),m)<0&&S(t.subarray(32,64),m)<0}function x(t){return t instanceof Uint8Array&&64===t.length&&S(t.subarray(0,32),_)<0}function O(t){return t instanceof Uint8Array&&t.length===b}function k(t){return void 0===t||t instanceof Uint8Array&&t.length===v}function P(t){if(\"string\"!=typeof t)throw new TypeError(\"hexToNumber: expected string, got \"+typeof t);return BigInt(`0x${t}`)}function R(t){let e;if(\"bigint\"==typeof t)e=t;else if(\"number\"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if(\"string\"==typeof t){if(64!==t.length)throw new Error(\"Expected 32 bytes of private scalar\");e=P(t)}else{if(!(t instanceof Uint8Array))throw new TypeError(\"Expected valid private scalar\");if(32!==t.length)throw new Error(\"Expected 32 bytes of private scalar\");r=t,e=P(u.utils.bytesToHex(r))}var r;if(e<0)throw new Error(\"Expected private scalar >= 0\");return e}const B=(t,e,r)=>{const n=u.Point.fromHex(t),i=R(e),o=u.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error(\"Tweaked point at infinity\");return o.toRawBytes(r)};function C(t,e){return void 0===t?void 0===e||j(e):!!t}function N(t){try{return t()}catch(t){return null}}function L(t,e){if(32===t.length!==e)return!1;try{return!!u.Point.fromHex(t)}catch(t){return!1}}function U(t){return L(t,!1)}function j(t){return L(t,!1)&&33===t.length}function M(t){return u.utils.isValidPrivateKey(t)}function H(t){return L(t,!0)}function F(t){if(!U(t))throw new Error(h);return t.slice(1,33)}function D(t,e){if(!M(t))throw new Error(f);return N((()=>u.getPublicKey(t,C(e))))}e.isPoint=U,e.isPointCompressed=j,e.isPrivate=M,e.isXOnlyPoint=H,e.pointAdd=function(t,e,r){if(!U(t)||!U(e))throw new Error(h);return N((()=>{const n=u.Point.fromHex(t),i=u.Point.fromHex(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(C(r,t))}))},e.pointAddScalar=function(t,e,r){if(!U(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>B(t,e,C(r,t))))},e.pointCompress=function(t,e){if(!U(t))throw new Error(h);return u.Point.fromHex(t).toRawBytes(C(e,t))},e.pointFromScalar=D,e.pointMultiply=function(t,e,r){if(!U(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>((t,e,r)=>{const n=u.Point.fromHex(t),i=\"string\"==typeof e?e:u.utils.bytesToHex(e),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)})(t,e,C(r,t))))},e.privateAdd=function(t,e){if(!1===M(t))throw new Error(f);if(!1===I(e))throw new Error(l);return N((()=>((t,e)=>{const r=g(t),n=R(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r+n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.privateNegate=function(t){if(!1===M(t))throw new Error(f);return(t=>{const e=g(t),r=u.utils._bigintTo32Bytes(u.CURVE.n-e);return u.utils.isValidPrivateKey(r)?r:null})(t)},e.privateSub=function(t,e){if(!1===M(t))throw new Error(f);if(!1===I(e))throw new Error(l);return N((()=>((t,e)=>{const r=g(t),n=R(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r-n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.recover=function(t,e,r,n){if(!O(t))throw new Error(\"Expected Hash\");if(!T(e)||!function(t){return!(A(t.subarray(0,32))||A(t.subarray(32,64)))}(e))throw new Error(p);if(2&r&&!x(e))throw new Error(\"Bad Recovery Id\");if(!H(e.subarray(0,32)))throw new Error(p);return u.recoverPublicKey(t,e,r,C(n))},e.sign=function(t,e,r){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);return u.signSync(t,e,{der:!1,extraEntropy:r})},e.signRecoverable=function(t,e,r){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);const[n,i]=u.signSync(t,e,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}},e.signSchnorr=function(t,e,r=n.alloc(32,0)){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);return u.schnorr.signSync(t,e,r)},e.verify=function(t,e,r,n){if(!U(e))throw new Error(h);if(!T(r))throw new Error(p);if(!O(t))throw new Error(y);return u.verify(r,t,e,{strict:n})},e.verifySchnorr=function(t,e,r){if(!H(e))throw new Error(h);if(!T(r))throw new Error(p);if(!O(t))throw new Error(y);return u.schnorr.verifySync(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!H(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>{const r=B(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=F,e.xOnlyPointFromScalar=function(t){if(!M(t))throw new Error(f);return F(D(t))}},4857:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(4857),i=r(9019);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},4347:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(4857),i=r(9019);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),\"function\"!=typeof this.iHash.update)throw new Error(\"Expected instance of class which extends utils.Hash\");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;tnew o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},7651:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(8822),i=r(9019),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},9019:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(4605),i=r(4857);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},8460:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function i(t,...e){if(!((r=t)instanceof Uint8Array||null!=r&&\"object\"==typeof r&&\"Uint8Array\"===r.constructor.name))throw new Error(\"Expected Uint8Array\");var r;if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function o(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function a(t,e){i(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.add=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=e.split=e.fromBig=void 0;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;oBigInt(t>>>0)<>>0);e.toBig=s;const a=(t,e,r)=>t>>>r;e.shrSH=a;const c=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=c;const u=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=u;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const h=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=h;const l=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=l;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<>>32-r;e.rotlSH=y;const g=(t,e,r)=>e<>>32-r;e.rotlSL=g;const b=(t,e,r)=>e<>>64-r;e.rotlBH=b;const w=(t,e,r)=>t<>>64-r;function m(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w,e.add=m;const v=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=v;const E=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=E;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const A=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=A;const I=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=I;const T={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:h,rotrBL:l,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:g,rotlBH:b,rotlBL:w,add:m,add3L:v,add3H:E,add4L:_,add4H:S,add5H:I,add5L:A};e.default=T},6910:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},448:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.shake256=e.shake128=e.keccak_512=e.keccak_384=e.keccak_256=e.keccak_224=e.sha3_512=e.sha3_384=e.sha3_256=e.sha3_224=e.Keccak=e.keccakP=void 0;const n=r(8460),i=r(8081),o=r(9074),[s,a,c]=[[],[],[]],u=BigInt(0),f=BigInt(1),h=BigInt(2),l=BigInt(7),p=BigInt(256),d=BigInt(113);for(let t=0,e=f,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],s.push(2*(5*n+r)),a.push((t+1)*(t+2)/2%64);let i=u;for(let t=0;t<7;t++)e=(e<>l)*d)%p,e&h&&(i^=f<<(f<r>32?(0,i.rotlBH)(t,e,r):(0,i.rotlSH)(t,e,r),w=(t,e,r)=>r>32?(0,i.rotlBL)(t,e,r):(0,i.rotlSL)(t,e,r);function m(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,i=(e+2)%10,o=r[i],s=r[i+1],a=b(o,s,1)^r[n],c=w(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=c}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=a[r],o=b(e,i,n),c=w(e,i,n),u=s[r];e=t[u],i=t[u+1],t[u]=o,t[u+1]=c}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=y[n],t[1]^=g[n]}r.fill(0)}e.keccakP=m;class v extends o.Hash{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,n.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error(\"Sha3 supports only keccak-f1600 function\");this.state=new Uint8Array(200),this.state32=(0,o.u32)(this.state)}keccak(){m(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){(0,n.exists)(this);const{blockLen:e,state:r}=this,i=(t=(0,o.toBytes)(t)).length;for(let n=0;n=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error(\"XOF is not possible for this instance\");return this.writeInto(t)}xof(t){return(0,n.number)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,n.output)(t,this),this.finished)throw new Error(\"digest() was already called\");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return t||(t=new v(e,r,n,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=o,t.destroyed=this.destroyed,t}}e.Keccak=v;const E=(t,e,r)=>(0,o.wrapConstructor)((()=>new v(e,t,r)));e.sha3_224=E(6,144,28),e.sha3_256=E(6,136,32),e.sha3_384=E(6,104,48),e.sha3_512=E(6,72,64),e.keccak_224=E(1,144,28),e.keccak_256=E(1,136,32),e.keccak_384=E(1,104,48),e.keccak_512=E(1,72,64);const _=(t,e,r)=>(0,o.wrapXOFConstructorWithOpts)(((n={})=>new v(e,t,void 0===n.dkLen?r:n.dkLen,!0)));e.shake128=_(31,168,16),e.shake256=_(31,136,32)},9074:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const n=r(6910);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error(\"Non little-endian hardware is not supported\");const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){if(!i(t))throw new Error(\"Uint8Array expected\");let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},4261:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const n=r(2028),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),c=BigInt(8),u=Object.freeze({a:i,b:BigInt(7),P:BigInt(\"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\"),n:BigInt(\"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"),h:o,Gx:BigInt(\"55066263022277343669578718895168534326250603453777594175500187360389116729240\"),Gy:BigInt(\"32670510020758816978083085130507043184471273380659243275938904335757337482424\"),beta:BigInt(\"0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee\")});e.CURVE=u;const f=(t,e)=>(t+e/s)/e,h={beta:BigInt(\"0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee\"),splitScalar(t){const{n:e}=u,r=BigInt(\"0x3086d221a7d46bcde86c90e49284eb15\"),n=-o*BigInt(\"0xe4437ed6010e88286f547fa90abfe4c3\"),i=BigInt(\"0x114ca50f7a8e2f3f657c1108d9d44cfd8\"),s=r,a=BigInt(\"0x100000000000000000000000000000000\"),c=f(s*t,e),h=f(-n*t,e);let l=H(t-c*r-h*i,e),p=H(-c*n-h*s,e);const d=l>a,y=p>a;if(d&&(l=e-l),y&&(p=e-p),l>a||p>a)throw new Error(\"splitScalarEndo: Endomorphism failed, k=\"+t);return{k1neg:d,k1:l,k2neg:y,k2:p}}},l=32,p=32,d=l+1,y=2*l+1;function g(t){const{a:e,b:r}=u,n=H(t*t),i=H(n*t);return H(i+e*t+r)}const b=u.a===i;class w extends Error{constructor(t){super(t)}}function m(t){if(!(t instanceof v))throw new TypeError(\"JacobianPoint expected\")}class v{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof S))throw new TypeError(\"JacobianPoint#fromAffine: expected Point\");return t.equals(S.ZERO)?v.ZERO:new v(t.x,t.y,o)}static toAffineBatch(t){const e=function(t,e=u.P){const r=new Array(t.length),n=t.reduce(((t,n,o)=>n===i?t:(r[o]=t,H(t*n,e))),o),s=D(n,e);return t.reduceRight(((t,n,o)=>n===i?t:(r[o]=H(t*r[o],e),H(t*n,e))),s),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return v.toAffineBatch(t).map(v.fromAffine)}equals(t){m(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:s}=t,a=H(n*n),c=H(s*s),u=H(e*c),f=H(i*a),h=H(H(r*s)*c),l=H(H(o*n)*a);return u===f&&h===l}negate(){return new v(this.x,H(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=H(t*t),i=H(e*e),o=H(i*i),u=t+i,f=H(s*(H(u*u)-n-o)),h=H(a*n),l=H(h*h),p=H(l-s*f),d=H(h*(f-p)-c*o),y=H(s*e*r);return new v(p,d,y)}add(t){m(t);const{x:e,y:r,z:n}=this,{x:o,y:a,z:c}=t;if(o===i||a===i)return this;if(e===i||r===i)return t;const u=H(n*n),f=H(c*c),h=H(e*f),l=H(o*u),p=H(H(r*c)*f),d=H(H(a*n)*u),y=H(l-h),g=H(d-p);if(y===i)return g===i?this.double():v.ZERO;const b=H(y*y),w=H(y*b),E=H(h*b),_=H(g*g-w-s*E),S=H(g*(E-_)-p*w),A=H(n*c*y);return new v(_,S,A)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=v.ZERO;if(\"bigint\"==typeof t&&t===i)return e;let r=M(t);if(r===o)return this;if(!b){let t=e,n=this;for(;r>i;)r&o&&(t=t.add(n)),n=n.double(),r>>=o;return t}let{k1neg:n,k1:s,k2neg:a,k2:c}=h.splitScalar(r),u=e,f=e,l=this;for(;s>i||c>i;)s&o&&(u=u.add(l)),c&o&&(f=f.add(l)),l=l.double(),s>>=o,c>>=o;return n&&(u=u.negate()),a&&(f=f.negate()),f=new v(H(f.x*h.beta),f.y,f.z),u.add(f)}precomputeWindow(t){const e=b?128/t+1:256/t+1,r=[];let n=this,i=n;for(let o=0;o>=h,a>c&&(a-=f,t+=o);const l=r,p=r+Math.abs(a)-1,d=e%2!=0,y=a<0;0===a?s=s.add(E(d,n[l])):i=i.add(E(y,n[p]))}return{p:i,f:s}}multiply(t,e){let r,n,i=M(t);if(b){const{k1neg:t,k1:o,k2neg:s,k2:a}=h.splitScalar(i);let{p:c,f:u}=this.wNAF(o,e),{p:f,f:l}=this.wNAF(a,e);c=E(t,c),f=E(s,f),f=new v(H(f.x*h.beta),f.y,f.z),r=c.add(f),n=u.add(l)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return v.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(v.ZERO);null==t&&(t=i?c:D(n));const s=t,a=H(s*s),u=H(a*s),f=H(e*a),h=H(r*u),l=H(n*s);if(i)return S.ZERO;if(l!==o)throw new Error(\"invZ was invalid\");return new S(f,h)}}function E(t,e){const r=e.negate();return t?r:e}v.BASE=new v(u.Gx,u.Gy,o),v.ZERO=new v(i,o,i);const _=new WeakMap;class S{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,_.delete(this)}hasEvenY(){return this.y%s===i}static fromCompressedHex(t){const e=32===t.length,r=U(e?t:t.subarray(1));if(!W(r))throw new Error(\"Point is not on curve\");let n=function(t){const{P:e}=u,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),c=BigInt(44),f=BigInt(88),h=t*t*t%e,l=h*h*t%e,p=F(l,a)*l%e,d=F(p,a)*l%e,y=F(d,s)*h%e,g=F(y,n)*y%e,b=F(g,i)*g%e,w=F(b,c)*b%e,m=F(w,f)*w%e,v=F(m,c)*b%e,E=F(v,a)*l%e,_=F(E,o)*g%e,S=F(_,r)*h%e,A=F(S,s);if(A*A%e!==t)throw new Error(\"Cannot find square root\");return A}(g(r));const i=(n&o)===o;if(e)i&&(n=H(-n));else{1==(1&t[0])!==i&&(n=H(-n))}const c=new S(r,n);return c.assertValidity(),c}static fromUncompressedHex(t){const e=U(t.subarray(1,l+1)),r=U(t.subarray(l+1,2*l+1)),n=new S(e,r);return n.assertValidity(),n}static fromHex(t){const e=j(t),r=e.length,n=e[0];if(r===l)return this.fromCompressedHex(e);if(r===d&&(2===n||3===n))return this.fromCompressedHex(e);if(r===y&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-${d} compressed bytes or ${y} uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return S.BASE.multiply(z(t))}static fromSignature(t,e,r){const{r:n,s:i}=Y(e);if(![0,1,2,3].includes(r))throw new Error(\"Cannot recover: invalid recovery bit\");const o=$(j(t)),{n:s}=u,a=2===r||3===r?n+s:n,c=D(a,s),f=H(-o*c,s),h=H(i*c,s),l=1&r?\"03\":\"02\",p=S.fromHex(l+R(a)),d=S.BASE.multiplyAndAddUnsafe(p,f,h);if(!d)throw new Error(\"Cannot recover signature: point at infinify\");return d.assertValidity(),d}toRawBytes(t=!1){return L(this.toHex(t))}toHex(t=!1){const e=R(this.x);if(t){return`${this.hasEvenY()?\"02\":\"03\"}${e}`}return`04${e}${R(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t=\"Point is not on elliptic curve\",{x:e,y:r}=this;if(!W(e)||!W(r))throw new Error(t);const n=H(r*r);if(H(n-g(e))!==i)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new S(this.x,H(-this.y))}double(){return v.fromAffine(this).double().toAffine()}add(t){return v.fromAffine(this).add(v.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return v.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=v.fromAffine(this),s=e===i||e===o||this!==S.BASE?n.multiplyUnsafe(e):n.multiply(e),a=v.fromAffine(t).multiplyUnsafe(r),c=s.add(a);return c.equals(v.ZERO)?void 0:c.toAffine()}}function A(t){return Number.parseInt(t[0],16)>=8?\"00\"+t:t}function I(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${k(t)}`);const e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error(\"Invalid signature integer: wrong length\");if(0===r[0]&&r[1]<=127)throw new Error(\"Invalid signature integer: trailing length\");return{data:U(r),left:t.subarray(e+2)}}e.Point=S,S.BASE=new S(u.Gx,u.Gy),S.ZERO=new S(i,i);class T{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,r=\"Signature.fromCompact\";if(\"string\"!=typeof t&&!e)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=e?k(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new T(N(n.slice(0,64)),N(n.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if(\"string\"!=typeof t&&!e)throw new TypeError(\"Signature.fromDER: Expected string or Uint8Array\");const{r,s:n}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${k(t)}`);if(t[1]!==t.length-2)throw new Error(\"Invalid signature: incorrect length\");const{data:e,left:r}=I(t.subarray(2)),{data:n,left:i}=I(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${k(i)}`);return{r:e,s:n}}(e?t:L(t));return new T(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!q(t))throw new Error(\"Invalid Signature: r must be 0 < r < n\");if(!q(e))throw new Error(\"Invalid Signature: s must be 0 < s < n\")}hasHighS(){const t=u.n>>o;return this.s>t}normalizeS(){return this.hasHighS()?new T(this.r,H(-this.s,u.n)):this}toDERRawBytes(){return L(this.toDERHex())}toDERHex(){const t=A(C(this.s)),e=A(C(this.r)),r=t.length/2,n=e.length/2,i=C(r),o=C(n);return`30${C(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return L(this.toCompactHex())}toCompactHex(){return R(this.r)+R(this.s)}}function x(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error(\"Uint8Array list expected\");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;ee.toString(16).padStart(2,\"0\")));function k(t){if(!(t instanceof Uint8Array))throw new Error(\"Expected Uint8Array\");let e=\"\";for(let r=0;r0)return BigInt(t);if(\"bigint\"==typeof t&&q(t))return t;throw new TypeError(\"Expected valid private scalar: 0 < scalar < curve.n\")}function H(t,e=u.P){const r=t%e;return r>=i?r:e+r}function F(t,e){const{P:r}=u;let n=t;for(;e-- >i;)n*=n,n%=r;return n}function D(t,e=u.P){if(t===i||e<=i)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=H(t,e),n=e,s=i,a=o,c=o,f=i;for(;r!==i;){const t=n/r,e=n%r,i=s-c*t,o=a-f*t;n=r,r=e,s=c,a=f,c=i,f=o}if(n!==o)throw new Error(\"invert: does not exist\");return H(s,e)}function $(t,e=!1){const r=function(t){const e=8*t.length-8*p,r=U(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=u;return r>=n?r-n:r}let K,V;class G{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,\"number\"!=typeof t||t<2)throw new Error(\"hashLen must be a number\");if(\"number\"!=typeof e||e<2)throw new Error(\"qByteLen must be a number\");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return e.utils.hmacSha256(this.k,...t)}hmacSync(...t){return V(this.k,...t)}checkSync(){if(\"function\"!=typeof V)throw new w(\"hmacSha256Sync needs to be set\")}incr(){if(this.counter>=1e3)throw new Error(\"Tried 1,000 k values for sign(), all were invalid\");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),0!==t.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),0!==t.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t0)e=BigInt(t);else if(\"string\"==typeof t){if(t.length!==2*p)throw new Error(\"Expected 32 bytes of private key\");e=N(t)}else{if(!(t instanceof Uint8Array))throw new TypeError(\"Expected valid private key\");if(t.length!==p)throw new Error(\"Expected 32 bytes of private key\");e=U(t)}if(!q(e))throw new Error(\"Expected private key: 0 < key < n\");return e}function J(t){return t instanceof S?(t.assertValidity(),t):S.fromHex(t)}function Y(t){if(t instanceof T)return t.assertValidity(),t;try{return T.fromDER(t)}catch(e){return T.fromCompact(t)}}function Z(t){const e=t instanceof Uint8Array,r=\"string\"==typeof t,n=(e||r)&&t.length;return e?n===d||n===y:r?n===2*d||n===2*y:t instanceof S}function Q(t){return U(t.length>l?t.slice(0,l):t)}function tt(t){const e=Q(t),r=H(e,u.n);return et(r{t=j(t);const e=p+8;if(t.length1024)throw new Error(\"Expected valid bytes of private key as per FIPS 186\");return B(H(U(t),u.n-o)+o)},randomBytes:(t=32)=>{if(lt.web)return lt.web.getRandomValues(new Uint8Array(t));if(lt.node){const{randomBytes:e}=lt.node;return Uint8Array.from(e(t))}throw new Error(\"The environment doesn't have randomBytes function\")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(p+8)),precompute(t=8,e=S.BASE){const r=e===S.BASE?e:new S(e.x,e.y);return r._setWindowSize(t),r.multiply(a),r},sha256:async(...t)=>{if(lt.web){const e=await lt.web.subtle.digest(\"SHA-256\",x(...t));return new Uint8Array(e)}if(lt.node){const{createHash:e}=lt.node,r=e(\"sha256\");return t.forEach((t=>r.update(t))),Uint8Array.from(r.digest())}throw new Error(\"The environment doesn't have sha256 function\")},hmacSha256:async(t,...e)=>{if(lt.web){const r=await lt.web.subtle.importKey(\"raw\",t,{name:\"HMAC\",hash:{name:\"SHA-256\"}},!1,[\"sign\"]),n=x(...e),i=await lt.web.subtle.sign(\"HMAC\",r,n);return new Uint8Array(i)}if(lt.node){const{createHmac:r}=lt.node,n=r(\"sha256\",t);return e.forEach((t=>n.update(t))),Uint8Array.from(n.digest())}throw new Error(\"The environment doesn't have hmac-sha256 function\")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...r)=>{let n=dt[t];if(void 0===n){const r=await e.utils.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=x(r,r),dt[t]=n}return e.utils.sha256(n,...r)},taggedHashSync:(t,...e)=>{if(\"function\"!=typeof K)throw new w(\"sha256Sync is undefined, you need to set it\");let r=dt[t];if(void 0===r){const e=K(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=x(e,e),dt[t]=r}return K(r,...e)},_JacobianPoint:v},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get:()=>K,set(t){K||(K=t)}},hmacSha256Sync:{configurable:!1,get:()=>V,set(t){V||(V=t)}}})},6710:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function n(...t){const e=(t,e)=>r=>t(e(r)),r=Array.from(t).reverse().reduce(((t,r)=>t?e(t,r.encode):r.encode),void 0),n=t.reduce(((t,r)=>t?e(t,r.decode):r.decode),void 0);return{encode:r,decode:n}}function i(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&\"number\"!=typeof e[0])throw new Error(\"alphabet.encode input should be an array of numbers\");return e.map((e=>{if(r(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&\"string\"!=typeof e[0])throw new Error(\"alphabet.decode input should be array of strings\");return e.map((e=>{if(\"string\"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: \"${e}\". Allowed: ${t}`);return r}))}}}function o(t=\"\"){if(\"string\"!=typeof t)throw new Error(\"join separator should be string\");return{encode:e=>{if(!Array.isArray(e)||e.length&&\"string\"!=typeof e[0])throw new Error(\"join.encode input should be array of strings\");for(let t of e)if(\"string\"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if(\"string\"!=typeof e)throw new Error(\"join.decode input should be string\");return e.split(t)}}}function s(t,e=\"=\"){if(r(t),\"string\"!=typeof e)throw new Error(\"padding chr should be string\");return{encode(r){if(!Array.isArray(r)||r.length&&\"string\"!=typeof r[0])throw new Error(\"padding.encode input should be array of strings\");for(let t of r)if(\"string\"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&\"string\"!=typeof r[0])throw new Error(\"padding.encode input should be array of strings\");for(let t of r)if(\"string\"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let n=r.length;if(n*t%8)throw new Error(\"Invalid padding: string should have whole number of bytes\");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error(\"Invalid padding: string has too much padding\");return r.slice(0,n)}}}function a(t){if(\"function\"!=typeof t)throw new Error(\"normalize fn should be function\");return{encode:t=>t,decode:e=>t(e)}}function c(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error(\"convertRadix: data should be array\");if(!t.length)return[];let i=0;const o=[],s=Array.from(t);for(s.forEach((t=>{if(r(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)}));;){let t=0,r=!0;for(let o=i;oe?u(e,t%e):t,f=(t,e)=>t+(e-u(t,e));function h(t,e,n,i){if(!Array.isArray(t))throw new Error(\"convertRadix2: data should be array\");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(f(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${f(e,n)}`);let o=0,s=0;const a=2**n-1,c=[];for(const i of t){if(r(i),i>=2**e)throw new Error(`convertRadix2: invalid data word=${i} from=${e}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)c.push((o>>s-n&a)>>>0);o&=2**s-1}if(o=o<=e)throw new Error(\"Excess padding\");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&c.push(o>>>0),c}function l(t){return r(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error(\"radix.encode input should be Uint8Array\");return c(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&\"number\"!=typeof e[0])throw new Error(\"radix.decode input should be array of strings\");return Uint8Array.from(c(e,t,256))}}}function p(t,e=!1){if(r(t),t<=0||t>32)throw new Error(\"radix2: bits should be in (0..32]\");if(f(8,t)>32||f(t,8)>32)throw new Error(\"radix2: carry overflow\");return{encode:r=>{if(!(r instanceof Uint8Array))throw new Error(\"radix2.encode input should be Uint8Array\");return h(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&\"number\"!=typeof r[0])throw new Error(\"radix2.decode input should be array of strings\");return Uint8Array.from(h(r,t,8,e))}}}function d(t){if(\"function\"!=typeof t)throw new Error(\"unsafeWrapper fn should be function\");return function(...e){try{return t.apply(null,e)}catch(t){}}}function y(t,e){if(r(t),\"function\"!=typeof e)throw new Error(\"checksum fn should be function\");return{encode(r){if(!(r instanceof Uint8Array))throw new Error(\"checksum.encode: input should be Uint8Array\");const n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!(r instanceof Uint8Array))throw new Error(\"checksum.decode: input should be Uint8Array\");const n=r.slice(0,-t),i=e(n).slice(0,t),o=r.slice(-t);for(let e=0;et.toUpperCase().replace(/O/g,\"0\").replace(/[IL]/g,\"1\")))),e.base64=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"),s(6),o(\"\")),e.base64url=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\"),s(6),o(\"\")),e.base64urlnopad=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\"),o(\"\"));const g=t=>n(l(58),i(t),o(\"\"));e.base58=g(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\"),e.base58flickr=g(\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"),e.base58xrp=g(\"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz\");const b=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let r=\"\";for(let n=0;nn(y(4,(e=>t(t(e)))),e.base58);const w=n(i(\"qpzry9x8gf2tvdw0s3jn54khce6mua7l\"),o(\"\")),m=[996825010,642813549,513874426,1027748829,705979059];function v(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t>t&1)&&(r^=m[t]);return r}function E(t,e,r=1){const n=t.length;let i=1;for(let e=0;e126)throw new Error(`Invalid prefix (${t})`);i=v(i)^r>>5}i=v(i);for(let e=0;er)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${r})`);const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())throw new Error(\"String must be lowercase or uppercase\");const i=(t=n).lastIndexOf(\"1\");if(0===i||-1===i)throw new Error('Letter \"1\" must be present between prefix and data only');const o=t.slice(0,i),s=t.slice(i+1);if(s.length<6)throw new Error(\"Data must be at least 6 characters long\");const a=w.decode(s).slice(0,-6),c=E(o,a,e);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected \"${c}\"`);return{prefix:o,words:a}}return{encode:function(t,r,n=90){if(\"string\"!=typeof t)throw new Error(\"bech32.encode prefix should be string, not \"+typeof t);if(!Array.isArray(r)||r.length&&\"number\"!=typeof r[0])throw new Error(\"bech32.encode words should be array of numbers, not \"+typeof r);const i=t.length+7+r.length;if(!1!==n&&i>n)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=t.toLowerCase(),s=E(o,r,e);return`${o}1${w.encode(r)}${s}`},decode:s,decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:d(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}e.bech32=_(\"bech32\"),e.bech32m=_(\"bech32m\"),e.utf8={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},e.hex=n(p(4),i(\"0123456789abcdef\"),o(\"\"),a((t=>{if(\"string\"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));const S={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},A=\"Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr\";e.bytesToString=(t,e)=>{if(\"string\"!=typeof t||!S.hasOwnProperty(t))throw new TypeError(A);if(!(e instanceof Uint8Array))throw new TypeError(\"bytesToString() expects Uint8Array\");return S[t].encode(e)},e.str=e.bytesToString;e.stringToBytes=(t,e)=>{if(!S.hasOwnProperty(t))throw new TypeError(A);if(\"string\"!=typeof e)throw new TypeError(\"stringToBytes() expects string\");return S[t].decode(e)},e.bytes=e.stringToBytes},9784:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError(\"Alphabet too long\");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,p=s-1;(0!==h||l>>0,f[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error(\"Non-zero carry\");o=l,r++}for(var d=s-o;d!==s&&0===f[d];)d++;var y=n.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var g=i;d!==s;)y[g++]=f[d++];return y}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError(\"Expected Buffer\");if(0===e.length)return\"\";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var l=e[o],p=0,d=u-1;(0!==l||p>>0,h[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error(\"Non-zero carry\");i=p,o++}for(var y=u-i;y!==u&&0===h[y];)y++;for(var g=c.repeat(r);y{\"use strict\";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],c=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,c)),f=0,h=c>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===c&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===c&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,u=n-i;au?u:a+s));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+\"==\")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\"));return o.join(\"\")};for(var r=[],n=[],i=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,o=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var r=t.indexOf(\"=\");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,n){for(var i,o,s=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join(\"\")}n[\"-\".charCodeAt(0)]=62,n[\"_\".charCodeAt(0)]=63},6586:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.bech32m=e.bech32=void 0;const r=\"qpzry9x8gf2tvdw0s3jn54khce6mua7l\",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r126)return\"Invalid prefix (\"+t+\")\";e=i(e)^n>>5}e=i(e);for(let r=0;r=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)return\"Excess padding\";if(i<r)return\"Exceeds length limit\";const s=t.toLowerCase(),a=t.toUpperCase();if(t!==s&&t!==a)return\"Mixed-case string \"+t;const c=(t=s).lastIndexOf(\"1\");if(-1===c)return\"No separator character for \"+t;if(0===c)return\"Missing prefix for \"+t;const u=t.slice(0,c),f=t.slice(c+1);if(f.length<6)return\"Data too short\";let h=o(u);if(\"string\"==typeof h)return h;const l=[];for(let t=0;t=f.length||l.push(r)}return h!==e?\"Invalid checksum for \"+t:{prefix:u,words:l}}return e=\"bech32\"===t?1:734539939,{decodeUnsafe:function(t,e){const r=s(t,e);if(\"object\"==typeof r)return r},decode:function(t,e){const r=s(t,e);if(\"object\"==typeof r)return r;throw new Error(r)},encode:function(t,n,s){if(s=s||90,t.length+7+n.length>s)throw new TypeError(\"Exceeds length limit\");let a=o(t=t.toLowerCase());if(\"string\"==typeof a)throw new Error(a);let c=t+\"1\";for(let t=0;t>5!=0)throw new Error(\"Non 5-bit word\");a=i(a)^e,c+=r.charAt(e)}for(let t=0;t<6;++t)a=i(a);a^=e;for(let t=0;t<6;++t){c+=r.charAt(a>>5*(5-t)&31)}return c},toWords:a,fromWordsUnsafe:c,fromWords:u}}e.bech32=f(\"bech32\"),e.bech32m=f(\"bech32m\")},3162:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});const n=r(6808);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter((t=>t.key.toString(\"hex\")===n))[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function s(t){const e=new Set;return t.forEach((t=>{const r=t.key.toString(\"hex\");if(e.has(r))throw new Error(\"Combine: KeyValue Map keys should be unique\");e.add(r)})),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),a=t.slice(1);if(0===a.length)throw new Error(\"Combine: Nothing to combine\");const c=o(e);if(void 0===c)throw new Error(\"Combine: Self missing transaction\");const u=s(r.globalKeyVals),f=r.inputKeyVals.map(s),h=r.outputKeyVals.map(s);for(const t of a){const e=o(t);if(void 0===e||!e.toBuffer().equals(c.toBuffer()))throw new Error(\"Combine: One of the Psbts does not have the same transaction.\");const a=n.psbtToKeyVals(t);s(a.globalKeyVals).forEach(i(u,r.globalKeyVals,a.globalKeyVals));a.inputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(f[e],r.inputKeyVals[e],a.inputKeyVals[e]))));a.outputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(h[e],r.outputKeyVals[e],a.outputKeyVals[e]))))}return n.psbtFromKeyVals(c,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},9977:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error(\"Decode Error: could not decode globalXpub with key 0x\"+t.key.toString(\"hex\"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error(\"Decode Error: globalXpub has invalid extended pubkey in key 0x\"+t.key.toString(\"hex\"));if(t.value.length/4%1!=0)throw new Error(\"Decode Error: Global GLOBAL_XPUB value length should be multiple of 4\");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:\"m\"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+=\"/\"+o.toString(10)+(i?\"'\":\"\")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split(\"/\"),s=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e=\"'\"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:r,value:s}},e.expected=\"{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }\",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&\"string\"==typeof i&&!!i.match(/^m(\\/\\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.extendedPubkey.equals(e.extendedPubkey))).length)}},3398:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},6317:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});const n=r(9889),i=r(9977),o=r(3398),s=r(7312),a=r(1661),c=r(8730),u=r(5098),f=r(4474),h=r(9175),l=r(7279),p=r(7544),d=r(241),y=r(3155),g=r(4709),b=r(9574),w=r(6896),m=r(437),v=r(5400),E=r(2751),_=r(9632),S=r(9079),A={unsignedTx:o,globalXpub:i,checkPubkey:m.makeChecker([])};e.globals=A;const I={nonWitnessUtxo:c,partialSig:u,sighashType:h,finalScriptSig:s,finalScriptWitness:a,porCommitment:f,witnessUtxo:g,bip32Derivation:w.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:l,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:E.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:_.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=I;const T={bip32Derivation:w.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:E.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:b,tapInternalKey:_.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},7312:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error(\"Decode Error: could not decode finalScriptSig with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},1661:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error(\"Decode Error: could not decode finalScriptWitness with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},8730:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error(\"Decode Error: could not decode nonWitnessUtxo with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},5098:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error(\"Decode Error: could not decode partialSig with key 0x\"+t.key.toString(\"hex\"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error(\"Decode Error: partialSig has invalid pubkey in key 0x\"+t.key.toString(\"hex\"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected=\"{ pubkey: Buffer; signature: Buffer; }\",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}},4474:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error(\"Decode Error: could not decode porCommitment with key 0x\"+t.key.toString(\"hex\"));return t.value.toString(\"utf8\")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,\"utf8\")}},e.expected=\"string\",e.check=function(t){return\"string\"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}},9175:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error(\"Decode Error: could not decode sighashType with key 0x\"+t.key.toString(\"hex\"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected=\"number\",e.check=function(t){return\"number\"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},7279:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapKeySig with key 0x\"+t.key.toString(\"hex\"));if(!o(t.value))throw new Error(\"Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature\");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected=\"Buffer\",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},7544:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error(\"Decode Error: could not decode tapLeafScript with key 0x\"+t.key.toString(\"hex\"));if((t.key.length-2)%32!=0)throw new Error(\"Decode Error: tapLeafScript has invalid control block in key 0x\"+t.key.toString(\"hex\"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error(\"Decode Error: tapLeafScript bad leaf version in key 0x\"+t.key.toString(\"hex\"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected=\"{ controlBlock: Buffer; leafVersion: number, script: Buffer; }\",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.controlBlock.equals(e.controlBlock))).length)}},241:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapMerkleRoot with key 0x\"+t.key.toString(\"hex\"));if(!o(t.value))throw new Error(\"Decode Error: tapMerkleRoot not a 32-byte hash\");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected=\"Buffer\",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},3155:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error(\"Decode Error: could not decode tapScriptSig with key 0x\"+t.key.toString(\"hex\"));if(65!==t.key.length)throw new Error(\"Decode Error: tapScriptSig has invalid key 0x\"+t.key.toString(\"hex\"));if(64!==t.value.length&&65!==t.value.length)throw new Error(\"Decode Error: tapScriptSig has invalid signature in key 0x\"+t.key.toString(\"hex\"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected=\"{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }\",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString(\"hex\")+e.leafHash.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash))).length)}},4709:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889),o=r(5962),s=r(2715);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error(\"Decode Error: could not decode witnessUtxo with key 0x\"+t.key.toString(\"hex\"));const e=o.readUInt64LE(t.value,0);let r=8;const n=s.decode(t.value,r);r+=s.encodingLength(n);const a=t.value.slice(r);if(a.length!==n)throw new Error(\"Decode Error: WITNESS_UTXO script is not proper length\");return{script:a,value:e}},e.encode=function(t){const{script:e,value:r}=t,a=s.encodingLength(e.length),c=n.allocUnsafe(8+a+e.length);return o.writeUInt64LE(c,r,0),s.encode(e.length,c,8),e.copy(c,8+a),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:c}},e.expected=\"{ script: Buffer; value: number; }\",e.check=function(t){return n.isBuffer(t.script)&&\"number\"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},9574:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889),o=r(2715);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapTree with key 0x\"+t.key.toString(\"hex\"));let e=0;const r=[];for(;e[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script])));return{key:e,value:n.concat(r)}},e.expected=\"{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }\",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every((t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script)))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},6896:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=t=>33===t.length&&[2,3].includes(t[0])||65===t.length&&4===t[0];e.makeConverter=function(t,e=i){return{decode:function(r){if(r.key[0]!==t)throw new Error(\"Decode Error: could not decode bip32Derivation with key 0x\"+r.key.toString(\"hex\"));const n=r.key.slice(1);if(!e(n))throw new Error(\"Decode Error: bip32Derivation has invalid pubkey in key 0x\"+r.key.toString(\"hex\"));if(r.value.length/4%1!=0)throw new Error(\"Decode Error: Input BIP32_DERIVATION value length should be multiple of 4\");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:\"m\"};for(const t of(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+=\"/\"+o.toString(10)+(n?\"'\":\"\")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split(\"/\"),s=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e=\"'\"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:i,value:s}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&\"string\"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:\"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }\",canAddToArray:function(t,e,r){const n=e.pubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}}}},437:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error(\"Format Error: invalid pubkey in key 0x\"+e.key.toString(\"hex\"));return r}}},5400:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error(\"Decode Error: could not decode redeemScript with key 0x\"+e.key.toString(\"hex\"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.redeemScript}}}},2751:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(2715),o=r(6896),s=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,s);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),s=new Array(r);for(let e=0,i=n;en.isBuffer(t)&&32===t.length))&&e.check(t)},expected:\"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }\",canAddToArray:e.canAddToArray}}},9632:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t||1!==e.key.length)throw new Error(\"Decode Error: could not decode tapInternalKey with key 0x\"+e.key.toString(\"hex\"));if(32!==e.value.length)throw new Error(\"Decode Error: tapInternalKey not a 32-byte x-only pubkey\");return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)&&32===t.length},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.tapInternalKey}}}},9079:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error(\"Decode Error: could not decode witnessScript with key 0x\"+e.key.toString(\"hex\"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.witnessScript}}}},5962:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(2715);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),s=i.encodingLength(r),a=n.allocUnsafe(o+e+s+r);return i.encode(e,a,0),t.key.copy(a,o),i.encode(r,a,o+e),t.value.copy(a,o+e+s),a}function s(t,e){if(\"number\"!=typeof t)throw new Error(\"cannot write a non-number as a number\");if(t<0)throw new Error(\"specified a negative value for writing an unsigned value\");if(t>e)throw new Error(\"RangeError: value out of range\");if(Math.floor(t)!==t)throw new Error(\"value has a fractional component\")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError(\"value out of range\")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.encode=function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError(\"buffer must be a Buffer instance\");return i||(i=0),e<253?(r.writeUInt8(e,i),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError(\"buffer must be a Buffer instance\");r||(r=0);const i=e.readUInt8(r);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===i)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),i=4294967296*e.readUInt32LE(r+5)+n;return o(i),i}},e.encodingLength=s},4112:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317),o=r(5962),s=r(2715),a=r(9889);function c(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString(\"hex\")}`)}function u(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const s={unsignedTx:t};let u=0;for(const t of e)switch(t.key[0]){case a.GlobalTypes.UNSIGNED_TX:if(c(\"global\",t.key,a.GlobalTypes.UNSIGNED_TX),u>0)throw new Error(\"Format Error: GlobalMap has multiple UNSIGNED_TX\");u++;break;case a.GlobalTypes.GLOBAL_XPUB:void 0===s.globalXpub&&(s.globalXpub=[]),s.globalXpub.push(i.globals.globalXpub.decode(t));break;default:s.unknownKeyVals||(s.unknownKeyVals=[]),s.unknownKeyVals.push(t)}const f=r.length,h=n.length,l=[],p=[];for(const t of o.range(f)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case a.InputTypes.NON_WITNESS_UTXO:if(c(\"input\",n.key,a.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error(\"Format Error: Input has multiple NON_WITNESS_UTXO\");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case a.InputTypes.WITNESS_UTXO:if(c(\"input\",n.key,a.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error(\"Format Error: Input has multiple WITNESS_UTXO\");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case a.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case a.InputTypes.SIGHASH_TYPE:if(c(\"input\",n.key,a.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error(\"Format Error: Input has multiple SIGHASH_TYPE\");e.sighashType=i.inputs.sighashType.decode(n);break;case a.InputTypes.REDEEM_SCRIPT:if(c(\"input\",n.key,a.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error(\"Format Error: Input has multiple REDEEM_SCRIPT\");e.redeemScript=i.inputs.redeemScript.decode(n);break;case a.InputTypes.WITNESS_SCRIPT:if(c(\"input\",n.key,a.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error(\"Format Error: Input has multiple WITNESS_SCRIPT\");e.witnessScript=i.inputs.witnessScript.decode(n);break;case a.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case a.InputTypes.FINAL_SCRIPTSIG:c(\"input\",n.key,a.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case a.InputTypes.FINAL_SCRIPTWITNESS:c(\"input\",n.key,a.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case a.InputTypes.POR_COMMITMENT:c(\"input\",n.key,a.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case a.InputTypes.TAP_KEY_SIG:c(\"input\",n.key,a.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case a.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case a.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case a.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case a.InputTypes.TAP_INTERNAL_KEY:c(\"input\",n.key,a.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case a.InputTypes.TAP_MERKLE_ROOT:c(\"input\",n.key,a.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}l.push(e)}for(const t of o.range(h)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case a.OutputTypes.REDEEM_SCRIPT:if(c(\"output\",r.key,a.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error(\"Format Error: Output has multiple REDEEM_SCRIPT\");e.redeemScript=i.outputs.redeemScript.decode(r);break;case a.OutputTypes.WITNESS_SCRIPT:if(c(\"output\",r.key,a.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error(\"Format Error: Output has multiple WITNESS_SCRIPT\");e.witnessScript=i.outputs.witnessScript.decode(r);break;case a.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case a.OutputTypes.TAP_INTERNAL_KEY:c(\"output\",r.key,a.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case a.OutputTypes.TAP_TREE:c(\"output\",r.key,a.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case a.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:s,inputs:l,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=s.decode(t,r);r+=s.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function c(){if(r>=t.length)throw new Error(\"Format Error: Unexpected End of PSBT\");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error(\"Format Error: Invalid Magic Number\");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error(\"Format Error: Magic Number must be followed by 0xff separator\");const f=[],h={};for(;!c();){const t=i(),e=t.key.toString(\"hex\");if(h[e])throw new Error(\"Format Error: Keys must be unique for global keymap: key \"+e);h[e]=1,f.push(t)}const l=f.filter((t=>t.key[0]===a.GlobalTypes.UNSIGNED_TX));if(1!==l.length)throw new Error(\"Format Error: Only one UNSIGNED_TX allowed\");const p=e(l[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),g=[],b=[];for(const t of o.range(d)){const e={},r=[];for(;!c();){const n=i(),o=n.key.toString(\"hex\");if(e[o])throw new Error(\"Format Error: Keys must be unique for each input: input index \"+t+\" key \"+o);e[o]=1,r.push(n)}g.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!c();){const n=i(),o=n.key.toString(\"hex\");if(e[o])throw new Error(\"Format Error: Keys must be unique for each output: output index \"+t+\" key \"+o);e[o]=1,r.push(n)}b.push(r)}return u(p,{globalMapKeyVals:f,inputKeyVals:g,outputKeyVals:b})},e.checkKeyBuffer=c,e.psbtFromKeyVals=u},6808:(t,e,r)=>{\"use strict\";function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,\"__esModule\",{value:!0}),n(r(4112)),n(r(2673))},2673:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317),o=r(5962);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:s,outputKeyVals:a}=c({globalMap:t,inputs:e,outputs:r}),u=o.keyValsToBuffer(i),f=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),h=f(s),l=f(a),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,u].concat(h,l))};const s=(t,e)=>t.key.compare(e.key);function a(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if(\"unknownKeyVals\"===n)return t;const o=e[n];if(void 0===o)return t;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((t=>t.key.toString(\"hex\"))).forEach((t=>{if(r.has(t))throw new Error(\"Serialize Error: Duplicate key: \"+t);r.add(t)})),t.concat(s)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString(\"hex\")))):[];return n.concat(i).sort(s)}function c({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:a(t,i.globals),inputKeyVals:e.map((t=>a(t,i.inputs))),outputKeyVals:r.map((t=>a(t,i.outputs)))}}e.psbtToKeyVals=c},7003:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(3162),o=r(6808),s=r(9889),a=r(2431);e.Psbt=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,\"base64\");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,\"hex\");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString(\"base64\")}toHex(){return this.toBuffer().toString(\"hex\")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return a.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=a.checkForInput(this.inputs,t);return a.updateInput(e,r),this}updateOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return a.checkHasKey(t,this.globalMap.unknownKeyVals,a.getEnumLength(s.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=a.checkForInput(this.inputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error(\"unknownKeyVals must be an Array\");return e.forEach((t=>this.addUnknownKeyValToInput(r,t))),a.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error(\"unknownKeyVals must be an Array\");return e.forEach((t=>this.addUnknownKeyValToOutput(r,t))),a.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=a.checkForInput(this.inputs,t);a.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))[\"witnessUtxo\",\"nonWitnessUtxo\",\"finalScriptSig\",\"finalScriptWitness\",\"unknownKeyVals\"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},9889:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),function(t){t[t.UNSIGNED_TX=0]=\"UNSIGNED_TX\",t[t.GLOBAL_XPUB=1]=\"GLOBAL_XPUB\"}(e.GlobalTypes||(e.GlobalTypes={})),e.GLOBAL_TYPE_NAMES=[\"unsignedTx\",\"globalXpub\"],function(t){t[t.NON_WITNESS_UTXO=0]=\"NON_WITNESS_UTXO\",t[t.WITNESS_UTXO=1]=\"WITNESS_UTXO\",t[t.PARTIAL_SIG=2]=\"PARTIAL_SIG\",t[t.SIGHASH_TYPE=3]=\"SIGHASH_TYPE\",t[t.REDEEM_SCRIPT=4]=\"REDEEM_SCRIPT\",t[t.WITNESS_SCRIPT=5]=\"WITNESS_SCRIPT\",t[t.BIP32_DERIVATION=6]=\"BIP32_DERIVATION\",t[t.FINAL_SCRIPTSIG=7]=\"FINAL_SCRIPTSIG\",t[t.FINAL_SCRIPTWITNESS=8]=\"FINAL_SCRIPTWITNESS\",t[t.POR_COMMITMENT=9]=\"POR_COMMITMENT\",t[t.TAP_KEY_SIG=19]=\"TAP_KEY_SIG\",t[t.TAP_SCRIPT_SIG=20]=\"TAP_SCRIPT_SIG\",t[t.TAP_LEAF_SCRIPT=21]=\"TAP_LEAF_SCRIPT\",t[t.TAP_BIP32_DERIVATION=22]=\"TAP_BIP32_DERIVATION\",t[t.TAP_INTERNAL_KEY=23]=\"TAP_INTERNAL_KEY\",t[t.TAP_MERKLE_ROOT=24]=\"TAP_MERKLE_ROOT\"}(e.InputTypes||(e.InputTypes={})),e.INPUT_TYPE_NAMES=[\"nonWitnessUtxo\",\"witnessUtxo\",\"partialSig\",\"sighashType\",\"redeemScript\",\"witnessScript\",\"bip32Derivation\",\"finalScriptSig\",\"finalScriptWitness\",\"porCommitment\",\"tapKeySig\",\"tapScriptSig\",\"tapLeafScript\",\"tapBip32Derivation\",\"tapInternalKey\",\"tapMerkleRoot\"],function(t){t[t.REDEEM_SCRIPT=0]=\"REDEEM_SCRIPT\",t[t.WITNESS_SCRIPT=1]=\"WITNESS_SCRIPT\",t[t.BIP32_DERIVATION=2]=\"BIP32_DERIVATION\",t[t.TAP_INTERNAL_KEY=5]=\"TAP_INTERNAL_KEY\",t[t.TAP_TREE=6]=\"TAP_TREE\",t[t.TAP_BIP32_DERIVATION=7]=\"TAP_BIP32_DERIVATION\"}(e.OutputTypes||(e.OutputTypes={})),e.OUTPUT_TYPE_NAMES=[\"redeemScript\",\"witnessScript\",\"bip32Derivation\",\"tapInternalKey\",\"tapTree\",\"tapBip32Derivation\"]},2431:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function s(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function a(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function c(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:s,canAddToArray:c,check:u,expected:f}=i[t+\"s\"][n]||{};if(u)if(!!c){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(u)||a(t,n,f,o);const e=r[n]||[],i=new Set;if(!o.every((t=>c(e,t,i))))throw new Error(\"Can not add duplicate data to array\");r[n]=e.concat(o)}else{if(u(o)||a(t,n,f,o),!s(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=s,e.checkHasKey=function(t,e,r){if(t.key[0]e.key.equals(t.key))).length)throw new Error(`Duplicate Key: ${t.key.toString(\"hex\")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach((t=>{Number(isNaN(Number(t)))&&e++})),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,s=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=c(\"global\"),e.updateInput=c(\"input\"),e.updateOutput=c(\"output\"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=s(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error(\"Set Version: Invalid Transaction\");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error(\"Set Locktime: Invalid Transaction\");return e.writeUInt32LE(t,e.length-4),e}},3678:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(3678),i=r(1752);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.add=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=e.split=e.fromBig=void 0;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;oBigInt(t>>>0)<>>0);e.toBig=s;const a=(t,e,r)=>t>>>r;e.shrSH=a;const c=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=c;const u=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=u;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const h=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=h;const l=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=l;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<>>32-r;e.rotlSH=y;const g=(t,e,r)=>e<>>32-r;e.rotlSL=g;const b=(t,e,r)=>e<>>64-r;e.rotlBH=b;const w=(t,e,r)=>t<>>64-r;function m(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w,e.add=m;const v=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=v;const E=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=E;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const A=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=A;const I=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=I;const T={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:h,rotrBL:l,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:g,rotlBH:b,rotlBL:w,add:m,add3L:v,add3H:E,add4L:_,add4H:S,add5H:I,add5L:A};e.default=T},8280:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},4966:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(3678),i=r(1752);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),\"function\"!=typeof this.iHash.update)throw new Error(\"Expected instance of class which extends utils.Hash\");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;tnew o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},2985:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(7653),i=r(1752),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),a=s.map((t=>(9*t+5)%16));let c=[s],u=[a];for(let t=0;t<4;t++)for(let e of[c,u])e.push(e[t].map((t=>o[t])));const f=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),l=u.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const g=new Uint32Array(16);class b extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)g[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,a=0|this.h2,f=a,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=p[t],_=d[t],S=c[t],A=u[t],I=h[t],T=l[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,a,b)+g[S[e]]+E,I[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(a,10),a=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,s,f,w)+g[A[t]]+_,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(f,10),f=s,s=r}}this.set(this.h1+a+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+f|0)}roundClean(){g.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=b,e.ripemd160=(0,i.wrapConstructor)((()=>new b))},4458:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(7653),i=r(1752),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},4787:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha384=e.sha512_256=e.sha512_224=e.sha512=e.SHA512=void 0;const n=r(7653),i=r(6079),o=r(1752),[s,a]=i.default.split([\"0x428a2f98d728ae22\",\"0x7137449123ef65cd\",\"0xb5c0fbcfec4d3b2f\",\"0xe9b5dba58189dbbc\",\"0x3956c25bf348b538\",\"0x59f111f1b605d019\",\"0x923f82a4af194f9b\",\"0xab1c5ed5da6d8118\",\"0xd807aa98a3030242\",\"0x12835b0145706fbe\",\"0x243185be4ee4b28c\",\"0x550c7dc3d5ffb4e2\",\"0x72be5d74f27b896f\",\"0x80deb1fe3b1696b1\",\"0x9bdc06a725c71235\",\"0xc19bf174cf692694\",\"0xe49b69c19ef14ad2\",\"0xefbe4786384f25e3\",\"0x0fc19dc68b8cd5b5\",\"0x240ca1cc77ac9c65\",\"0x2de92c6f592b0275\",\"0x4a7484aa6ea6e483\",\"0x5cb0a9dcbd41fbd4\",\"0x76f988da831153b5\",\"0x983e5152ee66dfab\",\"0xa831c66d2db43210\",\"0xb00327c898fb213f\",\"0xbf597fc7beef0ee4\",\"0xc6e00bf33da88fc2\",\"0xd5a79147930aa725\",\"0x06ca6351e003826f\",\"0x142929670a0e6e70\",\"0x27b70a8546d22ffc\",\"0x2e1b21385c26c926\",\"0x4d2c6dfc5ac42aed\",\"0x53380d139d95b3df\",\"0x650a73548baf63de\",\"0x766a0abb3c77b2a8\",\"0x81c2c92e47edaee6\",\"0x92722c851482353b\",\"0xa2bfe8a14cf10364\",\"0xa81a664bbc423001\",\"0xc24b8b70d0f89791\",\"0xc76c51a30654be30\",\"0xd192e819d6ef5218\",\"0xd69906245565a910\",\"0xf40e35855771202a\",\"0x106aa07032bbd1b8\",\"0x19a4c116b8d2d0c8\",\"0x1e376c085141ab53\",\"0x2748774cdf8eeb99\",\"0x34b0bcb5e19b48a8\",\"0x391c0cb3c5c95a63\",\"0x4ed8aa4ae3418acb\",\"0x5b9cca4f7763e373\",\"0x682e6ff3d6b2b8a3\",\"0x748f82ee5defb2fc\",\"0x78a5636f43172f60\",\"0x84c87814a1f0ab72\",\"0x8cc702081a6439ec\",\"0x90befffa23631e28\",\"0xa4506cebde82bde9\",\"0xbef9a3f7b2c67915\",\"0xc67178f2e372532b\",\"0xca273eceea26619c\",\"0xd186b8c721c0c207\",\"0xeada7dd6cde0eb1e\",\"0xf57d4f7fee6ed178\",\"0x06f067aa72176fba\",\"0x0a637dc5a2c898a6\",\"0x113f9804bef90dae\",\"0x1b710b35131c471b\",\"0x28db77f523047d84\",\"0x32caab7b40c72493\",\"0x3c9ebe0a15c9bebc\",\"0x431d67c49c100d4c\",\"0x4cc5d4becb3e42b6\",\"0x597f299cfc657e2a\",\"0x5fcb6fab3ad6faec\",\"0x6c44198c4a475817\"].map((t=>BigInt(t)))),c=new Uint32Array(80),u=new Uint32Array(80);class f extends n.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:f,Fl:h,Gh:l,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,s,a,c,u,f,h,l,p,d,y]}set(t,e,r,n,i,o,s,a,c,u,f,h,l,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|f,this.Fl=0|h,this.Gh=0|l,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)c[r]=t.getUint32(e),u[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|c[t-15],r=0|u[t-15],n=i.default.rotrSH(e,r,1)^i.default.rotrSH(e,r,8)^i.default.shrSH(e,r,7),o=i.default.rotrSL(e,r,1)^i.default.rotrSL(e,r,8)^i.default.shrSL(e,r,7),s=0|c[t-2],a=0|u[t-2],f=i.default.rotrSH(s,a,19)^i.default.rotrBH(s,a,61)^i.default.shrSH(s,a,6),h=i.default.rotrSL(s,a,19)^i.default.rotrBL(s,a,61)^i.default.shrSL(s,a,6),l=i.default.add4L(o,h,u[t-7],u[t-16]),p=i.default.add4H(l,n,f,c[t-7],c[t-16]);c[t]=0|p,u[t]=0|l}let{Ah:r,Al:n,Bh:o,Bl:f,Ch:h,Cl:l,Dh:p,Dl:d,Eh:y,El:g,Fh:b,Fl:w,Gh:m,Gl:v,Hh:E,Hl:_}=this;for(let t=0;t<80;t++){const e=i.default.rotrSH(y,g,14)^i.default.rotrSH(y,g,18)^i.default.rotrBH(y,g,41),S=i.default.rotrSL(y,g,14)^i.default.rotrSL(y,g,18)^i.default.rotrBL(y,g,41),A=y&b^~y&m,I=g&w^~g&v,T=i.default.add5L(_,S,I,a[t],u[t]),x=i.default.add5H(T,E,e,A,s[t],c[t]),O=0|T,k=i.default.rotrSH(r,n,28)^i.default.rotrBH(r,n,34)^i.default.rotrBH(r,n,39),P=i.default.rotrSL(r,n,28)^i.default.rotrBL(r,n,34)^i.default.rotrBL(r,n,39),R=r&o^r&h^o&h,B=n&f^n&l^f&l;E=0|m,_=0|v,m=0|b,v=0|w,b=0|y,w=0|g,({h:y,l:g}=i.default.add(0|p,0|d,0|x,0|O)),p=0|h,d=0|l,h=0|o,l=0|f,o=0|r,f=0|n;const C=i.default.add3L(O,P,B);r=i.default.add3H(C,x,k,R),n=0|C}({h:r,l:n}=i.default.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:f}=i.default.add(0|this.Bh,0|this.Bl,0|o,0|f)),({h,l}=i.default.add(0|this.Ch,0|this.Cl,0|h,0|l)),({h:p,l:d}=i.default.add(0|this.Dh,0|this.Dl,0|p,0|d)),({h:y,l:g}=i.default.add(0|this.Eh,0|this.El,0|y,0|g)),({h:b,l:w}=i.default.add(0|this.Fh,0|this.Fl,0|b,0|w)),({h:m,l:v}=i.default.add(0|this.Gh,0|this.Gl,0|m,0|v)),({h:E,l:_}=i.default.add(0|this.Hh,0|this.Hl,0|E,0|_)),this.set(r,n,o,f,h,l,p,d,y,g,b,w,m,v,E,_)}roundClean(){c.fill(0),u.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}e.SHA512=f;class h extends f{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class l extends f{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class p extends f{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}e.sha512=(0,o.wrapConstructor)((()=>new f)),e.sha512_224=(0,o.wrapConstructor)((()=>new h)),e.sha512_256=(0,o.wrapConstructor)((()=>new l)),e.sha384=(0,o.wrapConstructor)((()=>new p))},1752:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(8280),i=r(3678);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},3803:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.BIP32Factory=void 0;const i=r(1772),o=r(8899),s=r(6710),a=r(4458),c=r(973),u=r(6952),f=(0,s.base58check)(a.sha256),h=t=>f.encode(Uint8Array.from(t)),l=t=>n.from(f.decode(t));e.BIP32Factory=function(t){(0,o.testEcc)(t);const e=c.BufferN(32),r=c.compile({wif:c.UInt8,bip32:{public:c.UInt32,private:c.UInt32}}),s={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},a=2147483648,f=Math.pow(2,31)-1;function p(t){return c.String(t)&&null!==t.match(/^(m\\/)?(\\d+'?\\/)*\\d+'?$/)}function d(t){return c.UInt32(t)&&t<=f}class y{constructor(t,e){this.__D=t,this.__Q=e,this.lowR=!1}get publicKey(){return void 0===this.__Q&&(this.__Q=n.from(t.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error(\"Missing private key\");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.privateKey));{let r=n.from(t.sign(e,this.privateKey));const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=n.from(t.sign(e,this.privateKey,i));return r}}signSchnorr(e){if(!this.privateKey)throw new Error(\"Missing private key\");if(!t.signSchnorr)throw new Error(\"signSchnorr not supported by ecc library\");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error(\"verifySchnorr not supported by ecc library\");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}}class g extends y{constructor(t,e,n,i,o=0,s=0,a=0){super(t,e),this.chainCode=n,this.network=i,this.__DEPTH=o,this.__INDEX=s,this.__PARENT_FINGERPRINT=a,c(r,i)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return i.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return m(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=n.allocUnsafe(78);return r.writeUInt32BE(e,0),r.writeUInt8(this.depth,4),r.writeUInt32BE(this.parentFingerprint,5),r.writeUInt32BE(this.index,9),this.chainCode.copy(r,13),this.isNeutered()?this.publicKey.copy(r,45):(r.writeUInt8(0,45),this.privateKey.copy(r,46)),h(r)}toWIF(){if(!this.privateKey)throw new TypeError(\"Missing private key\");return u.encode(this.network.wif,this.privateKey,!0)}derive(e){c(c.UInt32,e);const r=e>=a,o=n.allocUnsafe(37);if(r){if(this.isNeutered())throw new TypeError(\"Missing private key for hardened child key\");o[0]=0,this.privateKey.copy(o,1),o.writeUInt32BE(e,33)}else this.publicKey.copy(o,0),o.writeUInt32BE(e,33);const s=i.hmacSHA512(this.chainCode,o),u=s.slice(0,32),f=s.slice(32);if(!t.isPrivate(u))return this.derive(e+1);let h;if(this.isNeutered()){const r=n.from(t.pointAddScalar(this.publicKey,u,!0));if(null===r)return this.derive(e+1);h=m(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}else{const r=n.from(t.privateAdd(this.privateKey,u));if(null==r)return this.derive(e+1);h=w(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}return h}deriveHardened(t){return c(d,t),this.derive(t+a)}derivePath(t){c(p,t);let e=t.split(\"/\");if(\"m\"===e[0]){if(this.parentFingerprint)throw new TypeError(\"Expected master, got child\");e=e.slice(1)}return e.reduce(((t,e)=>{let r;return\"'\"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error(\"xOnlyPointAddTweak not supported by ecc library\");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error(\"Cannot tweak public key!\");const s=n.from([0===o.parity?2:3]),a=n.concat([s,o.xOnlyPubkey]);return new y(void 0,a)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&1==(1&this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error(\"privateNegate not supported by ecc library\")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error(\"Invalid tweaked private key!\");return new y(n.from(o),void 0)}}function b(t,e,r){return w(t,e,r)}function w(r,n,i,o,a,u){if(c({privateKey:e,chainCode:e},{privateKey:r,chainCode:n}),i=i||s,!t.isPrivate(r))throw new TypeError(\"Private key not in range [1, n)\");return new g(r,void 0,n,i,o,a,u)}function m(r,n,i,o,a,u){if(c({publicKey:c.BufferN(33),chainCode:e},{publicKey:r,chainCode:n}),i=i||s,!t.isPoint(r))throw new TypeError(\"Point is not on the curve\");return new g(void 0,r,n,i,o,a,u)}return{fromSeed:function(t,e){if(c(c.Buffer,t),t.length<16)throw new TypeError(\"Seed should be at least 128 bits\");if(t.length>64)throw new TypeError(\"Seed should be at most 512 bits\");e=e||s;const r=i.hmacSHA512(n.from(\"Bitcoin seed\",\"utf8\"),t);return b(r.slice(0,32),r.slice(32),e)},fromBase58:function(t,e){const r=l(t);if(78!==r.length)throw new TypeError(\"Invalid buffer length\");e=e||s;const n=r.readUInt32BE(0);if(n!==e.bip32.private&&n!==e.bip32.public)throw new TypeError(\"Invalid network version\");const i=r[4],o=r.readUInt32BE(5);if(0===i&&0!==o)throw new TypeError(\"Invalid parent fingerprint\");const a=r.readUInt32BE(9);if(0===i&&0!==a)throw new TypeError(\"Invalid index\");const c=r.slice(13,45);let u;if(n===e.bip32.private){if(0!==r.readUInt8(45))throw new TypeError(\"Invalid private key\");u=w(r.slice(46,78),c,e,i,a,o)}else{u=m(r.slice(45,78),c,e,i,a,o)}return u},fromPublicKey:function(t,e,r){return m(t,e,r)},fromPrivateKey:b}}},1772:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmacSHA512=e.hash160=void 0;const i=r(4966),o=r(2985),s=r(4458),a=r(4787);e.hash160=function(t){const e=(0,s.sha256)(Uint8Array.from(t));return n.from((0,o.ripemd160)(e))},e.hmacSHA512=function(t,e){return n.from((0,i.hmac)(a.sha512,t,e))}},3553:(t,e,r)=>{\"use strict\";e.Pr=void 0;var n=r(3803);Object.defineProperty(e,\"Pr\",{enumerable:!0,get:function(){return n.BIP32Factory}})},8899:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,\"hex\");function o(t){if(!t)throw new Error(\"ecc library invalid\")}e.testEcc=function(t){if(o(t.isPoint(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(!t.isPoint(i(\"030000000000000000000000000000000000000000000000000000000000000005\"))),o(t.isPrivate(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(!t.isPrivate(i(\"0000000000000000000000000000000000000000000000000000000000000000\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142\"))),o(n.from(t.pointFromScalar(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99\"))),t.xOnlyPointAddTweak){o(null===t.xOnlyPointAddTweak(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\")));let e=t.xOnlyPointAddTweak(i(\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\"),i(\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\"));o(n.from(e.xOnlyPubkey).equals(i(\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"))&&1===e.parity),e=t.xOnlyPointAddTweak(i(\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\"),i(\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\"))}o(n.from(t.pointAddScalar(i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"0000000000000000000000000000000000000000000000000000000000000003\"))).equals(i(\"02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\"))),o(n.from(t.privateAdd(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"),i(\"0000000000000000000000000000000000000000000000000000000000000002\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),t.privateNegate&&(o(n.from(t.privateNegate(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(n.from(t.privateNegate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateNegate(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792\")))),o(n.from(t.sign(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))).equals(i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),o(t.verify(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),t.signSchnorr&&o(n.from(t.signSchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9\"),i(\"c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906\"))).equals(i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\"))),t.verifySchnorr&&o(t.verifySchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8\"),i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\")))}},3877:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(3877),i=r(775);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},742:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(1810),i=r(775),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),a=s.map((t=>(9*t+5)%16));let c=[s],u=[a];for(let t=0;t<4;t++)for(let e of[c,u])e.push(e[t].map((t=>o[t])));const f=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),l=u.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const g=new Uint32Array(16);class b extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)g[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,a=0|this.h2,f=a,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=p[t],_=d[t],S=c[t],A=u[t],I=h[t],T=l[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,a,b)+g[S[e]]+E,I[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(a,10),a=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,s,f,w)+g[A[t]]+_,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(f,10),f=s,s=r}}this.set(this.h1+a+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+f|0)}roundClean(){g.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=b,e.ripemd160=(0,i.wrapConstructor)((()=>new b))},3293:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha1=void 0;const n=r(1810),i=r(775),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),s=new Uint32Array(80);class a extends n.HashMD{constructor(){super(64,20,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4]}get(){const{A:t,B:e,C:r,D:n,E:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)s[t]=(0,i.rotl)(s[t-3]^s[t-8]^s[t-14]^s[t-16],1);let{A:r,B:o,C:a,D:c,E:u}=this;for(let t=0;t<80;t++){let e,f;t<20?(e=(0,n.Chi)(o,a,c),f=1518500249):t<40?(e=o^a^c,f=1859775393):t<60?(e=(0,n.Maj)(o,a,c),f=2400959708):(e=o^a^c,f=3395469782);const h=(0,i.rotl)(r,5)+e+u+f+s[t]|0;u=c,c=a,a=(0,i.rotl)(o,30),o=r,r=h}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,c=c+this.D|0,u=u+this.E|0,this.set(r,o,a,c,u)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.sha1=(0,i.wrapConstructor)((()=>new a))},5743:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(1810),i=r(775),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},775:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(8713),i=r(3877);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},7748:t=>{\"use strict\";t.exports=function(t){if(t.length>=255)throw new TypeError(\"Alphabet too long\");for(var e=new Uint8Array(256),r=0;r>>0,u=new Uint8Array(o);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,l=o-1;(0!==f||h>>0,u[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error(\"Non-zero carry\");i=h,r++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var d=new Uint8Array(n+(o-p)),y=n;p!==o;)d[y++]=u[p++];return d}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError(\"Expected Uint8Array\");if(0===e.length)return\"\";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var c=(o-i)*u+1>>>0,f=new Uint8Array(c);i!==o;){for(var h=e[i],l=0,p=c-1;(0!==h||l>>0,f[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error(\"Non-zero carry\");n=l,i++}for(var d=c-n;d!==c&&0===f[d];)d++;for(var y=a.repeat(r);d{const n=r(7748);t.exports=n(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\")},5940:(t,e,r)=>{\"use strict\";var n=r(8155);t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),i=t(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error(\"Invalid checksum\");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},7329:(t,e,r)=>{\"use strict\";var{sha256:n}=r(5743),i=r(5940);t.exports=i((function(t){return n(n(t))}))},3348:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.toOutputScript=e.fromOutputScript=e.toBech32=e.toBase58Check=e.fromBech32=e.fromBase58Check=void 0;const i=r(2529),o=r(8614),s=r(4009),a=r(5593),c=r(6586),u=r(7329),f=40,h=2,l=16,p=2,d=80,y=\"WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.\";function g(t){const e=n.from(u.decode(t));if(e.length<21)throw new TypeError(t+\" is too short\");if(e.length>21)throw new TypeError(t+\" is too long\");return{version:e.readUInt8(0),hash:e.slice(1)}}function b(t){let e,r;try{e=c.bech32.decode(t)}catch(t){}if(e){if(r=e.words[0],0!==r)throw new TypeError(t+\" uses wrong encoding\")}else if(e=c.bech32m.decode(t),r=e.words[0],0===r)throw new TypeError(t+\" uses wrong encoding\");const i=c.bech32.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:n.from(i)}}function w(t,e,r){const n=c.bech32.toWords(t);return n.unshift(e),0===e?c.bech32.encode(r,n):c.bech32m.encode(r,n)}e.fromBase58Check=g,e.fromBech32=b,e.toBase58Check=function(t,e){(0,a.typeforce)((0,a.tuple)(a.Hash160bit,a.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),u.encode(r)},e.toBech32=w,e.fromOutputScript=function(t,e){e=e||i.bitcoin;try{return o.p2pkh({output:t,network:e}).address}catch(t){}try{return o.p2sh({output:t,network:e}).address}catch(t){}try{return o.p2wpkh({output:t,network:e}).address}catch(t){}try{return o.p2wsh({output:t,network:e}).address}catch(t){}try{return o.p2tr({output:t,network:e}).address}catch(t){}try{return function(t,e){const r=t.slice(2);if(r.lengthf)throw new TypeError(\"Invalid program length for segwit address\");const n=t[0]-d;if(nl)throw new TypeError(\"Invalid version for segwit address\");if(t[1]!==r.length)throw new TypeError(\"Invalid script for segwit address\");return console.warn(y),w(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(s.toASM(t)+\" has no matching Address\")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=g(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===e.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=b(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+\" has an invalid prefix\");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=p&&n.version<=l&&n.data.length>=h&&n.data.length<=f)return console.warn(y),s.compile([n.version+d,n.data])}}throw new Error(t+\" has no matching Script\")}},195:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=e.check=void 0,e.check=function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;const e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;const r=t[5+e];return 0!==r&&(6+e+r===t.length&&(!(128&t[4])&&(!(e>1&&0===t[4]&&!(128&t[5]))&&(!(128&t[e+6])&&!(r>1&&0===t[e+6]&&!(128&t[e+7]))))))},e.decode=function(t){if(t.length<8)throw new Error(\"DER sequence length is too short\");if(t.length>72)throw new Error(\"DER sequence length is too long\");if(48!==t[0])throw new Error(\"Expected DER sequence\");if(t[1]!==t.length-2)throw new Error(\"DER sequence length is invalid\");if(2!==t[2])throw new Error(\"Expected DER integer\");const e=t[3];if(0===e)throw new Error(\"R length is zero\");if(5+e>=t.length)throw new Error(\"R length is too long\");if(2!==t[4+e])throw new Error(\"Expected DER integer (2)\");const r=t[5+e];if(0===r)throw new Error(\"S length is zero\");if(6+e+r!==t.length)throw new Error(\"S length is invalid\");if(128&t[4])throw new Error(\"R value is negative\");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error(\"R value excessively padded\");if(128&t[e+6])throw new Error(\"S value is negative\");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error(\"S value excessively padded\");return{r:t.slice(4,4+e),s:t.slice(6+e)}},e.encode=function(t,e){const r=t.length,i=e.length;if(0===r)throw new Error(\"R length is zero\");if(0===i)throw new Error(\"S length is zero\");if(r>33)throw new Error(\"R length is too long\");if(i>33)throw new Error(\"S length is too long\");if(128&t[0])throw new Error(\"R value is negative\");if(128&e[0])throw new Error(\"S value is negative\");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error(\"R value excessively padded\");if(i>1&&0===e[0]&&!(128&e[1]))throw new Error(\"S value excessively padded\");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=t.length,t.copy(o,4),o[4+r]=2,o[5+r]=e.length,e.copy(o,6+r),o}},1169:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Block=void 0;const i=r(3831),o=r(6891),s=r(7992),a=r(3063),c=r(5593),{typeforce:u}=c,f=new TypeError(\"Cannot compute merkle root for zero transactions\"),h=new TypeError(\"Cannot compute witness commit for non-segwit block\");class l{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(t){if(t.length<80)throw new Error(\"Buffer too small (< 80 bytes)\");const e=new i.BufferReader(t),r=new l;if(r.version=e.readInt32(),r.prevHash=e.readSlice(32),r.merkleRoot=e.readSlice(32),r.timestamp=e.readUInt32(),r.bits=e.readUInt32(),r.nonce=e.readUInt32(),80===t.length)return r;const n=()=>{const t=a.Transaction.fromBuffer(e.buffer.slice(e.offset),!0);return e.offset+=t.byteLength(),t},o=e.readVarInt();r.transactions=[];for(let t=0;t>24)-3,r=8388607&t,i=n.alloc(32,0);return i.writeUIntBE(r,29-e,3),i}static calculateMerkleRoot(t,e){if(u([{getHash:c.Function}],t),0===t.length)throw f;if(e&&!p(t))throw h;const r=t.map((t=>t.getHash(e))),i=(0,s.fastMerkleRoot)(r,o.hash256);return e?o.hash256(n.concat([i,t[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!p(this.transactions))return null;const t=this.transactions[0].outs.filter((t=>t.script.slice(0,6).equals(n.from(\"6a24aa21a9ed\",\"hex\")))).map((t=>t.script.slice(6,38)));if(0===t.length)return null;const e=t[t.length-1];return e instanceof n&&32===e.length?e:null}hasWitnessCommit(){return this.witnessCommit instanceof n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(t=this.transactions)instanceof Array&&t.some((t=>\"object\"==typeof t&&t.ins instanceof Array&&t.ins.some((t=>\"object\"==typeof t&&t.witness instanceof Array&&t.witness.length>0))));var t}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(t,e=!0){return t||!this.transactions?80:80+i.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((t,r)=>t+r.byteLength(e)),0)}getHash(){return o.hash256(this.toBuffer(!0))}getId(){return(0,i.reverseBuffer)(this.getHash()).toString(\"hex\")}getUTCDate(){const t=new Date(0);return t.setUTCSeconds(this.timestamp),t}toBuffer(t){const e=n.allocUnsafe(this.byteLength(t)),r=new i.BufferWriter(e);return r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),t||!this.transactions||(i.varuint.encode(this.transactions.length,e,r.offset),r.offset+=i.varuint.encode.bytes,this.transactions.forEach((t=>{const n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}toHex(t){return this.toBuffer(t).toString(\"hex\")}checkTxRoots(){const t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&(this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit()))}checkProofOfWork(){const t=(0,i.reverseBuffer)(this.getHash()),e=l.calculateTarget(this.bits);return t.compare(e)<=0}__checkMerkleRoot(){if(!this.transactions)throw f;const t=l.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw f;if(!this.hasWitnessCommit())throw h;const t=l.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}function p(t){return t instanceof Array&&t[0]&&t[0].ins&&t[0].ins instanceof Array&&t[0].ins[0]&&t[0].ins[0].witness&&t[0].ins[0].witness instanceof Array&&t[0].ins[0].witness.length>0}e.Block=l},3831:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.BufferReader=e.BufferWriter=e.cloneBuffer=e.reverseBuffer=e.writeUInt64LE=e.readUInt64LE=e.varuint=void 0;const i=r(5593),{typeforce:o}=i,s=r(7820);function a(t,e){if(\"number\"!=typeof t)throw new Error(\"cannot write a non-number as a number\");if(t<0)throw new Error(\"specified a negative value for writing an unsigned value\");if(t>e)throw new Error(\"RangeError: value out of range\");if(Math.floor(t)!==t)throw new Error(\"value has a fractional component\")}function c(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r}function u(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}e.varuint=s,e.readUInt64LE=c,e.writeUInt64LE=u,e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;nthis.writeVarSlice(t)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}e.BufferWriter=f;e.BufferReader=class{constructor(t,e=0){this.buffer=t,this.offset=e,o(i.tuple(i.Buffer,i.UInt32),[t,e])}readUInt8(){const t=this.buffer.readUInt8(this.offset);return this.offset++,t}readInt32(){const t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}readUInt32(){const t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}readUInt64(){const t=c(this.buffer,this.offset);return this.offset+=8,t}readVarInt(){const t=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,t}readSlice(t){if(this.buffer.length{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const i=r(742),o=r(3293),s=r(5743);function a(t){return n.from((0,s.sha256)(Uint8Array.from(t)))}e.ripemd160=function(t){return n.from((0,i.ripemd160)(Uint8Array.from(t)))},e.sha1=function(t){return n.from((0,o.sha1)(Uint8Array.from(t)))},e.sha256=a,e.hash160=function(t){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(t))))},e.TAGS=[\"BIP0340/challenge\",\"BIP0340/aux\",\"BIP0340/nonce\",\"TapLeaf\",\"TapBranch\",\"TapSighash\",\"TapTweak\",\"KeyAgg list\",\"KeyAgg coefficient\"],e.TAGGED_HASH_PREFIXES={\"BIP0340/challenge\":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),\"BIP0340/aux\":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),\"BIP0340/nonce\":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),\"KeyAgg list\":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),\"KeyAgg coefficient\":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},e.taggedHash=function(t,r){return a(n.concat([e.TAGGED_HASH_PREFIXES[t],r]))}},6313:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.getEccLib=e.initEccLib=void 0;const i={};e.initEccLib=function(t){var e;t?t!==i.eccLib&&(s(\"function\"==typeof(e=t).isXOnlyPoint),s(e.isXOnlyPoint(o(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),s(e.isXOnlyPoint(o(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e\"))),s(e.isXOnlyPoint(o(\"f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9\"))),s(e.isXOnlyPoint(o(\"0000000000000000000000000000000000000000000000000000000000000001\"))),s(!e.isXOnlyPoint(o(\"0000000000000000000000000000000000000000000000000000000000000000\"))),s(!e.isXOnlyPoint(o(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\"))),s(\"function\"==typeof e.xOnlyPointAddTweak),a.forEach((t=>{const r=e.xOnlyPointAddTweak(o(t.pubkey),o(t.tweak));null===t.result?s(null===r):(s(null!==r),s(r.parity===t.parity),s(n.from(r.xOnlyPubkey).equals(o(t.result))))})),i.eccLib=t):i.eccLib=t},e.getEccLib=function(){if(!i.eccLib)throw new Error(\"No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance\");return i.eccLib};const o=t=>n.from(t,\"hex\");function s(t){if(!t)throw new Error(\"ecc library invalid\")}const a=[{pubkey:\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\",tweak:\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\",parity:-1,result:null},{pubkey:\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\",tweak:\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\",parity:1,result:\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"},{pubkey:\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\",tweak:\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\",parity:0,result:\"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c\"}]},7612:(t,e,r)=>{\"use strict\";e.ZX=e.iL=e.KT=e.o8=e.hl=void 0;const n=r(3348);e.hl=n;r(6891);const i=r(2529);e.o8=i;const o=r(8614);e.KT=o;r(4009);var s=r(1169);var a=r(6689);Object.defineProperty(e,\"iL\",{enumerable:!0,get:function(){return a.Psbt}});var c=r(8156);var u=r(3063);Object.defineProperty(e,\"ZX\",{enumerable:!0,get:function(){return u.Transaction}});var f=r(6313)},7992:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.fastMerkleRoot=void 0,e.fastMerkleRoot=function(t,e){if(!Array.isArray(t))throw TypeError(\"Expected values Array\");if(\"function\"!=typeof e)throw TypeError(\"Expected digest Function\");let r=t.length;const i=t.concat();for(;r>1;){let t=0;for(let o=0;o{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.testnet=e.regtest=e.bitcoin=void 0,e.bitcoin={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.regtest={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bcrt\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},e.testnet={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"tb\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},8156:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.REVERSE_OPS=e.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};e.OPS=r;const n={};e.REVERSE_OPS=n;for(const t of Object.keys(r)){n[r[t]]=t}},5247:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(1048),i=r(6313),o=r(6891),s=r(3831),a=r(5593);e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128;function c(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return o.taggedHash(\"TapLeaf\",n.Buffer.concat([n.Buffer.from([r]),h(t.output)]))}function u(t,e){return o.taggedHash(\"TapTweak\",n.Buffer.concat(e?[t,e]:[t]))}function f(t,e){return o.taggedHash(\"TapBranch\",n.Buffer.concat([t,e]))}function h(t){const e=s.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return s.varuint.encode(t.length,r),n.Buffer.concat([r,t])}e.rootHashFromPath=function(t,e){if(t.length<33)throw new TypeError(`The control-block length is too small. Got ${t.length}, expected min 33.`);const r=(t.length-33)/32;let n=e;for(let e=0;et.hash.compare(e.hash)));const[n,i]=r;return{hash:f(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function t(e,r){if(\"left\"in(n=e)&&\"right\"in n){const n=t(e.left,r);if(void 0!==n)return[...n,e.right.hash];const i=t(e.right,r);if(void 0!==i)return[...i,e.left.hash]}else if(e.hash.equals(r))return[];var n},e.tapleafHash=c,e.tapTweakHash=u,e.tweakKey=function(t,e){if(!n.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;const r=u(t,e),o=(0,i.getEccLib)().xOnlyPointAddTweak(t,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},271:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2data=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;e.p2data=function(t,e){if(!t.data&&!t.output)throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},t);const r={name:\"embed\",network:t.network||n.bitcoin};if(s.prop(r,\"output\",(()=>{if(t.data)return i.compile([a.OP_RETURN].concat(t.data))})),s.prop(r,\"data\",(()=>{if(t.output)return i.decompile(t.output).slice(1)})),e.validate&&t.output){const e=i.decompile(t.output);if(e[0]!==a.OP_RETURN)throw new TypeError(\"Output is invalid\");if(!e.slice(1).every(o.typeforce.Buffer))throw new TypeError(\"Output is invalid\");if(t.data&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.data,r.data))throw new TypeError(\"Data mismatch\")}return Object.assign(r,t)}},8614:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const n=r(271);Object.defineProperty(e,\"embed\",{enumerable:!0,get:function(){return n.p2data}});const i=r(2810);Object.defineProperty(e,\"p2ms\",{enumerable:!0,get:function(){return i.p2ms}});const o=r(5643);Object.defineProperty(e,\"p2pk\",{enumerable:!0,get:function(){return o.p2pk}});const s=r(9379);Object.defineProperty(e,\"p2pkh\",{enumerable:!0,get:function(){return s.p2pkh}});const a=r(2129);Object.defineProperty(e,\"p2sh\",{enumerable:!0,get:function(){return a.p2sh}});const c=r(7090);Object.defineProperty(e,\"p2wpkh\",{enumerable:!0,get:function(){return c.p2wpkh}});const u=r(2366);Object.defineProperty(e,\"p2wsh\",{enumerable:!0,get:function(){return u.p2wsh}});const f=r(1992);Object.defineProperty(e,\"p2tr\",{enumerable:!0,get:function(){return f.p2tr}})},9158:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.value=e.prop=void 0,e.prop=function(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){const t=r.call(this);return this[e]=t,t},set(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})},e.value=function(t){let e;return()=>(void 0!==e||(e=t()),e)}},2810:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2ms=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS,c=a.OP_RESERVED;function u(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}e.p2ms=function(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError(\"Not enough data\");function r(t){return i.isCanonicalScriptSignature(t)||void 0!==(e.allowIncomplete&&t===a.OP_0)}e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const f={network:t.network||n.bitcoin};let h=[],l=!1;function p(t){l||(l=!0,h=i.decompile(t),f.m=h[0]-c,f.n=h[h.length-2]-c,f.pubkeys=h.slice(1,-2))}if(s.prop(f,\"output\",(()=>{if(t.m&&f.n&&t.pubkeys)return i.compile([].concat(c+t.m,t.pubkeys,c+f.n,a.OP_CHECKMULTISIG))})),s.prop(f,\"m\",(()=>{if(f.output)return p(f.output),f.m})),s.prop(f,\"n\",(()=>{if(f.pubkeys)return f.pubkeys.length})),s.prop(f,\"pubkeys\",(()=>{if(t.output)return p(t.output),f.pubkeys})),s.prop(f,\"signatures\",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),s.prop(f,\"input\",(()=>{if(t.signatures)return i.compile([a.OP_0].concat(t.signatures))})),s.prop(f,\"witness\",(()=>{if(f.input)return[]})),s.prop(f,\"name\",(()=>{if(f.m&&f.n)return`p2ms(${f.m} of ${f.n})`})),e.validate){if(t.output){if(p(t.output),!o.typeforce.Number(h[0]))throw new TypeError(\"Output is invalid\");if(!o.typeforce.Number(h[h.length-2]))throw new TypeError(\"Output is invalid\");if(h[h.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError(\"Output is invalid\");if(f.m<=0||f.n>16||f.m>f.n||f.n!==h.length-3)throw new TypeError(\"Output is invalid\");if(!f.pubkeys.every((t=>(0,o.isPoint)(t))))throw new TypeError(\"Output is invalid\");if(void 0!==t.m&&t.m!==f.m)throw new TypeError(\"m mismatch\");if(void 0!==t.n&&t.n!==f.n)throw new TypeError(\"n mismatch\");if(t.pubkeys&&!u(t.pubkeys,f.pubkeys))throw new TypeError(\"Pubkeys mismatch\")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError(\"Pubkey count mismatch\");if(f.n=t.pubkeys.length,f.nf.m)throw new TypeError(\"Too many signatures provided\")}if(t.input){if(t.input[0]!==a.OP_0)throw new TypeError(\"Input is invalid\");if(0===f.signatures.length||!f.signatures.every(r))throw new TypeError(\"Input has invalid signature(s)\");if(t.signatures&&!u(t.signatures,f.signatures))throw new TypeError(\"Signature mismatch\");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError(\"Signature count mismatch\")}}return Object.assign(f,t)}},5643:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2pk=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;e.p2pk=function(t,e){if(!(t.input||t.output||t.pubkey||t.input||t.signature))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const r=s.value((()=>i.decompile(t.input))),c={name:\"p2pk\",network:t.network||n.bitcoin};if(s.prop(c,\"output\",(()=>{if(t.pubkey)return i.compile([t.pubkey,a.OP_CHECKSIG])})),s.prop(c,\"pubkey\",(()=>{if(t.output)return t.output.slice(1,-1)})),s.prop(c,\"signature\",(()=>{if(t.input)return r()[0]})),s.prop(c,\"input\",(()=>{if(t.signature)return i.compile([t.signature])})),s.prop(c,\"witness\",(()=>{if(c.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==a.OP_CHECKSIG)throw new TypeError(\"Output is invalid\");if(!(0,o.isPoint)(c.pubkey))throw new TypeError(\"Output pubkey is invalid\");if(t.pubkey&&!t.pubkey.equals(c.pubkey))throw new TypeError(\"Pubkey mismatch\")}if(t.signature&&t.input&&!t.input.equals(c.input))throw new TypeError(\"Signature mismatch\");if(t.input){if(1!==r().length)throw new TypeError(\"Input is invalid\");if(!i.isCanonicalScriptSignature(c.signature))throw new TypeError(\"Input has invalid signature\")}}return Object.assign(c,t)}},9379:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2pkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(7329),f=s.OPS;e.p2pkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(25)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),input:a.typeforce.maybe(a.typeforce.Buffer)},t);const r=c.value((()=>{const e=n.from(u.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),h=c.value((()=>s.decompile(t.input))),l=t.network||o.bitcoin,p={name:\"p2pkh\",network:l};if(c.prop(p,\"address\",(()=>{if(!p.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(l.pubKeyHash,0),p.hash.copy(t,1),u.encode(t)})),c.prop(p,\"hash\",(()=>t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),c.prop(p,\"output\",(()=>{if(p.hash)return s.compile([f.OP_DUP,f.OP_HASH160,p.hash,f.OP_EQUALVERIFY,f.OP_CHECKSIG])})),c.prop(p,\"pubkey\",(()=>{if(t.input)return h()[1]})),c.prop(p,\"signature\",(()=>{if(t.input)return h()[0]})),c.prop(p,\"input\",(()=>{if(t.pubkey&&t.signature)return s.compile([t.signature,t.pubkey])})),c.prop(p,\"witness\",(()=>{if(p.input)return[]})),e.validate){let e=n.from([]);if(t.address){if(r().version!==l.pubKeyHash)throw new TypeError(\"Invalid version or Network mismatch\");if(20!==r().hash.length)throw new TypeError(\"Invalid address\");e=r().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==f.OP_DUP||t.output[1]!==f.OP_HASH160||20!==t.output[2]||t.output[23]!==f.OP_EQUALVERIFY||t.output[24]!==f.OP_CHECKSIG)throw new TypeError(\"Output is invalid\");const r=t.output.slice(3,23);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.input){const r=h();if(2!==r.length)throw new TypeError(\"Input is invalid\");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError(\"Input has invalid signature\");if(!(0,a.isPoint)(r[1]))throw new TypeError(\"Input has invalid pubkey\");if(t.signature&&!t.signature.equals(r[0]))throw new TypeError(\"Signature mismatch\");if(t.pubkey&&!t.pubkey.equals(r[1]))throw new TypeError(\"Pubkey mismatch\");const n=i.hash160(r[1]);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\")}}return Object.assign(p,t)}},2129:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2sh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(7329),f=s.OPS;e.p2sh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(23)),redeem:a.typeforce.maybe({network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||o.bitcoin);const h={network:r},l=c.value((()=>{const e=n.from(u.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),p=c.value((()=>s.decompile(t.input))),d=c.value((()=>{const e=p(),i=e[e.length-1];return{network:r,output:i===f.OP_FALSE?n.from([]):i,input:s.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(c.prop(h,\"address\",(()=>{if(!h.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(h.network.scriptHash,0),h.hash.copy(t,1),u.encode(t)})),c.prop(h,\"hash\",(()=>t.output?t.output.slice(2,22):t.address?l().hash:h.redeem&&h.redeem.output?i.hash160(h.redeem.output):void 0)),c.prop(h,\"output\",(()=>{if(h.hash)return s.compile([f.OP_HASH160,h.hash,f.OP_EQUAL])})),c.prop(h,\"redeem\",(()=>{if(t.input)return d()})),c.prop(h,\"input\",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return s.compile([].concat(s.decompile(t.redeem.input),t.redeem.output))})),c.prop(h,\"witness\",(()=>h.redeem&&h.redeem.witness?h.redeem.witness:h.input?[]:void 0)),c.prop(h,\"name\",(()=>{const t=[\"p2sh\"];return void 0!==h.redeem&&void 0!==h.redeem.name&&t.push(h.redeem.name),t.join(\"-\")})),e.validate){let e=n.from([]);if(t.address){if(l().version!==r.scriptHash)throw new TypeError(\"Invalid version or Network mismatch\");if(20!==l().hash.length)throw new TypeError(\"Invalid address\");e=l().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==f.OP_HASH160||20!==t.output[1]||t.output[22]!==f.OP_EQUAL)throw new TypeError(\"Output is invalid\");const r=t.output.slice(2,22);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}const o=t=>{if(t.output){const r=s.decompile(t.output);if(!r||r.length<1)throw new TypeError(\"Redeem.output too short\");if(t.output.byteLength>520)throw new TypeError(\"Redeem.output unspendable if larger than 520 bytes\");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError(\"Redeem.output unspendable with more than 201 non-push ops\");const n=i.hash160(t.output);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\");e=n}if(t.input){const e=t.input.length>0,r=t.witness&&t.witness.length>0;if(!e&&!r)throw new TypeError(\"Empty input\");if(e&&r)throw new TypeError(\"Input and witness provided\");if(e){const e=s.decompile(t.input);if(!s.isPushOnly(e))throw new TypeError(\"Non push-only scriptSig\")}}};if(t.input){const t=p();if(!t||t.length<1)throw new TypeError(\"Input too short\");if(!n.isBuffer(d().output))throw new TypeError(\"Input is invalid\");o(d())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError(\"Network mismatch\");if(t.input){const e=d();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError(\"Redeem.output mismatch\");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError(\"Redeem.input mismatch\")}o(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,t.witness))throw new TypeError(\"Witness and redeem.witness mismatch\")}return Object.assign(h,t)}},1992:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2tr=void 0;const n=r(1048),i=r(2529),o=r(4009),s=r(5593),a=r(6313),c=r(5247),u=r(9158),f=r(6586),h=o.OPS;e.p2tr=function(t,e){if(!(t.address||t.output||t.pubkey||t.internalPubkey||t.witness&&t.witness.length>1))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},t);const r=u.value((()=>{const e=f.bech32m.decode(t.address),r=e.words.shift(),i=f.bech32m.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.Buffer.from(i)}})),l=u.value((()=>{if(t.witness&&t.witness.length)return t.witness.length>=2&&80===t.witness[t.witness.length-1][0]?t.witness.slice(0,-1):t.witness.slice()})),p=u.value((()=>t.scriptTree?(0,c.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),d=t.network||i.bitcoin,y={name:\"p2tr\",network:d};if(u.prop(y,\"address\",(()=>{if(!y.pubkey)return;const t=f.bech32m.toWords(y.pubkey);return t.unshift(1),f.bech32m.encode(d.bech32,t)})),u.prop(y,\"hash\",(()=>{const t=p();if(t)return t.hash;const e=l();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&s.TAPLEAF_VERSION_MASK,n=e[e.length-2],i=(0,c.tapleafHash)({output:n,version:r});return(0,c.rootHashFromPath)(t,i)}return null})),u.prop(y,\"output\",(()=>{if(y.pubkey)return o.compile([h.OP_1,y.pubkey])})),u.prop(y,\"redeemVersion\",(()=>t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:c.LEAF_VERSION_TAPSCRIPT)),u.prop(y,\"redeem\",(()=>{const t=l();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&s.TAPLEAF_VERSION_MASK}})),u.prop(y,\"pubkey\",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(y.internalPubkey){const t=(0,c.tweakKey)(y.internalPubkey,y.hash);if(t)return t.x}})),u.prop(y,\"internalPubkey\",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=l();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),u.prop(y,\"signature\",(()=>{if(t.signature)return t.signature;const e=l();return e&&1===e.length?e[0]:void 0})),u.prop(y,\"witness\",(()=>{if(t.witness)return t.witness;const e=p();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,c.tapleafHash)({output:t.redeem.output,version:y.redeemVersion}),i=(0,c.findScriptPath)(e,r);if(!i)return;const o=(0,c.tweakKey)(t.internalPubkey,e.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([y.redeemVersion|o.parity]),t.internalPubkey].concat(i));return[t.redeem.output,s]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(d&&d.bech32!==r().prefix)throw new TypeError(\"Invalid prefix or Network mismatch\");if(1!==r().version)throw new TypeError(\"Invalid address version\");if(32!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.pubkey){if(e.length>0&&!e.equals(t.pubkey))throw new TypeError(\"Pubkey mismatch\");e=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==h.OP_1||32!==t.output[1])throw new TypeError(\"Output is invalid\");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError(\"Pubkey mismatch\");e=t.output.slice(2)}if(t.internalPubkey){const r=(0,c.tweakKey)(t.internalPubkey,y.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError(\"Pubkey mismatch\");e=r.x}if(e&&e.length&&!(0,a.getEccLib)().isXOnlyPoint(e))throw new TypeError(\"Invalid pubkey for p2tr\");const i=p();if(t.hash&&i&&!t.hash.equals(i.hash))throw new TypeError(\"Hash mismatch\");if(t.redeem&&t.redeem.output&&i){const e=(0,c.tapleafHash)({output:t.redeem.output,version:y.redeemVersion});if(!(0,c.findScriptPath)(i,e))throw new TypeError(\"Redeem script not in tree\")}const u=l();if(t.redeem&&y.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==y.redeem.redeemVersion)throw new TypeError(\"Redeem.redeemVersion and witness mismatch\");if(t.redeem.output){if(0===o.decompile(t.redeem.output).length)throw new TypeError(\"Redeem.output is invalid\");if(y.redeem.output&&!t.redeem.output.equals(y.redeem.output))throw new TypeError(\"Redeem.output and witness mismatch\")}if(t.redeem.witness&&y.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,y.redeem.witness))throw new TypeError(\"Redeem.witness and witness mismatch\")}if(u&&u.length)if(1===u.length){if(t.signature&&!t.signature.equals(u[0]))throw new TypeError(\"Signature mismatch\")}else{const r=u[u.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(i))throw new TypeError(\"Internal pubkey mismatch\");if(!(0,a.getEccLib)().isXOnlyPoint(i))throw new TypeError(\"Invalid internalPubkey for p2tr witness\");const o=r[0]&s.TAPLEAF_VERSION_MASK,f=u[u.length-2],h=(0,c.tapleafHash)({output:f,version:o}),l=(0,c.rootHashFromPath)(r,h),p=(0,c.tweakKey)(i,l);if(!p)throw new TypeError(\"Invalid outputKey for p2tr witness\");if(e.length&&!e.equals(p.x))throw new TypeError(\"Pubkey mismatch for p2tr witness\");if(p.parity!==(1&r[0]))throw new Error(\"Incorrect parity\")}}return Object.assign(y,t)}},7090:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2wpkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(6586),f=s.OPS,h=n.alloc(0);e.p2wpkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(22)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=c.value((()=>{const e=u.bech32.decode(t.address),r=e.words.shift(),i=u.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),l=t.network||o.bitcoin,p={name:\"p2wpkh\",network:l};if(c.prop(p,\"address\",(()=>{if(!p.hash)return;const t=u.bech32.toWords(p.hash);return t.unshift(0),u.bech32.encode(l.bech32,t)})),c.prop(p,\"hash\",(()=>t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),c.prop(p,\"output\",(()=>{if(p.hash)return s.compile([f.OP_0,p.hash])})),c.prop(p,\"pubkey\",(()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0)),c.prop(p,\"signature\",(()=>{if(t.witness)return t.witness[0]})),c.prop(p,\"input\",(()=>{if(p.witness)return h})),c.prop(p,\"witness\",(()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){let e=n.from([]);if(t.address){if(l&&l.bech32!==r().prefix)throw new TypeError(\"Invalid prefix or Network mismatch\");if(0!==r().version)throw new TypeError(\"Invalid address version\");if(20!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==f.OP_0||20!==t.output[1])throw new TypeError(\"Output is invalid\");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError(\"Hash mismatch\");e=t.output.slice(2)}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");if(e=r,!(0,a.isPoint)(t.pubkey)||33!==t.pubkey.length)throw new TypeError(\"Invalid pubkey for p2wpkh\")}if(t.witness){if(2!==t.witness.length)throw new TypeError(\"Witness is invalid\");if(!s.isCanonicalScriptSignature(t.witness[0]))throw new TypeError(\"Witness has invalid signature\");if(!(0,a.isPoint)(t.witness[1])||33!==t.witness[1].length)throw new TypeError(\"Witness has invalid pubkey\");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError(\"Signature mismatch\");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError(\"Pubkey mismatch\");const r=i.hash160(t.witness[1]);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\")}}return Object.assign(p,t)}},2366:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2wsh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(6586),f=s.OPS,h=n.alloc(0);function l(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,a.isPoint)(t))}e.p2wsh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),output:a.typeforce.maybe(a.typeforce.BufferN(34)),redeem:a.typeforce.maybe({input:a.typeforce.maybe(a.typeforce.Buffer),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.BufferN(0)),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=c.value((()=>{const e=u.bech32.decode(t.address),r=e.words.shift(),i=u.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),p=c.value((()=>s.decompile(t.redeem.input)));let d=t.network;d||(d=t.redeem&&t.redeem.network||o.bitcoin);const y={network:d};if(c.prop(y,\"address\",(()=>{if(!y.hash)return;const t=u.bech32.toWords(y.hash);return t.unshift(0),u.bech32.encode(d.bech32,t)})),c.prop(y,\"hash\",(()=>t.output?t.output.slice(2):t.address?r().data:y.redeem&&y.redeem.output?i.sha256(y.redeem.output):void 0)),c.prop(y,\"output\",(()=>{if(y.hash)return s.compile([f.OP_0,y.hash])})),c.prop(y,\"redeem\",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:h,witness:t.witness.slice(0,-1)}})),c.prop(y,\"input\",(()=>{if(y.witness)return h})),c.prop(y,\"witness\",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=s.toStack(p());return y.redeem=Object.assign({witness:e},t.redeem),y.redeem.input=h,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),c.prop(y,\"name\",(()=>{const t=[\"p2wsh\"];return void 0!==y.redeem&&void 0!==y.redeem.name&&t.push(y.redeem.name),t.join(\"-\")})),e.validate){let e=n.from([]);if(t.address){if(r().prefix!==d.bech32)throw new TypeError(\"Invalid prefix or Network mismatch\");if(0!==r().version)throw new TypeError(\"Invalid address version\");if(32!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==f.OP_0||32!==t.output[1])throw new TypeError(\"Output is invalid\");const r=t.output.slice(2);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.redeem){if(t.redeem.network&&t.redeem.network!==d)throw new TypeError(\"Network mismatch\");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError(\"Ambiguous witness source\");if(t.redeem.output){const r=s.decompile(t.redeem.output);if(!r||r.length<1)throw new TypeError(\"Redeem.output is invalid\");if(t.redeem.output.byteLength>3600)throw new TypeError(\"Redeem.output unspendable if larger than 3600 bytes\");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError(\"Redeem.output unspendable with more than 201 non-push ops\");const n=i.sha256(t.redeem.output);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\");e=n}if(t.redeem.input&&!s.isPushOnly(p()))throw new TypeError(\"Non push-only scriptSig\");if(t.witness&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.witness,t.redeem.witness))throw new TypeError(\"Witness and redeem.witness mismatch\");if(t.redeem.input&&p().some(l)||t.redeem.output&&(s.decompile(t.redeem.output)||[]).some(l))throw new TypeError(\"redeem.input or redeem.output contains uncompressed pubkey\")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError(\"Witness and redeem.output mismatch\");if(t.witness.some(l)||(s.decompile(e)||[]).some(l))throw new TypeError(\"Witness contains uncompressed pubkey\")}}return Object.assign(y,t)}},6689:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Psbt=void 0;const i=r(7003),o=r(2715),s=r(2431),a=r(3348),c=r(3831),u=r(2529),f=r(8614),h=r(5247),l=r(4009),p=r(3063),d=r(6412),y=r(8990),g={network:u.bitcoin,maximumFeeRate:5e3};class b{static fromBase64(t,e={}){const r=n.from(t,\"base64\");return this.fromBuffer(r,e)}static fromHex(t,e={}){const r=n.from(t,\"hex\");return this.fromBuffer(r,e)}static fromBuffer(t,e={}){const r=i.Psbt.fromBuffer(t,w),n=new b(e,r);var o,s;return o=n.__CACHE.__TX,s=n.__CACHE,o.ins.forEach((t=>{x(s,t)})),n}constructor(t={},e=new i.Psbt(new m)){this.data=e,this.opts=Object.assign({},g,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(t,e,r,n)=>Object.defineProperty(t,e,{enumerable:r,writable:n});r(this,\"__CACHE\",!1,!0),r(this,\"opts\",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map((t=>({hash:(0,c.cloneBuffer)(t.hash),index:t.index,sequence:t.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((t=>{let e;try{e=(0,a.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,c.cloneBuffer)(t.script),value:t.value,address:e}}))}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){const t=b.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){A(t),this.opts.maximumFeeRate=t}setVersion(t){A(t),I(this.data.inputs,\"setVersion\");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){A(t),I(this.data.inputs,\"setLocktime\");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){A(e),I(this.data.inputs,\"setInputSequence\");const r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error(\"Input index too high\");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach((t=>this.addInput(t))),this}addInput(t){if(arguments.length>1||!t||void 0===t.hash||void 0===t.index)throw new Error(\"Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]\");(0,d.checkTaprootInputFields)(t,t,\"addInput\"),I(this.data.inputs,\"addInput\"),t.witnessScript&&X(t.witnessScript);const e=this.__CACHE;this.data.addInput(t);x(e,e.__TX.ins[e.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&D(this.__CACHE,n,r),e.__FEE=void 0,e.__FEE_RATE=void 0,e.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach((t=>this.addOutput(t))),this}addOutput(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error(\"Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]\");I(this.data.inputs,\"addOutput\");const{address:e}=t;if(\"string\"==typeof e){const{network:r}=this.opts,n=(0,a.toOutputScript)(e,r);t=Object.assign(t,{script:n})}(0,d.checkTaprootOutputFields)(t,t,\"addOutput\");const r=this.__CACHE;return this.data.addOutput(t),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(_))throw new Error(\"Not finalized\");const e=this.__CACHE;if(t||function(t,e,r){const n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,e,this.opts),e.__EXTRACTED_TX)return e.__EXTRACTED_TX;const r=e.__TX.clone();return $(this.data.inputs,r,e,!0),r}getFeeRate(){return R(\"__FEE_RATE\",\"fee rate\",this.data.inputs,this.__CACHE)}getFee(){return R(\"__FEE\",\"fee\",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,s.checkForInput)(this.data.inputs,0),J(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(r)?this._finalizeTaprootInput(t,r,void 0,e):this._finalizeInput(t,r,e)}finalizeTaprootInput(t,e,r=d.tapScriptFinalizer){const n=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,e,r=B){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(t,e,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){const o=K(r,e,t),s=n.ins[t].index;i.script=o.outs[s].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);(e.witnessScript||(0,y.isP2WPKH)(i.script))&&(i.isSegwit=!0);return i}(t,e,this.__CACHE);if(!n)throw new Error(`No script found for input #${t}`);!function(t){if(!t.sighashType||!t.partialSig)return;const{partialSig:e,sighashType:r}=t;e.forEach((t=>{const{hashType:e}=l.signature.decode(t.signature);if(r!==e)throw new Error(\"Signature sighash does not match input sighash type\")}))}(e);const{finalScriptSig:a,finalScriptWitness:c}=r(t,e,n,s,i,o);if(a&&this.data.updateInput(t,{finalScriptSig:a}),c&&this.data.updateInput(t,{finalScriptWitness:c}),!a&&!c)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,e,r,n=d.tapScriptFinalizer){if(!e.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(e.tapKeySig){const r=f.p2tr({output:e.witnessUtxo.script,signature:e.tapKeySig}),n=(0,y.witnessStackToScriptWitness)(r.witness);this.data.updateInput(t,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(t,e,r);this.data.updateInput(t,{finalScriptWitness:i})}return this.data.clearFinalizedInput(t),this}getInputType(t){const e=(0,s.checkForInput)(this.data.inputs,t),r=W(V(t,e,this.__CACHE),t,\"input\",e.redeemScript||function(t){if(!t)return;const e=l.decompile(t);if(!e)return;const r=e[e.length-1];if(!n.isBuffer(r)||q(r)||(i=r,l.isCanonicalScriptSignature(i)))return;var i;if(!l.decompile(r))return;return r}(e.finalScriptSig),e.witnessScript||function(t){if(!t)return;const e=F(t),r=e[e.length-1];if(q(r))return;if(!l.decompile(r))return;return r}(e.finalScriptWitness));return(\"raw\"===r.type?\"\":r.type+\"-\")+z(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=V(r,e,n),{meaningfulScript:o}=W(i,r,\"input\",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,s.checkForInput)(this.data.inputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(t,e){return function(t,e,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=W(i,r,\"output\",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,s.checkForOutput)(this.data.outputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){(0,s.checkForInput)(this.data.inputs,0);return J(this.data.inputs.length).map((e=>this.validateSignaturesOfInput(e,t))).reduce(((t,e)=>!0===e&&t),!0)}validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t];return(0,d.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}_validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error(\"No signatures to validate\");if(\"function\"!=typeof e)throw new Error(\"Need validator function to validate signatures\");const o=r?i.filter((t=>t.pubkey.equals(r))):i;if(o.length<1)throw new Error(\"No signatures for this pubkey\");const s=[];let a,c,u;for(const r of o){const i=l.signature.decode(r.signature),{hash:o,script:f}=u!==i.hashType?N(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:c};u=i.hashType,a=o,c=f,T(r.pubkey,f,\"verify\"),s.push(e(r.pubkey,o,i.signature))}return s.every((t=>!0===t))}validateSignaturesOfTaprootInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error(\"No signatures to validate\");if(\"function\"!=typeof e)throw new Error(\"Need validator function to validate signatures\");const s=(r=r&&(0,d.toXOnly)(r))?j(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=L(t,e,n);r&&i.push(r)}if(e.tapScriptSig){const t=e.tapScriptSig.map((t=>t.pubkey));i.push(...t)}const o=i.map((i=>j(t,e,r,i,n)));return o.flat()}(t,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error(\"No signatures for this pubkey\");const a=s.find((t=>!t.leafHash));let c=0;if(i&&a){if(!e(a.pubkey,a.hash,U(i)))return!1;c++}if(o)for(const t of o){const r=s.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,U(t.signature)))return!1;c++}}return c>0}signAllInputsHD(t,e=[p.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error(\"Need HDSigner to sign input\");const r=[];for(const n of J(this.data.inputs.length))try{this.signInputHD(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error(\"No inputs were signed\");return this}signAllInputsHDAsync(t,e=[p.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!t||!t.publicKey||!t.fingerprint)return n(new Error(\"Need HDSigner to sign input\"));const i=[],o=[];for(const r of J(this.data.inputs.length))o.push(this.signInputHDAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error(\"No inputs were signed\"));r()}))}))}signInputHD(t,e,r=[p.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error(\"Need HDSigner to sign input\");return H(t,this.data.inputs,e).forEach((e=>this.signInput(t,e,r))),this}signInputHDAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!e||!e.publicKey||!e.fingerprint)return i(new Error(\"Need HDSigner to sign input\"));const o=H(t,this.data.inputs,e).map((e=>this.signInputAsync(t,e,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(t,e){if(!t||!t.publicKey)throw new Error(\"Need Signer to sign input\");const r=[];for(const n of J(this.data.inputs.length))try{this.signInput(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error(\"No inputs were signed\");return this}signAllInputsAsync(t,e){return new Promise(((r,n)=>{if(!t||!t.publicKey)return n(new Error(\"Need Signer to sign input\"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error(\"No inputs were signed\"));r()}))}))}signInput(t,e,r){if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}signTaprootInput(t,e,r,n){if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInput(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=C(this.data.inputs,t,e.publicKey,this.__CACHE,r),o=[{pubkey:e.publicKey,signature:l.signature.encode(e.sign(n),i)}];return this.data.updateInput(t,{partialSig:o}),this}_signTaprootInput(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=o.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],a=o.filter((t=>!!t.leafHash)).map((t=>({pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash})));return s&&this.data.updateInput(t,{tapKeySig:s}),a.length&&this.data.updateInput(t,{tapScriptSig:a}),this}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInputAsync(t,n,e,void 0,r):this._signInputAsync(t,e,r)}))}signTaprootInputAsync(t,e,r,n){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInputAsync(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}))}_signInputAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=C(this.data.inputs,t,e.publicKey,this.__CACHE,r);return Promise.resolve(e.sign(n)).then((r=>{const n=[{pubkey:e.publicKey,signature:l.signature.encode(r,i)}];this.data.updateInput(t,{partialSig:n})}))}async _signTaprootInputAsync(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=[],a=o.filter((t=>!t.leafHash))[0];if(a){const t=Promise.resolve(r.signSchnorr(a.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));s.push(t)}const c=o.filter((t=>!!t.leafHash));if(c.length){const t=c.map((t=>Promise.resolve(r.signSchnorr(t.hash)).then((n=>({tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]})))));s.push(...t)}return Promise.all(s).then((e=>{e.forEach((e=>this.data.updateInput(t,e)))}))}checkTaprootHashesForSig(t,e,r,n,i){if(\"function\"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const o=j(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${t} with the key ${r.publicKey.toString(\"hex\")}`);return o}toBuffer(){return v(this.__CACHE),this.data.toBuffer()}toHex(){return v(this.__CACHE),this.data.toHex()}toBase64(){return v(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&X(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,\"updateInput\"),this.data.updateInput(t,e),e.nonWitnessUtxo&&D(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,e){const r=this.data.outputs[t];return(0,d.checkTaprootOutputFields)(r,e,\"updateOutput\"),this.data.updateOutput(t,e),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,e){return this.data.addUnknownKeyValToInput(t,e),this}addUnknownKeyValToOutput(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}e.Psbt=b;const w=t=>new m(t);class m{constructor(t=n.from([2,0,0,0,0,0,0,0,0,0])){this.tx=p.Transaction.fromBuffer(t),function(t){if(!t.ins.every((t=>t.script&&0===t.script.length&&t.witness&&0===t.witness.length)))throw new Error(\"Format Error: Transaction ScriptSigs are not empty\")}(this.tx),Object.defineProperty(this,\"tx\",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!n.isBuffer(t.hash)&&\"string\"!=typeof t.hash||\"number\"!=typeof t.index)throw new Error(\"Error adding input.\");const e=\"string\"==typeof t.hash?(0,c.reverseBuffer)(n.from(t.hash,\"hex\")):t.hash;this.tx.addInput(e,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!n.isBuffer(t.script)||\"number\"!=typeof t.value)throw new Error(\"Error adding output.\");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function v(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error(\"Not BIP174 compliant, can not export\")}function E(t,e,r){if(!e)return!1;let n;if(n=r?r.map((t=>{const r=function(t){if(65===t.length){const e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((t=>t.pubkey.equals(r)))})).filter((t=>!!t)):e,n.length>t)throw new Error(\"Too many signatures\");return n.length===t}function _(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function S(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function A(t){if(\"number\"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error(\"Invalid 32 bit integer\")}function I(t,e){t.forEach((t=>{if((0,d.isTaprootInput)(t)?(0,d.checkTaprootInputForSigs)(t,e):(0,y.checkInputForSig)(t,e))throw new Error(\"Can not modify transaction, signatures exist.\")}))}function T(t,e,r){if(!(0,y.pubkeyInScript)(t,e))throw new Error(`Can not ${r} for this input with the key ${t.toString(\"hex\")}`)}function x(t,e){const r=(0,c.reverseBuffer)(n.from(e.hash)).toString(\"hex\")+\":\"+e.index;if(t.__TX_IN_CACHE[r])throw new Error(\"Duplicate input detected.\");t.__TX_IN_CACHE[r]=1}function O(t,e){return(r,n,i,o)=>{const s=t({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${e} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const k=O(f.p2sh,\"Redeem script\"),P=O(f.p2wsh,\"Witness script\");function R(t,e,r,n){if(!r.every(_))throw new Error(`PSBT must be finalized to calculate ${e}`);if(\"__FEE_RATE\"===t&&n.__FEE_RATE)return n.__FEE_RATE;if(\"__FEE\"===t&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),$(r,i,n,o),\"__FEE_RATE\"===t?n.__FEE_RATE:\"__FEE\"===t?n.__FEE:void 0}function B(t,e,r,n,i,o){const s=z(r);if(!function(t,e,r){switch(r){case\"pubkey\":case\"pubkeyhash\":case\"witnesspubkeyhash\":return E(1,t.partialSig);case\"multisig\":const r=f.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,s))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,o){let s,a;const c=function(t,e,r){let n;switch(e){case\"multisig\":const e=function(t,e){const r=f.p2ms({output:t});return r.pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=f.p2ms({output:t,signatures:e});break;case\"pubkey\":n=f.p2pk({output:t,signature:r[0].signature});break;case\"pubkeyhash\":n=f.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case\"witnesspubkeyhash\":n=f.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),u=o?f.p2wsh({redeem:c}):null,h=i?f.p2sh({redeem:u||c}):null;n?(a=u?(0,y.witnessStackToScriptWitness)(u.witness):(0,y.witnessStackToScriptWitness)(c.witness),h&&(s=h.input)):s=h?h.input:c.input;return{finalScriptSig:s,finalScriptWitness:a}}(r,s,e.partialSig,n,i,o)}function C(t,e,r,n,i){const o=(0,s.checkForInput)(t,e),{hash:a,sighashType:c,script:u}=N(e,o,n,!1,i);return T(r,u,\"sign\"),{hash:a,sighashType:c}}function N(t,e,r,n,i){const o=r.__TX,s=e.sighashType||p.Transaction.SIGHASH_ALL;let a,c;if(M(s,i),e.nonWitnessUtxo){const n=K(r,e,t),i=o.ins[t].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const a=o.ins[t].index;c=n.outs[a]}else{if(!e.witnessUtxo)throw new Error(\"Need a Utxo input item for signing\");c=e.witnessUtxo}const{meaningfulScript:u,type:h}=W(c.script,t,\"input\",e.redeemScript,e.witnessScript);if([\"p2sh-p2wsh\",\"p2wsh\"].indexOf(h)>=0)a=o.hashForWitnessV0(t,u,c.value,s);else if((0,y.isP2WPKH)(u)){const e=f.p2pkh({hash:u.slice(2)}).output;a=o.hashForWitnessV0(t,e,c.value,s)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${t} has witnessUtxo but non-segwit script: ${u.toString(\"hex\")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn(\"Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecesor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\\n*********************\\nPROCEED WITH CAUTION!\\n*********************\"),a=o.hashForSignature(t,u,s)}return{script:u,sighashType:s,hash:a}}function L(t,e,r){const{script:n}=G(t,e,r);return(0,y.isP2TR)(n)?n.subarray(2,34):null}function U(t){return 64===t.length?t:t.subarray(0,64)}function j(t,e,r,i,o,s,a){const c=o.__TX,u=e.sighashType||p.Transaction.SIGHASH_DEFAULT;M(u,a);const f=r.map(((t,e)=>G(e,t,o))),l=f.map((t=>t.script)),g=f.map((t=>t.value)),b=[];if(e.tapInternalKey&&!s){const r=L(t,e,o)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=c.hashForWitnessV1(t,l,g,u);b.push({pubkey:i,hash:e})}}const w=(e.tapLeafScript||[]).filter((t=>(0,y.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,h.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!s||s.equals(t.hash))).map((e=>{const r=c.hashForWitnessV1(t,l,g,p.Transaction.SIGHASH_DEFAULT,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return b.concat(w)}function M(t,e){if(e&&e.indexOf(t)<0){const e=function(t){let e=t&p.Transaction.SIGHASH_ANYONECANPAY?\"SIGHASH_ANYONECANPAY | \":\"\";switch(31&t){case p.Transaction.SIGHASH_ALL:e+=\"SIGHASH_ALL\";break;case p.Transaction.SIGHASH_SINGLE:e+=\"SIGHASH_SINGLE\";break;case p.Transaction.SIGHASH_NONE:e+=\"SIGHASH_NONE\"}return e}(t);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${e}`)}}function H(t,e,r){const n=(0,s.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error(\"Need bip32Derivation to sign with HD\");const i=n.bip32Derivation.map((t=>t.masterFingerprint.equals(r.fingerprint)?t:void 0)).filter((t=>!!t));if(0===i.length)throw new Error(\"Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint\");return i.map((t=>{const e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error(\"pubkey did not match bip32Derivation\");return e}))}function F(t){let e=0;function r(){const r=o.decode(t,e);return e+=o.decode.bytes,r}function n(){return n=r(),e+=n,t.slice(e-n,e);var n}return function(){const t=r(),e=[];for(let r=0;r{if(n&&t.finalScriptSig&&(e.ins[o].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[o].witness=F(t.finalScriptWitness)),t.witnessUtxo)i+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=K(r,t,o),s=e.ins[o].index,a=n.outs[s];i+=a.value}}));const o=e.outs.reduce(((t,e)=>t+e.value),0),s=i-o;if(s<0)throw new Error(\"Outputs are spending more than Inputs\");const a=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/a)}function K(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||D(t,e,r),n[r]}function V(t,e,r){const{script:n}=G(t,e,r);return n}function G(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=K(r,e,t).outs[r.__TX.ins[t].index];return{script:n.script,value:n.value}}throw new Error(\"Can't find pubkey in input without Utxo data\")}function q(t){return 33===t.length&&l.isCanonicalPubKey(t)}function W(t,e,r,n,i){const o=(0,y.isP2SHScript)(t),s=o&&n&&(0,y.isP2WSHScript)(n),a=(0,y.isP2WSHScript)(t);if(o&&void 0===n)throw new Error(\"scriptPubkey is P2SH but redeemScript missing\");if((a||s)&&void 0===i)throw new Error(\"scriptPubkey or redeemScript is P2WSH but witnessScript missing\");let c;return s?(c=i,k(e,t,n,r),P(e,n,i,r),X(c)):a?(c=i,P(e,t,i,r),X(c)):o?(c=n,k(e,t,n,r)):c=t,{meaningfulScript:c,type:s?\"p2sh-p2wsh\":o?\"p2sh\":a?\"p2wsh\":\"raw\"}}function X(t){if((0,y.isP2WPKH)(t)||(0,y.isP2SHScript)(t))throw new Error(\"P2WPKH or P2SH can not be contained within P2WSH\")}function z(t){return(0,y.isP2WPKH)(t)?\"witnesspubkeyhash\":(0,y.isP2PKH)(t)?\"pubkeyhash\":(0,y.isP2MS)(t)?\"multisig\":(0,y.isP2PK)(t)?\"pubkey\":\"nonstandard\"}function J(t){return[...Array(t).keys()]}},6412:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.checkTaprootInputForSigs=e.tapTreeFromList=e.tapTreeToList=e.tweakInternalPubKey=e.checkTaprootOutputFields=e.checkTaprootInputFields=e.isTaprootOutput=e.isTaprootInput=e.serializeTaprootSignature=e.tapScriptFinalizer=e.toXOnly=void 0;const i=r(5593),o=r(3063),s=r(8990),a=r(5247),c=r(8614),u=r(8990);function f(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,s.isP2TR)(t.witnessUtxo.script))}function h(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,s.isP2TR)(e))}function l(t=[]){return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){let e;for(const r of t)if(e=y(r,e),!e)throw new Error(\"No room left to insert tapleaf in tree\");return e}(t)}function p(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function d(t,e=[],r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error(\"Max taptree depth exceeded.\");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||a.LEAF_VERSION_TAPSCRIPT,script:t.output}),e):(t[0]&&d(t[0],e,r+1),t[1]&&d(t[1],e,r+1),e):[]}function y(t,e,r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error(\"Max taptree depth exceeded.\");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if((0,i.isTapleaf)(e))return;const n=y(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];const o=y(t,e&&e[1],r+1);return o?[e&&e[0],o]:void 0}function g(t,e){if(!e)return!0;const r=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(0,a.rootHashFromPath)(t.controlBlock,r).equals(e)}function b(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}e.toXOnly=t=>32===t.length?t:t.slice(1,33),e.tapScriptFinalizer=function(t,e,r){const n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${e}. No tapleaf script signature provided.`);const n=(t.tapLeafScript||[]).sort(((t,e)=>t.controlBlock.length-e.controlBlock.length)).find((e=>function(t,e,r){const n=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((t=>t.leafHash.equals(n)))}(e,t.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`);return n}(e,t,r);try{const t=function(t,e){const r=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((t=>t.leafHash.equals(r))).map((t=>function(t,e){return Object.assign({positionInScript:(0,s.pubkeyPositionInScript)(e.pubkey,t)},e)}(e.script,t))).sort(((t,e)=>e.positionInScript-t.positionInScript)).map((t=>t.signature))}(e,n),r=t.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,s.witnessStackToScriptWitness)(r)}}catch(e){throw new Error(`Can not finalize taproot input #${t}: ${e}`)}},e.serializeTaprootSignature=function(t,e){const r=e?n.from([e]):n.from([]);return n.concat([t,r])},e.isTaprootInput=f,e.isTaprootOutput=h,e.checkTaprootInputFields=function(t,e,r){!function(t,e,r){const n=f(t)&&b(e),i=b(t)&&f(e),o=t===e&&f(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot){if(!(e.tapLeafScript||[]).every((e=>g(e,t.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}}(t,e,r)},e.checkTaprootOutputFields=function(t,e,r){!function(t,e,r){const n=h(t)&&b(e),i=b(t)&&h(e),o=t===e&&h(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e){if(!e.tapTree&&!e.tapInternalKey)return;const r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){const{script:e}=t,i=function(t,e){const r=e&&l(e.leaves),{output:n}=(0,c.p2tr)({internalPubkey:t,scriptTree:r});return n}(r,n);if(e&&!e.equals(i))throw new Error(\"Error adding output. Script or address missmatch.\")}}(t,e)},e.tweakInternalPubKey=function(t,e){const r=e.tapInternalKey,n=r&&(0,a.tweakKey)(r,e.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${t}. Public key: ${r&&r.toString(\"hex\")}`);return n.x},e.tapTreeToList=function(t){if(!(0,i.isTaptree)(t))throw new Error(\"Cannot convert taptree to tapleaf list. Expecting a tapree structure.\");return d(t)},e.tapTreeFromList=l,e.checkTaprootInputForSigs=function(t,e){return function(t){const e=[];t.tapKeySig&&e.push(t.tapKeySig);t.tapScriptSig&&e.push(...t.tapScriptSig.map((t=>t.signature)));if(!e.length){const r=function(t){if(!t)return;const e=t.slice(2);if(64===e.length||65===e.length)return e}(t.finalScriptWitness);r&&e.push(r)}return e}(t).some((t=>(0,u.signatureBlocksAction)(t,p,e)))}},8990:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.signatureBlocksAction=e.checkInputForSig=e.pubkeyInScript=e.pubkeyPositionInScript=e.witnessStackToScriptWitness=e.isP2TR=e.isP2SHScript=e.isP2WSHScript=e.isP2WPKH=e.isP2PKH=e.isP2PK=e.isP2MS=void 0;const i=r(2715),o=r(4009),s=r(3063),a=r(6891),c=r(8614);function u(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function f(t,e){const r=(0,a.hash160)(t),n=t.slice(1,33),i=o.decompile(e);if(null===i)throw new Error(\"Unknown script error\");return i.findIndex((e=>\"number\"!=typeof e&&(e.equals(t)||e.equals(r)||e.equals(n))))}function h(t,e,r){const{hashType:n}=e(t),i=[];n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push(\"addInput\");switch(31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push(\"addOutput\"),i.push(\"setInputSequence\")}return-1===i.indexOf(r)}e.isP2MS=u(c.p2ms),e.isP2PK=u(c.p2pk),e.isP2PKH=u(c.p2pkh),e.isP2WPKH=u(c.p2wpkh),e.isP2WSHScript=u(c.p2wsh),e.isP2SHScript=u(c.p2sh),e.isP2TR=u(c.p2tr),e.witnessStackToScriptWitness=function(t){let e=n.allocUnsafe(0);function r(t){const r=e.length,o=i.encodingLength(t);e=n.concat([e,n.allocUnsafe(o)]),i.encode(t,e,r)}function o(t){r(t.length),function(t){e=n.concat([e,n.from(t)])}(t)}var s;return r((s=t).length),s.forEach(o),e},e.pubkeyPositionInScript=f,e.pubkeyInScript=function(t,e){return-1!==f(t,e)},e.checkInputForSig=function(t,e){return function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){const e=t.finalScriptSig&&o.decompile(t.finalScriptSig)||[],r=t.finalScriptWitness&&o.decompile(t.finalScriptWitness)||[];return e.concat(r).filter((t=>n.isBuffer(t)&&o.isCanonicalScriptSignature(t))).map((t=>({signature:t})))}(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t).some((t=>h(t,o.signature.decode,e)))},e.signatureBlocksAction=h},1213:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.decode=e.encode=e.encodingLength=void 0;const n=r(8156);function i(t){return tt.length)return null;i=t.readUInt8(e+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(e+3>t.length)return null;i=t.readUInt16LE(e+1),o=3}else{if(e+5>t.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error(\"Unexpected opcode\");i=t.readUInt32LE(e+1),o=5}return{opcode:r,number:i,size:o}}},4009:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const i=r(195),o=r(8156);Object.defineProperty(e,\"OPS\",{enumerable:!0,get:function(){return o.OPS}});const s=r(1213),a=r(5333),c=r(1108),u=r(5593),{typeforce:f}=u,h=o.OPS.OP_RESERVED;function l(t){return u.Buffer(t)||function(t){return u.Number(t)&&(t===o.OPS.OP_0||t>=o.OPS.OP_1&&t<=o.OPS.OP_16||t===o.OPS.OP_1NEGATE)}(t)}function p(t){return u.Array(t)&&t.every(l)}function d(t){return 0===t.length?o.OPS.OP_0:1===t.length?t[0]>=1&&t[0]<=16?h+t[0]:129===t[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(t){return n.isBuffer(t)}function g(t){return n.isBuffer(t)}function b(t){if(y(t))return t;f(u.Array,t);const e=t.reduce(((t,e)=>g(e)?1===e.length&&void 0!==d(e)?t+1:t+s.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(g(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=s.encode(r,t.length,i),t.copy(r,i),i+=t.length}else r.writeUInt8(t,i),i+=1})),i!==r.length)throw new Error(\"Could not decode chunks\");return r}function w(t){if(e=t,u.Array(e))return t;var e;f(u.Buffer,t);const r=[];let n=0;for(;no.OPS.OP_0&&e<=o.OPS.OP_PUSHDATA4){const e=s.decode(t,n);if(null===e)return null;if(n+=e.size,n+e.number>t.length)return null;const i=t.slice(n,n+e.number);n+=e.number;const o=d(i);void 0!==o?r.push(o):r.push(i)}else r.push(e),n+=1}return r}function m(t){const e=-129&t;return e>0&&e<4}e.isPushOnly=p,e.countNonPushOnlyOPs=function(t){return t.length-t.filter(l).length},e.compile=b,e.decompile=w,e.toASM=function(t){return y(t)&&(t=w(t)),t.map((t=>{if(g(t)){const e=d(t);if(void 0===e)return t.toString(\"hex\");t=e}return o.REVERSE_OPS[t]})).join(\" \")},e.fromASM=function(t){return f(u.String,t),b(t.split(\" \").map((t=>void 0!==o.OPS[t]?o.OPS[t]:(f(u.Hex,t),n.from(t,\"hex\")))))},e.toStack=function(t){return t=w(t),f(p,t),t.map((t=>g(t)?t:t===o.OPS.OP_0?n.allocUnsafe(0):a.encode(t-h)))},e.isCanonicalPubKey=function(t){return u.isPoint(t)},e.isDefinedHashType=m,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&(!!m(t[t.length-1])&&i.check(t.slice(0,-1)))},e.number=a,e.signature=c},5333:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=void 0,e.decode=function(t,e,r){e=e||4,r=void 0===r||r;const n=t.length;if(0===n)return 0;if(n>e)throw new TypeError(\"Script number overflow\");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error(\"Non-minimally encoded script number\");if(5===n){const e=t.readUInt32LE(0),r=t.readUInt8(4);return 128&r?-(4294967296*(-129&r)+e):4294967296*r+e}let i=0;for(let e=0;e2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),i=n.allocUnsafe(r),o=t<0;for(let t=0;t>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i}},1108:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=void 0;const i=r(195),o=r(5593),{typeforce:s}=o,a=n.alloc(1,0);function c(t){let e=0;for(;0===t[e];)++e;return e===t.length?a:128&(t=t.slice(e))[0]?n.concat([a,t],1+t.length):t}function u(t){0===t[0]&&(t=t.slice(1));const e=n.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}e.decode=function(t){const e=t.readUInt8(t.length-1),r=-129&e;if(r<=0||r>=4)throw new Error(\"Invalid hashType \"+e);const o=i.decode(t.slice(0,-1)),s=u(o.r),a=u(o.s);return{signature:n.concat([s,a],64),hashType:e}},e.encode=function(t,e){s({signature:o.BufferN(64),hashType:o.UInt8},{signature:t,hashType:e});const r=-129&e;if(r<=0||r>=4)throw new Error(\"Invalid hashType \"+e);const a=n.allocUnsafe(1);a.writeUInt8(e,0);const u=c(t.slice(0,32)),f=c(t.slice(32,64));return n.concat([i.encode(u,f),a])}},3063:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Transaction=void 0;const i=r(3831),o=r(6891),s=r(4009),a=r(4009),c=r(5593),{typeforce:u}=c;function f(t){const e=t.length;return i.varuint.encodingLength(e)+e}const h=n.allocUnsafe(0),l=[],p=n.from(\"0000000000000000000000000000000000000000000000000000000000000000\",\"hex\"),d=n.from(\"0000000000000000000000000000000000000000000000000000000000000001\",\"hex\"),y=n.from(\"ffffffffffffffff\",\"hex\"),g={script:h,valueBuffer:y};class b{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,e){const r=new i.BufferReader(t),n=new b;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let a=!1;o===b.ADVANCED_TRANSACTION_MARKER&&s===b.ADVANCED_TRANSACTION_FLAG?a=!0:r.offset-=2;const c=r.readVarInt();for(let t=0;t0!==t.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const e=t&&this.hasWitnesses();return(e?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce(((t,e)=>t+40+f(e.script)),0)+this.outs.reduce(((t,e)=>t+8+f(e.script)),0)+(e?this.ins.reduce(((t,e)=>t+function(t){const e=t.length;return i.varuint.encodingLength(e)+t.reduce(((t,e)=>t+f(e)),0)}(e.witness)),0):0)}clone(){const t=new b;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((t=>({hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}))),t.outs=this.outs.map((t=>({script:t.script,value:t.value}))),t}hashForSignature(t,e,r){if(u(c.tuple(c.UInt32,c.Buffer,c.Number),arguments),t>=this.ins.length)return d;const i=s.compile(s.decompile(e).filter((t=>t!==a.OPS.OP_CODESEPARATOR))),f=this.clone();if((31&r)===b.SIGHASH_NONE)f.outs=[],f.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===b.SIGHASH_SINGLE){if(t>=this.outs.length)return d;f.outs.length=t+1;for(let e=0;e{r!==t&&(e.sequence=0)}))}r&b.SIGHASH_ANYONECANPAY?(f.ins=[f.ins[t]],f.ins[0].script=i):(f.ins.forEach((t=>{t.script=h})),f.ins[t].script=i);const l=n.allocUnsafe(f.byteLength(!1)+4);return l.writeInt32LE(r,l.length-4),f.__toBuffer(l,0,!1),o.hash256(l)}hashForWitnessV1(t,e,r,s,a,l){if(u(c.tuple(c.UInt32,u.arrayOf(c.Buffer),u.arrayOf(c.Satoshi),c.UInt32),arguments),r.length!==this.ins.length||e.length!==this.ins.length)throw new Error(\"Must supply prevout script and value for all inputs\");const p=s===b.SIGHASH_DEFAULT?b.SIGHASH_ALL:s&b.SIGHASH_OUTPUT_MASK,d=(s&b.SIGHASH_INPUT_MASK)===b.SIGHASH_ANYONECANPAY,y=p===b.SIGHASH_NONE,g=p===b.SIGHASH_SINGLE;let w=h,m=h,v=h,E=h,_=h;if(!d){let t=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((e=>{t.writeSlice(e.hash),t.writeUInt32(e.index)})),w=o.sha256(t.end()),t=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach((e=>t.writeUInt64(e))),m=o.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(f).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),v=o.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),E=o.sha256(t.end())}if(y||g){if(g&&t8+f(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),_=o.sha256(e.end())}const S=(a?2:0)+(l?1:0),A=174-(d?49:0)-(y?32:0)+(l?32:0)+(a?37:0),I=i.BufferWriter.withCapacity(A);if(I.writeUInt8(s),I.writeInt32(this.version),I.writeUInt32(this.locktime),I.writeSlice(w),I.writeSlice(m),I.writeSlice(v),I.writeSlice(E),y||g||I.writeSlice(_),I.writeUInt8(S),d){const n=this.ins[t];I.writeSlice(n.hash),I.writeUInt32(n.index),I.writeUInt64(r[t]),I.writeVarSlice(e[t]),I.writeUInt32(n.sequence)}else I.writeUInt32(t);if(l){const t=i.BufferWriter.withCapacity(f(l));t.writeVarSlice(l),I.writeSlice(o.sha256(t.end()))}return g&&I.writeSlice(_),a&&(I.writeSlice(a),I.writeUInt8(0),I.writeUInt32(4294967295)),o.taggedHash(\"TapSighash\",n.concat([n.from([0]),I.end()]))}hashForWitnessV0(t,e,r,s){u(c.tuple(c.UInt32,c.Buffer,c.Satoshi,c.UInt32),arguments);let a,h=n.from([]),l=p,d=p,y=p;if(s&b.SIGHASH_ANYONECANPAY||(h=n.allocUnsafe(36*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeSlice(t.hash),a.writeUInt32(t.index)})),d=o.hash256(h)),s&b.SIGHASH_ANYONECANPAY||(31&s)===b.SIGHASH_SINGLE||(31&s)===b.SIGHASH_NONE||(h=n.allocUnsafe(4*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeUInt32(t.sequence)})),y=o.hash256(h)),(31&s)!==b.SIGHASH_SINGLE&&(31&s)!==b.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+f(e.script)),0);h=n.allocUnsafe(t),a=new i.BufferWriter(h,0),this.outs.forEach((t=>{a.writeUInt64(t.value),a.writeVarSlice(t.script)})),l=o.hash256(h)}else if((31&s)===b.SIGHASH_SINGLE&&t{o.writeSlice(t.hash),o.writeUInt32(t.index),o.writeVarSlice(t.script),o.writeUInt32(t.sequence)})),o.writeVarInt(this.outs.length),this.outs.forEach((t=>{void 0!==t.value?o.writeUInt64(t.value):o.writeSlice(t.valueBuffer),o.writeVarSlice(t.script)})),s&&this.ins.forEach((t=>{o.writeVector(t.witness)})),o.writeUInt32(this.locktime),void 0!==e?t.slice(e,o.offset):t}}e.Transaction=b,b.DEFAULT_SEQUENCE=4294967295,b.SIGHASH_DEFAULT=0,b.SIGHASH_ALL=1,b.SIGHASH_NONE=2,b.SIGHASH_SINGLE=3,b.SIGHASH_ANYONECANPAY=128,b.SIGHASH_OUTPUT_MASK=3,b.SIGHASH_INPUT_MASK=128,b.ADVANCED_TRANSACTION_MARKER=0,b.ADVANCED_TRANSACTION_FLAG=1},5593:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const n=r(1048);e.typeforce=r(973);const i=n.Buffer.alloc(32,0),o=n.Buffer.from(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\",\"hex\");e.isPoint=function(t){if(!n.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;const e=t[0],r=t.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;const s=t.slice(33);return 0!==s.compare(i)&&(!(s.compare(o)>=0)&&(4===e&&65===t.length))};const s=Math.pow(2,31)-1;function a(t){return e.typeforce.String(t)&&!!t.match(/^(m\\/)?(\\d+'?\\/)*\\d+'?$/)}e.UInt31=function(t){return e.typeforce.UInt32(t)&&t<=s},e.BIP32Path=a,a.toJSON=()=>\"BIP32 derivation path\",e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||\"function\"==typeof t.getPublicKey)&&\"function\"==typeof t.sign};function c(t){return!(!t||!(\"output\"in t))&&(!!n.Buffer.isBuffer(t.output)&&(void 0===t.version||(t.version&e.TAPLEAF_VERSION_MASK)===t.version))}e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.ECPoint=e.typeforce.quacksLike(\"Point\"),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=c,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):c(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf},9216:(t,e,r)=>{var n=r(9784);t.exports=n(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\")},7639:(t,e,r)=>{\"use strict\";var n=r(9216),i=r(5636).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error(\"Invalid checksum\");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},9848:(t,e,r)=>{\"use strict\";var n=r(3257),i=r(7639);t.exports=i((function(t){var e=n(\"sha256\").update(t).digest();return n(\"sha256\").update(e).digest()}))},1048:(t,e,r)=>{\"use strict\";const n=r(7991),i=r(9318),o=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null;e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if(\"number\"==typeof t){if(\"string\"==typeof e)throw new TypeError('The \"string\" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,e,r){if(\"string\"==typeof t)return function(t,e){\"string\"==typeof e&&\"\"!==e||(e=\"utf8\");if(!c.isEncoding(e))throw new TypeError(\"Unknown encoding: \"+e);const r=0|y(t,e);let n=a(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(z(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof t);if(z(t,ArrayBuffer)||t&&z(t.buffer,ArrayBuffer))return p(t,e,r);if(\"undefined\"!=typeof SharedArrayBuffer&&(z(t,SharedArrayBuffer)||t&&z(t.buffer,SharedArrayBuffer)))return p(t,e,r);if(\"number\"==typeof t)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return c.from(n,e,r);const i=function(t){if(c.isBuffer(t)){const e=0|d(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return\"number\"!=typeof t.length||J(t.length)?a(0):l(t);if(\"Buffer\"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(i)return i;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive](\"string\"),e,r);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof t)}function f(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be of type number');if(t<0)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"')}function h(t){return f(t),a(t<0?0:0|d(t))}function l(t){const e=t.length<0?0:0|d(t.length),r=a(e);for(let n=0;n=s)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+s.toString(16)+\" bytes\");return 0|t}function y(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||z(t,ArrayBuffer))return t.byteLength;if(\"string\"!=typeof t)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case\"ascii\":case\"latin1\":case\"binary\":return r;case\"utf8\":case\"utf-8\":return q(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*r;case\"hex\":return r>>>1;case\"base64\":return W(t).length;default:if(i)return n?-1:q(t).length;e=(\"\"+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return\"\";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return\"\";if((r>>>=0)<=(e>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return P(this,e,r);case\"utf8\":case\"utf-8\":return T(this,e,r);case\"ascii\":return O(this,e,r);case\"latin1\":case\"binary\":return k(this,e,r);case\"base64\":return I(this,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return R(this,e,r);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if(\"string\"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if(\"string\"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if(\"number\"==typeof e)return e&=255,\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function m(t,e,r,n,i){let o,s=1,a=t.length,c=e.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;ni&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function I(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(o=c));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r=\"\",n=0;for(;nn.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!c.isBuffer(e))throw new TypeError('\"list\" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},c.byteLength=y,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let e=0;er&&(t+=\" ... \"),\"\"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(t,e,r,n,i){if(z(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),u=this.slice(n,i),f=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n=\"utf8\")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let o=!1;for(;;)switch(n){case\"hex\":return v(this,t,e,r);case\"utf8\":case\"utf-8\":return E(this,t,e,r);case\"ascii\":case\"latin1\":case\"binary\":return _(this,t,e,r);case\"base64\":return S(this,t,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return A(this,t,e,r);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function O(t,e,r){let n=\"\";r=Math.min(t.length,r);for(let i=e;in)&&(r=n);let i=\"\";for(let n=e;nr)throw new RangeError(\"Trying to access beyond buffer length\")}function C(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError(\"Index out of range\")}function N(t,e,r,n,i){$(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function L(t,e,r,n,i){$(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError(\"Index out of range\");if(r<0)throw new RangeError(\"Index out of range\")}function j(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=Z((function(t){K(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o=i&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=Z((function(t){K(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){C(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,!n){C(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=Z((function(t,e=0){return N(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeBigUInt64BE=Z((function(t,e=0){return L(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=Z((function(t,e=0){return N(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeBigInt64BE=Z((function(t,e=0){return L(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError(\"argument should be a Buffer\");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),\"number\"==typeof t)for(i=e;i=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function $(t,e,r,n,i,o){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new H.ERR_OUT_OF_RANGE(\"value\",i,t)}!function(t,e,r){K(e,\"offset\"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(n,i,o)}function K(t,e){if(\"number\"!=typeof t)throw new H.ERR_INVALID_ARG_TYPE(e,\"number\",t)}function V(t,e,r){if(Math.floor(t)!==t)throw K(t,r),new H.ERR_OUT_OF_RANGE(r||\"offset\",\"an integer\",t);if(e<0)throw new H.ERR_BUFFER_OUT_OF_BOUNDS;throw new H.ERR_OUT_OF_RANGE(r||\"offset\",`>= ${r?1:0} and <= ${e}`,t)}F(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(t){return t?`${t} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),F(\"ERR_INVALID_ARG_TYPE\",(function(t,e){return`The \"${t}\" argument must be of type number. Received type ${typeof e}`}),TypeError),F(\"ERR_OUT_OF_RANGE\",(function(t,e,r){let n=`The value of \"${t}\" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):\"bigint\"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+=\"n\"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error(\"Invalid code point\");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function W(t){return n.toByteArray(function(t){if((t=(t=t.split(\"=\")[0]).trim().replace(G,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}(t))}function X(t,e,r,n){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Y=function(){const t=\"0123456789abcdef\",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Z(t){return\"undefined\"==typeof BigInt?Q:t}function Q(){throw new Error(\"BigInt not supported\")}},7589:(t,e,r)=>{var n=r(5636).Buffer,i=r(1983).Transform,o=r(8888).I;function s(t){i.call(this),this.hashMode=\"string\"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(5615)(s,i),s.prototype.update=function(t,e,r){\"string\"==typeof t&&(t=n.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error(\"trying to get auth tag in unsupported state\")},s.prototype.setAuthTag=function(){throw new Error(\"trying to set auth tag in unsupported state\")},s.prototype.setAAD=function(){throw new Error(\"trying to set aad in unsupported state\")},s.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error(\"can't switch encodings\");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=s},7232:(t,e,r)=>{var n=r(366);t.exports=function(t,e,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],e),o=0,s=[],a=n.sumOrNaN(e),c=0;cu.value){if(c===t.length-1)return{fee:r*(i+f)}}else if(i+=f,o+=l,s.push(u),!(o{var n=r(366);t.exports=function(t,e,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],e),o=0,s=[],a=n.sumOrNaN(e),c=n.dustThreshold({},r),u=0;ua+l+c)&&(i+=h,o+=p,s.push(f),!(o{var n=r(7232),i=r(2379),o=r(366);function s(t,e){return t.value-e*o.inputBytes(t)}t.exports=function(t,e,r){t=t.concat().sort((function(t,e){return s(e,r)-s(t,r)}));var o=i(t,e,r);return o.inputs?o:n(t,e,r)}},366:t=>{var e=10,r=41,n=107,i=9,o=25;function s(t){return r+(t.script?t.script.length:n)}function a(t){return i+(t.script?t.script.length:o)}function c(t,e){return s({})*e}function u(t,r){return e+t.reduce((function(t,e){return t+s(e)}),0)+r.reduce((function(t,e){return t+a(e)}),0)}function f(t){return\"number\"!=typeof t?NaN:isFinite(t)?Math.floor(t)!==t||t<0?NaN:t:NaN}function h(t){return t.reduce((function(t,e){return t+f(e.value)}),0)}var l=a({});t.exports={dustThreshold:c,finalize:function(t,e,r){var n=u(t,e),i=r*(n+l),o=h(t)-(h(e)+i);o>c(0,r)&&(e=e.concat({value:o}));var s=h(t)-h(e);return isFinite(s)?{inputs:t,outputs:e,fee:s}:{fee:r*n}},inputBytes:s,outputBytes:a,sumOrNaN:h,sumForgiving:function(t){return t.reduce((function(t,e){return t+(isFinite(e.value)?e.value:0)}),0)},transactionBytes:u,uintOrNaN:f}},3257:(t,e,r)=>{\"use strict\";var n=r(5615),i=r(3275),o=r(5586),s=r(3229),a=r(7589);function c(t){a.call(this,\"digest\"),this._hash=t}n(c,a),c.prototype._update=function(t){this._hash.update(t)},c.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return\"md5\"===(t=t.toLowerCase())?new i:\"rmd160\"===t||\"ripemd160\"===t?new o:new c(s(t))}},8437:t=>{var e=1e3,r=60*e,n=60*r,i=24*n,o=7*i,s=365.25*i;function a(t,e,r,n){var i=e>=1.5*r;return Math.round(t/r)+\" \"+n+(i?\"s\":\"\")}t.exports=function(t,c){c=c||{};var u=typeof t;if(\"string\"===u&&t.length>0)return function(t){if((t=String(t)).length>100)return;var a=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return c*s;case\"weeks\":case\"week\":case\"w\":return c*o;case\"days\":case\"day\":case\"d\":return c*i;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return c*n;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return c*r;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return c*e;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return c;default:return}}(t);if(\"number\"===u&&isFinite(t))return c.long?function(t){var o=Math.abs(t);if(o>=i)return a(t,o,i,\"day\");if(o>=n)return a(t,o,n,\"hour\");if(o>=r)return a(t,o,r,\"minute\");if(o>=e)return a(t,o,e,\"second\");return t+\" ms\"}(t):function(t){var o=Math.abs(t);if(o>=i)return Math.round(t/i)+\"d\";if(o>=n)return Math.round(t/n)+\"h\";if(o>=r)return Math.round(t/r)+\"m\";if(o>=e)return Math.round(t/e)+\"s\";return t+\"ms\"}(t);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(t))}},124:(t,e,r)=>{e.formatArgs=function(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+t.exports.humanize(this.diff),!this.useColors)return;const r=\"color: \"+this.color;e.splice(1,0,r,\"color: inherit\");let n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(t=>{\"%%\"!==t&&(n++,\"%c\"===t&&(i=n))})),e.splice(i,0,r)},e.save=function(t){try{t?e.storage.setItem(\"debug\",t):e.storage.removeItem(\"debug\")}catch(t){}},e.load=function(){let t;try{t=e.storage.getItem(\"debug\")}catch(t){}!t&&\"undefined\"!=typeof process&&\"env\"in process&&(t=\"false\");return t},e.useColors=function(){if(\"undefined\"!=typeof window&&window.process&&(\"renderer\"===window.process.type||window.process.__nwjs))return!0;if(\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))return!1;return\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),e.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],e.log=console.debug||console.log||(()=>{}),t.exports=r(7891)(e);const{formatters:n}=t.exports;n.j=function(t){try{return JSON.stringify(t)}catch(t){return\"[UnexpectedJSONParseError]: \"+t.message}}},7891:(t,e,r)=>{t.exports=function(t){function e(t){let r,i,o,s=null;function a(...t){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,t[0]=e.coerce(t[0]),\"string\"!=typeof t[0]&&t.unshift(\"%O\");let s=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if(\"%%\"===r)return\"%\";s++;const o=e.formatters[i];if(\"function\"==typeof o){const e=t[s];r=o.call(n,e),t.splice(s,1),s--}return r})),e.formatArgs.call(n,t);(n.log||e.log).apply(n,t)}return a.namespace=t,a.useColors=e.useColors(),a.color=e.selectColor(t),a.extend=n,a.destroy=e.destroy,Object.defineProperty(a,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==e.namespaces&&(i=e.namespaces,o=e.enabled(t)),o),set:t=>{s=t}}),\"function\"==typeof e.init&&e.init(a),a}function n(t,r){const n=e(this.namespace+(void 0===r?\":\":r)+t);return n.log=this.log,n}function i(t){return t.toString().substring(2,t.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return e.debug=e,e.default=e,e.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},e.disable=function(){const t=[...e.names.map(i),...e.skips.map(i).map((t=>\"-\"+t))].join(\",\");return e.enable(\"\"),t},e.enable=function(t){let r;e.save(t),e.namespaces=t,e.names=[],e.skips=[];const n=(\"string\"==typeof t?t:\"\").split(/[\\s,]+/),i=n.length;for(r=0;r{e[r]=t[r]})),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let r=0;for(let e=0;e{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(3540);e.networks=i;const o=r(146),s=r(2644),a=r(6952),c=r(5581),u=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError(\"Private key not in range [1, n)\");return o.typeforce(u,r),new f(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(u,r),new f(void 0,e,r)}(0,c.testEcc)(t);class f{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error(\"Missing private key\");return a.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error(\"Missing private key\");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error(\"Missing private key\");if(!t.signSchnorr)throw new Error(\"signSchnorr not supported by ecc library\");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error(\"verifySchnorr not supported by ecc library\");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const s=t.xOnlyPointAddTweak(i,e);if(!s||null===s.xOnlyPubkey)throw new Error(\"Cannot tweak public key!\");const a=n.from([0===s.parity?2:3]);return r(n.concat([a,s.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3===this.publicKey[0]||4===this.publicKey[0]&&1==(1&this.publicKey[64])?t.privateNegate(this.privateKey):this.privateKey,o=t.privateAdd(i,r);if(!o)throw new Error(\"Invalid tweaked private key!\");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=a.decode(t),s=n.version;if(o.Array(r)){if(!(r=r.filter((t=>s===t.wif)).pop()))throw new Error(\"Unknown network version\")}else if(r=r||i.bitcoin,s!==r.wif)throw new Error(\"Invalid network version\");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(u,r),void 0===r&&(r={});const n=r.rng||s;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},1075:(t,e,r)=>{\"use strict\";e.Ay=void 0;var n=r(2239);Object.defineProperty(e,\"Ay\",{enumerable:!0,get:function(){return n.ECPairFactory}})},3540:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"tb\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},5581:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,\"hex\");function o(t){if(!t)throw new Error(\"ecc library invalid\")}e.testEcc=function(t){o(t.isPoint(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(!t.isPoint(i(\"030000000000000000000000000000000000000000000000000000000000000005\"))),o(t.isPrivate(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(!t.isPrivate(i(\"0000000000000000000000000000000000000000000000000000000000000000\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142\"))),o(n.from(t.privateAdd(i(\"0000000000000000000000000000000000000000000000000000000000000001\"),i(\"0000000000000000000000000000000000000000000000000000000000000000\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))),o(null===t.privateAdd(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"),i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateAdd(i(\"e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500\"),i(\"b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665\"))).equals(i(\"9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24\"))),o(n.from(t.privateNegate(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(n.from(t.privateNegate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateNegate(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792\"))),o(n.from(t.pointCompress(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"),!0)).equals(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(n.from(t.pointCompress(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"),!1)).equals(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"))),o(n.from(t.pointCompress(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),!0)).equals(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(n.from(t.pointCompress(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),!1)).equals(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"))),o(n.from(t.pointFromScalar(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99\"))),o(null===t.xOnlyPointAddTweak(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\")));let e=t.xOnlyPointAddTweak(i(\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\"),i(\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\"));o(n.from(e.xOnlyPubkey).equals(i(\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"))&&1===e.parity),e=t.xOnlyPointAddTweak(i(\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\"),i(\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\")),o(n.from(e.xOnlyPubkey).equals(i(\"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c\"))&&0===e.parity),o(n.from(t.sign(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))).equals(i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),o(t.verify(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),t.signSchnorr&&o(n.from(t.signSchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9\"),i(\"c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906\"))).equals(i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\"))),t.verifySchnorr&&o(t.verifySchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8\"),i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\")))}},146:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(973),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},46:t=>{\"use strict\";var e,r=\"object\"==typeof Reflect?Reflect:null,n=r&&\"function\"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&\"function\"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){\"function\"==typeof t.removeListener&&t.removeListener(\"error\",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),\"error\"!==e&&function(t,e,r){\"function\"==typeof t.on&&y(t,\"error\",e,r)}(t,i,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if(\"function\"!=typeof t)throw new TypeError('The \"listener\" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var i,o,s,u;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit(\"newListener\",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if(\"function\"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(t))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error(\"Possible EventEmitter memory leak detected. \"+s.length+\" \"+String(e)+\" listeners added. Use emitter.setMaxListeners() to increase limit\");f.name=\"MaxListenersExceededWarning\",f.emitter=t,f.type=e,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function l(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:\"function\"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(s=e[0]),s instanceof Error)throw s;var a=new Error(\"Unhandled error.\"+(s?\" (\"+s.message+\")\":\"\"));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if(\"function\"==typeof c)n(c,this,e);else{var u=c.length,f=d(c,u);for(r=0;r=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return l(this,t,!0)},o.prototype.rawListeners=function(t){return l(this,t,!1)},o.listenerCount=function(t,e){return\"function\"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},282:t=>{t.exports=s,s.default=s,s.stable=f,s.stableStringify=f;var e=\"[...]\",r=\"[Circular]\",n=[],i=[];function o(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function s(t,e,r,s){var a;void 0===s&&(s=o()),c(t,\"\",0,[],void 0,0,s);try{a=0===i.length?JSON.stringify(t,e,r):JSON.stringify(t,l(e),r)}catch(t){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function a(t,e,r,o){var s=Object.getOwnPropertyDescriptor(o,r);void 0!==s.get?s.configurable?(Object.defineProperty(o,r,{value:t}),n.push([o,r,e,s])):i.push([e,r,t]):(o[r]=t,n.push([o,r,e]))}function c(t,n,i,o,s,u,f){var h;if(u+=1,\"object\"==typeof t&&null!==t){for(h=0;hf.depthLimit)return void a(e,t,n,s);if(void 0!==f.edgesLimit&&i+1>f.edgesLimit)return void a(e,t,n,s);if(o.push(t),Array.isArray(t))for(h=0;he?1:0}function f(t,e,r,s){void 0===s&&(s=o());var a,c=h(t,\"\",0,[],void 0,0,s)||t;try{a=0===i.length?JSON.stringify(c,e,r):JSON.stringify(c,l(e),r)}catch(t){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function h(t,i,o,s,c,f,l){var p;if(f+=1,\"object\"==typeof t&&null!==t){for(p=0;pl.depthLimit)return void a(e,t,i,c);if(void 0!==l.edgesLimit&&o+1>l.edgesLimit)return void a(e,t,i,c);if(s.push(t),Array.isArray(t))for(p=0;p0)for(var n=0;n{\"use strict\";const n=r(919),i=r(6226),o=r(5181);t.exports={XMLParser:i,XMLValidator:n,XMLBuilder:o}},1209:(t,e)=>{\"use strict\";const r=\":A-Za-z_\\\\u00C0-\\\\u00D6\\\\u00D8-\\\\u00F6\\\\u00F8-\\\\u02FF\\\\u0370-\\\\u037D\\\\u037F-\\\\u1FFF\\\\u200C-\\\\u200D\\\\u2070-\\\\u218F\\\\u2C00-\\\\u2FEF\\\\u3001-\\\\uD7FF\\\\uF900-\\\\uFDCF\\\\uFDF0-\\\\uFFFD\",n=\"[\"+r+\"][\"+(r+\"\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040\")+\"]*\",i=new RegExp(\"^\"+n+\"$\");e.isExist=function(t){return void 0!==t},e.isEmptyObject=function(t){return 0===Object.keys(t).length},e.merge=function(t,e,r){if(e){const n=Object.keys(e),i=n.length;for(let o=0;o{\"use strict\";const n=r(1209),i={allowBooleanAttributes:!1,unpairedTags:[]};function o(t){return\" \"===t||\"\\t\"===t||\"\\n\"===t||\"\\r\"===t}function s(t,e){const r=e;for(;e5&&\"xml\"===n)return d(\"InvalidXml\",\"XML declaration allowed only at the start of the document.\",g(t,e));if(\"?\"==t[e]&&\">\"==t[e+1]){e++;break}}return e}function a(t,e){if(t.length>e+5&&\"-\"===t[e+1]&&\"-\"===t[e+2]){for(e+=3;e\"===t[e+2]){e+=2;break}}else if(t.length>e+8&&\"D\"===t[e+1]&&\"O\"===t[e+2]&&\"C\"===t[e+3]&&\"T\"===t[e+4]&&\"Y\"===t[e+5]&&\"P\"===t[e+6]&&\"E\"===t[e+7]){let r=1;for(e+=8;e\"===t[e]&&(r--,0===r))break}else if(t.length>e+9&&\"[\"===t[e+1]&&\"C\"===t[e+2]&&\"D\"===t[e+3]&&\"A\"===t[e+4]&&\"T\"===t[e+5]&&\"A\"===t[e+6]&&\"[\"===t[e+7])for(e+=8;e\"===t[e+2]){e+=2;break}return e}e.validate=function(t,e){e=Object.assign({},i,e);const r=[];let c=!1,u=!1;\"\\ufeff\"===t[0]&&(t=t.substr(1));for(let i=0;i\"!==t[i]&&\" \"!==t[i]&&\"\\t\"!==t[i]&&\"\\n\"!==t[i]&&\"\\r\"!==t[i];i++)w+=t[i];if(w=w.trim(),\"/\"===w[w.length-1]&&(w=w.substring(0,w.length-1),i--),h=w,!n.isName(h)){let e;return e=0===w.trim().length?\"Invalid space after '<'.\":\"Tag '\"+w+\"' is an invalid name.\",d(\"InvalidTag\",e,g(t,i))}const m=f(t,i);if(!1===m)return d(\"InvalidAttr\",\"Attributes for '\"+w+\"' have open quote.\",g(t,i));let v=m.value;if(i=m.index,\"/\"===v[v.length-1]){const r=i-v.length;v=v.substring(0,v.length-1);const n=l(v,e);if(!0!==n)return d(n.err.code,n.err.msg,g(t,r+n.err.line));c=!0}else if(b){if(!m.tagClosed)return d(\"InvalidTag\",\"Closing tag '\"+w+\"' doesn't have proper closing.\",g(t,i));if(v.trim().length>0)return d(\"InvalidTag\",\"Closing tag '\"+w+\"' can't have attributes or invalid starting.\",g(t,y));{const e=r.pop();if(w!==e.tagName){let r=g(t,e.tagStartPos);return d(\"InvalidTag\",\"Expected closing tag '\"+e.tagName+\"' (opened in line \"+r.line+\", col \"+r.col+\") instead of closing tag '\"+w+\"'.\",g(t,y))}0==r.length&&(u=!0)}}else{const n=l(v,e);if(!0!==n)return d(n.err.code,n.err.msg,g(t,i-v.length+n.err.line));if(!0===u)return d(\"InvalidXml\",\"Multiple possible root nodes found.\",g(t,i));-1!==e.unpairedTags.indexOf(w)||r.push({tagName:w,tagStartPos:y}),c=!0}for(i++;i0)||d(\"InvalidXml\",\"Invalid '\"+JSON.stringify(r.map((t=>t.tagName)),null,4).replace(/\\r?\\n/g,\"\")+\"' found.\",{line:1,col:1}):d(\"InvalidXml\",\"Start tag expected.\",1)};const c='\"',u=\"'\";function f(t,e){let r=\"\",n=\"\",i=!1;for(;e\"===t[e]&&\"\"===n){i=!0;break}r+=t[e]}return\"\"===n&&{value:r,index:e,tagClosed:i}}const h=new RegExp(\"(\\\\s*)([^\\\\s=]+)(\\\\s*=)?(\\\\s*(['\\\"])(([\\\\s\\\\S])*?)\\\\5)?\",\"g\");function l(t,e){const r=n.getAllMatches(t,h),i={};for(let t=0;t{\"use strict\";const n=r(4655),i={attributeNamePrefix:\"@_\",attributesGroupName:!1,textNodeName:\"#text\",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:\" \",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp(\"&\",\"g\"),val:\"&\"},{regex:new RegExp(\">\",\"g\"),val:\">\"},{regex:new RegExp(\"<\",\"g\"),val:\"<\"},{regex:new RegExp(\"'\",\"g\"),val:\"'\"},{regex:new RegExp('\"',\"g\"),val:\""\"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function o(t){this.options=Object.assign({},i,t),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=c),this.processTextOrObjNode=s,this.options.format?(this.indentate=a,this.tagEndChar=\">\\n\",this.newLine=\"\\n\"):(this.indentate=function(){return\"\"},this.tagEndChar=\">\",this.newLine=\"\")}function s(t,e,r){const n=this.j2x(t,r+1);return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,r):this.buildObjectNode(n.val,e,n.attrStr,r)}function a(t){return this.options.indentBy.repeat(t)}function c(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}o.prototype.build=function(t){return this.options.preserveOrder?n(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0).val)},o.prototype.j2x=function(t,e){let r=\"\",n=\"\";for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i))if(void 0===t[i])this.isAttribute(i)&&(n+=\"\");else if(null===t[i])this.isAttribute(i)?n+=\"\":\"?\"===i[0]?n+=this.indentate(e)+\"<\"+i+\"?\"+this.tagEndChar:n+=this.indentate(e)+\"<\"+i+\"/\"+this.tagEndChar;else if(t[i]instanceof Date)n+=this.buildTextValNode(t[i],i,\"\",e);else if(\"object\"!=typeof t[i]){const o=this.isAttribute(i);if(o)r+=this.buildAttrPairStr(o,\"\"+t[i]);else if(i===this.options.textNodeName){let e=this.options.tagValueProcessor(i,\"\"+t[i]);n+=this.replaceEntitiesValue(e)}else n+=this.buildTextValNode(t[i],i,\"\",e)}else if(Array.isArray(t[i])){const r=t[i].length;let o=\"\";for(let s=0;s\"+t+i}},o.prototype.closeTag=function(t){let e=\"\";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e=\"/\"):e=this.options.suppressEmptyNode?\"/\":`>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(n)+`\\x3c!--${t}--\\x3e`+this.newLine;if(\"?\"===e[0])return this.indentate(n)+\"<\"+e+r+\"?\"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),\"\"===i?this.indentate(n)+\"<\"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(n)+\"<\"+e+r+\">\"+i+\"0&&this.options.processEntities)for(let e=0;e{function e(t,s,a,c){let u=\"\",f=!1;for(let h=0;h`,f=!1;continue}if(p===s.commentPropName){u+=c+`\\x3c!--${l[p][0][s.textNodeName]}--\\x3e`,f=!0;continue}if(\"?\"===p[0]){const t=n(l[\":@\"],s),e=\"?xml\"===p?\"\":c;let r=l[p][0][s.textNodeName];r=0!==r.length?\" \"+r:\"\",u+=e+`<${p}${r}${t}?>`,f=!0;continue}let y=c;\"\"!==y&&(y+=s.indentBy);const g=c+`<${p}${n(l[\":@\"],s)}`,b=e(l[p],s,d,y);-1!==s.unpairedTags.indexOf(p)?s.suppressUnpairedNode?u+=g+\">\":u+=g+\"/>\":b&&0!==b.length||!s.suppressEmptyNode?b&&b.endsWith(\">\")?u+=g+`>${b}${c}`:(u+=g+\">\",b&&\"\"!==c&&(b.includes(\"/>\")||b.includes(\"`):u+=g+\"/>\",f=!0}return u}function r(t){const e=Object.keys(t);for(let r=0;r0&&e.processEntities)for(let r=0;r0&&(n=\"\\n\"),e(t,r,\"\",n)}},3233:(t,e,r)=>{const n=r(1209);function i(t,e){let r=\"\";for(;e\"===t[e]){if(l?\"-\"===t[e-1]&&\"-\"===t[e-2]&&(l=!1,n--):n--,0===n)break}else\"[\"===t[e]?h=!0:p+=t[e];else{if(h&&s(t,e))e+=7,[entityName,val,e]=i(t,e+1),-1===val.indexOf(\"&\")&&(r[f(entityName)]={regx:RegExp(`&${entityName};`,\"g\"),val});else if(h&&a(t,e))e+=8;else if(h&&c(t,e))e+=8;else if(h&&u(t,e))e+=9;else{if(!o)throw new Error(\"Invalid DOCTYPE\");l=!0}n++,p=\"\"}if(0!==n)throw new Error(\"Unclosed DOCTYPE\")}return{entities:r,i:e}}},7063:(t,e)=>{const r={preserveOrder:!1,attributeNamePrefix:\"@_\",attributesGroupName:!1,textNodeName:\"#text\",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t}};e.buildOptions=function(t){return Object.assign({},r,t)},e.defaultOptions=r},5139:(t,e,r)=>{\"use strict\";const n=r(1209),i=r(5381),o=r(3233),s=r(8262);function a(t){const e=Object.keys(t);for(let r=0;r0)){s||(t=this.replaceEntitiesValue(t));const n=this.options.tagValueProcessor(e,t,r,i,o);if(null==n)return t;if(typeof n!=typeof t||n!==t)return n;if(this.options.trimValues)return v(t,this.options.parseTagValue,this.options.numberParseOptions);return t.trim()===t?v(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function u(t){if(this.options.removeNSPrefix){const e=t.split(\":\"),r=\"/\"===t.charAt(0)?\"/\":\"\";if(\"xmlns\"===e[0])return\"\";2===e.length&&(t=r+e[1])}return t}const f=new RegExp(\"([^\\\\s=]+)\\\\s*(=\\\\s*(['\\\"])([\\\\s\\\\S]*?)\\\\3)?\",\"gm\");function h(t,e,r){if(!this.options.ignoreAttributes&&\"string\"==typeof t){const r=n.getAllMatches(t,f),i=r.length,o={};for(let t=0;t\",a,\"Closing Tag is not closed.\");let i=t.substring(a+2,e).trim();if(this.options.removeNSPrefix){const t=i.indexOf(\":\");-1!==t&&(i=i.substr(t+1))}this.options.transformTagName&&(i=this.options.transformTagName(i)),r&&(n=this.saveTextToParentTag(n,r,s));const o=s.substring(s.lastIndexOf(\".\")+1);if(i&&-1!==this.options.unpairedTags.indexOf(i))throw new Error(`Unpaired tag can not be used as closing tag: `);let c=0;o&&-1!==this.options.unpairedTags.indexOf(o)?(c=s.lastIndexOf(\".\",s.lastIndexOf(\".\")-1),this.tagsNodeStack.pop()):c=s.lastIndexOf(\".\"),s=s.substring(0,c),r=this.tagsNodeStack.pop(),n=\"\",a=e}else if(\"?\"===t[a+1]){let e=w(t,a,!1,\"?>\");if(!e)throw new Error(\"Pi Tag is not closed.\");if(n=this.saveTextToParentTag(n,r,s),this.options.ignoreDeclaration&&\"?xml\"===e.tagName||this.options.ignorePiTags);else{const t=new i(e.tagName);t.add(this.options.textNodeName,\"\"),e.tagName!==e.tagExp&&e.attrExpPresent&&(t[\":@\"]=this.buildAttributesMap(e.tagExp,s,e.tagName)),this.addChild(r,t,s)}a=e.closeIndex+1}else if(\"!--\"===t.substr(a+1,3)){const e=b(t,\"--\\x3e\",a+4,\"Comment is not closed.\");if(this.options.commentPropName){const i=t.substring(a+4,e-2);n=this.saveTextToParentTag(n,r,s),r.add(this.options.commentPropName,[{[this.options.textNodeName]:i}])}a=e}else if(\"!D\"===t.substr(a+1,2)){const e=o(t,a);this.docTypeEntities=e.entities,a=e.i}else if(\"![\"===t.substr(a+1,2)){const e=b(t,\"]]>\",a,\"CDATA is not closed.\")-2,i=t.substring(a+9,e);n=this.saveTextToParentTag(n,r,s);let o=this.parseTextData(i,r.tagname,s,!0,!1,!0,!0);null==o&&(o=\"\"),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:i}]):r.add(this.options.textNodeName,o),a=e+2}else{let o=w(t,a,this.options.removeNSPrefix),c=o.tagName;const u=o.rawTagName;let f=o.tagExp,h=o.attrExpPresent,l=o.closeIndex;this.options.transformTagName&&(c=this.options.transformTagName(c)),r&&n&&\"!xml\"!==r.tagname&&(n=this.saveTextToParentTag(n,r,s,!1));const p=r;if(p&&-1!==this.options.unpairedTags.indexOf(p.tagname)&&(r=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf(\".\"))),c!==e.tagname&&(s+=s?\".\"+c:c),this.isItStopNode(this.options.stopNodes,s,c)){let e=\"\";if(f.length>0&&f.lastIndexOf(\"/\")===f.length-1)a=o.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(c))a=o.closeIndex;else{const r=this.readStopNodeData(t,u,l+1);if(!r)throw new Error(`Unexpected end of ${u}`);a=r.i,e=r.tagContent}const n=new i(c);c!==f&&h&&(n[\":@\"]=this.buildAttributesMap(f,s,c)),e&&(e=this.parseTextData(e,c,s,!0,h,!0,!0)),s=s.substr(0,s.lastIndexOf(\".\")),n.add(this.options.textNodeName,e),this.addChild(r,n,s)}else{if(f.length>0&&f.lastIndexOf(\"/\")===f.length-1){\"/\"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),f=c):f=f.substr(0,f.length-1),this.options.transformTagName&&(c=this.options.transformTagName(c));const t=new i(c);c!==f&&h&&(t[\":@\"]=this.buildAttributesMap(f,s,c)),this.addChild(r,t,s),s=s.substr(0,s.lastIndexOf(\".\"))}else{const t=new i(c);this.tagsNodeStack.push(r),c!==f&&h&&(t[\":@\"]=this.buildAttributesMap(f,s,c)),this.addChild(r,t,s),r=t}n=\"\",a=l}}else n+=t[a]}return e.child};function p(t,e,r){const n=this.options.updateTag(e.tagname,r,e[\":@\"]);!1===n||(\"string\"==typeof n?(e.tagname=n,t.addChild(e)):t.addChild(e))}const d=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const r=this.docTypeEntities[e];t=t.replace(r.regx,r.val)}for(let e in this.lastEntities){const r=this.lastEntities[e];t=t.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const r=this.htmlEntities[e];t=t.replace(r.regex,r.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function y(t,e,r,n){return t&&(void 0===n&&(n=0===Object.keys(e.child).length),void 0!==(t=this.parseTextData(t,e.tagname,r,!1,!!e[\":@\"]&&0!==Object.keys(e[\":@\"]).length,n))&&\"\"!==t&&e.add(this.options.textNodeName,t),t=\"\"),t}function g(t,e,r){const n=\"*.\"+r;for(const r in t){const i=t[r];if(n===i||e===i)return!0}return!1}function b(t,e,r,n){const i=t.indexOf(e,r);if(-1===i)throw new Error(n);return i+e.length-1}function w(t,e,r,n=\">\"){const i=function(t,e,r=\">\"){let n,i=\"\";for(let o=e;o\",r,`${e} is not closed`);if(t.substring(r+2,o).trim()===e&&(i--,0===i))return{tagContent:t.substring(n,r),i:o};r=o}else if(\"?\"===t[r+1]){r=b(t,\"?>\",r+1,\"StopNode is not closed.\")}else if(\"!--\"===t.substr(r+1,3)){r=b(t,\"--\\x3e\",r+3,\"StopNode is not closed.\")}else if(\"![\"===t.substr(r+1,2)){r=b(t,\"]]>\",r,\"StopNode is not closed.\")-2}else{const n=w(t,r,\">\");if(n){(n&&n.tagName)===e&&\"/\"!==n.tagExp[n.tagExp.length-1]&&i++,r=n.closeIndex}}}function v(t,e,r){if(e&&\"string\"==typeof t){const e=t.trim();return\"true\"===e||\"false\"!==e&&s(t,r)}return n.isExist(t)?t:\"\"}t.exports=class{constructor(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:\"'\"},gt:{regex:/&(gt|#62|#x3E);/g,val:\">\"},lt:{regex:/&(lt|#60|#x3C);/g,val:\"<\"},quot:{regex:/&(quot|#34|#x22);/g,val:'\"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:\"&\"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:\" \"},cent:{regex:/&(cent|#162);/g,val:\"¢\"},pound:{regex:/&(pound|#163);/g,val:\"£\"},yen:{regex:/&(yen|#165);/g,val:\"¥\"},euro:{regex:/&(euro|#8364);/g,val:\"€\"},copyright:{regex:/&(copy|#169);/g,val:\"©\"},reg:{regex:/&(reg|#174);/g,val:\"®\"},inr:{regex:/&(inr|#8377);/g,val:\"₹\"}},this.addExternalEntities=a,this.parseXml=l,this.parseTextData=c,this.resolveNameSpace=u,this.buildAttributesMap=h,this.isItStopNode=g,this.replaceEntitiesValue=d,this.readStopNodeData=m,this.saveTextToParentTag=y,this.addChild=p}}},6226:(t,e,r)=>{const{buildOptions:n}=r(7063),i=r(5139),{prettify:o}=r(896),s=r(919);t.exports=class{constructor(t){this.externalEntities={},this.options=n(t)}parse(t,e){if(\"string\"==typeof t);else{if(!t.toString)throw new Error(\"XML data is accepted in String or Bytes[] form.\");t=t.toString()}if(e){!0===e&&(e={});const r=s.validate(t,e);if(!0!==r)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const r=new i(this.options);r.addExternalEntities(this.externalEntities);const n=r.parseXml(t);return this.options.preserveOrder||void 0===n?n:o(n,this.options)}addEntity(t,e){if(-1!==e.indexOf(\"&\"))throw new Error(\"Entity value can't have '&'\");if(-1!==t.indexOf(\"&\")||-1!==t.indexOf(\";\"))throw new Error(\"An entity must be set without '&' and ';'. Eg. use '#xD' for ' '\");if(\"&\"===e)throw new Error(\"An entity with value '&' is not permitted\");this.externalEntities[t]=e}}},896:(t,e)=>{\"use strict\";function r(t,e,s){let a;const c={};for(let u=0;u0&&(c[e.textNodeName]=a):void 0!==a&&(c[e.textNodeName]=a),c}function n(t){const e=Object.keys(t);for(let t=0;t{\"use strict\";t.exports=class{constructor(t){this.tagname=t,this.child=[],this[\":@\"]={}}add(t,e){\"__proto__\"===t&&(t=\"#__proto__\"),this.child.push({[t]:e})}addChild(t){\"__proto__\"===t.tagname&&(t.tagname=\"#__proto__\"),t[\":@\"]&&Object.keys(t[\":@\"]).length>0?this.child.push({[t.tagname]:t.child,\":@\":t[\":@\"]}):this.child.push({[t.tagname]:t.child})}}},9467:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=r(4156).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(5615)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t,e){if(!n.isBuffer(t)&&\"string\"!=typeof t)throw new TypeError(e+\" must be a string or a buffer\")}(t,\"Data\"),this._finalized)throw new Error(\"Digest already called\");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error(\"_update is not implemented\")},o.prototype.digest=function(t){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error(\"_digest is not implemented\")},t.exports=o},9318:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,c=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=u}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,u-=8);t[r+p-d]|=128*y}},5615:t=>{\"function\"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},3624:(t,e,r)=>{\"use strict\";const n=r(222),i=Symbol(\"max\"),o=Symbol(\"length\"),s=Symbol(\"lengthCalculator\"),a=Symbol(\"allowStale\"),c=Symbol(\"maxAge\"),u=Symbol(\"dispose\"),f=Symbol(\"noDisposeOnSet\"),h=Symbol(\"lruList\"),l=Symbol(\"cache\"),p=Symbol(\"updateAgeOnGet\"),d=()=>1;const y=(t,e,r)=>{const n=t[l].get(e);if(n){const e=n.value;if(g(t,e)){if(w(t,n),!t[a])return}else r&&(t[p]&&(n.value.now=Date.now()),t[h].unshiftNode(n));return e.value}},g=(t,e)=>{if(!e||!e.maxAge&&!t[c])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[c]&&r>t[c]},b=t=>{if(t[o]>t[i])for(let e=t[h].tail;t[o]>t[i]&&null!==e;){const r=e.prev;w(t,e),e=r}},w=(t,e)=>{if(e){const r=e.value;t[u]&&t[u](r.key,r.value),t[o]-=r.length,t[l].delete(r.key),t[h].removeNode(e)}};class m{constructor(t,e,r,n,i){this.key=t,this.value=e,this.length=r,this.now=n,this.maxAge=i||0}}const v=(t,e,r,n)=>{let i=r.value;g(t,i)&&(w(t,r),t[a]||(i=void 0)),i&&e.call(n,i.value,i.key,t)};t.exports=class{constructor(t){if(\"number\"==typeof t&&(t={max:t}),t||(t={}),t.max&&(\"number\"!=typeof t.max||t.max<0))throw new TypeError(\"max must be a non-negative number\");this[i]=t.max||1/0;const e=t.length||d;if(this[s]=\"function\"!=typeof e?d:e,this[a]=t.stale||!1,t.maxAge&&\"number\"!=typeof t.maxAge)throw new TypeError(\"maxAge must be a number\");this[c]=t.maxAge||0,this[u]=t.dispose,this[f]=t.noDisposeOnSet||!1,this[p]=t.updateAgeOnGet||!1,this.reset()}set max(t){if(\"number\"!=typeof t||t<0)throw new TypeError(\"max must be a non-negative number\");this[i]=t||1/0,b(this)}get max(){return this[i]}set allowStale(t){this[a]=!!t}get allowStale(){return this[a]}set maxAge(t){if(\"number\"!=typeof t)throw new TypeError(\"maxAge must be a non-negative number\");this[c]=t,b(this)}get maxAge(){return this[c]}set lengthCalculator(t){\"function\"!=typeof t&&(t=d),t!==this[s]&&(this[s]=t,this[o]=0,this[h].forEach((t=>{t.length=this[s](t.value,t.key),this[o]+=t.length}))),b(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[h].length}rforEach(t,e){e=e||this;for(let r=this[h].tail;null!==r;){const n=r.prev;v(this,t,r,e),r=n}}forEach(t,e){e=e||this;for(let r=this[h].head;null!==r;){const n=r.next;v(this,t,r,e),r=n}}keys(){return this[h].toArray().map((t=>t.key))}values(){return this[h].toArray().map((t=>t.value))}reset(){this[u]&&this[h]&&this[h].length&&this[h].forEach((t=>this[u](t.key,t.value))),this[l]=new Map,this[h]=new n,this[o]=0}dump(){return this[h].map((t=>!g(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[h]}set(t,e,r){if((r=r||this[c])&&\"number\"!=typeof r)throw new TypeError(\"maxAge must be a number\");const n=r?Date.now():0,a=this[s](e,t);if(this[l].has(t)){if(a>this[i])return w(this,this[l].get(t)),!1;const s=this[l].get(t).value;return this[u]&&(this[f]||this[u](t,s.value)),s.now=n,s.maxAge=r,s.value=e,this[o]+=a-s.length,s.length=a,this.get(t),b(this),!0}const p=new m(t,e,a,n,r);return p.length>this[i]?(this[u]&&this[u](t,e),!1):(this[o]+=p.length,this[h].unshift(p),this[l].set(t,this[h].head),b(this),!0)}has(t){if(!this[l].has(t))return!1;const e=this[l].get(t).value;return!g(this,e)}get(t){return y(this,t,!0)}peek(t){return y(this,t,!1)}pop(){const t=this[h].tail;return t?(w(this,t),t.value):null}del(t){w(this,this[l].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const n=t[r],i=n.e||0;if(0===i)this.set(n.k,n.v);else{const t=i-e;t>0&&this.set(n.k,n.v,t)}}}prune(){this[l].forEach(((t,e)=>y(this,e,!1)))}}},3275:(t,e,r)=>{\"use strict\";var n=r(5615),i=r(9467),o=r(5636).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return c(t+(e&r|~e&n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return c(t+(e&n|r&~n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return c(t+(e^r^n)+i+o|0,s)+e|0}function l(t,e,r,n,i,o,s){return c(t+(r^(e|~n))+i+o|0,s)+e|0}n(a,i),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,o=this._d;r=u(r,n,i,o,t[0],3614090360,7),o=u(o,r,n,i,t[1],3905402710,12),i=u(i,o,r,n,t[2],606105819,17),n=u(n,i,o,r,t[3],3250441966,22),r=u(r,n,i,o,t[4],4118548399,7),o=u(o,r,n,i,t[5],1200080426,12),i=u(i,o,r,n,t[6],2821735955,17),n=u(n,i,o,r,t[7],4249261313,22),r=u(r,n,i,o,t[8],1770035416,7),o=u(o,r,n,i,t[9],2336552879,12),i=u(i,o,r,n,t[10],4294925233,17),n=u(n,i,o,r,t[11],2304563134,22),r=u(r,n,i,o,t[12],1804603682,7),o=u(o,r,n,i,t[13],4254626195,12),i=u(i,o,r,n,t[14],2792965006,17),r=f(r,n=u(n,i,o,r,t[15],1236535329,22),i,o,t[1],4129170786,5),o=f(o,r,n,i,t[6],3225465664,9),i=f(i,o,r,n,t[11],643717713,14),n=f(n,i,o,r,t[0],3921069994,20),r=f(r,n,i,o,t[5],3593408605,5),o=f(o,r,n,i,t[10],38016083,9),i=f(i,o,r,n,t[15],3634488961,14),n=f(n,i,o,r,t[4],3889429448,20),r=f(r,n,i,o,t[9],568446438,5),o=f(o,r,n,i,t[14],3275163606,9),i=f(i,o,r,n,t[3],4107603335,14),n=f(n,i,o,r,t[8],1163531501,20),r=f(r,n,i,o,t[13],2850285829,5),o=f(o,r,n,i,t[2],4243563512,9),i=f(i,o,r,n,t[7],1735328473,14),r=h(r,n=f(n,i,o,r,t[12],2368359562,20),i,o,t[5],4294588738,4),o=h(o,r,n,i,t[8],2272392833,11),i=h(i,o,r,n,t[11],1839030562,16),n=h(n,i,o,r,t[14],4259657740,23),r=h(r,n,i,o,t[1],2763975236,4),o=h(o,r,n,i,t[4],1272893353,11),i=h(i,o,r,n,t[7],4139469664,16),n=h(n,i,o,r,t[10],3200236656,23),r=h(r,n,i,o,t[13],681279174,4),o=h(o,r,n,i,t[0],3936430074,11),i=h(i,o,r,n,t[3],3572445317,16),n=h(n,i,o,r,t[6],76029189,23),r=h(r,n,i,o,t[9],3654602809,4),o=h(o,r,n,i,t[12],3873151461,11),i=h(i,o,r,n,t[15],530742520,16),r=l(r,n=h(n,i,o,r,t[2],3299628645,23),i,o,t[0],4096336452,6),o=l(o,r,n,i,t[7],1126891415,10),i=l(i,o,r,n,t[14],2878612391,15),n=l(n,i,o,r,t[5],4237533241,21),r=l(r,n,i,o,t[12],1700485571,6),o=l(o,r,n,i,t[3],2399980690,10),i=l(i,o,r,n,t[10],4293915773,15),n=l(n,i,o,r,t[1],2240044497,21),r=l(r,n,i,o,t[8],1873313359,6),o=l(o,r,n,i,t[15],4264355552,10),i=l(i,o,r,n,t[6],2734768916,15),n=l(n,i,o,r,t[13],1309151649,21),r=l(r,n,i,o,t[4],4149444226,6),o=l(o,r,n,i,t[11],3174756917,10),i=l(i,o,r,n,t[2],718787259,15),n=l(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=o.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},9756:(t,e,r)=>{\"use strict\";const{ErrorWithCause:n}=r(4525),{findCauseByReference:i,getErrorCause:o,messageWithCauses:s,stackWithCauses:a}=r(2197);t.exports={ErrorWithCause:n,findCauseByReference:i,getErrorCause:o,stackWithCauses:a,messageWithCauses:s}},4525:t=>{\"use strict\";class e extends Error{constructor(t,{cause:r}={}){super(t),this.name=e.name,r&&(this.cause=r),this.message=t}}t.exports={ErrorWithCause:e}},2197:t=>{\"use strict\";const e=t=>{if(t&&\"object\"==typeof t&&\"cause\"in t){if(\"function\"==typeof t.cause){const e=t.cause();return e instanceof Error?e:void 0}return t.cause instanceof Error?t.cause:void 0}},r=(t,n)=>{if(!(t instanceof Error))return\"\";const i=t.stack||\"\";if(n.has(t))return i+\"\\ncauses have become circular...\";const o=e(t);return o?(n.add(t),i+\"\\ncaused by: \"+r(o,n)):i},n=(t,r,i)=>{if(!(t instanceof Error))return\"\";const o=i?\"\":t.message||\"\";if(r.has(t))return o+\": ...\";const s=e(t);if(s){r.add(t);const e=\"cause\"in t&&\"function\"==typeof t.cause;return o+(e?\"\":\": \")+n(s,r,e)}return o};t.exports={findCauseByReference:(t,r)=>{if(!t||!r)return;if(!(t instanceof Error))return;if(!(r.prototype instanceof Error)&&r!==Error)return;const n=new Set;let i=t;for(;i&&!n.has(i);){if(n.add(i),i instanceof r)return i;i=e(i)}},getErrorCause:e,stackWithCauses:t=>r(t,new Set),messageWithCauses:t=>n(t,new Set)}},2644:(t,e,r)=>{\"use strict\";var n=65536,i=4294967295;var o=r(5636).Buffer,s=r.g.crypto||r.g.msCrypto;s&&s.getRandomValues?t.exports=function(t,e){if(t>i)throw new RangeError(\"requested too many random bytes\");var r=o.allocUnsafe(t);if(t>0)if(t>n)for(var a=0;a{\"use strict\";var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return\"string\"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?\"one of \".concat(e,\" \").concat(t.slice(0,r-1).join(\", \"),\", or \")+t[r-1]:2===r?\"one of \".concat(e,\" \").concat(t[0],\" or \").concat(t[1]):\"of \".concat(e,\" \").concat(t[0])}return\"of \".concat(e,\" \").concat(String(t))}r(\"ERR_INVALID_OPT_VALUE\",(function(t,e){return'The value \"'+e+'\" is invalid for option \"'+t+'\"'}),TypeError),r(\"ERR_INVALID_ARG_TYPE\",(function(t,e,r){var i,o,s,a;if(\"string\"==typeof e&&(o=\"not \",e.substr(!s||s<0?0:+s,o.length)===o)?(i=\"must not be\",e=e.replace(/^not /,\"\")):i=\"must be\",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t,\" argument\"))a=\"The \".concat(t,\" \").concat(i,\" \").concat(n(e,\"type\"));else{var c=function(t,e,r){return\"number\"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,\".\")?\"property\":\"argument\";a='The \"'.concat(t,'\" ').concat(c,\" \").concat(i,\" \").concat(n(e,\"type\"))}return a+=\". Received type \".concat(typeof r)}),TypeError),r(\"ERR_STREAM_PUSH_AFTER_EOF\",\"stream.push() after EOF\"),r(\"ERR_METHOD_NOT_IMPLEMENTED\",(function(t){return\"The \"+t+\" method is not implemented\"})),r(\"ERR_STREAM_PREMATURE_CLOSE\",\"Premature close\"),r(\"ERR_STREAM_DESTROYED\",(function(t){return\"Cannot call \"+t+\" after a stream was destroyed\"})),r(\"ERR_MULTIPLE_CALLBACK\",\"Callback called multiple times\"),r(\"ERR_STREAM_CANNOT_PIPE\",\"Cannot pipe, not readable\"),r(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\"),r(\"ERR_STREAM_NULL_VALUES\",\"May not write null values to stream\",TypeError),r(\"ERR_UNKNOWN_ENCODING\",(function(t){return\"Unknown encoding: \"+t}),TypeError),r(\"ERR_STREAM_UNSHIFT_AFTER_END_EVENT\",\"stream.unshift() after end event\"),t.exports.F=e},1265:(t,e,r)=>{\"use strict\";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=u;var i=r(8199),o=r(5291);r(5615)(u,i);for(var s=n(o.prototype),a=0;a{\"use strict\";t.exports=i;var n=r(9415);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(5615)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},8199:(t,e,r)=>{\"use strict\";var n;t.exports=A,A.ReadableState=S;r(46).EventEmitter;var i=function(t,e){return t.listeners(e).length},o=r(4856),s=r(1048).Buffer,a=(void 0!==r.g?r.g:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var c,u=r(3951);c=u&&u.debuglog?u.debuglog(\"stream\"):function(){};var f,h,l,p=r(82),d=r(6527),y=r(9952).getHighWaterMark,g=r(5699).F,b=g.ERR_INVALID_ARG_TYPE,w=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,v=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(5615)(A,o);var E=d.errorOrDestroy,_=[\"error\",\"close\",\"destroy\",\"pause\",\"resume\"];function S(t,e,i){n=n||r(1265),t=t||{},\"boolean\"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,\"readableHighWaterMark\",i),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(8888).I),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function A(t){if(n=n||r(1265),!(this instanceof A))return new A(t);var e=this instanceof n;this._readableState=new S(t,this,e),this.readable=!0,t&&(\"function\"==typeof t.read&&(this._read=t.read),\"function\"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function I(t,e,r,n,i){c(\"readableAddChunk\",e);var o,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(c(\"onEofChunk\"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?k(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,P(t)))}(t,u);else if(i||(o=function(t,e){var r;n=e,s.isBuffer(n)||n instanceof a||\"string\"==typeof e||void 0===e||t.objectMode||(r=new b(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],e));var n;return r}(u,e)),o)E(t,o);else if(u.objectMode||e&&e.length>0)if(\"string\"==typeof e||u.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),n)u.endEmitted?E(t,new v):T(t,u,e,!0);else if(u.ended)E(t,new w);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!r?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):R(t,u)):T(t,u,e,!1)}else n||(u.reading=!1,R(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function k(t){var e=t._readableState;c(\"emitReadable\",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c(\"emitReadable\",e.flowing),e.emittedReadable=!0,process.nextTick(P,t))}function P(t){var e=t._readableState;c(\"emitReadable_\",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit(\"readable\"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,U(t)}function R(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(B,t,e))}function B(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount(\"data\")>0&&t.resume()}function N(t){c(\"readable nexttick read 0\"),t.read(0)}function L(t,e){c(\"resume\",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit(\"resume\"),U(t),e.flowing&&!e.reading&&t.read(0)}function U(t){var e=t._readableState;for(c(\"flow\",e.flowing);e.flowing&&null!==t.read(););}function j(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(\"\"):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function M(t){var e=t._readableState;c(\"endReadable\",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(H,e,t))}function H(t,e){if(c(\"endReadableNT\",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit(\"end\"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function F(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return c(\"read: emitReadable\",e.length,e.ended),0===e.length&&e.ended?M(this):k(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,i=e.needReadable;return c(\"need readable\",i),(0===e.length||e.length-t0?j(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit(\"data\",n),n},A.prototype._read=function(t){E(this,new m(\"_read()\"))},A.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,c(\"pipe count=%d opts=%j\",n.pipesCount,e);var o=(!e||!1!==e.end)&&t!==process.stdout&&t!==process.stderr?a:y;function s(e,i){c(\"onunpipe\"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,c(\"cleanup\"),t.removeListener(\"close\",p),t.removeListener(\"finish\",d),t.removeListener(\"drain\",u),t.removeListener(\"error\",l),t.removeListener(\"unpipe\",s),r.removeListener(\"end\",a),r.removeListener(\"end\",y),r.removeListener(\"data\",h),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}function a(){c(\"onend\"),t.end()}n.endEmitted?process.nextTick(o):r.once(\"end\",o),t.on(\"unpipe\",s);var u=function(t){return function(){var e=t._readableState;c(\"pipeOnDrain\",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,\"data\")&&(e.flowing=!0,U(t))}}(r);t.on(\"drain\",u);var f=!1;function h(e){c(\"ondata\");var i=t.write(e);c(\"dest.write\",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==F(n.pipes,t))&&!f&&(c(\"false write response, pause\",n.awaitDrain),n.awaitDrain++),r.pause())}function l(e){c(\"onerror\",e),y(),t.removeListener(\"error\",l),0===i(t,\"error\")&&E(t,e)}function p(){t.removeListener(\"finish\",d),y()}function d(){c(\"onfinish\"),t.removeListener(\"close\",p),y()}function y(){c(\"unpipe\"),r.unpipe(t)}return r.on(\"data\",h),function(t,e,r){if(\"function\"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,\"error\",l),t.once(\"close\",p),t.once(\"finish\",d),t.emit(\"pipe\",r),n.flowing||(c(\"pipe resume\"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit(\"unpipe\",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==n.flowing&&this.resume()):\"readable\"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,c(\"on readable\",n.length,n.reading),n.length?k(this):n.reading||process.nextTick(N,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,e){var r=o.prototype.removeListener.call(this,t,e);return\"readable\"===t&&process.nextTick(C,this),r},A.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return\"readable\"!==t&&void 0!==t||process.nextTick(C,this),e},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(c(\"resume\"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(L,t,e))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return c(\"call pause flowing=%j\",this._readableState.flowing),!1!==this._readableState.flowing&&(c(\"pause\"),this._readableState.flowing=!1,this.emit(\"pause\")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on(\"end\",(function(){if(c(\"wrapped end\"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on(\"data\",(function(i){(c(\"wrapped data\"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&\"function\"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o<_.length;o++)t.on(_[o],this.emit.bind(this,_[o]));return this._read=function(e){c(\"wrapped _read\",e),n&&(n=!1,t.resume())},this},\"function\"==typeof Symbol&&(A.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(534)),h(this)}),Object.defineProperty(A.prototype,\"readableHighWaterMark\",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(A.prototype,\"readableBuffer\",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(A.prototype,\"readableFlowing\",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),A._fromList=j,Object.defineProperty(A.prototype,\"readableLength\",{enumerable:!1,get:function(){return this._readableState.length}}),\"function\"==typeof Symbol&&(A.from=function(t,e){return void 0===l&&(l=r(1260)),l(A,t,e)})},9415:(t,e,r)=>{\"use strict\";t.exports=f;var n=r(5699).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,c=r(1265);function u(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit(\"error\",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{\"use strict\";function n(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;t.entry=null;for(;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}var i;t.exports=A,A.WritableState=S;var o={deprecate:r(6732)},s=r(4856),a=r(1048).Buffer,c=(void 0!==r.g?r.g:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var u,f=r(6527),h=r(9952).getHighWaterMark,l=r(5699).F,p=l.ERR_INVALID_ARG_TYPE,d=l.ERR_METHOD_NOT_IMPLEMENTED,y=l.ERR_MULTIPLE_CALLBACK,g=l.ERR_STREAM_CANNOT_PIPE,b=l.ERR_STREAM_DESTROYED,w=l.ERR_STREAM_NULL_VALUES,m=l.ERR_STREAM_WRITE_AFTER_END,v=l.ERR_UNKNOWN_ENCODING,E=f.errorOrDestroy;function _(){}function S(t,e,o){i=i||r(1265),t=t||{},\"boolean\"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,\"writableHighWaterMark\",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(\"function\"!=typeof i)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(P,t,e),t._writableState.errorEmitted=!0,E(t,n)):(i(n),t._writableState.errorEmitted=!0,E(t,n),P(t,e))}(t,r,n,e,i);else{var o=O(r)||t.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||x(t,r),n?process.nextTick(T,t,r,o,i):T(t,r,o,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function A(t){var e=this instanceof(i=i||r(1265));if(!e&&!u.call(A,this))return new A(t);this._writableState=new S(t,this,e),this.writable=!0,t&&(\"function\"==typeof t.write&&(this._write=t.write),\"function\"==typeof t.writev&&(this._writev=t.writev),\"function\"==typeof t.destroy&&(this._destroy=t.destroy),\"function\"==typeof t.final&&(this._final=t.final)),s.call(this)}function I(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b(\"write\")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function T(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit(\"drain\"))}(t,e),e.pendingcb--,n(),P(t,e)}function x(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,o=new Array(i),s=e.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)o[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;o.allBuffers=c,I(t,e,!0,e.length,o,\"\",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new n(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(I(t,e,!1,e.objectMode?1:u.length,u,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function O(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function k(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit(\"prefinish\"),P(t,e)}))}function P(t,e){var r=O(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||(\"function\"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit(\"prefinish\")):(e.pendingcb++,e.finalCalled=!0,process.nextTick(k,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit(\"finish\"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(5615)(A,s),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,\"buffer\",{get:o.deprecate((function(){return this.getBuffer()}),\"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.\",\"DEP0003\")})}catch(t){}}(),\"function\"==typeof Symbol&&Symbol.hasInstance&&\"function\"==typeof Function.prototype[Symbol.hasInstance]?(u=Function.prototype[Symbol.hasInstance],Object.defineProperty(A,Symbol.hasInstance,{value:function(t){return!!u.call(this,t)||this===A&&(t&&t._writableState instanceof S)}})):u=function(t){return t instanceof this},A.prototype.pipe=function(){E(this,new g)},A.prototype.write=function(t,e,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=t,a.isBuffer(n)||n instanceof c);return s&&!a.isBuffer(t)&&(t=function(t){return a.from(t)}(t)),\"function\"==typeof e&&(r=e,e=null),s?e=\"buffer\":e||(e=i.defaultEncoding),\"function\"!=typeof r&&(r=_),i.ending?function(t,e){var r=new m;E(t,r),process.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var i;return null===r?i=new w:\"string\"==typeof r||e.objectMode||(i=new p(\"chunk\",[\"string\",\"Buffer\"],r)),!i||(E(t,i),process.nextTick(n,i),!1)}(this,i,t,r))&&(i.pendingcb++,o=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||\"string\"!=typeof e||(e=a.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i=\"buffer\",n=s)}var c=e.objectMode?1:n.length;e.length+=c;var u=e.length-1))throw new v(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(A.prototype,\"writableBuffer\",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(t,e,r){r(new d(\"_write()\"))},A.prototype._writev=null,A.prototype.end=function(t,e,r){var n=this._writableState;return\"function\"==typeof t?(r=t,t=null,e=null):\"function\"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,P(t,e),r&&(e.finished?process.nextTick(r):t.once(\"finish\",r));e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(A.prototype,\"writableLength\",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,\"destroyed\",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),A.prototype.destroy=f.destroy,A.prototype._undestroy=f.undestroy,A.prototype._destroy=function(t,e){e(t)}},534:(t,e,r)=>{\"use strict\";var n;function i(t,e,r){return(e=function(t){var e=function(t,e){if(\"object\"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||\"default\");if(\"object\"!=typeof n)return n;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===e?String:Number)(t)}(t,\"string\");return\"symbol\"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=r(4869),s=Symbol(\"lastResolve\"),a=Symbol(\"lastReject\"),c=Symbol(\"error\"),u=Symbol(\"ended\"),f=Symbol(\"lastPromise\"),h=Symbol(\"handlePromise\"),l=Symbol(\"stream\");function p(t,e){return{value:t,done:e}}function d(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(p(r,!1)))}}function y(t){process.nextTick(d,t)}var g=Object.getPrototypeOf((function(){})),b=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(p(void 0,!0));if(this[l].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[c]?r(t[c]):e(p(void 0,!0))}))}));var r,n=this[f];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[u]?r(p(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var i=this[l].read();if(null!==i)return Promise.resolve(p(i,!1));r=new Promise(this[h])}return this[f]=r,r}},Symbol.asyncIterator,(function(){return this})),i(n,\"return\",(function(){var t=this;return new Promise((function(e,r){t[l].destroy(null,(function(t){t?r(t):e(p(void 0,!0))}))}))})),n),g);t.exports=function(t){var e,r=Object.create(b,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,c,{value:null,writable:!0}),i(e,u,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var n=r[l].read();n?(r[f]=null,r[s]=null,r[a]=null,t(p(n,!1))):(r[s]=t,r[a]=e)},writable:!0}),e));return r[f]=null,o(t,(function(t){if(t&&\"ERR_STREAM_PREMATURE_CLOSE\"!==t.code){var e=r[a];return null!==e&&(r[f]=null,r[s]=null,r[a]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[f]=null,r[s]=null,r[a]=null,n(p(void 0,!0))),r[u]=!0})),t.on(\"readable\",y.bind(null,r)),r}},82:(t,e,r)=>{\"use strict\";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:\"unshift\",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:\"shift\",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:\"clear\",value:function(){this.head=this.tail=null,this.length=0}},{key:\"join\",value:function(t){if(0===this.length)return\"\";for(var e=this.head,r=\"\"+e.data;e=e.next;)r+=t+e.data;return r}},{key:\"concat\",value:function(t){if(0===this.length)return c.alloc(0);for(var e,r,n,i=c.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,c.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:\"consume\",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:\"_getBuffer\",value:function(t){var e=c.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return u(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&s(e.prototype,r),n&&s(e,n),Object.defineProperty(e,\"prototype\",{writable:!1}),t}()},6527:t=>{\"use strict\";function e(t,e){n(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit(\"close\")}function n(t,e){t.emit(\"error\",e)}t.exports={destroy:function(t,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?o._writableState?o._writableState.errorEmitted?process.nextTick(r,o):(o._writableState.errorEmitted=!0,process.nextTick(e,o,t)):process.nextTick(e,o,t):i?(process.nextTick(r,o),i(t)):process.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit(\"error\",e)}}},4869:(t,e,r)=>{\"use strict\";var n=r(5699).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if(\"function\"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i{t.exports=function(){throw new Error(\"Readable.from is not available in the browser\")}},6815:(t,e,r)=>{\"use strict\";var n;var i=r(5699).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function c(t){t()}function u(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){f||(f=t),t&&l.forEach(c),o||(l.forEach(c),h(f))}))}));return e.reduce(u)}},9952:(t,e,r)=>{\"use strict\";var n=r(5699).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:\"highWaterMark\",o);return Math.floor(o)}return t.objectMode?16:16384}}},4856:(t,e,r)=>{t.exports=r(46).EventEmitter},4156:(t,e,r)=>{(e=t.exports=r(8199)).Stream=e,e.Readable=e,e.Writable=r(5291),e.Duplex=r(1265),e.Transform=r(9415),e.PassThrough=r(4421),e.finished=r(4869),e.pipeline=r(6815)},5586:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer,i=r(5615),o=r(9467),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],c=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],l=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function y(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function w(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}i(p,o),p.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,v=0|this._a,E=0|this._b,_=0|this._c,S=0|this._d,A=0|this._e,I=0;I<80;I+=1){var T,x;I<16?(T=y(r,n,i,o,p,t[a[I]],h[0],u[I]),x=m(v,E,_,S,A,t[c[I]],l[0],f[I])):I<32?(T=g(r,n,i,o,p,t[a[I]],h[1],u[I]),x=w(v,E,_,S,A,t[c[I]],l[1],f[I])):I<48?(T=b(r,n,i,o,p,t[a[I]],h[2],u[I]),x=b(v,E,_,S,A,t[c[I]],l[2],f[I])):I<64?(T=w(r,n,i,o,p,t[a[I]],h[3],u[I]),x=g(v,E,_,S,A,t[c[I]],l[3],f[I])):(T=m(r,n,i,o,p,t[a[I]],h[4],u[I]),x=y(v,E,_,S,A,t[c[I]],l[4],f[I])),r=p,p=o,o=d(i,10),i=n,n=T,v=A,A=S,S=d(_,10),_=E,E=x}var O=this._b+i+S|0;this._b=this._c+o+A|0,this._c=this._d+p+v|0,this._d=this._e+r+E|0,this._e=this._a+n+_|0,this._a=O},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},5636:(t,e,r)=>{var n=r(1048),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if(\"number\"==typeof t)throw new TypeError(\"Argument must not be a number\");return i(t,e,r)},s.alloc=function(t,e,r){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");var n=i(t);return void 0!==e?\"string\"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return i(t)},s.allocUnsafeSlow=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return n.SlowBuffer(t)}},1565:(t,e,r)=>{const n=Symbol(\"SemVer ANY\");class i{static get ANY(){return n}constructor(t,e){if(e=o(e),t instanceof i){if(t.loose===!!e.loose)return t;t=t.value}t=t.trim().split(/\\s+/).join(\" \"),u(\"comparator\",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===n?this.value=\"\":this.value=this.operator+this.semver.version,u(\"comp\",this)}parse(t){const e=this.options.loose?s[a.COMPARATORLOOSE]:s[a.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==r[1]?r[1]:\"\",\"=\"===this.operator&&(this.operator=\"\"),r[2]?this.semver=new f(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(t){if(u(\"Comparator.test\",t,this.options.loose),this.semver===n||t===n)return!0;if(\"string\"==typeof t)try{t=new f(t,this.options)}catch(t){return!1}return c(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof i))throw new TypeError(\"a Comparator is required\");return\"\"===this.operator?\"\"===this.value||new h(t.value,e).test(this.value):\"\"===t.operator?\"\"===t.value||new h(this.value,e).test(t.semver):(!(e=o(e)).includePrerelease||\"<0.0.0-0\"!==this.value&&\"<0.0.0-0\"!==t.value)&&(!(!e.includePrerelease&&(this.value.startsWith(\"<0.0.0\")||t.value.startsWith(\"<0.0.0\")))&&(!(!this.operator.startsWith(\">\")||!t.operator.startsWith(\">\"))||(!(!this.operator.startsWith(\"<\")||!t.operator.startsWith(\"<\"))||(!(this.semver.version!==t.semver.version||!this.operator.includes(\"=\")||!t.operator.includes(\"=\"))||(!!(c(this.semver,\"<\",t.semver,e)&&this.operator.startsWith(\">\")&&t.operator.startsWith(\"<\"))||!!(c(this.semver,\">\",t.semver,e)&&this.operator.startsWith(\"<\")&&t.operator.startsWith(\">\")))))))}}t.exports=i;const o=r(3990),{safeRe:s,t:a}=r(2841),c=r(4004),u=r(1361),f=r(4517),h=r(7476)},7476:(t,e,r)=>{class n{constructor(t,e){if(e=o(e),t instanceof n)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new n(t.raw,e);if(t instanceof s)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t.trim().split(/\\s+/).join(\" \"),this.set=this.raw.split(\"||\").map((t=>this.parseRange(t.trim()))).filter((t=>t.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const t=this.set[0];if(this.set=this.set.filter((t=>!g(t[0]))),0===this.set.length)this.set=[t];else if(this.set.length>1)for(const t of this.set)if(1===t.length&&b(t[0])){this.set=[t];break}}this.format()}format(){return this.range=this.set.map((t=>t.join(\" \").trim())).join(\"||\").trim(),this.range}toString(){return this.range}parseRange(t){const e=((this.options.includePrerelease&&d)|(this.options.loose&&y))+\":\"+t,r=i.get(e);if(r)return r;const n=this.options.loose,o=n?u[f.HYPHENRANGELOOSE]:u[f.HYPHENRANGE];t=t.replace(o,k(this.options.includePrerelease)),a(\"hyphen replace\",t),t=t.replace(u[f.COMPARATORTRIM],h),a(\"comparator trim\",t),t=t.replace(u[f.TILDETRIM],l),a(\"tilde trim\",t),t=t.replace(u[f.CARETTRIM],p),a(\"caret trim\",t);let c=t.split(\" \").map((t=>m(t,this.options))).join(\" \").split(/\\s+/).map((t=>O(t,this.options)));n&&(c=c.filter((t=>(a(\"loose invalid filter\",t,this.options),!!t.match(u[f.COMPARATORLOOSE]))))),a(\"range list\",c);const b=new Map,w=c.map((t=>new s(t,this.options)));for(const t of w){if(g(t))return[t];b.set(t.value,t)}b.size>1&&b.has(\"\")&&b.delete(\"\");const v=[...b.values()];return i.set(e,v),v}intersects(t,e){if(!(t instanceof n))throw new TypeError(\"a Range is required\");return this.set.some((r=>w(r,e)&&t.set.some((t=>w(t,e)&&r.every((r=>t.every((t=>r.intersects(t,e)))))))))}test(t){if(!t)return!1;if(\"string\"==typeof t)try{t=new c(t,this.options)}catch(t){return!1}for(let e=0;e\"<0.0.0-0\"===t.value,b=t=>\"\"===t.value,w=(t,e)=>{let r=!0;const n=t.slice();let i=n.pop();for(;r&&n.length;)r=n.every((t=>i.intersects(t,e))),i=n.pop();return r},m=(t,e)=>(a(\"comp\",t,e),t=S(t,e),a(\"caret\",t),t=E(t,e),a(\"tildes\",t),t=I(t,e),a(\"xrange\",t),t=x(t,e),a(\"stars\",t),t),v=t=>!t||\"x\"===t.toLowerCase()||\"*\"===t,E=(t,e)=>t.trim().split(/\\s+/).map((t=>_(t,e))).join(\" \"),_=(t,e)=>{const r=e.loose?u[f.TILDELOOSE]:u[f.TILDE];return t.replace(r,((e,r,n,i,o)=>{let s;return a(\"tilde\",t,e,r,n,i,o),v(r)?s=\"\":v(n)?s=`>=${r}.0.0 <${+r+1}.0.0-0`:v(i)?s=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:o?(a(\"replaceTilde pr\",o),s=`>=${r}.${n}.${i}-${o} <${r}.${+n+1}.0-0`):s=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,a(\"tilde return\",s),s}))},S=(t,e)=>t.trim().split(/\\s+/).map((t=>A(t,e))).join(\" \"),A=(t,e)=>{a(\"caret\",t,e);const r=e.loose?u[f.CARETLOOSE]:u[f.CARET],n=e.includePrerelease?\"-0\":\"\";return t.replace(r,((e,r,i,o,s)=>{let c;return a(\"caret\",t,e,r,i,o,s),v(r)?c=\"\":v(i)?c=`>=${r}.0.0${n} <${+r+1}.0.0-0`:v(o)?c=\"0\"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:s?(a(\"replaceCaret pr\",s),c=\"0\"===r?\"0\"===i?`>=${r}.${i}.${o}-${s} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}-${s} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o}-${s} <${+r+1}.0.0-0`):(a(\"no pr\"),c=\"0\"===r?\"0\"===i?`>=${r}.${i}.${o}${n} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o} <${+r+1}.0.0-0`),a(\"caret return\",c),c}))},I=(t,e)=>(a(\"replaceXRanges\",t,e),t.split(/\\s+/).map((t=>T(t,e))).join(\" \")),T=(t,e)=>{t=t.trim();const r=e.loose?u[f.XRANGELOOSE]:u[f.XRANGE];return t.replace(r,((r,n,i,o,s,c)=>{a(\"xRange\",t,r,n,i,o,s,c);const u=v(i),f=u||v(o),h=f||v(s),l=h;return\"=\"===n&&l&&(n=\"\"),c=e.includePrerelease?\"-0\":\"\",u?r=\">\"===n||\"<\"===n?\"<0.0.0-0\":\"*\":n&&l?(f&&(o=0),s=0,\">\"===n?(n=\">=\",f?(i=+i+1,o=0,s=0):(o=+o+1,s=0)):\"<=\"===n&&(n=\"<\",f?i=+i+1:o=+o+1),\"<\"===n&&(c=\"-0\"),r=`${n+i}.${o}.${s}${c}`):f?r=`>=${i}.0.0${c} <${+i+1}.0.0-0`:h&&(r=`>=${i}.${o}.0${c} <${i}.${+o+1}.0-0`),a(\"xRange return\",r),r}))},x=(t,e)=>(a(\"replaceStars\",t,e),t.trim().replace(u[f.STAR],\"\")),O=(t,e)=>(a(\"replaceGTE0\",t,e),t.trim().replace(u[e.includePrerelease?f.GTE0PRE:f.GTE0],\"\")),k=t=>(e,r,n,i,o,s,a,c,u,f,h,l,p)=>`${r=v(n)?\"\":v(i)?`>=${n}.0.0${t?\"-0\":\"\"}`:v(o)?`>=${n}.${i}.0${t?\"-0\":\"\"}`:s?`>=${r}`:`>=${r}${t?\"-0\":\"\"}`} ${c=v(u)?\"\":v(f)?`<${+u+1}.0.0-0`:v(h)?`<${u}.${+f+1}.0-0`:l?`<=${u}.${f}.${h}-${l}`:t?`<${u}.${f}.${+h+1}-0`:`<=${c}`}`.trim(),P=(t,e,r)=>{for(let r=0;r0){const n=t[r].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}},4517:(t,e,r)=>{const n=r(1361),{MAX_LENGTH:i,MAX_SAFE_INTEGER:o}=r(9543),{safeRe:s,t:a}=r(2841),c=r(3990),{compareIdentifiers:u}=r(3806);class f{constructor(t,e){if(e=c(e),t instanceof f){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(\"string\"!=typeof t)throw new TypeError(`Invalid version. Must be a string. Got type \"${typeof t}\".`);if(t.length>i)throw new TypeError(`version is longer than ${i} characters`);n(\"SemVer\",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;const r=t.trim().match(e.loose?s[a.LOOSE]:s[a.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>o||this.major<0)throw new TypeError(\"Invalid major version\");if(this.minor>o||this.minor<0)throw new TypeError(\"Invalid minor version\");if(this.patch>o||this.patch<0)throw new TypeError(\"Invalid patch version\");r[4]?this.prerelease=r[4].split(\".\").map((t=>{if(/^[0-9]+$/.test(t)){const e=+t;if(e>=0&&e=0;)\"number\"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(e===this.prerelease.join(\".\")&&!1===r)throw new Error(\"invalid increment argument: identifier already exists\");this.prerelease.push(t)}}if(e){let n=[e,t];!1===r&&(n=[e]),0===u(this.prerelease[0],e)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(\".\")}`),this}}t.exports=f},2281:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t.trim().replace(/^[=v]+/,\"\"),e);return r?r.version:null}},4004:(t,e,r)=>{const n=r(8848),i=r(8220),o=r(9761),s=r(2386),a=r(1262),c=r(9639);t.exports=(t,e,r,u)=>{switch(e){case\"===\":return\"object\"==typeof t&&(t=t.version),\"object\"==typeof r&&(r=r.version),t===r;case\"!==\":return\"object\"==typeof t&&(t=t.version),\"object\"==typeof r&&(r=r.version),t!==r;case\"\":case\"=\":case\"==\":return n(t,r,u);case\"!=\":return i(t,r,u);case\">\":return o(t,r,u);case\">=\":return s(t,r,u);case\"<\":return a(t,r,u);case\"<=\":return c(t,r,u);default:throw new TypeError(`Invalid operator: ${e}`)}}},6783:(t,e,r)=>{const n=r(4517),i=r(3955),{safeRe:o,t:s}=r(2841);t.exports=(t,e)=>{if(t instanceof n)return t;if(\"number\"==typeof t&&(t=String(t)),\"string\"!=typeof t)return null;let r=null;if((e=e||{}).rtl){const n=e.includePrerelease?o[s.COERCERTLFULL]:o[s.COERCERTL];let i;for(;(i=n.exec(t))&&(!r||r.index+r[0].length!==t.length);)r&&i.index+i[0].length===r.index+r[0].length||(r=i),n.lastIndex=i.index+i[1].length+i[2].length;n.lastIndex=-1}else r=t.match(e.includePrerelease?o[s.COERCEFULL]:o[s.COERCE]);if(null===r)return null;const a=r[2],c=r[3]||\"0\",u=r[4]||\"0\",f=e.includePrerelease&&r[5]?`-${r[5]}`:\"\",h=e.includePrerelease&&r[6]?`+${r[6]}`:\"\";return i(`${a}.${c}.${u}${f}${h}`,e)}},6106:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r)=>{const i=new n(t,r),o=new n(e,r);return i.compare(o)||i.compareBuild(o)}},2132:(t,e,r)=>{const n=r(7851);t.exports=(t,e)=>n(t,e,!0)},7851:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r)=>new n(t,r).compare(new n(e,r))},3269:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,null,!0),i=n(e,null,!0),o=r.compare(i);if(0===o)return null;const s=o>0,a=s?r:i,c=s?i:r,u=!!a.prerelease.length;if(!!c.prerelease.length&&!u)return c.patch||c.minor?a.patch?\"patch\":a.minor?\"minor\":\"major\":\"major\";const f=u?\"pre\":\"\";return r.major!==i.major?f+\"major\":r.minor!==i.minor?f+\"minor\":r.patch!==i.patch?f+\"patch\":\"prerelease\"}},8848:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>0===n(t,e,r)},9761:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)>0},2386:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)>=0},8868:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r,i,o)=>{\"string\"==typeof r&&(o=i,i=r,r=void 0);try{return new n(t instanceof n?t.version:t,r).inc(e,i,o).version}catch(t){return null}}},1262:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)<0},9639:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)<=0},6381:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).major},1353:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).minor},8220:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>0!==n(t,e,r)},3955:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r=!1)=>{if(t instanceof n)return t;try{return new n(t,e)}catch(t){if(!r)return null;throw t}}},6082:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).patch},9428:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,e);return r&&r.prerelease.length?r.prerelease:null}},7555:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(e,t,r)},3810:(t,e,r)=>{const n=r(6106);t.exports=(t,e)=>t.sort(((t,r)=>n(r,t,e)))},7229:(t,e,r)=>{const n=r(7476);t.exports=(t,e,r)=>{try{e=new n(e,r)}catch(t){return!1}return e.test(t)}},4042:(t,e,r)=>{const n=r(6106);t.exports=(t,e)=>t.sort(((t,r)=>n(t,r,e)))},8474:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,e);return r?r.version:null}},2722:(t,e,r)=>{const n=r(2841),i=r(9543),o=r(4517),s=r(3806),a=r(3955),c=r(8474),u=r(2281),f=r(8868),h=r(3269),l=r(6381),p=r(1353),d=r(6082),y=r(9428),g=r(7851),b=r(7555),w=r(2132),m=r(6106),v=r(4042),E=r(3810),_=r(9761),S=r(1262),A=r(8848),I=r(8220),T=r(2386),x=r(9639),O=r(4004),k=r(6783),P=r(1565),R=r(7476),B=r(7229),C=r(6364),N=r(5039),L=r(5357),U=r(1280),j=r(7403),M=r(8854),H=r(7226),F=r(7183),D=r(8623),$=r(6486),K=r(583);t.exports={parse:a,valid:c,clean:u,inc:f,diff:h,major:l,minor:p,patch:d,prerelease:y,compare:g,rcompare:b,compareLoose:w,compareBuild:m,sort:v,rsort:E,gt:_,lt:S,eq:A,neq:I,gte:T,lte:x,cmp:O,coerce:k,Comparator:P,Range:R,satisfies:B,toComparators:C,maxSatisfying:N,minSatisfying:L,minVersion:U,validRange:j,outside:M,gtr:H,ltr:F,intersects:D,simplifyRange:$,subset:K,SemVer:o,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers}},9543:t=>{const e=Number.MAX_SAFE_INTEGER||9007199254740991;t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:[\"major\",\"premajor\",\"minor\",\"preminor\",\"patch\",\"prepatch\",\"prerelease\"],SEMVER_SPEC_VERSION:\"2.0.0\",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},1361:t=>{const e=\"object\"==typeof process&&process.env&&/\\bsemver\\b/i.test(\"false\")?(...t)=>console.error(\"SEMVER\",...t):()=>{};t.exports=e},3806:t=>{const e=/^[0-9]+$/,r=(t,r)=>{const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:tr(e,t)}},3990:t=>{const e=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=t=>t?\"object\"!=typeof t?e:t:r},2841:(t,e,r)=>{const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:o}=r(9543),s=r(1361),a=(e=t.exports={}).re=[],c=e.safeRe=[],u=e.src=[],f=e.t={};let h=0;const l=\"[a-zA-Z0-9-]\",p=[[\"\\\\s\",1],[\"\\\\d\",o],[l,i]],d=(t,e,r)=>{const n=(t=>{for(const[e,r]of p)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t})(e),i=h++;s(t,i,e),f[t]=i,u[i]=e,a[i]=new RegExp(e,r?\"g\":void 0),c[i]=new RegExp(n,r?\"g\":void 0)};d(\"NUMERICIDENTIFIER\",\"0|[1-9]\\\\d*\"),d(\"NUMERICIDENTIFIERLOOSE\",\"\\\\d+\"),d(\"NONNUMERICIDENTIFIER\",`\\\\d*[a-zA-Z-]${l}*`),d(\"MAINVERSION\",`(${u[f.NUMERICIDENTIFIER]})\\\\.(${u[f.NUMERICIDENTIFIER]})\\\\.(${u[f.NUMERICIDENTIFIER]})`),d(\"MAINVERSIONLOOSE\",`(${u[f.NUMERICIDENTIFIERLOOSE]})\\\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),d(\"PRERELEASEIDENTIFIER\",`(?:${u[f.NUMERICIDENTIFIER]}|${u[f.NONNUMERICIDENTIFIER]})`),d(\"PRERELEASEIDENTIFIERLOOSE\",`(?:${u[f.NUMERICIDENTIFIERLOOSE]}|${u[f.NONNUMERICIDENTIFIER]})`),d(\"PRERELEASE\",`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\\\.${u[f.PRERELEASEIDENTIFIER]})*))`),d(\"PRERELEASELOOSE\",`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),d(\"BUILDIDENTIFIER\",`${l}+`),d(\"BUILD\",`(?:\\\\+(${u[f.BUILDIDENTIFIER]}(?:\\\\.${u[f.BUILDIDENTIFIER]})*))`),d(\"FULLPLAIN\",`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),d(\"FULL\",`^${u[f.FULLPLAIN]}$`),d(\"LOOSEPLAIN\",`[v=\\\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),d(\"LOOSE\",`^${u[f.LOOSEPLAIN]}$`),d(\"GTLT\",\"((?:<|>)?=?)\"),d(\"XRANGEIDENTIFIERLOOSE\",`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\\\*`),d(\"XRANGEIDENTIFIER\",`${u[f.NUMERICIDENTIFIER]}|x|X|\\\\*`),d(\"XRANGEPLAIN\",`[v=\\\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\\\.(${u[f.XRANGEIDENTIFIER]})(?:\\\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),d(\"XRANGEPLAINLOOSE\",`[v=\\\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),d(\"XRANGE\",`^${u[f.GTLT]}\\\\s*${u[f.XRANGEPLAIN]}$`),d(\"XRANGELOOSE\",`^${u[f.GTLT]}\\\\s*${u[f.XRANGEPLAINLOOSE]}$`),d(\"COERCEPLAIN\",`(^|[^\\\\d])(\\\\d{1,${n}})(?:\\\\.(\\\\d{1,${n}}))?(?:\\\\.(\\\\d{1,${n}}))?`),d(\"COERCE\",`${u[f.COERCEPLAIN]}(?:$|[^\\\\d])`),d(\"COERCEFULL\",u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?`+`(?:${u[f.BUILD]})?(?:$|[^\\\\d])`),d(\"COERCERTL\",u[f.COERCE],!0),d(\"COERCERTLFULL\",u[f.COERCEFULL],!0),d(\"LONETILDE\",\"(?:~>?)\"),d(\"TILDETRIM\",`(\\\\s*)${u[f.LONETILDE]}\\\\s+`,!0),e.tildeTrimReplace=\"$1~\",d(\"TILDE\",`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),d(\"TILDELOOSE\",`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),d(\"LONECARET\",\"(?:\\\\^)\"),d(\"CARETTRIM\",`(\\\\s*)${u[f.LONECARET]}\\\\s+`,!0),e.caretTrimReplace=\"$1^\",d(\"CARET\",`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),d(\"CARETLOOSE\",`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),d(\"COMPARATORLOOSE\",`^${u[f.GTLT]}\\\\s*(${u[f.LOOSEPLAIN]})$|^$`),d(\"COMPARATOR\",`^${u[f.GTLT]}\\\\s*(${u[f.FULLPLAIN]})$|^$`),d(\"COMPARATORTRIM\",`(\\\\s*)${u[f.GTLT]}\\\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=\"$1$2$3\",d(\"HYPHENRANGE\",`^\\\\s*(${u[f.XRANGEPLAIN]})\\\\s+-\\\\s+(${u[f.XRANGEPLAIN]})\\\\s*$`),d(\"HYPHENRANGELOOSE\",`^\\\\s*(${u[f.XRANGEPLAINLOOSE]})\\\\s+-\\\\s+(${u[f.XRANGEPLAINLOOSE]})\\\\s*$`),d(\"STAR\",\"(<|>)?=?\\\\s*\\\\*\"),d(\"GTE0\",\"^\\\\s*>=\\\\s*0\\\\.0\\\\.0\\\\s*$\"),d(\"GTE0PRE\",\"^\\\\s*>=\\\\s*0\\\\.0\\\\.0-0\\\\s*$\")},7226:(t,e,r)=>{const n=r(8854);t.exports=(t,e,r)=>n(t,e,\">\",r)},8623:(t,e,r)=>{const n=r(7476);t.exports=(t,e,r)=>(t=new n(t,r),e=new n(e,r),t.intersects(e,r))},7183:(t,e,r)=>{const n=r(8854);t.exports=(t,e,r)=>n(t,e,\"<\",r)},5039:(t,e,r)=>{const n=r(4517),i=r(7476);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new i(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&-1!==s.compare(t)||(o=t,s=new n(o,r)))})),o}},5357:(t,e,r)=>{const n=r(4517),i=r(7476);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new i(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&1!==s.compare(t)||(o=t,s=new n(o,r)))})),o}},1280:(t,e,r)=>{const n=r(4517),i=r(7476),o=r(9761);t.exports=(t,e)=>{t=new i(t,e);let r=new n(\"0.0.0\");if(t.test(r))return r;if(r=new n(\"0.0.0-0\"),t.test(r))return r;r=null;for(let e=0;e{const e=new n(t.semver.version);switch(t.operator){case\">\":0===e.prerelease.length?e.patch++:e.prerelease.push(0),e.raw=e.format();case\"\":case\">=\":s&&!o(e,s)||(s=e);break;case\"<\":case\"<=\":break;default:throw new Error(`Unexpected operation: ${t.operator}`)}})),!s||r&&!o(r,s)||(r=s)}return r&&t.test(r)?r:null}},8854:(t,e,r)=>{const n=r(4517),i=r(1565),{ANY:o}=i,s=r(7476),a=r(7229),c=r(9761),u=r(1262),f=r(9639),h=r(2386);t.exports=(t,e,r,l)=>{let p,d,y,g,b;switch(t=new n(t,l),e=new s(e,l),r){case\">\":p=c,d=f,y=u,g=\">\",b=\">=\";break;case\"<\":p=u,d=h,y=c,g=\"<\",b=\"<=\";break;default:throw new TypeError('Must provide a hilo val of \"<\" or \">\"')}if(a(t,e,l))return!1;for(let r=0;r{t.semver===o&&(t=new i(\">=0.0.0\")),s=s||t,a=a||t,p(t.semver,s.semver,l)?s=t:y(t.semver,a.semver,l)&&(a=t)})),s.operator===g||s.operator===b)return!1;if((!a.operator||a.operator===g)&&d(t,a.semver))return!1;if(a.operator===b&&y(t,a.semver))return!1}return!0}},6486:(t,e,r)=>{const n=r(7229),i=r(7851);t.exports=(t,e,r)=>{const o=[];let s=null,a=null;const c=t.sort(((t,e)=>i(t,e,r)));for(const t of c){n(t,e,r)?(a=t,s||(s=t)):(a&&o.push([s,a]),a=null,s=null)}s&&o.push([s,null]);const u=[];for(const[t,e]of o)t===e?u.push(t):e||t!==c[0]?e?t===c[0]?u.push(`<=${e}`):u.push(`${t} - ${e}`):u.push(`>=${t}`):u.push(\"*\");const f=u.join(\" || \"),h=\"string\"==typeof e.raw?e.raw:String(e);return f.length{const n=r(7476),i=r(1565),{ANY:o}=i,s=r(7229),a=r(7851),c=[new i(\">=0.0.0-0\")],u=[new i(\">=0.0.0\")],f=(t,e,r)=>{if(t===e)return!0;if(1===t.length&&t[0].semver===o){if(1===e.length&&e[0].semver===o)return!0;t=r.includePrerelease?c:u}if(1===e.length&&e[0].semver===o){if(r.includePrerelease)return!0;e=u}const n=new Set;let i,f,p,d,y,g,b;for(const e of t)\">\"===e.operator||\">=\"===e.operator?i=h(i,e,r):\"<\"===e.operator||\"<=\"===e.operator?f=l(f,e,r):n.add(e.semver);if(n.size>1)return null;if(i&&f){if(p=a(i.semver,f.semver,r),p>0)return null;if(0===p&&(\">=\"!==i.operator||\"<=\"!==f.operator))return null}for(const t of n){if(i&&!s(t,String(i),r))return null;if(f&&!s(t,String(f),r))return null;for(const n of e)if(!s(t,String(n),r))return!1;return!0}let w=!(!f||r.includePrerelease||!f.semver.prerelease.length)&&f.semver,m=!(!i||r.includePrerelease||!i.semver.prerelease.length)&&i.semver;w&&1===w.prerelease.length&&\"<\"===f.operator&&0===w.prerelease[0]&&(w=!1);for(const t of e){if(b=b||\">\"===t.operator||\">=\"===t.operator,g=g||\"<\"===t.operator||\"<=\"===t.operator,i)if(m&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===m.major&&t.semver.minor===m.minor&&t.semver.patch===m.patch&&(m=!1),\">\"===t.operator||\">=\"===t.operator){if(d=h(i,t,r),d===t&&d!==i)return!1}else if(\">=\"===i.operator&&!s(i.semver,String(t),r))return!1;if(f)if(w&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===w.major&&t.semver.minor===w.minor&&t.semver.patch===w.patch&&(w=!1),\"<\"===t.operator||\"<=\"===t.operator){if(y=l(f,t,r),y===t&&y!==f)return!1}else if(\"<=\"===f.operator&&!s(f.semver,String(t),r))return!1;if(!t.operator&&(f||i)&&0!==p)return!1}return!(i&&g&&!f&&0!==p)&&(!(f&&b&&!i&&0!==p)&&(!m&&!w))},h=(t,e,r)=>{if(!t)return e;const n=a(t.semver,e.semver,r);return n>0?t:n<0||\">\"===e.operator&&\">=\"===t.operator?e:t},l=(t,e,r)=>{if(!t)return e;const n=a(t.semver,e.semver,r);return n<0?t:n>0||\"<\"===e.operator&&\"<=\"===t.operator?e:t};t.exports=(t,e,r={})=>{if(t===e)return!0;t=new n(t,r),e=new n(e,r);let i=!1;t:for(const n of t.set){for(const t of e.set){const e=f(n,t,r);if(i=i||null!==e,e)continue t}if(i)return!1}return!0}},6364:(t,e,r)=>{const n=r(7476);t.exports=(t,e)=>new n(t,e).set.map((t=>t.map((t=>t.value)).join(\" \").trim().split(\" \")))},7403:(t,e,r)=>{const n=r(7476);t.exports=(t,e)=>{try{return new n(t,e).range||\"*\"}catch(t){return null}}},1229:(t,e,r)=>{var n=r(5636).Buffer;function i(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){\"string\"==typeof t&&(e=e||\"utf8\",t=n.from(t,e));for(var r=this._block,i=this._blockSize,o=t.length,s=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error(\"_update must be implemented by subclass\")},t.exports=i},3229:(t,e,r)=>{var n=t.exports=function(t){t=t.toLowerCase();var e=n[t];if(!e)throw new Error(t+\" is not supported (we accept pull requests)\");return new e};n.sha=r(3675),n.sha1=r(8980),n.sha224=r(947),n.sha256=r(2826),n.sha384=r(9922),n.sha512=r(6080)},3675:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var p=~~(l/20),d=0|((e=n)<<5|e>>>27)+f(p,i,o,a)+c+r[l]+s[p];c=a,a=o,o=u(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=c},8980:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function f(t){return t<<30|t>>>2}function h(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var p=0;p<80;++p){var d=~~(p/20),y=u(n)+h(d,i,o,a)+c+r[p]+s[d]|0;c=a,a=o,o=f(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=c},947:(t,e,r)=>{var n=r(5615),i=r(2826),o=r(1229),s=r(5636).Buffer,a=new Array(64);function c(){this.init(),this._w=a,o.call(this,64,56)}n(c,i),c.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},c.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=c},2826:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=new Array(64);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function h(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function l(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(c,i),c.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,d=0|this._f,y=0|this._g,g=0|this._h,b=0;b<16;++b)r[b]=t.readInt32BE(4*b);for(;b<64;++b)r[b]=0|(((e=r[b-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[b-7]+p(r[b-15])+r[b-16];for(var w=0;w<64;++w){var m=g+l(c)+u(c,d,y)+s[w]+r[w]|0,v=h(n)+f(n,i,o)|0;g=y,y=d,d=c,c=a+m|0,a=o,o=i,i=n,n=m+v|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0,this._f=d+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},c.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=c},9922:(t,e,r)=>{var n=r(5615),i=r(6080),o=r(1229),s=r(5636).Buffer,a=new Array(160);function c(){this.init(),this._w=a,o.call(this,128,112)}n(c,i),c.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},c.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=c},6080:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function c(){this.init(),this._w=a,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function h(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function l(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0>>0?1:0}n(c,i),c.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},c.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,c=0|this._fh,w=0|this._gh,m=0|this._hh,v=0|this._al,E=0|this._bl,_=0|this._cl,S=0|this._dl,A=0|this._el,I=0|this._fl,T=0|this._gl,x=0|this._hl,O=0;O<32;O+=2)e[O]=t.readInt32BE(4*O),e[O+1]=t.readInt32BE(4*O+4);for(;O<160;O+=2){var k=e[O-30],P=e[O-30+1],R=p(k,P),B=d(P,k),C=y(k=e[O-4],P=e[O-4+1]),N=g(P,k),L=e[O-14],U=e[O-14+1],j=e[O-32],M=e[O-32+1],H=B+U|0,F=R+L+b(H,B)|0;F=(F=F+C+b(H=H+N|0,N)|0)+j+b(H=H+M|0,M)|0,e[O]=F,e[O+1]=H}for(var D=0;D<160;D+=2){F=e[D],H=e[D+1];var $=f(r,n,i),K=f(v,E,_),V=h(r,v),G=h(v,r),q=l(a,A),W=l(A,a),X=s[D],z=s[D+1],J=u(a,c,w),Y=u(A,I,T),Z=x+W|0,Q=m+q+b(Z,x)|0;Q=(Q=(Q=Q+J+b(Z=Z+Y|0,Y)|0)+X+b(Z=Z+z|0,z)|0)+F+b(Z=Z+H|0,H)|0;var tt=G+K|0,et=V+$+b(tt,G)|0;m=w,x=T,w=c,T=I,c=a,I=A,a=o+Q+b(A=S+Z|0,S)|0,o=i,S=_,i=n,_=E,n=r,E=v,r=Q+et+b(v=Z+tt|0,Z)|0}this._al=this._al+v|0,this._bl=this._bl+E|0,this._cl=this._cl+_|0,this._dl=this._dl+S|0,this._el=this._el+A|0,this._fl=this._fl+I|0,this._gl=this._gl+T|0,this._hl=this._hl+x|0,this._ah=this._ah+r+b(this._al,v)|0,this._bh=this._bh+n+b(this._bl,E)|0,this._ch=this._ch+i+b(this._cl,_)|0,this._dh=this._dh+o+b(this._dl,S)|0,this._eh=this._eh+a+b(this._el,A)|0,this._fh=this._fh+c+b(this._fl,I)|0,this._gh=this._gh+w+b(this._gl,T)|0,this._hh=this._hh+m+b(this._hl,x)|0},c.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=c},1983:(t,e,r)=>{t.exports=i;var n=r(46).EventEmitter;function i(){n.call(this)}r(5615)(i,n),i.Readable=r(8199),i.Writable=r(5291),i.Duplex=r(1265),i.Transform=r(9415),i.PassThrough=r(4421),i.finished=r(4869),i.pipeline=r(6815),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on(\"data\",i),t.on(\"drain\",o),t._isStdio||e&&!1===e.end||(r.on(\"end\",a),r.on(\"close\",c));var s=!1;function a(){s||(s=!0,t.end())}function c(){s||(s=!0,\"function\"==typeof t.destroy&&t.destroy())}function u(t){if(f(),0===n.listenerCount(this,\"error\"))throw t}function f(){r.removeListener(\"data\",i),t.removeListener(\"drain\",o),r.removeListener(\"end\",a),r.removeListener(\"close\",c),r.removeListener(\"error\",u),t.removeListener(\"error\",u),r.removeListener(\"end\",f),r.removeListener(\"close\",f),t.removeListener(\"close\",f)}return r.on(\"error\",u),t.on(\"error\",u),r.on(\"end\",f),r.on(\"close\",f),t.on(\"close\",f),t.emit(\"pipe\",r),t}},8888:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=n.isEncoding||function(t){switch((t=\"\"+t)&&t.toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":case\"raw\":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return\"utf8\";for(var e;;)switch(t){case\"utf8\":case\"utf-8\":return\"utf8\";case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return\"utf16le\";case\"latin1\":case\"binary\":return\"latin1\";case\"base64\":case\"ascii\":case\"hex\":return t;default:if(e)return;t=(\"\"+t).toLowerCase(),e=!0}}(t);if(\"string\"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error(\"Unknown encoding: \"+t);return e||t}(t),this.encoding){case\"utf16le\":this.text=c,this.end=u,e=4;break;case\"utf8\":this.fillLast=a,e=4;break;case\"base64\":this.text=f,this.end=h,e=3;break;default:return this.write=l,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,\"�\";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,\"�\";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,\"�\"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function c(t,e){if((t.length-e)%2==0){var r=t.toString(\"utf16le\",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString(\"utf16le\",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):\"\";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString(\"utf16le\",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString(\"base64\",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString(\"base64\",e,t.length-r))}function h(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+this.lastChar.toString(\"base64\",0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):\"\"}e.I=o,o.prototype.write=function(t){if(0===t.length)return\"\";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return\"\";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString(\"utf8\",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString(\"utf8\",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},8262:t=>{const e=/^[-+]?0x[a-fA-F0-9]+$/,r=/^([\\-\\+])?(0*)(\\.[0-9]+([eE]\\-?[0-9]+)?|[0-9]+(\\.[0-9]+([eE]\\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const n={hex:!0,leadingZeros:!0,decimalPoint:\".\",eNotation:!0};t.exports=function(t,i={}){if(i=Object.assign({},n,i),!t||\"string\"!=typeof t)return t;let o=t.trim();if(void 0!==i.skipLike&&i.skipLike.test(o))return t;if(i.hex&&e.test(o))return Number.parseInt(o,16);{const e=r.exec(o);if(e){const r=e[1],n=e[2];let s=function(t){if(t&&-1!==t.indexOf(\".\"))return\".\"===(t=t.replace(/0+$/,\"\"))?t=\"0\":\".\"===t[0]?t=\"0\"+t:\".\"===t[t.length-1]&&(t=t.substr(0,t.length-1)),t;return t}(e[3]);const a=e[4]||e[6];if(!i.leadingZeros&&n.length>0&&r&&\".\"!==o[2])return t;if(!i.leadingZeros&&n.length>0&&!r&&\".\"!==o[1])return t;{const e=Number(o),c=\"\"+e;return-1!==c.search(/[eE]/)||a?i.eNotation?e:t:-1!==o.indexOf(\".\")?\"0\"===c&&\"\"===s||c===s||r&&c===\"-\"+s?e:t:n?s===c||r+s===c?e:t:o===c||o===r+c?e:t}}return t}}},4322:(t,e,r)=>{var n=r(2890);function i(t){return t.name||t.toString().match(/function (.*?)\\s*\\(/)[1]}function o(t){return n.Nil(t)?\"\":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?\"Array\":t&&n.Object(t)?\"Object\":void 0!==t?t:\"\"}function c(t,e,r){var i=function(t){return n.Function(t)?\"\":n.String(t)?JSON.stringify(t):t&&n.Object(t)?\"\":t}(e);return\"Expected \"+a(t)+\", got\"+(\"\"!==r?\" \"+r:\"\")+(\"\"!==i?\" \"+i:\"\")}function u(t,e,r){r=r||o(e),this.message=c(t,e,r),s(this,u),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='\" of type ';return\"key\"===e&&(o='\" with key type '),c('property \"'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property \"'+e+'\"',s(this,u),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,f.prototype=Object.create(Error.prototype),f.prototype.constructor=u,t.exports={TfTypeError:u,TfPropertyTypeError:f,tfCustomError:function(t,e){return new u(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+\".\"+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof u&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},315:(t,e,r)=>{var n=r(1048).Buffer,i=r(2890),o=r(4322);function s(t){return n.isBuffer(t)}function a(t){return\"string\"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function c(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+\"(Length: \"+e+\")\",r+\"(Length: \"+n.length+\")\")}return n.toJSON=function(){return r},n}var u=c.bind(null,i.Array),f=c.bind(null,s),h=c.bind(null,a),l=c.bind(null,i.String);var p=Math.pow(2,53)-1;var d={ArrayN:u,Buffer:s,BufferN:f,Finite:function(t){return\"number\"==typeof t&&isFinite(t)},Hex:a,HexN:h,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return\"number\"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n>>0===t},UInt53:function(t){return\"number\"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},973:(t,e,r)=>{var n=r(4322),i=r(2890),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,u=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return l(t,e,n)}catch(t){throw c(t,r)}}))))))}return t=h(t),e=e||{},r.toJSON=function(){var r=\"[\"+o(t)+\"]\";return void 0!==e.length?r+=\"{\"+e.length+\"}\":void 0===e.minLength&&void 0===e.maxLength||(r+=\"{\"+(void 0===e.minLength?0:e.minLength)+\",\"+(void 0===e.maxLength?1/0:e.maxLength)+\"}\"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return\"?\"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw c(t,o,\"key\")}try{var s=r[o];l(t,s,n)}catch(t){throw c(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return\"{\"+o(e)+\": \"+o(t)+\"}\"}:function(){return\"{\"+o(t)+\"}\"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw c(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some((function(t){try{return l(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(\"|\")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every((function(t){try{return l(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(\" & \")},e},quacksLike:function(t){function e(e){return t===u(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every((function(t,n){try{return l(t,e[n],r)}catch(t){throw c(t,n)}}))))}return e.toJSON=function(){return\"(\"+t.map(o).join(\", \")+\")\"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return\"?\"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError(\"Expected compile() parameter of type Array of length 1\");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var p in f.oneOf=f.anyOf,i)l[p]=i[p];for(p in f)l[p]=f[p];var d=r(315);for(p in d)l[p]=d[p];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,t.exports=l},2890:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return\"boolean\"==typeof t},Function:function(t){return\"function\"==typeof t},Nil:function(t){return null==t},Number:function(t){return\"number\"==typeof t},Object:function(t){return\"object\"==typeof t},String:function(t){return\"string\"==typeof t},\"\":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},6732:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&\"true\"===String(e).toLowerCase()}t.exports=function(t,e){if(n(\"noDeprecation\"))return t;var r=!1;return function(){if(!r){if(n(\"throwDeprecation\"))throw new Error(e);n(\"traceDeprecation\")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},4596:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),Object.defineProperty(e,\"NIL\",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(e,\"parse\",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(e,\"stringify\",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(e,\"v1\",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,\"v3\",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,\"v4\",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,\"v5\",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,\"validate\",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,\"version\",{enumerable:!0,get:function(){return c.default}});var n=l(r(4603)),i=l(r(9917)),o=l(r(2712)),s=l(r(3423)),a=l(r(5911)),c=l(r(4072)),u=l(r(4564)),f=l(r(6585)),h=l(r(9975));function l(t){return t&&t.__esModule?t:{default:t}}},2668:(t,e)=>{\"use strict\";function r(t){return 14+(t+64>>>9<<4)+1}function n(t,e){const r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function i(t,e,r,i,o,s){return n((a=n(n(e,t),n(i,s)))<<(c=o)|a>>>32-c,r);var a,c}function o(t,e,r,n,o,s,a){return i(e&r|~e&n,t,e,o,s,a)}function s(t,e,r,n,o,s,a){return i(e&n|r&~n,t,e,o,s,a)}function a(t,e,r,n,o,s,a){return i(e^r^n,t,e,o,s,a)}function c(t,e,r,n,o,s,a){return i(r^(e|~n),t,e,o,s,a)}Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var u=function(t){if(\"string\"==typeof t){const e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(let r=0;r>5]>>>i%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(15&r),16);e.push(o)}return e}(function(t,e){t[e>>5]|=128<>5]|=(255&t[r/8])<{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var r={randomUUID:\"undefined\"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};e.default=r},5911:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;e.default=\"00000000-0000-0000-0000-000000000000\"},9975:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};var o=function(t){if(!(0,i.default)(t))throw TypeError(\"Invalid UUID\");let e;const r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=255&e,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=255&e,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=255&e,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=255&e,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=255&e,r};e.default=o},6635:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;e.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},4089:(t,e)=>{\"use strict\";let r;Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=function(){if(!r&&(r=\"undefined\"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!r))throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");return r(n)};const n=new Uint8Array(16)},4271:(t,e)=>{\"use strict\";function r(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function n(t,e){return t<>>32-e}Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var i=function(t){const e=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520];if(\"string\"==typeof t){const e=unescape(encodeURIComponent(t));t=[];for(let r=0;r>>0;h=f,f=u,u=n(c,30)>>>0,c=s,s=a}i[0]=i[0]+s>>>0,i[1]=i[1]+c>>>0,i[2]=i[2]+u>>>0,i[3]=i[3]+f>>>0,i[4]=i[4]+h>>>0}return[i[0]>>24&255,i[0]>>16&255,i[0]>>8&255,255&i[0],i[1]>>24&255,i[1]>>16&255,i[1]>>8&255,255&i[1],i[2]>>24&255,i[2]>>16&255,i[2]>>8&255,255&i[2],i[3]>>24&255,i[3]>>16&255,i[3]>>8&255,255&i[3],i[4]>>24&255,i[4]>>16&255,i[4]>>8&255,255&i[4]]};e.default=i},6585:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0,e.unsafeStringify=s;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};const o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));function s(t,e=0){return o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+\"-\"+o[t[e+4]]+o[t[e+5]]+\"-\"+o[t[e+6]]+o[t[e+7]]+\"-\"+o[t[e+8]]+o[t[e+9]]+\"-\"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]}var a=function(t,e=0){const r=s(t,e);if(!(0,i.default)(r))throw TypeError(\"Stringified UUID is invalid\");return r};e.default=a},4603:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4089))&&n.__esModule?n:{default:n},o=r(6585);let s,a,c=0,u=0;var f=function(t,e,r){let n=e&&r||0;const f=e||new Array(16);let h=(t=t||{}).node||s,l=void 0!==t.clockseq?t.clockseq:a;if(null==h||null==l){const e=t.random||(t.rng||i.default)();null==h&&(h=s=[1|e[0],e[1],e[2],e[3],e[4],e[5]]),null==l&&(l=a=16383&(e[6]<<8|e[7]))}let p=void 0!==t.msecs?t.msecs:Date.now(),d=void 0!==t.nsecs?t.nsecs:u+1;const y=p-c+(d-u)/1e4;if(y<0&&void 0===t.clockseq&&(l=l+1&16383),(y<0||p>c)&&void 0===t.nsecs&&(d=0),d>=1e4)throw new Error(\"uuid.v1(): Can't create more than 10M uuids/sec\");c=p,u=d,a=l,p+=122192928e5;const g=(1e4*(268435455&p)+d)%4294967296;f[n++]=g>>>24&255,f[n++]=g>>>16&255,f[n++]=g>>>8&255,f[n++]=255&g;const b=p/4294967296*1e4&268435455;f[n++]=b>>>8&255,f[n++]=255&b,f[n++]=b>>>24&15|16,f[n++]=b>>>16&255,f[n++]=l>>>8|128,f[n++]=255&l;for(let t=0;t<6;++t)f[n+t]=h[t];return e||(0,o.unsafeStringify)(f)};e.default=f},9917:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=o(r(4782)),i=o(r(2668));function o(t){return t&&t.__esModule?t:{default:t}}var s=(0,n.default)(\"v3\",48,i.default);e.default=s},4782:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.URL=e.DNS=void 0,e.default=function(t,e,r){function n(t,n,s,a){var c;if(\"string\"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));const e=[];for(let r=0;r{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=s(r(193)),i=s(r(4089)),o=r(6585);function s(t){return t&&t.__esModule?t:{default:t}}var a=function(t,e,r){if(n.default.randomUUID&&!e&&!t)return n.default.randomUUID();const s=(t=t||{}).random||(t.rng||i.default)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e){r=r||0;for(let t=0;t<16;++t)e[r+t]=s[t];return e}return(0,o.unsafeStringify)(s)};e.default=a},3423:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=o(r(4782)),i=o(r(4271));function o(t){return t&&t.__esModule?t:{default:t}}var s=(0,n.default)(\"v5\",80,i.default);e.default=s},4564:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(6635))&&n.__esModule?n:{default:n};var o=function(t){return\"string\"==typeof t&&i.default.test(t)};e.default=o},4072:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};var o=function(t){if(!(0,i.default)(t))throw TypeError(\"Invalid UUID\");return parseInt(t.slice(14,15),16)};e.default=o},7820:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError(\"value out of range\")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError(\"buffer must be a Buffer instance\");return i||(i=0),e<253?(r.writeUInt8(e,i),t.bytes=1):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),t.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),t.bytes=9),r},decode:function t(e,r){if(!n.isBuffer(e))throw new TypeError(\"buffer must be a Buffer instance\");r||(r=0);var i=e.readUInt8(r);if(i<253)return t.bytes=1,i;if(253===i)return t.bytes=3,e.readUInt16LE(r+1);if(254===i)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var s=e.readUInt32LE(r+1),a=4294967296*e.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},6952:(t,e,r)=>{var n=r(1048).Buffer,i=r(9848);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error(\"Invalid network version\");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error(\"Invalid WIF length\");if(1!==t[33])throw new Error(\"Invalid compression flag\");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function s(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return\"number\"==typeof t?i.encode(s(t,e,r)):i.encode(s(t.version,t.privateKey,t.compressed))},encodeRaw:s}},7047:t=>{\"use strict\";t.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},222:(t,e,r)=>{\"use strict\";function n(t){var e=this;if(e instanceof n||(e=new n),e.tail=null,e.head=null,e.length=0,t&&\"function\"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,i=arguments.length;r1)r=e;else{if(!this.head)throw new TypeError(\"Reduce of empty list with no initial value\");n=this.head.next,r=this.head.value}for(var i=0;null!==n;i++)r=t(r,n.value,i),n=n.next;return r},n.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError(\"Reduce of empty list with no initial value\");n=this.tail.prev,r=this.tail.value}for(var i=this.length-1;null!==n;i--)r=t(r,n.value,i),n=n.prev;return r},n.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},n.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},n.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new n;if(ethis.length&&(e=this.length);for(var i=0,o=this.head;null!==o&&ithis.length&&(e=this.length);for(var i=this.length,o=this.tail;null!==o&&i>e;i--)o=o.prev;for(;null!==o&&i>t;i--,o=o.prev)r.push(o.value);return r},n.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var n=0,o=this.head;null!==o&&n{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.JsonRpcRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(4520);e.JsonRpcRequestStruct=(0,o.object)({jsonrpc:(0,i.literal)(\"2.0\"),id:(0,i.union)([(0,i.string)(),(0,i.number)(),(0,i.literal)(null)]),method:(0,i.string)(),params:(0,o.exactOptional)((0,i.union)([(0,i.array)(n.JsonStruct),(0,i.record)((0,i.string)(),n.JsonStruct)]))})},1236:function(t,e,r){\"use strict\";var n,i,o,s=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if(\"m\"===n)throw new TypeError(\"Private method is not writable\");if(\"a\"===n&&!i)throw new TypeError(\"Private accessor was defined without a setter\");if(\"function\"==typeof e?t!==e||!i:!e.has(t))throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");return\"a\"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},a=this&&this.__classPrivateFieldGet||function(t,e,r,n){if(\"a\"===r&&!n)throw new TypeError(\"Private accessor was defined without a getter\");if(\"function\"==typeof e?t!==e||!n:!e.has(t))throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");return\"m\"===r?n:\"a\"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringClient=void 0;const c=r(7251),u=r(4596),f=r(2582),h=r(1925),l=r(4520);e.KeyringClient=class{constructor(t){n.add(this),i.set(this,void 0),s(this,i,t,\"f\")}async listAccounts(){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ListAccounts}),f.ListAccountsResponseStruct)}async getAccount(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetAccount,params:{id:t}}),f.GetAccountResponseStruct)}async getAccountBalances(t,e){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetAccountBalances,params:{id:t,assets:e}}),f.GetAccountBalancesResponseStruct)}async createAccount(t={}){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.CreateAccount,params:{options:t}}),f.CreateAccountResponseStruct)}async filterAccountChains(t,e){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.FilterAccountChains,params:{id:t,chains:e}}),f.FilterAccountChainsResponseStruct)}async updateAccount(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.UpdateAccount,params:{account:t}}),f.UpdateAccountResponseStruct)}async deleteAccount(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.DeleteAccount,params:{id:t}}),f.DeleteAccountResponseStruct)}async exportAccount(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ExportAccount,params:{id:t}}),f.ExportAccountResponseStruct)}async listRequests(){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ListRequests}),f.ListRequestsResponseStruct)}async getRequest(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetRequest,params:{id:t}}),f.GetRequestResponseStruct)}async submitRequest(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.SubmitRequest,params:t}),f.SubmitRequestResponseStruct)}async approveRequest(t,e={}){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ApproveRequest,params:{id:t,data:e}}),f.ApproveRequestResponseStruct)}async rejectRequest(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.RejectRequest,params:{id:t}}),f.RejectRequestResponseStruct)}},i=new WeakMap,n=new WeakSet,o=async function(t){return a(this,i,\"f\").send({jsonrpc:\"2.0\",id:(0,u.v4)(),...t})}},4071:function(t,e,r){\"use strict\";var n,i,o=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if(\"m\"===n)throw new TypeError(\"Private method is not writable\");if(\"a\"===n&&!i)throw new TypeError(\"Private accessor was defined without a setter\");if(\"function\"==typeof e?t!==e||!i:!e.has(t))throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");return\"a\"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},s=this&&this.__classPrivateFieldGet||function(t,e,r,n){if(\"a\"===r&&!n)throw new TypeError(\"Private accessor was defined without a getter\");if(\"function\"==typeof e?t!==e||!n:!e.has(t))throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");return\"m\"===r?n:\"a\"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringSnapRpcClient=e.SnapRpcSender=void 0;const a=r(1236);class c{constructor(t,e){n.set(this,void 0),i.set(this,void 0),o(this,n,t,\"f\"),o(this,i,e,\"f\")}async send(t){return s(this,i,\"f\").request({method:\"wallet_invokeKeyring\",params:{snapId:s(this,n,\"f\"),request:t}})}}e.SnapRpcSender=c,n=new WeakMap,i=new WeakMap;class u extends a.KeyringClient{constructor(t,e){super(new c(t,e))}}e.KeyringSnapRpcClient=u},1950:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringAccountStruct=e.BtcAccountType=e.EthAccountType=void 0;const n=r(2049),i=r(7251),o=r(4520),s=r(6580);var a,c;!function(t){t.Eoa=\"eip155:eoa\",t.Erc4337=\"eip155:erc4337\"}(a=e.EthAccountType||(e.EthAccountType={})),function(t){t.P2wpkh=\"bip122:p2wpkh\"}(c=e.BtcAccountType||(e.BtcAccountType={})),e.KeyringAccountStruct=(0,o.object)({id:s.UuidStruct,type:(0,i.enums)([`${a.Eoa}`,`${a.Erc4337}`,`${c.P2wpkh}`]),address:(0,i.string)(),options:(0,i.record)((0,i.string)(),n.JsonStruct),methods:(0,i.array)((0,i.string)())})},3433:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.BalanceStruct=void 0;const n=r(7251),i=r(4520),o=r(6580);e.BalanceStruct=(0,i.object)({amount:o.StringNumberStruct,unit:(0,n.string)()})},8588:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.isCaipAssetId=e.isCaipAssetType=e.CaipAssetIdStruct=e.CaipAssetTypeStruct=void 0;const n=r(7251),i=r(4520);e.CaipAssetTypeStruct=(0,i.definePattern)(\"CaipAssetType\",/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})$/u),e.CaipAssetIdStruct=(0,i.definePattern)(\"CaipAssetId\",/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})\\/(?[-.%a-zA-Z0-9]{1,78})$/u),e.isCaipAssetType=function(t){return(0,n.is)(t,e.CaipAssetTypeStruct)},e.isCaipAssetId=function(t){return(0,n.is)(t,e.CaipAssetIdStruct)}},4015:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringAccountDataStruct=void 0;const n=r(2049),i=r(7251);e.KeyringAccountDataStruct=(0,i.record)((0,i.string)(),n.JsonStruct)},5417:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(1950),e),i(r(3433),e),i(r(8588),e),i(r(4015),e),i(r(5444),e),i(r(7884),e),i(r(6142),e)},5444:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},7884:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(4520),s=r(6580);e.KeyringRequestStruct=(0,o.object)({id:s.UuidStruct,scope:(0,i.string)(),account:s.UuidStruct,request:(0,o.object)({method:(0,i.string)(),params:(0,o.exactOptional)((0,i.union)([(0,i.array)(n.JsonStruct),(0,i.record)((0,i.string)(),n.JsonStruct)]))})})},6142:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringResponseStruct=void 0;const n=r(2049),i=r(7251),o=r(4520);e.KeyringResponseStruct=(0,i.union)([(0,o.object)({pending:(0,i.literal)(!0),redirect:(0,o.exactOptional)((0,o.object)({message:(0,o.exactOptional)((0,i.string)()),url:(0,o.exactOptional)((0,i.string)())}))}),(0,o.object)({pending:(0,i.literal)(!1),result:n.JsonStruct})])},5238:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(5787),e)},5787:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.BtcP2wpkhAccountStruct=e.BtcMethod=e.BtcP2wpkhAddressStruct=void 0;const n=r(6586),i=r(7251),o=r(5417),s=r(4520);var a;e.BtcP2wpkhAddressStruct=(0,i.refine)((0,i.string)(),\"BtcP2wpkhAddressStruct\",(t=>{try{n.bech32.decode(t)}catch(t){return new Error(`Could not decode P2WPKH address: ${t.message}`)}return!0})),function(t){t.SendMany=\"btc_sendmany\"}(a=e.BtcMethod||(e.BtcMethod={})),e.BtcP2wpkhAccountStruct=(0,s.object)({...o.KeyringAccountStruct.schema,address:e.BtcP2wpkhAddressStruct,type:(0,i.literal)(`${o.BtcAccountType.P2wpkh}`),methods:(0,i.array)((0,i.enums)([`${a.SendMany}`]))})},1360:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},322:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(4943),e)},4943:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.EthUserOperationPatchStruct=e.EthBaseUserOperationStruct=e.EthBaseTransactionStruct=e.EthUserOperationStruct=void 0;const n=r(4520),i=r(6580),o=r(6879);e.EthUserOperationStruct=(0,n.object)({sender:o.EthAddressStruct,nonce:o.EthUint256Struct,initCode:o.EthBytesStruct,callData:o.EthBytesStruct,callGasLimit:o.EthUint256Struct,verificationGasLimit:o.EthUint256Struct,preVerificationGas:o.EthUint256Struct,maxFeePerGas:o.EthUint256Struct,maxPriorityFeePerGas:o.EthUint256Struct,paymasterAndData:o.EthBytesStruct,signature:o.EthBytesStruct}),e.EthBaseTransactionStruct=(0,n.object)({to:o.EthAddressStruct,value:o.EthUint256Struct,data:o.EthBytesStruct}),e.EthBaseUserOperationStruct=(0,n.object)({nonce:o.EthUint256Struct,initCode:o.EthBytesStruct,callData:o.EthBytesStruct,gasLimits:(0,n.exactOptional)((0,n.object)({callGasLimit:o.EthUint256Struct,verificationGasLimit:o.EthUint256Struct,preVerificationGas:o.EthUint256Struct})),dummyPaymasterAndData:o.EthBytesStruct,dummySignature:o.EthBytesStruct,bundlerUrl:i.UrlStruct}),e.EthUserOperationPatchStruct=(0,n.object)({paymasterAndData:o.EthBytesStruct,callGasLimit:(0,n.exactOptional)(o.EthUint256Struct),verificationGasLimit:(0,n.exactOptional)(o.EthUint256Struct),preVerificationGas:(0,n.exactOptional)(o.EthUint256Struct)})},6034:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(322),e),i(r(6879),e),i(r(1267),e)},6879:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.EthErc4337AccountStruct=e.EthEoaAccountStruct=e.EthMethod=e.EthUint256Struct=e.EthAddressStruct=e.EthBytesStruct=void 0;const n=r(7251),i=r(5417),o=r(4520);var s;e.EthBytesStruct=(0,o.definePattern)(\"EthBytes\",/^0x[0-9a-f]*$/iu),e.EthAddressStruct=(0,o.definePattern)(\"EthAddress\",/^0x[0-9a-f]{40}$/iu),e.EthUint256Struct=(0,o.definePattern)(\"EthUint256\",/^0x([1-9a-f][0-9a-f]*|0)$/iu),function(t){t.PersonalSign=\"personal_sign\",t.Sign=\"eth_sign\",t.SignTransaction=\"eth_signTransaction\",t.SignTypedDataV1=\"eth_signTypedData_v1\",t.SignTypedDataV3=\"eth_signTypedData_v3\",t.SignTypedDataV4=\"eth_signTypedData_v4\",t.PrepareUserOperation=\"eth_prepareUserOperation\",t.PatchUserOperation=\"eth_patchUserOperation\",t.SignUserOperation=\"eth_signUserOperation\"}(s=e.EthMethod||(e.EthMethod={})),e.EthEoaAccountStruct=(0,o.object)({...i.KeyringAccountStruct.schema,address:e.EthAddressStruct,type:(0,n.literal)(`${i.EthAccountType.Eoa}`),methods:(0,n.array)((0,n.enums)([`${s.PersonalSign}`,`${s.Sign}`,`${s.SignTransaction}`,`${s.SignTypedDataV1}`,`${s.SignTypedDataV3}`,`${s.SignTypedDataV4}`]))}),e.EthErc4337AccountStruct=(0,o.object)({...i.KeyringAccountStruct.schema,address:e.EthAddressStruct,type:(0,n.literal)(`${i.EthAccountType.Erc4337}`),methods:(0,n.array)((0,n.enums)([`${s.PersonalSign}`,`${s.Sign}`,`${s.SignTypedDataV1}`,`${s.SignTypedDataV3}`,`${s.SignTypedDataV4}`,`${s.PrepareUserOperation}`,`${s.PatchUserOperation}`,`${s.SignUserOperation}`]))})},1267:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.isEvmAccountType=void 0;const n=r(5417);e.isEvmAccountType=function(t){return t===n.EthAccountType.Eoa||t===n.EthAccountType.Erc4337}},4433:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringEvent=void 0,function(t){t.AccountCreated=\"notify:accountCreated\",t.AccountUpdated=\"notify:accountUpdated\",t.AccountDeleted=\"notify:accountDeleted\",t.RequestApproved=\"notify:requestApproved\",t.RequestRejected=\"notify:requestRejected\"}(e.KeyringEvent||(e.KeyringEvent={}))},7962:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(5417),e),i(r(5238),e),i(r(1360),e),i(r(6034),e),i(r(4433),e),i(r(7470),e),i(r(1236),e),i(r(4071),e),i(r(3060),e),i(r(5524),e),i(r(4520),e)},2582:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.RejectRequestResponseStruct=e.RejectRequestRequestStruct=e.ApproveRequestResponseStruct=e.ApproveRequestRequestStruct=e.SubmitRequestResponseStruct=e.SubmitRequestRequestStruct=e.GetRequestResponseStruct=e.GetRequestRequestStruct=e.ListRequestsResponseStruct=e.ListRequestsRequestStruct=e.ExportAccountResponseStruct=e.ExportAccountRequestStruct=e.DeleteAccountResponseStruct=e.DeleteAccountRequestStruct=e.UpdateAccountResponseStruct=e.UpdateAccountRequestStruct=e.FilterAccountChainsResponseStruct=e.FilterAccountChainsStruct=e.GetAccountBalancesResponseStruct=e.GetAccountBalancesRequestStruct=e.CreateAccountResponseStruct=e.CreateAccountRequestStruct=e.GetAccountResponseStruct=e.GetAccountRequestStruct=e.ListAccountsResponseStruct=e.ListAccountsRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(5417),s=r(4520),a=r(6580),c=r(1925),u={jsonrpc:(0,i.literal)(\"2.0\"),id:(0,i.union)([(0,i.string)(),(0,i.number)(),(0,i.literal)(null)])};e.ListAccountsRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_listAccounts\")}),e.ListAccountsResponseStruct=(0,i.array)(o.KeyringAccountStruct),e.GetAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_getAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.GetAccountResponseStruct=o.KeyringAccountStruct,e.CreateAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_createAccount\"),params:(0,s.object)({options:(0,i.record)((0,i.string)(),n.JsonStruct)})}),e.CreateAccountResponseStruct=o.KeyringAccountStruct,e.GetAccountBalancesRequestStruct=(0,s.object)({...u,method:(0,i.literal)(`${c.KeyringRpcMethod.GetAccountBalances}`),params:(0,s.object)({id:a.UuidStruct,assets:(0,i.array)(o.CaipAssetTypeStruct)})}),e.GetAccountBalancesResponseStruct=(0,i.record)(o.CaipAssetTypeStruct,o.BalanceStruct),e.FilterAccountChainsStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_filterAccountChains\"),params:(0,s.object)({id:a.UuidStruct,chains:(0,i.array)((0,i.string)())})}),e.FilterAccountChainsResponseStruct=(0,i.array)((0,i.string)()),e.UpdateAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_updateAccount\"),params:(0,s.object)({account:o.KeyringAccountStruct})}),e.UpdateAccountResponseStruct=(0,i.literal)(null),e.DeleteAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_deleteAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.DeleteAccountResponseStruct=(0,i.literal)(null),e.ExportAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_exportAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.ExportAccountResponseStruct=o.KeyringAccountDataStruct,e.ListRequestsRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_listRequests\")}),e.ListRequestsResponseStruct=(0,i.array)(o.KeyringRequestStruct),e.GetRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_getRequest\"),params:(0,s.object)({id:a.UuidStruct})}),e.GetRequestResponseStruct=o.KeyringRequestStruct,e.SubmitRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_submitRequest\"),params:o.KeyringRequestStruct}),e.SubmitRequestResponseStruct=o.KeyringResponseStruct,e.ApproveRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_approveRequest\"),params:(0,s.object)({id:a.UuidStruct,data:(0,i.record)((0,i.string)(),n.JsonStruct)})}),e.ApproveRequestResponseStruct=(0,i.literal)(null),e.RejectRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_rejectRequest\"),params:(0,s.object)({id:a.UuidStruct})}),e.RejectRequestResponseStruct=(0,i.literal)(null)},6796:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},7841:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(6796),e)},3005:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.RequestRejectedEventStruct=e.RequestApprovedEventStruct=e.AccountDeletedEventStruct=e.AccountUpdatedEventStruct=e.AccountCreatedEventStruct=void 0;const n=r(2049),i=r(7251),o=r(5417),s=r(4433),a=r(4520),c=r(6580);e.AccountCreatedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountCreated}`),params:(0,a.object)({account:o.KeyringAccountStruct,accountNameSuggestion:(0,a.exactOptional)((0,i.string)()),displayConfirmation:(0,a.exactOptional)((0,i.boolean)())})}),e.AccountUpdatedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountUpdated}`),params:(0,a.object)({account:o.KeyringAccountStruct})}),e.AccountDeletedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountDeleted}`),params:(0,a.object)({id:c.UuidStruct})}),e.RequestApprovedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.RequestApproved}`),params:(0,a.object)({id:c.UuidStruct,result:n.JsonStruct})}),e.RequestRejectedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.RequestRejected}`),params:(0,a.object)({id:c.UuidStruct})})},7470:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(2582),e),i(r(7841),e),i(r(3005),e),i(r(1925),e),i(r(3699),e)},1925:(t,e)=>{\"use strict\";var r;Object.defineProperty(e,\"__esModule\",{value:!0}),e.isKeyringRpcMethod=e.KeyringRpcMethod=void 0,function(t){t.ListAccounts=\"keyring_listAccounts\",t.GetAccount=\"keyring_getAccount\",t.CreateAccount=\"keyring_createAccount\",t.GetAccountBalances=\"keyring_getAccountBalances\",t.FilterAccountChains=\"keyring_filterAccountChains\",t.UpdateAccount=\"keyring_updateAccount\",t.DeleteAccount=\"keyring_deleteAccount\",t.ExportAccount=\"keyring_exportAccount\",t.ListRequests=\"keyring_listRequests\",t.GetRequest=\"keyring_getRequest\",t.SubmitRequest=\"keyring_submitRequest\",t.ApproveRequest=\"keyring_approveRequest\",t.RejectRequest=\"keyring_rejectRequest\"}(r=e.KeyringRpcMethod||(e.KeyringRpcMethod={})),e.isKeyringRpcMethod=function(t){return Object.values(r).includes(t)}},3699:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.InternalAccountStruct=e.InternalAccountStructs=e.InternalBtcP2wpkhAccountStruct=e.InternalEthErc4337AccountStruct=e.InternalEthEoaAccountStruct=e.InternalAccountMetadataStruct=void 0;const n=r(7251),i=r(5417),o=r(5787),s=r(6879),a=r(4520);function c(t){return(0,a.object)({...t.schema,...e.InternalAccountMetadataStruct.schema})}e.InternalAccountMetadataStruct=(0,a.object)({metadata:(0,a.object)({name:(0,n.string)(),snap:(0,a.exactOptional)((0,a.object)({id:(0,n.string)(),enabled:(0,n.boolean)(),name:(0,n.string)()})),lastSelected:(0,a.exactOptional)((0,n.number)()),importTime:(0,n.number)(),keyring:(0,a.object)({type:(0,n.string)()})})}),e.InternalEthEoaAccountStruct=c(s.EthEoaAccountStruct),e.InternalEthErc4337AccountStruct=c(s.EthErc4337AccountStruct),e.InternalBtcP2wpkhAccountStruct=c(o.BtcP2wpkhAccountStruct),e.InternalAccountStructs={[`${i.EthAccountType.Eoa}`]:e.InternalEthEoaAccountStruct,[`${i.EthAccountType.Erc4337}`]:e.InternalEthErc4337AccountStruct,[`${i.BtcAccountType.P2wpkh}`]:e.InternalBtcP2wpkhAccountStruct},e.InternalAccountStruct=(0,a.object)({...i.KeyringAccountStruct.schema,...e.InternalAccountMetadataStruct.schema})},3060:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.handleKeyringRequest=e.MethodNotSupportedError=void 0;const n=r(7251),i=r(2582),o=r(1925),s=r(5978);class a extends Error{constructor(t){super(`Method not supported: ${t}`)}}e.MethodNotSupportedError=a,e.handleKeyringRequest=async function(t,e){try{return await async function(t,e){switch((0,n.assert)(e,s.JsonRpcRequestStruct),e.method){case o.KeyringRpcMethod.ListAccounts:return(0,n.assert)(e,i.ListAccountsRequestStruct),t.listAccounts();case o.KeyringRpcMethod.GetAccount:return(0,n.assert)(e,i.GetAccountRequestStruct),t.getAccount(e.params.id);case o.KeyringRpcMethod.CreateAccount:return(0,n.assert)(e,i.CreateAccountRequestStruct),t.createAccount(e.params.options);case o.KeyringRpcMethod.GetAccountBalances:if(void 0===t.getAccountBalances)throw new a(e.method);return(0,n.assert)(e,i.GetAccountBalancesRequestStruct),t.getAccountBalances(e.params.id,e.params.assets);case o.KeyringRpcMethod.FilterAccountChains:return(0,n.assert)(e,i.FilterAccountChainsStruct),t.filterAccountChains(e.params.id,e.params.chains);case o.KeyringRpcMethod.UpdateAccount:return(0,n.assert)(e,i.UpdateAccountRequestStruct),t.updateAccount(e.params.account);case o.KeyringRpcMethod.DeleteAccount:return(0,n.assert)(e,i.DeleteAccountRequestStruct),t.deleteAccount(e.params.id);case o.KeyringRpcMethod.ExportAccount:if(void 0===t.exportAccount)throw new a(e.method);return(0,n.assert)(e,i.ExportAccountRequestStruct),t.exportAccount(e.params.id);case o.KeyringRpcMethod.ListRequests:if(void 0===t.listRequests)throw new a(e.method);return(0,n.assert)(e,i.ListRequestsRequestStruct),t.listRequests();case o.KeyringRpcMethod.GetRequest:if(void 0===t.getRequest)throw new a(e.method);return(0,n.assert)(e,i.GetRequestRequestStruct),t.getRequest(e.params.id);case o.KeyringRpcMethod.SubmitRequest:return(0,n.assert)(e,i.SubmitRequestRequestStruct),t.submitRequest(e.params);case o.KeyringRpcMethod.ApproveRequest:if(void 0===t.approveRequest)throw new a(e.method);return(0,n.assert)(e,i.ApproveRequestRequestStruct),t.approveRequest(e.params.id,e.params.data);case o.KeyringRpcMethod.RejectRequest:if(void 0===t.rejectRequest)throw new a(e.method);return(0,n.assert)(e,i.RejectRequestRequestStruct),t.rejectRequest(e.params.id);default:throw new a(e.method)}}(t,e)}catch(t){const e=t instanceof Error&&\"string\"==typeof t.message?t.message:\"An unknown error occurred while handling the keyring request\";throw new Error(e)}}},5524:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.emitSnapKeyringEvent=void 0,e.emitSnapKeyringEvent=async function(t,e,r){await t.request({method:\"snap_manageAccounts\",params:{method:e,params:{...r}}})}},4520:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.strictMask=e.definePattern=e.exactOptional=e.object=void 0;const n=r(7251);function i(t){return t.path[t.path.length-1]in t.branch[t.branch.length-2]}e.object=function(t){return(0,n.object)(t)},e.exactOptional=function(t){return new n.Struct({...t,validator:(e,r)=>!i(r)||t.validator(e,r),refiner:(e,r)=>!i(r)||t.refiner(e,r)})},e.definePattern=function(t,e){return(0,n.define)(t,(t=>\"string\"==typeof t&&e.test(t)))},e.strictMask=function(t,e,r){return(0,n.assert)(t,e,r),t}},6580:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(8401),e),i(r(7765),e)},8401:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.StringNumberStruct=e.UrlStruct=e.UuidStruct=void 0;const n=r(7251),i=r(4520);e.UuidStruct=(0,i.definePattern)(\"UuidV4\",/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu),e.UrlStruct=(0,n.define)(\"Url\",(t=>{try{const e=new URL(t);return\"http:\"===e.protocol||\"https:\"===e.protocol}catch(t){return!1}})),e.StringNumberStruct=(0,i.definePattern)(\"StringNumber\",/^\\d+(\\.\\d+)?$/u)},7765:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.expectTrue=void 0,e.expectTrue=function(){}},1275:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n,i=r(124),o=((n=i)&&n.__esModule?n:{default:n}).default.call(void 0,\"metamask\");e.createProjectLogger=function(t){return o.extend(t)},e.createModuleLogger=function(t,e){return t.extend(e)}},5244:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r=(t,e,r)=>{if(!e.has(t))throw TypeError(\"Cannot \"+r)};e.__privateGet=(t,e,n)=>(r(t,e,\"read from private field\"),n?n.call(t):e.get(t)),e.__privateAdd=(t,e,r)=>{if(e.has(t))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(t):e.set(t,r)},e.__privateSet=(t,e,n,i)=>(r(t,e,\"write to private field\"),i?i.call(t,n):e.set(t,n),n)},3631:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(932),i=r(2722),o=r(7251),s=o.refine.call(void 0,o.string.call(void 0),\"Version\",(t=>null!==i.valid.call(void 0,t)||`Expected SemVer version, got \"${t}\"`)),a=o.refine.call(void 0,o.string.call(void 0),\"Version range\",(t=>null!==i.validRange.call(void 0,t)||`Expected SemVer range, got \"${t}\"`));e.VersionStruct=s,e.VersionRangeStruct=a,e.isValidSemVerVersion=function(t){return o.is.call(void 0,t,s)},e.isValidSemVerRange=function(t){return o.is.call(void 0,t,a)},e.assertIsSemVerVersion=function(t){n.assertStruct.call(void 0,t,s)},e.assertIsSemVerRange=function(t){n.assertStruct.call(void 0,t,a)},e.gtVersion=function(t,e){return i.gt.call(void 0,t,e)},e.gtRange=function(t,e){return i.gtr.call(void 0,t,e)},e.satisfiesVersionRange=function(t,e){return i.satisfies.call(void 0,t,e,{includePrerelease:!0})}},9116:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r,n=((r=n||{})[r.Millisecond=1]=\"Millisecond\",r[r.Second=1e3]=\"Second\",r[r.Minute=6e4]=\"Minute\",r[r.Hour=36e5]=\"Hour\",r[r.Day=864e5]=\"Day\",r[r.Week=6048e5]=\"Week\",r[r.Year=31536e6]=\"Year\",r),i=(t,e)=>{if(!(t=>Number.isInteger(t)&&t>=0)(t))throw new Error(`\"${e}\" must be a non-negative integer. Received: \"${t}\".`)};e.Duration=n,e.inMilliseconds=function(t,e){return i(t,\"count\"),t*e},e.timeSince=function(t){return i(t,\"timestamp\"),Date.now()-t}},7982:()=>{},1848:(t,e,r)=>{\"use strict\";function n(t,e){return null!=t?t:e()}Object.defineProperty(e,\"__esModule\",{value:!0});var i=r(932),o=r(7251);e.base64=(t,e={})=>{const r=n(e.paddingRequired,(()=>!1)),s=n(e.characterSet,(()=>\"base64\"));let a,c;return\"base64\"===s?a=String.raw`[A-Za-z0-9+\\/]`:(i.assert.call(void 0,\"base64url\"===s),a=String.raw`[-_A-Za-z0-9]`),c=r?new RegExp(`^(?:${a}{4})*(?:${a}{3}=|${a}{2}==)?$`,\"u\"):new RegExp(`^(?:${a}{4})*(?:${a}{2,3}|${a}{3}=|${a}{2}==)?$`,\"u\"),o.pattern.call(void 0,t,c)}},932:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(1486),i=r(7251);function o(t,e){return Boolean(\"string\"==typeof function(t){let e,r=t[0],n=1;for(;nr.call(e,...t))),e=void 0)}return r}([t,\"optionalAccess\",t=>t.prototype,\"optionalAccess\",t=>t.constructor,\"optionalAccess\",t=>t.name]))?new t({message:e}):t({message:e})}var s=class extends Error{constructor(t){super(t.message),this.code=\"ERR_ASSERTION\"}};e.AssertionError=s,e.assert=function(t,e=\"Assertion failed.\",r=s){if(!t){if(e instanceof Error)throw e;throw o(r,e)}},e.assertStruct=function(t,e,r=\"Assertion failed\",a=s){try{i.assert.call(void 0,t,e)}catch(t){throw o(a,`${r}: ${function(t){return n.getErrorMessage.call(void 0,t).replace(/\\.$/u,\"\")}(t)}.`)}},e.assertExhaustive=function(t){throw new Error(\"Invalid branch reached. Should be detected during compilation.\")}},9705:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.createDeferredPromise=function({suppressUnhandledRejection:t=!1}={}){let e,r;const n=new Promise(((t,n)=>{e=t,r=n}));return t&&n.catch((t=>{})),{promise:n,resolve:e,reject:r}}},1203:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(5363),i=r(932),o=r(7251),s=o.union.call(void 0,[o.number.call(void 0),o.bigint.call(void 0),o.string.call(void 0),n.StrictHexStruct]),a=o.coerce.call(void 0,o.number.call(void 0),s,Number),c=o.coerce.call(void 0,o.bigint.call(void 0),s,BigInt),u=(o.union.call(void 0,[n.StrictHexStruct,o.instance.call(void 0,Uint8Array)]),o.coerce.call(void 0,o.instance.call(void 0,Uint8Array),o.union.call(void 0,[n.StrictHexStruct]),n.hexToBytes)),f=o.coerce.call(void 0,n.StrictHexStruct,o.instance.call(void 0,Uint8Array),n.bytesToHex);e.createNumber=function(t){try{const e=o.create.call(void 0,t,a);return i.assert.call(void 0,Number.isFinite(e),`Expected a number-like value, got \"${t}\".`),e}catch(e){if(e instanceof o.StructError)throw new Error(`Expected a number-like value, got \"${t}\".`);throw e}},e.createBigInt=function(t){try{return o.create.call(void 0,t,c)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a number-like value, got \"${String(t.value)}\".`);throw t}},e.createBytes=function(t){if(\"string\"==typeof t&&\"0x\"===t.toLowerCase())return new Uint8Array;try{return o.create.call(void 0,t,u)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a bytes-like value, got \"${String(t.value)}\".`);throw t}},e.createHex=function(t){if(t instanceof Uint8Array&&0===t.length||\"string\"==typeof t&&\"0x\"===t.toLowerCase())return\"0x\";try{return o.create.call(void 0,t,f)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a bytes-like value, got \"${String(t.value)}\".`);throw t}}},1508:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(1848),i=r(7251),o=i.size.call(void 0,n.base64.call(void 0,i.string.call(void 0),{paddingRequired:!0}),44,44);e.ChecksumStruct=o},1423:()=>{},1486:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(6526),i=r(9756);function o(t){return\"object\"==typeof t&&null!==t&&\"code\"in t}function s(t){return\"object\"==typeof t&&null!==t&&\"message\"in t}e.isErrorWithCode=o,e.isErrorWithMessage=s,e.isErrorWithStack=function(t){return\"object\"==typeof t&&null!==t&&\"stack\"in t},e.getErrorMessage=function(t){return s(t)&&\"string\"==typeof t.message?t.message:n.isNullOrUndefined.call(void 0,t)?\"\":String(t)},e.wrapError=function(t,e){if((r=t)instanceof Error||n.isObject.call(void 0,r)&&\"Error\"===r.constructor.name){let r;return r=2===Error.length?new Error(e,{cause:t}):new(0,i.ErrorWithCause)(e,{cause:t}),o(t)&&(r.code=t.code),r}var r;return e.length>0?new Error(`${String(t)}: ${e}`):new Error(String(t))}},8383:()=>{},7427:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(932),i=r(6526),o=r(7251),s=t=>o.object.call(void 0,t);function a({path:t,branch:e}){const r=t[t.length-1];return i.hasProperty.call(void 0,e[e.length-2],r)}function c(t){return new(0,o.Struct)({...t,type:`optional ${t.type}`,validator:(e,r)=>!a(r)||t.validator(e,r),refiner:(e,r)=>!a(r)||t.refiner(e,r)})}var u=o.union.call(void 0,[o.literal.call(void 0,null),o.boolean.call(void 0),o.define.call(void 0,\"finite number\",(t=>o.is.call(void 0,t,o.number.call(void 0))&&Number.isFinite(t))),o.string.call(void 0),o.array.call(void 0,o.lazy.call(void 0,(()=>u))),o.record.call(void 0,o.string.call(void 0),o.lazy.call(void 0,(()=>u)))]),f=o.coerce.call(void 0,u,o.any.call(void 0),(t=>(n.assertStruct.call(void 0,t,u),JSON.parse(JSON.stringify(t,((t,e)=>{if(\"__proto__\"!==t&&\"constructor\"!==t)return e}))))));function h(t){return o.create.call(void 0,t,f)}var l=o.literal.call(void 0,\"2.0\"),p=o.nullable.call(void 0,o.union.call(void 0,[o.number.call(void 0),o.string.call(void 0)])),d=s({code:o.integer.call(void 0),message:o.string.call(void 0),data:c(f),stack:c(o.string.call(void 0))}),y=o.union.call(void 0,[o.record.call(void 0,o.string.call(void 0),f),o.array.call(void 0,f)]),g=s({id:p,jsonrpc:l,method:o.string.call(void 0),params:c(y)}),b=s({jsonrpc:l,method:o.string.call(void 0),params:c(y)});var w=o.object.call(void 0,{id:p,jsonrpc:l,result:o.optional.call(void 0,o.unknown.call(void 0)),error:o.optional.call(void 0,d)}),m=s({id:p,jsonrpc:l,result:f}),v=s({id:p,jsonrpc:l,error:d}),E=o.union.call(void 0,[m,v]);e.object=s,e.exactOptional=c,e.UnsafeJsonStruct=u,e.JsonStruct=f,e.isValidJson=function(t){try{return h(t),!0}catch(t){return!1}},e.getSafeJson=h,e.getJsonSize=function(t){n.assertStruct.call(void 0,t,f,\"Invalid JSON value\");const e=JSON.stringify(t);return(new TextEncoder).encode(e).byteLength},e.jsonrpc2=\"2.0\",e.JsonRpcVersionStruct=l,e.JsonRpcIdStruct=p,e.JsonRpcErrorStruct=d,e.JsonRpcParamsStruct=y,e.JsonRpcRequestStruct=g,e.JsonRpcNotificationStruct=b,e.isJsonRpcNotification=function(t){return o.is.call(void 0,t,b)},e.assertIsJsonRpcNotification=function(t,e){n.assertStruct.call(void 0,t,b,\"Invalid JSON-RPC notification\",e)},e.isJsonRpcRequest=function(t){return o.is.call(void 0,t,g)},e.assertIsJsonRpcRequest=function(t,e){n.assertStruct.call(void 0,t,g,\"Invalid JSON-RPC request\",e)},e.PendingJsonRpcResponseStruct=w,e.JsonRpcSuccessStruct=m,e.JsonRpcFailureStruct=v,e.JsonRpcResponseStruct=E,e.isPendingJsonRpcResponse=function(t){return o.is.call(void 0,t,w)},e.assertIsPendingJsonRpcResponse=function(t,e){n.assertStruct.call(void 0,t,w,\"Invalid pending JSON-RPC response\",e)},e.isJsonRpcResponse=function(t){return o.is.call(void 0,t,E)},e.assertIsJsonRpcResponse=function(t,e){n.assertStruct.call(void 0,t,E,\"Invalid JSON-RPC response\",e)},e.isJsonRpcSuccess=function(t){return o.is.call(void 0,t,m)},e.assertIsJsonRpcSuccess=function(t,e){n.assertStruct.call(void 0,t,m,\"Invalid JSON-RPC success response\",e)},e.isJsonRpcFailure=function(t){return o.is.call(void 0,t,v)},e.assertIsJsonRpcFailure=function(t,e){n.assertStruct.call(void 0,t,v,\"Invalid JSON-RPC failure response\",e)},e.isJsonRpcError=function(t){return o.is.call(void 0,t,d)},e.assertIsJsonRpcError=function(t,e){n.assertStruct.call(void 0,t,d,\"Invalid JSON-RPC error\",e)},e.getJsonRpcIdValidator=function(t){const{permitEmptyString:e,permitFractions:r,permitNull:n}={permitEmptyString:!0,permitFractions:!1,permitNull:!0,...t};return t=>Boolean(\"number\"==typeof t&&(r||Number.isInteger(t))||\"string\"==typeof t&&(e||t.length>0)||n&&null===t)}},5363:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});var i=r(932),o=r(448),s=r(7251),a=r(6710),c=48,u=58,f=87;var h=function(){const t=[];return()=>{if(0===t.length)for(let e=0;e<256;e++)t.push(e.toString(16).padStart(2,\"0\"));return t}}();function l(t){return t instanceof Uint8Array}function p(t){i.assert.call(void 0,l(t),\"Value must be a Uint8Array.\")}function d(t){if(p(t),0===t.length)return\"0x\";const e=h(),r=new Array(t.length);for(let n=0;nr.call(e,...t))),e=void 0)}return r}([t,\"optionalAccess\",t=>t.toLowerCase,\"optionalCall\",t=>t()]))return new Uint8Array;x(t);const e=R(t).toLowerCase(),r=e.length%2==0?e:`0${e}`,n=new Uint8Array(r.length/2);for(let t=0;t=BigInt(0),\"Value must be a non-negative bigint.\");return g(t.toString(16))}function w(t){i.assert.call(void 0,\"number\"==typeof t,\"Value must be a number.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative number.\"),i.assert.call(void 0,Number.isSafeInteger(t),\"Value is not a safe integer. Use `bigIntToBytes` instead.\");return g(t.toString(16))}function m(t){return i.assert.call(void 0,\"string\"==typeof t,\"Value must be a string.\"),(new TextEncoder).encode(t)}function v(t){if(\"bigint\"==typeof t)return b(t);if(\"number\"==typeof t)return w(t);if(\"string\"==typeof t)return t.startsWith(\"0x\")?g(t):m(t);if(l(t))return t;throw new TypeError(`Unsupported value type: \"${typeof t}\".`)}var E=s.pattern.call(void 0,s.string.call(void 0),/^(?:0x)?[0-9a-f]+$/iu),_=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-f]+$/iu),S=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-f]{40}$/u),A=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-fA-F]{40}$/u);function I(t){return s.is.call(void 0,t,E)}function T(t){return s.is.call(void 0,t,_)}function x(t){i.assert.call(void 0,I(t),\"Value must be a hexadecimal string.\")}function O(t){i.assert.call(void 0,s.is.call(void 0,t,A),\"Invalid hex address.\");const e=R(t.toLowerCase()),r=R(d(o.keccak_256.call(void 0,e)));return`0x${e.split(\"\").map(((t,e)=>{const n=r[e];return i.assert.call(void 0,s.is.call(void 0,n,s.string.call(void 0)),\"Hash shorter than address.\"),parseInt(n,16)>7?t.toUpperCase():t})).join(\"\")}`}function k(t){return!!s.is.call(void 0,t,A)&&O(t)===t}function P(t){return t.startsWith(\"0x\")?t:t.startsWith(\"0X\")?`0x${t.substring(2)}`:`0x${t}`}function R(t){return t.startsWith(\"0x\")||t.startsWith(\"0X\")?t.substring(2):t}e.HexStruct=E,e.StrictHexStruct=_,e.HexAddressStruct=S,e.HexChecksumAddressStruct=A,e.isHexString=I,e.isStrictHexString=T,e.assertIsHexString=x,e.assertIsStrictHexString=function(t){i.assert.call(void 0,T(t),'Value must be a hexadecimal string, starting with \"0x\".')},e.isValidHexAddress=function(t){return s.is.call(void 0,t,S)||k(t)},e.getChecksumAddress=O,e.isValidChecksumAddress=k,e.add0x=P,e.remove0x=R,e.isBytes=l,e.assertIsBytes=p,e.bytesToHex=d,e.bytesToBigInt=y,e.bytesToSignedBigInt=function(t){p(t);let e=BigInt(0);for(const r of t)e=(e<0,\"Byte length must be greater than 0.\"),i.assert.call(void 0,function(t,e){i.assert.call(void 0,e>0);const r=t>>BigInt(31);return!((~t&r)+(t&~r)>>BigInt(8*e-1))}(t,e),\"Byte length is too small to represent the given value.\");let r=t;const n=new Uint8Array(e);for(let t=0;t>=BigInt(8);return n.reverse()},e.numberToBytes=w,e.stringToBytes=m,e.base64ToBytes=function(t){return i.assert.call(void 0,\"string\"==typeof t,\"Value must be a string.\"),a.base64.decode(t)},e.valueToBytes=v,e.concatBytes=function(t){const e=new Array(t.length);let r=0;for(let n=0;n{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r,n=((r=n||{})[r.Null=4]=\"Null\",r[r.Comma=1]=\"Comma\",r[r.Wrapper=1]=\"Wrapper\",r[r.True=4]=\"True\",r[r.False=5]=\"False\",r[r.Quote=1]=\"Quote\",r[r.Colon=1]=\"Colon\",r[r.Date=24]=\"Date\",r),i=/\"|\\\\|\\n|\\r|\\t/gu;function o(t){return t.charCodeAt(0)<=127}e.isNonEmptyArray=function(t){return Array.isArray(t)&&t.length>0},e.isNullOrUndefined=function(t){return null==t},e.isObject=function(t){return Boolean(t)&&\"object\"==typeof t&&!Array.isArray(t)},e.hasProperty=(t,e)=>Object.hasOwnProperty.call(t,e),e.getKnownPropertyNames=function(t){return Object.getOwnPropertyNames(t)},e.JsonSize=n,e.ESCAPE_CHARACTERS_REGEXP=i,e.isPlainObject=function(t){if(\"object\"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}},e.isASCII=o,e.calculateStringSize=function(t){return t.split(\"\").reduce(((t,e)=>o(e)?t+1:t+2),0)+(e=t.match(i),r=()=>[],null!=e?e:r()).length;var e,r},e.calculateNumberSize=function(t){return t.toString().length}},1305:()=>{},3207:()=>{},1535:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(5363),i=r(932);e.numberToHex=t=>(i.assert.call(void 0,\"number\"==typeof t,\"Value must be a number.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative number.\"),i.assert.call(void 0,Number.isSafeInteger(t),\"Value is not a safe integer. Use `bigIntToHex` instead.\"),n.add0x.call(void 0,t.toString(16))),e.bigIntToHex=t=>(i.assert.call(void 0,\"bigint\"==typeof t,\"Value must be a bigint.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative bigint.\"),n.add0x.call(void 0,t.toString(16))),e.hexToNumber=t=>{n.assertIsHexString.call(void 0,t);const e=parseInt(t,16);return i.assert.call(void 0,Number.isSafeInteger(e),\"Value is not a safe integer. Use `hexToBigInt` instead.\"),e},e.hexToBigInt=t=>(n.assertIsHexString.call(void 0,t),BigInt(n.add0x.call(void 0,t)))},2489:(t,e,r)=>{\"use strict\";function n(t){let e,r=t[0],n=1;for(;nr.call(e,...t))),e=void 0)}return r}Object.defineProperty(e,\"__esModule\",{value:!0});var i,o=r(7251),s=/^(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})$/u,a=/^[-a-z0-9]{3,8}$/u,c=/^[-_a-zA-Z0-9]{1,32}$/u,u=/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})):(?[-.%a-zA-Z0-9]{1,128})$/u,f=/^[-.%a-zA-Z0-9]{1,128}$/u,h=o.pattern.call(void 0,o.string.call(void 0),s),l=o.pattern.call(void 0,o.string.call(void 0),a),p=o.pattern.call(void 0,o.string.call(void 0),c),d=o.pattern.call(void 0,o.string.call(void 0),u),y=o.pattern.call(void 0,o.string.call(void 0),f),g=((i=g||{}).Eip155=\"eip155\",i);function b(t){return o.is.call(void 0,t,l)}function w(t){return o.is.call(void 0,t,p)}e.CAIP_CHAIN_ID_REGEX=s,e.CAIP_NAMESPACE_REGEX=a,e.CAIP_REFERENCE_REGEX=c,e.CAIP_ACCOUNT_ID_REGEX=u,e.CAIP_ACCOUNT_ADDRESS_REGEX=f,e.CaipChainIdStruct=h,e.CaipNamespaceStruct=l,e.CaipReferenceStruct=p,e.CaipAccountIdStruct=d,e.CaipAccountAddressStruct=y,e.KnownCaipNamespace=g,e.isCaipChainId=function(t){return o.is.call(void 0,t,h)},e.isCaipNamespace=b,e.isCaipReference=w,e.isCaipAccountId=function(t){return o.is.call(void 0,t,d)},e.isCaipAccountAddress=function(t){return o.is.call(void 0,t,y)},e.parseCaipChainId=function(t){const e=s.exec(t);if(!n([e,\"optionalAccess\",t=>t.groups]))throw new Error(\"Invalid CAIP chain ID.\");return{namespace:e.groups.namespace,reference:e.groups.reference}},e.parseCaipAccountId=function(t){const e=u.exec(t);if(!n([e,\"optionalAccess\",t=>t.groups]))throw new Error(\"Invalid CAIP account ID.\");return{address:e.groups.accountAddress,chainId:e.groups.chainId,chain:{namespace:e.groups.namespace,reference:e.groups.reference}}},e.toCaipChainId=function(t,e){if(!b(t))throw new Error(`Invalid \"namespace\", must match: ${a.toString()}`);if(!w(e))throw new Error(`Invalid \"reference\", must match: ${c.toString()}`);return`${t}:${e}`}},1584:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n,i,o=r(5244),s=class{constructor(t){o.__privateAdd.call(void 0,this,n,void 0),o.__privateSet.call(void 0,this,n,new Map(t)),Object.freeze(this)}get size(){return o.__privateGet.call(void 0,this,n).size}[Symbol.iterator](){return o.__privateGet.call(void 0,this,n)[Symbol.iterator]()}entries(){return o.__privateGet.call(void 0,this,n).entries()}forEach(t,e){return o.__privateGet.call(void 0,this,n).forEach(((r,n,i)=>t.call(e,r,n,this)))}get(t){return o.__privateGet.call(void 0,this,n).get(t)}has(t){return o.__privateGet.call(void 0,this,n).has(t)}keys(){return o.__privateGet.call(void 0,this,n).keys()}values(){return o.__privateGet.call(void 0,this,n).values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map((([t,e])=>`${String(t)} => ${String(e)}`)).join(\", \")} `:\"\"}}`}};n=new WeakMap;var a=class{constructor(t){o.__privateAdd.call(void 0,this,i,void 0),o.__privateSet.call(void 0,this,i,new Set(t)),Object.freeze(this)}get size(){return o.__privateGet.call(void 0,this,i).size}[Symbol.iterator](){return o.__privateGet.call(void 0,this,i)[Symbol.iterator]()}entries(){return o.__privateGet.call(void 0,this,i).entries()}forEach(t,e){return o.__privateGet.call(void 0,this,i).forEach(((r,n,i)=>t.call(e,r,n,this)))}has(t){return o.__privateGet.call(void 0,this,i).has(t)}keys(){return o.__privateGet.call(void 0,this,i).keys()}values(){return o.__privateGet.call(void 0,this,i).values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map((t=>String(t))).join(\", \")} `:\"\"}}`}};i=new WeakMap,Object.freeze(s),Object.freeze(s.prototype),Object.freeze(a),Object.freeze(a.prototype),e.FrozenMap=s,e.FrozenSet=a},2049:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),r(7982);var n=r(1535);r(8383);var i=r(9705),o=r(9116);r(3207);var s=r(3631),a=r(7427);r(1305);var c=r(1275),u=r(2489),f=r(1508),h=r(1848),l=r(1203),p=r(5363),d=r(932),y=r(1486),g=r(6526),b=r(1584);r(5244),r(1423),e.AssertionError=d.AssertionError,e.CAIP_ACCOUNT_ADDRESS_REGEX=u.CAIP_ACCOUNT_ADDRESS_REGEX,e.CAIP_ACCOUNT_ID_REGEX=u.CAIP_ACCOUNT_ID_REGEX,e.CAIP_CHAIN_ID_REGEX=u.CAIP_CHAIN_ID_REGEX,e.CAIP_NAMESPACE_REGEX=u.CAIP_NAMESPACE_REGEX,e.CAIP_REFERENCE_REGEX=u.CAIP_REFERENCE_REGEX,e.CaipAccountAddressStruct=u.CaipAccountAddressStruct,e.CaipAccountIdStruct=u.CaipAccountIdStruct,e.CaipChainIdStruct=u.CaipChainIdStruct,e.CaipNamespaceStruct=u.CaipNamespaceStruct,e.CaipReferenceStruct=u.CaipReferenceStruct,e.ChecksumStruct=f.ChecksumStruct,e.Duration=o.Duration,e.ESCAPE_CHARACTERS_REGEXP=g.ESCAPE_CHARACTERS_REGEXP,e.FrozenMap=b.FrozenMap,e.FrozenSet=b.FrozenSet,e.HexAddressStruct=p.HexAddressStruct,e.HexChecksumAddressStruct=p.HexChecksumAddressStruct,e.HexStruct=p.HexStruct,e.JsonRpcErrorStruct=a.JsonRpcErrorStruct,e.JsonRpcFailureStruct=a.JsonRpcFailureStruct,e.JsonRpcIdStruct=a.JsonRpcIdStruct,e.JsonRpcNotificationStruct=a.JsonRpcNotificationStruct,e.JsonRpcParamsStruct=a.JsonRpcParamsStruct,e.JsonRpcRequestStruct=a.JsonRpcRequestStruct,e.JsonRpcResponseStruct=a.JsonRpcResponseStruct,e.JsonRpcSuccessStruct=a.JsonRpcSuccessStruct,e.JsonRpcVersionStruct=a.JsonRpcVersionStruct,e.JsonSize=g.JsonSize,e.JsonStruct=a.JsonStruct,e.KnownCaipNamespace=u.KnownCaipNamespace,e.PendingJsonRpcResponseStruct=a.PendingJsonRpcResponseStruct,e.StrictHexStruct=p.StrictHexStruct,e.UnsafeJsonStruct=a.UnsafeJsonStruct,e.VersionRangeStruct=s.VersionRangeStruct,e.VersionStruct=s.VersionStruct,e.add0x=p.add0x,e.assert=d.assert,e.assertExhaustive=d.assertExhaustive,e.assertIsBytes=p.assertIsBytes,e.assertIsHexString=p.assertIsHexString,e.assertIsJsonRpcError=a.assertIsJsonRpcError,e.assertIsJsonRpcFailure=a.assertIsJsonRpcFailure,e.assertIsJsonRpcNotification=a.assertIsJsonRpcNotification,e.assertIsJsonRpcRequest=a.assertIsJsonRpcRequest,e.assertIsJsonRpcResponse=a.assertIsJsonRpcResponse,e.assertIsJsonRpcSuccess=a.assertIsJsonRpcSuccess,e.assertIsPendingJsonRpcResponse=a.assertIsPendingJsonRpcResponse,e.assertIsSemVerRange=s.assertIsSemVerRange,e.assertIsSemVerVersion=s.assertIsSemVerVersion,e.assertIsStrictHexString=p.assertIsStrictHexString,e.assertStruct=d.assertStruct,e.base64=h.base64,e.base64ToBytes=p.base64ToBytes,e.bigIntToBytes=p.bigIntToBytes,e.bigIntToHex=n.bigIntToHex,e.bytesToBase64=p.bytesToBase64,e.bytesToBigInt=p.bytesToBigInt,e.bytesToHex=p.bytesToHex,e.bytesToNumber=p.bytesToNumber,e.bytesToSignedBigInt=p.bytesToSignedBigInt,e.bytesToString=p.bytesToString,e.calculateNumberSize=g.calculateNumberSize,e.calculateStringSize=g.calculateStringSize,e.concatBytes=p.concatBytes,e.createBigInt=l.createBigInt,e.createBytes=l.createBytes,e.createDataView=p.createDataView,e.createDeferredPromise=i.createDeferredPromise,e.createHex=l.createHex,e.createModuleLogger=c.createModuleLogger,e.createNumber=l.createNumber,e.createProjectLogger=c.createProjectLogger,e.exactOptional=a.exactOptional,e.getChecksumAddress=p.getChecksumAddress,e.getErrorMessage=y.getErrorMessage,e.getJsonRpcIdValidator=a.getJsonRpcIdValidator,e.getJsonSize=a.getJsonSize,e.getKnownPropertyNames=g.getKnownPropertyNames,e.getSafeJson=a.getSafeJson,e.gtRange=s.gtRange,e.gtVersion=s.gtVersion,e.hasProperty=g.hasProperty,e.hexToBigInt=n.hexToBigInt,e.hexToBytes=p.hexToBytes,e.hexToNumber=n.hexToNumber,e.inMilliseconds=o.inMilliseconds,e.isASCII=g.isASCII,e.isBytes=p.isBytes,e.isCaipAccountAddress=u.isCaipAccountAddress,e.isCaipAccountId=u.isCaipAccountId,e.isCaipChainId=u.isCaipChainId,e.isCaipNamespace=u.isCaipNamespace,e.isCaipReference=u.isCaipReference,e.isErrorWithCode=y.isErrorWithCode,e.isErrorWithMessage=y.isErrorWithMessage,e.isErrorWithStack=y.isErrorWithStack,e.isHexString=p.isHexString,e.isJsonRpcError=a.isJsonRpcError,e.isJsonRpcFailure=a.isJsonRpcFailure,e.isJsonRpcNotification=a.isJsonRpcNotification,e.isJsonRpcRequest=a.isJsonRpcRequest,e.isJsonRpcResponse=a.isJsonRpcResponse,e.isJsonRpcSuccess=a.isJsonRpcSuccess,e.isNonEmptyArray=g.isNonEmptyArray,e.isNullOrUndefined=g.isNullOrUndefined,e.isObject=g.isObject,e.isPendingJsonRpcResponse=a.isPendingJsonRpcResponse,e.isPlainObject=g.isPlainObject,e.isStrictHexString=p.isStrictHexString,e.isValidChecksumAddress=p.isValidChecksumAddress,e.isValidHexAddress=p.isValidHexAddress,e.isValidJson=a.isValidJson,e.isValidSemVerRange=s.isValidSemVerRange,e.isValidSemVerVersion=s.isValidSemVerVersion,e.jsonrpc2=a.jsonrpc2,e.numberToBytes=p.numberToBytes,e.numberToHex=n.numberToHex,e.object=a.object,e.parseCaipAccountId=u.parseCaipAccountId,e.parseCaipChainId=u.parseCaipChainId,e.remove0x=p.remove0x,e.satisfiesVersionRange=s.satisfiesVersionRange,e.signedBigIntToBytes=p.signedBigIntToBytes,e.stringToBytes=p.stringToBytes,e.timeSince=o.timeSince,e.toCaipChainId=u.toCaipChainId,e.valueToBytes=p.valueToBytes,e.wrapError=y.wrapError},2028:()=>{},3011:()=>{},3951:()=>{},7251:(t,e,r)=>{\"use strict\";r.r(e),r.d(e,{Struct:()=>f,StructError:()=>n,any:()=>I,array:()=>T,assert:()=>h,assign:()=>g,bigint:()=>x,boolean:()=>O,coerce:()=>J,create:()=>l,date:()=>k,defaulted:()=>Y,define:()=>b,deprecated:()=>w,dynamic:()=>m,empty:()=>Q,enums:()=>P,func:()=>R,instance:()=>B,integer:()=>C,intersection:()=>N,is:()=>d,lazy:()=>v,literal:()=>L,map:()=>U,mask:()=>p,max:()=>et,min:()=>rt,never:()=>j,nonempty:()=>nt,nullable:()=>M,number:()=>H,object:()=>F,omit:()=>E,optional:()=>D,partial:()=>_,pattern:()=>it,pick:()=>S,record:()=>$,refine:()=>st,regexp:()=>K,set:()=>V,size:()=>ot,string:()=>G,struct:()=>A,trimmed:()=>Z,tuple:()=>q,type:()=>W,union:()=>X,unknown:()=>z,validate:()=>y});class n extends TypeError{constructor(t,e){let r;const{message:n,explanation:i,...o}=t,{path:s}=t,a=0===s.length?n:`At path: ${s.join(\".\")} -- ${n}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function i(t){return\"object\"==typeof t&&null!=t}function o(t){if(\"[object Object]\"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function s(t){return\"symbol\"==typeof t?t.toString():\"string\"==typeof t?JSON.stringify(t):`${t}`}function a(t,e,r,n){if(!0===t)return;!1===t?t={}:\"string\"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:a}=r,{refinement:c,message:u=`Expected a value of type \\`${a}\\`${c?` with refinement \\`${c}\\``:\"\"}, but received: \\`${s(n)}\\``}=t;return{value:n,type:a,refinement:c,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*c(t,e,r,n){var o;i(o=t)&&\"function\"==typeof o[Symbol.iterator]||(t=[t]);for(const i of t){const t=a(i,e,r,n);t&&(yield t)}}function*u(t,e,r={}){const{path:n=[],branch:o=[t],coerce:s=!1,mask:a=!1}=r,c={path:n,branch:o};if(s&&(t=e.coercer(t,c),a&&\"type\"!==e.type&&i(e.schema)&&i(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let f=\"valid\";for(const n of e.validator(t,c))n.explanation=r.message,f=\"not_valid\",yield[n,void 0];for(let[h,l,p]of e.entries(t,c)){const e=u(l,p,{path:void 0===h?n:[...n,h],branch:void 0===h?o:[...o,l],coerce:s,mask:a,message:r.message});for(const r of e)r[0]?(f=null!=r[0].refinement?\"not_refined\":\"not_valid\",yield[r[0],void 0]):s&&(l=r[1],void 0===h?t=l:t instanceof Map?t.set(h,l):t instanceof Set?t.add(l):i(t)&&(void 0!==l||h in t)&&(t[h]=l))}if(\"not_valid\"!==f)for(const n of e.refiner(t,c))n.explanation=r.message,f=\"not_refined\",yield[n,void 0];\"valid\"===f&&(yield[void 0,t])}class f{constructor(t){const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>c(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>c(i(t,e),e,this,t):()=>[]}assert(t,e){return h(t,this,e)}create(t,e){return l(t,this,e)}is(t){return d(t,this)}mask(t,e){return p(t,this,e)}validate(t,e={}){return y(t,this,e)}}function h(t,e,r){const n=y(t,e,{message:r});if(n[0])throw n[0]}function l(t,e,r){const n=y(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function p(t,e,r){const n=y(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function d(t,e){return!y(t,e)[0]}function y(t,e,r={}){const i=u(t,e,r),o=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(i);if(o[0]){return[new n(o[0],(function*(){for(const t of i)t[0]&&(yield t[0])})),void 0]}return[void 0,o[1]]}function g(...t){const e=\"type\"===t[0].type,r=t.map((t=>t.schema)),n=Object.assign({},...r);return e?W(n):F(n)}function b(t,e){return new f({type:t,schema:null,validator:e})}function w(t,e){return new f({...t,refiner:(e,r)=>void 0===e||t.refiner(e,r),validator:(r,n)=>void 0===r||(e(r,n),t.validator(r,n))})}function m(t){return new f({type:\"dynamic\",schema:null,*entries(e,r){const n=t(e,r);yield*n.entries(e,r)},validator:(e,r)=>t(e,r).validator(e,r),coercer:(e,r)=>t(e,r).coercer(e,r),refiner:(e,r)=>t(e,r).refiner(e,r)})}function v(t){let e;return new f({type:\"lazy\",schema:null,*entries(r,n){e??(e=t()),yield*e.entries(r,n)},validator:(r,n)=>(e??(e=t()),e.validator(r,n)),coercer:(r,n)=>(e??(e=t()),e.coercer(r,n)),refiner:(r,n)=>(e??(e=t()),e.refiner(r,n))})}function E(t,e){const{schema:r}=t,n={...r};for(const t of e)delete n[t];return\"type\"===t.type?W(n):F(n)}function _(t){const e=t instanceof f?{...t.schema}:{...t};for(const t in e)e[t]=D(e[t]);return F(e)}function S(t,e){const{schema:r}=t,n={};for(const t of e)n[t]=r[t];return F(n)}function A(t,e){return console.warn(\"superstruct@0.11 - The `struct` helper has been renamed to `define`.\"),b(t,e)}function I(){return b(\"any\",(()=>!0))}function T(t){return new f({type:\"array\",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||`Expected an array value, but received: ${s(t)}`})}function x(){return b(\"bigint\",(t=>\"bigint\"==typeof t))}function O(){return b(\"boolean\",(t=>\"boolean\"==typeof t))}function k(){return b(\"date\",(t=>t instanceof Date&&!isNaN(t.getTime())||`Expected a valid \\`Date\\` object, but received: ${s(t)}`))}function P(t){const e={},r=t.map((t=>s(t))).join();for(const r of t)e[r]=r;return new f({type:\"enums\",schema:e,validator:e=>t.includes(e)||`Expected one of \\`${r}\\`, but received: ${s(e)}`})}function R(){return b(\"func\",(t=>\"function\"==typeof t||`Expected a function, but received: ${s(t)}`))}function B(t){return b(\"instance\",(e=>e instanceof t||`Expected a \\`${t.name}\\` instance, but received: ${s(e)}`))}function C(){return b(\"integer\",(t=>\"number\"==typeof t&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${s(t)}`))}function N(t){return new f({type:\"intersection\",schema:null,*entries(e,r){for(const n of t)yield*n.entries(e,r)},*validator(e,r){for(const n of t)yield*n.validator(e,r)},*refiner(e,r){for(const n of t)yield*n.refiner(e,r)}})}function L(t){const e=s(t),r=typeof t;return new f({type:\"literal\",schema:\"string\"===r||\"number\"===r||\"boolean\"===r?t:null,validator:r=>r===t||`Expected the literal \\`${e}\\`, but received: ${s(r)}`})}function U(t,e){return new f({type:\"map\",schema:null,*entries(r){if(t&&e&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,t],yield[n,i,e]},coercer:t=>t instanceof Map?new Map(t):t,validator:t=>t instanceof Map||`Expected a \\`Map\\` object, but received: ${s(t)}`})}function j(){return b(\"never\",(()=>!1))}function M(t){return new f({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function H(){return b(\"number\",(t=>\"number\"==typeof t&&!isNaN(t)||`Expected a number, but received: ${s(t)}`))}function F(t){const e=t?Object.keys(t):[],r=j();return new f({type:\"object\",schema:t||null,*entries(n){if(t&&i(n)){const i=new Set(Object.keys(n));for(const r of e)i.delete(r),yield[r,n[r],t[r]];for(const t of i)yield[t,n[t],r]}},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`,coercer:t=>i(t)?{...t}:t})}function D(t){return new f({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function $(t,e){return new f({type:\"record\",schema:null,*entries(r){if(i(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`})}function K(){return b(\"regexp\",(t=>t instanceof RegExp))}function V(t){return new f({type:\"set\",schema:null,*entries(e){if(t&&e instanceof Set)for(const r of e)yield[r,r,t]},coercer:t=>t instanceof Set?new Set(t):t,validator:t=>t instanceof Set||`Expected a \\`Set\\` object, but received: ${s(t)}`})}function G(){return b(\"string\",(t=>\"string\"==typeof t||`Expected a string, but received: ${s(t)}`))}function q(t){const e=j();return new f({type:\"tuple\",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;iArray.isArray(t)||`Expected an array, but received: ${s(t)}`})}function W(t){const e=Object.keys(t);return new f({type:\"type\",schema:t,*entries(r){if(i(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`,coercer:t=>i(t)?{...t}:t})}function X(t){const e=t.map((t=>t.type)).join(\" | \");return new f({type:\"union\",schema:null,coercer(e){for(const r of t){const[t,n]=r.validate(e,{coerce:!0});if(!t)return n}return e},validator(r,n){const i=[];for(const e of t){const[...t]=u(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return[`Expected the value to satisfy a union of \\`${e}\\`, but received: ${s(r)}`,...i]}})}function z(){return b(\"unknown\",(()=>!0))}function J(t,e,r){return new f({...t,coercer:(n,i)=>d(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}function Y(t,e,r={}){return J(t,z(),(t=>{const n=\"function\"==typeof e?e():e;if(void 0===t)return n;if(!r.strict&&o(t)&&o(n)){const e={...t};let r=!1;for(const t in n)void 0===e[t]&&(e[t]=n[t],r=!0);if(r)return e}return t}))}function Z(t){return J(t,G(),(t=>t.trim()))}function Q(t){return st(t,\"empty\",(e=>{const r=tt(e);return 0===r||`Expected an empty ${t.type} but received one with a size of \\`${r}\\``}))}function tt(t){return t instanceof Map||t instanceof Set?t.size:t.length}function et(t,e,r={}){const{exclusive:n}=r;return st(t,\"max\",(r=>n?rn?r>e:r>=e||`Expected a ${t.type} greater than ${n?\"\":\"or equal to \"}${e} but received \\`${r}\\``))}function nt(t){return st(t,\"nonempty\",(e=>tt(e)>0||`Expected a nonempty ${t.type} but received an empty one`))}function it(t,e){return st(t,\"pattern\",(r=>e.test(r)||`Expected a ${t.type} matching \\`/${e.source}/\\` but received \"${r}\"`))}function ot(t,e,r=e){const n=`Expected a ${t.type}`,i=e===r?`of \\`${e}\\``:`between \\`${e}\\` and \\`${r}\\``;return st(t,\"size\",(t=>{if(\"number\"==typeof t||t instanceof Date)return e<=t&&t<=r||`${n} ${i} but received \\`${t}\\``;if(t instanceof Map||t instanceof Set){const{size:o}=t;return e<=o&&o<=r||`${n} with a size ${i} but received one with a size of \\`${o}\\``}{const{length:o}=t;return e<=o&&o<=r||`${n} with a length ${i} but received one with a length of \\`${o}\\``}}))}function st(t,e,r){return new f({...t,*refiner(n,i){yield*t.refiner(n,i);const o=c(r(n,i),i,t,n);for(const t of o)yield{...t,refinement:e}}})}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if(\"object\"==typeof globalThis)return globalThis;try{return this||new Function(\"return this\")()}catch(t){if(\"object\"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})};var n={};(()=>{\"use strict\";r.r(n),r.d(n,{onKeyringRequest:()=>Zn,onRpcRequest:()=>Yn,validateOrigin:()=>Jn});var t=r(7962);function e(t){return Boolean(t)&&\"object\"==typeof t&&!Array.isArray(t)}var i=(t,e)=>Object.hasOwnProperty.call(t,e);var o,s=((o=s||{})[o.Null=4]=\"Null\",o[o.Comma=1]=\"Comma\",o[o.Wrapper=1]=\"Wrapper\",o[o.True=4]=\"True\",o[o.False=5]=\"False\",o[o.Quote=1]=\"Quote\",o[o.Colon=1]=\"Colon\",o[o.Date=24]=\"Date\",o);function a(t){if(\"object\"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}}Error;var c=r(7251);function u(t){return function(t){return function(t){return\"object\"==typeof t&&null!==t&&\"message\"in t}(t)&&\"string\"==typeof t.message?t.message:null==t?\"\":String(t)}(t).replace(/\\.$/u,\"\")}function f(t,e){return r=t,Boolean(\"string\"==typeof r?.prototype?.constructor?.name)?new t({message:e}):t({message:e});var r}var h=class extends Error{constructor(t){super(t.message),this.code=\"ERR_ASSERTION\"}};function l(t,e=\"Assertion failed.\",r=h){if(!t){if(e instanceof Error)throw e;throw f(r,e)}}function p(t,e,r=\"Assertion failed\",n=h){try{(0,c.assert)(t,e)}catch(t){throw f(n,`${r}: ${u(t)}.`)}}var d=t=>(0,c.object)(t);function y({path:t,branch:e}){const r=t[t.length-1];return i(e[e.length-2],r)}function g(t){return new c.Struct({...t,type:`optional ${t.type}`,validator:(e,r)=>!y(r)||t.validator(e,r),refiner:(e,r)=>!y(r)||t.refiner(e,r)})}var b=(0,c.union)([(0,c.literal)(null),(0,c.boolean)(),(0,c.define)(\"finite number\",(t=>(0,c.is)(t,(0,c.number)())&&Number.isFinite(t))),(0,c.string)(),(0,c.array)((0,c.lazy)((()=>b))),(0,c.record)((0,c.string)(),(0,c.lazy)((()=>b)))]),w=(0,c.coerce)(b,(0,c.any)(),(t=>(p(t,b),JSON.parse(JSON.stringify(t,((t,e)=>{if(\"__proto__\"!==t&&\"constructor\"!==t)return e}))))));function m(t){try{return function(t){(0,c.create)(t,w)}(t),!0}catch{return!1}}var v=(0,c.literal)(\"2.0\"),E=(0,c.nullable)((0,c.union)([(0,c.number)(),(0,c.string)()])),_=d({code:(0,c.integer)(),message:(0,c.string)(),data:g(w),stack:g((0,c.string)())}),S=(0,c.union)([(0,c.record)((0,c.string)(),w),(0,c.array)(w)]);d({id:E,jsonrpc:v,method:(0,c.string)(),params:g(S)}),d({jsonrpc:v,method:(0,c.string)(),params:g(S)});(0,c.object)({id:E,jsonrpc:v,result:(0,c.optional)((0,c.unknown)()),error:(0,c.optional)(_)});var A=d({id:E,jsonrpc:v,result:w}),I=d({id:E,jsonrpc:v,error:_});(0,c.union)([A,I]);var T=r(2763),x={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},O={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},k={\"-32700\":{standard:\"JSON RPC 2.0\",message:\"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.\"},\"-32600\":{standard:\"JSON RPC 2.0\",message:\"The JSON sent is not a valid Request object.\"},\"-32601\":{standard:\"JSON RPC 2.0\",message:\"The method does not exist / is not available.\"},\"-32602\":{standard:\"JSON RPC 2.0\",message:\"Invalid method parameter(s).\"},\"-32603\":{standard:\"JSON RPC 2.0\",message:\"Internal JSON-RPC error.\"},\"-32000\":{standard:\"EIP-1474\",message:\"Invalid input.\"},\"-32001\":{standard:\"EIP-1474\",message:\"Resource not found.\"},\"-32002\":{standard:\"EIP-1474\",message:\"Resource unavailable.\"},\"-32003\":{standard:\"EIP-1474\",message:\"Transaction rejected.\"},\"-32004\":{standard:\"EIP-1474\",message:\"Method not supported.\"},\"-32005\":{standard:\"EIP-1474\",message:\"Request limit exceeded.\"},4001:{standard:\"EIP-1193\",message:\"User rejected the request.\"},4100:{standard:\"EIP-1193\",message:\"The requested account and/or method has not been authorized by the user.\"},4200:{standard:\"EIP-1193\",message:\"The requested method is not supported by this Ethereum provider.\"},4900:{standard:\"EIP-1193\",message:\"The provider is disconnected from all chains.\"},4901:{standard:\"EIP-1193\",message:\"The provider is disconnected from the specified chain.\"}},P=x.internal,R=\"Unspecified error message. This is a bug, please report it.\",B=(C(P),\"Unspecified server error.\");function C(t,e=R){if(function(t){return Number.isInteger(t)}(t)){const e=t.toString();if(i(k,e))return k[e].message;if(function(t){return t>=-32099&&t<=-32e3}(t))return B}return e}function N(t){return Array.isArray(t)?t.map((t=>m(t)?t:e(t)?L(t):null)):e(t)?L(t):m(t)?t:null}function L(t){return Object.getOwnPropertyNames(t).reduce(((e,r)=>{const n=t[r];return m(n)&&(e[r]=n),e}),{})}var U=r(282),j=class extends Error{constructor(t,e,r){if(!Number.isInteger(t))throw new Error('\"code\" must be an integer.');if(!e||\"string\"!=typeof e)throw new Error('\"message\" must be a non-empty string.');super(e),this.code=t,void 0!==r&&(this.data=r)}serialize(){const t={code:this.code,message:this.message};return void 0!==this.data&&(t.data=this.data,a(this.data)&&(t.data.cause=N(this.data.cause))),this.stack&&(t.stack=this.stack),t}toString(){return U(this.serialize(),H,2)}},M=class extends j{constructor(t,e,r){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('\"code\" must be an integer such that: 1000 <= code <= 4999');super(t,e,r)}};function H(t,e){if(\"[Circular]\"!==e)return e}var F=t=>rt(x.parse,t),D=t=>rt(x.invalidRequest,t),$=t=>rt(x.invalidParams,t),K=t=>rt(x.methodNotFound,t),V=t=>rt(x.internal,t),G=t=>rt(x.invalidInput,t),q=t=>rt(x.resourceNotFound,t),W=t=>rt(x.resourceUnavailable,t),X=t=>rt(x.transactionRejected,t),z=t=>rt(x.methodNotSupported,t),J=t=>rt(x.limitExceeded,t),Y=t=>nt(O.userRejectedRequest,t),Z=t=>nt(O.unauthorized,t),Q=t=>nt(O.unsupportedMethod,t),tt=t=>nt(O.disconnected,t),et=t=>nt(O.chainDisconnected,t);function rt(t,e){const[r,n]=it(e);return new j(t,r??C(t),n)}function nt(t,e){const[r,n]=it(e);return new M(t,r??C(t),n)}function it(t){if(t){if(\"string\"==typeof t)return[t];if(\"object\"==typeof t&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&\"string\"!=typeof e)throw new Error(\"Must specify string message.\");return[e??void 0,r]}}return[]}r(1048).Buffer;!function(){const t=[]}();(0,c.pattern)((0,c.string)(),/^(?:0x)?[0-9a-f]+$/iu),(0,c.pattern)((0,c.string)(),/^0x[0-9a-f]+$/iu),(0,c.pattern)((0,c.string)(),/^0x[0-9a-f]{40}$/u);var ot=(0,c.pattern)((0,c.string)(),/^0x[0-9a-fA-F]{40}$/u);var st,at,ct,ut,ft=(t,e,r)=>{if(!e.has(t))throw TypeError(\"Cannot \"+r)},ht=(t,e,r)=>(ft(t,e,\"read from private field\"),r?r.call(t):e.get(t)),lt=(t,e,r)=>{if(e.has(t))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(t):e.set(t,r)},pt=(t,e,r,n)=>(ft(t,e,\"write to private field\"),n?n.call(t,r):e.set(t,r),r),dt=class extends Error{constructor(t,r={}){const n=function(t){if(e(t)&&i(t,\"message\")&&\"string\"==typeof t.message)return t.message;return String(t)}(t);super(n),lt(this,st,void 0),lt(this,at,void 0),lt(this,ct,void 0),lt(this,ut,void 0),pt(this,at,n),pt(this,st,function(t){if(e(t)&&i(t,\"code\")&&\"number\"==typeof t.code&&Number.isInteger(t.code))return t.code;return-32603}(t));const o={...wt(t),...r};Object.keys(o).length>0&&pt(this,ct,o),pt(this,ut,super.stack)}get name(){return\"SnapError\"}get code(){return ht(this,st)}get message(){return ht(this,at)}get data(){return ht(this,ct)}get stack(){return ht(this,ut)}toJSON(){return{code:gt,message:bt,data:{cause:{code:this.code,message:this.message,stack:this.stack,...this.data?{data:this.data}:{}}}}}serialize(){return this.toJSON()}};function yt(t){return class extends dt{constructor(e,r){if(\"object\"==typeof e){const r=t();return void super({code:r.code,message:r.message,data:e})}const n=t(e);super({code:n.code,message:n.message,data:r})}}}st=new WeakMap,at=new WeakMap,ct=new WeakMap,ut=new WeakMap;var gt=-31002,bt=\"Snap Error\";function wt(t){return e(t)&&i(t,\"data\")&&\"object\"==typeof t.data&&null!==t.data&&m(t.data)&&!Array.isArray(t.data)?t.data:{}}function mt(t){return(0,c.define)(JSON.stringify(t),(0,c.literal)(t).validator)}function vt(t){return mt(t)}function Et(t){return function([t,...e]){const r=(0,c.union)([t,...e]);return new c.Struct({...r,schema:[t,...e]})}(t)}function _t(t){try{return function(t){try{const r=t.trim();l(r.length>0);const n=new T.XMLParser({ignoreAttributes:!1,parseAttributeValue:!0}).parse(r,!0);return l(i(n,\"svg\")),e(n.svg)?n.svg:{}}catch{throw new Error(\"Snap icon must be a valid SVG.\")}}(t),!0}catch{return!1}}var St=yt(V),At=yt(G),It=yt($),Tt=yt(D),xt=yt(J),Ot=yt(K),kt=yt(z),Pt=yt(F),Rt=yt(q),Bt=yt(W),Ct=yt(X),Nt=yt(et),Lt=yt(tt),Ut=yt(Z),jt=yt(Q),Mt=yt(Y);function Ht(t,e,r=[]){return(...n)=>{if(1===n.length&&a(n[0])){const r={...n[0],type:t};return p(r,e,`Invalid ${t} component`),r}const i=r.reduce(((t,e,r)=>void 0!==n[r]?{...t,[e]:n[r]}:t),{type:t});return p(i,e,`Invalid ${t} component`),i}}var Ft,Dt=((Ft=Dt||{}).Copyable=\"copyable\",Ft.Divider=\"divider\",Ft.Heading=\"heading\",Ft.Panel=\"panel\",Ft.Spinner=\"spinner\",Ft.Text=\"text\",Ft.Image=\"image\",Ft.Row=\"row\",Ft.Address=\"address\",Ft.Button=\"button\",Ft.Input=\"input\",Ft.Form=\"form\",Ft),$t=(0,c.object)({type:(0,c.string)()}),Kt=(0,c.assign)($t,(0,c.object)({value:(0,c.unknown)()})),Vt=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"address\"),value:ot})),Gt=(Ht(\"address\",Vt,[\"value\"]),(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"copyable\"),value:(0,c.string)(),sensitive:(0,c.optional)((0,c.boolean)())}))),qt=(Ht(\"copyable\",Gt,[\"value\",\"sensitive\"]),(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"divider\")}))),Wt=Ht(\"divider\",qt),Xt=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"heading\"),value:(0,c.string)()})),zt=Ht(\"heading\",Xt,[\"value\"]);var Jt,Yt,Zt,Qt,te=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"image\"),value:(0,c.refine)((0,c.string)(),\"SVG\",(t=>!!_t(t)||\"Value is not a valid SVG.\"))})),ee=(Ht(\"image\",te,[\"value\"]),(Jt=ee||{}).Primary=\"primary\",Jt.Secondary=\"secondary\",Jt),re=((Yt=re||{}).Button=\"button\",Yt.Submit=\"submit\",Yt),ne=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"button\"),value:(0,c.string)(),variant:(0,c.optional)((0,c.union)([vt(\"primary\"),vt(\"secondary\")])),buttonType:(0,c.optional)((0,c.union)([vt(\"button\"),vt(\"submit\")])),name:(0,c.optional)((0,c.string)())})),ie=(Ht(\"button\",ne,[\"value\",\"buttonType\",\"name\",\"variant\"]),(Zt=ie||{}).Text=\"text\",Zt.Number=\"number\",Zt.Password=\"password\",Zt),oe=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"input\"),value:(0,c.optional)((0,c.string)()),name:(0,c.string)(),inputType:(0,c.optional)((0,c.union)([vt(\"text\"),vt(\"password\"),vt(\"number\")])),placeholder:(0,c.optional)((0,c.string)()),label:(0,c.optional)((0,c.string)()),error:(0,c.optional)((0,c.string)())})),se=(Ht(\"input\",oe,[\"name\",\"inputType\",\"placeholder\",\"value\",\"label\"]),(0,c.union)([oe,ne])),ae=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"form\"),children:(0,c.array)(se),name:(0,c.string)()})),ce=(Ht(\"form\",ae,[\"name\",\"children\"]),(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"text\"),value:(0,c.string)(),markdown:(0,c.optional)((0,c.boolean)())}))),ue=Ht(\"text\",ce,[\"value\",\"markdown\"]),fe=((Qt=fe||{}).Default=\"default\",Qt.Critical=\"critical\",Qt.Warning=\"warning\",Qt),he=(0,c.union)([te,ce,Vt]),le=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"row\"),variant:(0,c.optional)((0,c.union)([vt(\"default\"),vt(\"critical\"),vt(\"warning\")])),label:(0,c.string)(),value:he})),pe=Ht(\"row\",le,[\"label\",\"value\",\"variant\"]),de=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"spinner\")})),ye=(Ht(\"spinner\",de),(0,c.assign)($t,(0,c.object)({children:(0,c.array)((0,c.lazy)((()=>we)))}))),ge=(0,c.assign)(ye,(0,c.object)({type:(0,c.literal)(\"panel\")})),be=Ht(\"panel\",ge,[\"children\"]),we=(0,c.union)([Gt,qt,Xt,te,ge,de,ce,le,Vt,oe,ae,ne]);var me,ve,Ee,_e,Se,Ae,Ie=((me=Ie||{}).Critical=\"critical\",me),Te=((ve=Te||{}).ButtonClickEvent=\"ButtonClickEvent\",ve.FormSubmitEvent=\"FormSubmitEvent\",ve.InputChangeEvent=\"InputChangeEvent\",ve),xe=(0,c.object)({type:(0,c.string)(),name:(0,c.optional)((0,c.string)())}),Oe=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"ButtonClickEvent\"),name:(0,c.optional)((0,c.string)())})),ke=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"FormSubmitEvent\"),value:(0,c.record)((0,c.string)(),(0,c.nullable)((0,c.string)())),name:(0,c.string)()})),Pe=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"InputChangeEvent\"),name:(0,c.string)(),value:(0,c.string)()})),Re=((0,c.union)([Oe,ke,Pe]),(Ee=Re||{}).Alert=\"alert\",Ee.Confirmation=\"confirmation\",Ee.Prompt=\"prompt\",Ee),Be=((_e=Be||{}).Base64=\"base64\",_e.Hex=\"hex\",_e.Utf8=\"utf8\",_e),Ce=((Se=Ce||{}).ClearState=\"clear\",Se.GetState=\"get\",Se.UpdateState=\"update\",Se),Ne=((Ae=Ne||{}).InApp=\"inApp\",Ae.Native=\"native\",Ae),Le=Et([(0,c.string)(),(0,c.number)()]),Ue=je((0,c.string)());(0,c.object)({type:(0,c.string)(),props:(0,c.record)((0,c.string)(),w),key:(0,c.nullable)(Le)});function je(t){return Et([t,(0,c.array)(t)])}function Me(t,e={}){return(0,c.object)({type:mt(t),props:(0,c.object)(e),key:(0,c.nullable)(Le)})}var He,Fe,De=Me(\"Button\",{children:Ue,name:(0,c.optional)((0,c.string)()),type:(0,c.optional)(Et([mt(\"button\"),mt(\"submit\")])),variant:(0,c.optional)(Et([mt(\"primary\"),mt(\"destructive\")])),disabled:(0,c.optional)((0,c.boolean)())}),$e=Me(\"Input\",{name:(0,c.string)(),type:(0,c.optional)(Et([mt(\"text\"),mt(\"password\"),mt(\"number\")])),value:(0,c.optional)((0,c.string)()),placeholder:(0,c.optional)((0,c.string)())}),Ke=Me(\"Option\",{value:(0,c.string)(),children:(0,c.string)()}),Ve=Me(\"Dropdown\",{name:(0,c.string)(),value:(0,c.optional)((0,c.string)()),children:je(Ke)}),Ge=Me(\"Field\",{label:(0,c.optional)((0,c.string)()),error:(0,c.optional)((0,c.string)()),children:Et([(0,c.tuple)([$e,De]),$e,Ve])}),qe=Me(\"Form\",{children:je(Et([Ge,De])),name:(0,c.string)()}),We=Me(\"Bold\",{children:je((0,c.nullable)(Et([(0,c.string)(),(0,c.lazy)((()=>Xe))])))}),Xe=Me(\"Italic\",{children:je((0,c.nullable)(Et([(0,c.string)(),(0,c.lazy)((()=>We))])))}),ze=Et([We,Xe]),Je=Me(\"Address\",{address:ot}),Ye=Me(\"Box\",{children:je((0,c.nullable)((0,c.lazy)((()=>ar)))),direction:(0,c.optional)(Et([mt(\"horizontal\"),mt(\"vertical\")])),alignment:(0,c.optional)(Et([mt(\"start\"),mt(\"center\"),mt(\"end\"),mt(\"space-between\"),mt(\"space-around\")]))}),Ze=Me(\"Copyable\",{value:(0,c.string)(),sensitive:(0,c.optional)((0,c.boolean)())}),Qe=Me(\"Divider\"),tr=Me(\"Value\",{value:(0,c.string)(),extra:(0,c.string)()}),er=Me(\"Heading\",{children:Ue}),rr=Me(\"Image\",{src:(0,c.string)(),alt:(0,c.optional)((0,c.string)())}),nr=Me(\"Link\",{href:(0,c.string)(),children:je((0,c.nullable)(Et([ze,(0,c.string)()])))}),ir=Me(\"Text\",{children:je((0,c.nullable)(Et([(0,c.string)(),We,Xe,nr])))}),or=Me(\"Row\",{label:(0,c.string)(),children:Et([Je,rr,ir,tr]),variant:(0,c.optional)(Et([mt(\"default\"),mt(\"warning\"),mt(\"error\")]))}),sr=Me(\"Spinner\"),ar=Et([De,$e,qe,We,Xe,Je,Ye,Ze,Qe,er,rr,nr,or,sr,ir,Ve]),cr=ar,ur=(Et([De,$e,Ge,qe,We,Xe,Je,Ye,Ze,Qe,er,rr,nr,or,sr,ir,Ve,Ke,tr]),(0,c.record)((0,c.string)(),(0,c.nullable)((0,c.string)())));(0,c.record)((0,c.string)(),(0,c.union)([ur,(0,c.nullable)((0,c.string)())])),(0,c.union)([we,cr]),(0,c.record)((0,c.string)(),w);!function(t){t.Mainnet=\"bip122:000000000019d6689c085ae165831e93\",t.Testnet=\"bip122:000000000933ea01ad0ee984209779ba\"}(He||(He={})),function(t){t.Btc=\"bip122:000000000019d6689c085ae165831e93/slip44:0\",t.TBtc=\"bip122:000000000933ea01ad0ee984209779ba/slip44:0\"}(Fe||(Fe={}));const fr={onChainService:{dataClient:{options:{apiKey:\"A___agdRpkDchYPuxqWhXfFidteuWj4m\"}}},wallet:{defaultAccountIndex:0,defaultAccountType:\"bip122:p2wpkh\"},avaliableNetworks:Object.values(He),avaliableAssets:Object.values(Fe),unit:\"BTC\",explorer:{[He.Mainnet]:\"https://blockstream.info/address/${address}\",[He.Testnet]:\"https://blockstream.info/testnet/address/${address}\"},logLevel:\"6\"},hr={randomUUID:\"undefined\"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let lr;const pr=new Uint8Array(16);function dr(){if(!lr&&(lr=\"undefined\"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!lr))throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");return lr(pr)}const yr=[];for(let t=0;t<256;++t)yr.push((t+256).toString(16).slice(1));function gr(t,e=0){return yr[t[e+0]]+yr[t[e+1]]+yr[t[e+2]]+yr[t[e+3]]+\"-\"+yr[t[e+4]]+yr[t[e+5]]+\"-\"+yr[t[e+6]]+yr[t[e+7]]+\"-\"+yr[t[e+8]]+yr[t[e+9]]+\"-\"+yr[t[e+10]]+yr[t[e+11]]+yr[t[e+12]]+yr[t[e+13]]+yr[t[e+14]]+yr[t[e+15]]}const br=function(t,e,r){if(hr.randomUUID&&!e&&!t)return hr.randomUUID();const n=(t=t||{}).random||(t.rng||dr)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(let t=0;t<16;++t)e[r+t]=n[t];return e}return gr(n)};class wr extends Error{name;constructor(t){super(t),Object.defineProperty(this,\"name\",{value:new.target.name,enumerable:!1,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace(this,this.constructor)}}function mr(t,e){return t instanceof e?t:new e(t.message)}function vr(t){return[dt,Ot,Mt,kt,Ot,Pt,Rt,Bt,Ct,Nt,Lt,Ut,jt,St,At,It,Tt,xt].some((e=>t instanceof e))}var Er=r(1048);function _r(t,e=!0){try{return Er.Buffer.from(e?function(t){return t.startsWith(\"0x\")?t.substring(2):t}(t):t,\"hex\")}catch(t){throw new Error(\"Unable to convert hex string to buffer\")}}function Sr(t,e){try{return t.toString(e)}catch(t){throw new Error(\"Unable to convert buffer to string\")}}const Ar=(0,c.enums)(fr.avaliableAssets),Ir=(0,c.enums)(fr.avaliableNetworks),Tr=(0,c.pattern)((0,c.string)(),/^(?!0\\d)(\\d+(\\.\\d+)?)$/u),xr=(new Error(\"timeout while waiting for mutex to become available\"),new Error(\"mutex already locked\"),new Error(\"request for lock canceled\"));var Or=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};class kr{constructor(t,e=xr){if(this._maxConcurrency=t,this._cancelError=e,this._queue=[],this._waiters=[],t<=0)throw new Error(\"semaphore must be initialized to a positive value\");this._value=t}acquire(){const t=this.isLocked(),e=new Promise(((t,e)=>this._queue.push({resolve:t,reject:e})));return t||this._dispatch(),e}runExclusive(t){return Or(this,void 0,void 0,(function*(){const[e,r]=yield this.acquire();try{return yield t(e)}finally{r()}}))}waitForUnlock(){return Or(this,void 0,void 0,(function*(){if(!this.isLocked())return Promise.resolve();return new Promise((t=>this._waiters.push({resolve:t})))}))}isLocked(){return this._value<=0}release(){if(this._maxConcurrency>1)throw new Error(\"this method is unavailable on semaphores with concurrency > 1; use the scoped release returned by acquire instead\");if(this._currentReleaser){const t=this._currentReleaser;this._currentReleaser=void 0,t()}}cancel(){this._queue.forEach((t=>t.reject(this._cancelError))),this._queue=[]}_dispatch(){const t=this._queue.shift();if(!t)return;let e=!1;this._currentReleaser=()=>{e||(e=!0,this._value++,this._resolveWaiters(),this._dispatch())},t.resolve([this._value--,this._currentReleaser])}_resolveWaiters(){this._waiters.forEach((t=>t.resolve())),this._waiters=[]}}var Pr=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};class Rr{constructor(t){this._semaphore=new kr(1,t)}acquire(){return Pr(this,void 0,void 0,(function*(){const[,t]=yield this._semaphore.acquire();return t}))}runExclusive(t){return this._semaphore.runExclusive((()=>t()))}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Br=new Rr;var Cr;!function(t){t[t.ERROR=1]=\"ERROR\",t[t.WARN=2]=\"WARN\",t[t.INFO=3]=\"INFO\",t[t.DEBUG=4]=\"DEBUG\",t[t.TRACE=5]=\"TRACE\",t[t.ALL=6]=\"ALL\",t[t.OFF=0]=\"OFF\"}(Cr||(Cr={}));const Nr=(t,...e)=>{};const Lr=new class{log;warn;error;debug;info;trace;#t=Cr.OFF;set logLevel(t){this.#t=t,this.init()}get logLevel(){return this.#t}init(){this.error=console.error.bind(console),this.warn=console.warn.bind(console),this.info=console.info.bind(console),this.debug=console.debug.bind(console),this.trace=console.trace.bind(console),this.log=console.log.bind(console),this.#t{const e=await this.get();await t(e),await this.set(e)}))}async withTransaction(t){await this.mtx.runExclusive((async()=>{if(await this.#n(),!this.#e.current||!this.#e.orgState||!this.#e.id)throw new Error(\"Failed to begin transaction\");Lr.info(`SnapStateManager.withTransaction [${this.#r}]: begin transaction`);try{await t(this.#e.current),await this.set(this.#e.current)}catch(t){throw Lr.info(`SnapStateManager.withTransaction [${this.#r}]: error : ${JSON.stringify(t.message)}`),await this.#i(),t}finally{this.#o()}}))}async commit(){if(!this.#e.current||!this.#e.orgState)throw new Error(\"Failed to commit transaction\");this.#e.hasCommited=!0,await this.set(this.#e.current)}async#n(){this.#e={id:br(),orgState:await this.get(),current:await this.get(),isRollingBack:!1,hasCommited:!1}}async#i(){try{this.#e.hasCommited&&!this.#e.isRollingBack&&this.#e.orgState&&(Lr.info(`SnapStateManager.rollback [${this.#r}]: attemp to rollback state`),this.#e.isRollingBack=!0,await this.set(this.#e.orgState))}catch(t){throw Lr.info(`SnapStateManager.rollback [${this.#r}]: error : ${JSON.stringify(t)}`),new Error(\"Failed to rollback state\")}}#o(){this.#e.orgState=void 0,this.#e.current=void 0,this.#e.id=void 0,this.#e.isRollingBack=!1,this.#e.hasCommited=!1}get#r(){return this.#e.id??\"\"}}function jr(t,e){try{(0,c.assert)(t,e)}catch(t){throw new It(t.message)}}function Mr(t,e){try{(0,c.assert)(t,e)}catch(t){throw new dt(\"Invalid Response\")}}var Hr=1e6,Fr=1e6,Dr=\"[big.js] \",$r=Dr+\"Invalid \",Kr=$r+\"decimal places\",Vr=$r+\"rounding mode\",Gr=Dr+\"Division by zero\",qr={},Wr=void 0,Xr=/^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i;function zr(t,e,r,n){var i=t.c;if(r===Wr&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(Vr);if(e<1)n=3===r&&(n||!!i[0])||0===e&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(n||i[1]!==Wr))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e=5||2===r&&(i[e]>5||5===i[e]&&(n||i[e+1]!==Wr||1&i[e-1]))||3===r&&(n||!!i[0]),i.length=e,n)for(;++i[--e]>9;)if(i[e]=0,0===e){++t.e,i.unshift(1);break}for(e=i.length;!i[--e];)i.pop()}return t}function Jr(t,e,r){var n=t.e,i=t.c.join(\"\"),o=i.length;if(e)i=i.charAt(0)+(o>1?\".\"+i.slice(1):\"\")+(n<0?\"e\":\"e+\")+n;else if(n<0){for(;++n;)i=\"0\"+i;i=\"0.\"+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+=\"0\";else n1&&(i=i.charAt(0)+\".\"+i.slice(1));return t.s<0&&r?\"-\"+i:i}qr.abs=function(){var t=new this.constructor(this);return t.s=1,t},qr.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,s=t.s,a=r.e,c=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(e=o<0,a!=c)return a>c^e?1:-1;for(s=(a=n.length)<(c=i.length)?a:c,o=-1;++oi[o]^e?1:-1;return a==c?0:a>c^e?1:-1},qr.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,o=e.s==t.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>Hr)throw Error(Kr);if(!i[0])throw Error(Gr);if(!n[0])return t.s=o,t.c=[t.e=0],t;var a,c,u,f,h,l=i.slice(),p=a=i.length,d=n.length,y=n.slice(0,a),g=y.length,b=t,w=b.c=[],m=0,v=s+(b.e=e.e-t.e)+1;for(b.s=o,o=v<0?0:v,l.unshift(0);g++g?1:-1;else for(h=-1,f=0;++hy[h]?1:-1;break}if(!(f<0))break;for(c=g==a?i:l;g;){if(y[--g]v&&zr(b,v,r.RM,y[0]!==Wr),b},qr.eq=function(t){return 0===this.cmp(t)},qr.gt=function(t){return this.cmp(t)>0},qr.gte=function(t){return this.cmp(t)>-1},qr.lt=function(t){return this.cmp(t)<0},qr.lte=function(t){return this.cmp(t)<1},qr.minus=qr.sub=function(t){var e,r,n,i,o=this,s=o.constructor,a=o.s,c=(t=new s(t)).s;if(a!=c)return t.s=-c,o.plus(t);var u=o.c.slice(),f=o.e,h=t.c,l=t.e;if(!u[0]||!h[0])return h[0]?t.s=-c:u[0]?t=new s(o):t.s=1,t;if(a=f-l){for((i=a<0)?(a=-a,n=u):(l=f,n=h),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(r=((i=u.length0)for(;c--;)u[e++]=0;for(c=e;r>a;){if(u[--r]0?(c=s,n=u):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-u.length<0&&(n=u,u=a,a=n),e=u.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+u[e]+r)/10|0;for(r&&(a.unshift(r),++c),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=c,t},qr.pow=function(t){var e=this,r=new e.constructor(\"1\"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>Fr)throw Error($r+\"exponent\");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},qr.prec=function(t,e){if(t!==~~t||t<1||t>Hr)throw Error($r+\"precision\");return zr(new this.constructor(this),t,e)},qr.round=function(t,e){if(t===Wr)t=0;else if(t!==~~t||t<-Hr||t>Hr)throw Error(Kr);return zr(new this.constructor(this),t+this.e+1,e)},qr.sqrt=function(){var t,e,r,n=this,i=n.constructor,o=n.s,s=n.e,a=new i(\"0.5\");if(!n.c[0])return new i(n);if(o<0)throw Error(Dr+\"No square root\");0===(o=Math.sqrt(n+\"\"))||o===1/0?((e=n.c.join(\"\")).length+s&1||(e+=\"0\"),s=((s+1)/2|0)-(s<0||1&s),t=new i(((o=Math.sqrt(e))==1/0?\"5e\":(o=o.toExponential()).slice(0,o.indexOf(\"e\")+1))+s)):t=new i(o+\"\"),s=t.e+(i.DP+=4);do{r=t,t=a.times(r.plus(n.div(r)))}while(r.c.slice(0,s).join(\"\")!==t.c.slice(0,s).join(\"\"));return zr(t,(i.DP-=4)+t.e+1,i.RM)},qr.times=qr.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,s=i.length,a=o.length,c=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=c+u,sc;)a=e[u]+o[c]*i[u-c-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},qr.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==Wr){if(t!==~~t||t<0||t>Hr)throw Error(Kr);for(r=zr(new r.constructor(r),++t,e);r.c.lengthHr)throw Error(Kr);for(t=t+(r=zr(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length=e.PE,!!t.c[0])},qr.toNumber=function(){var t=Number(Jr(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(Dr+\"Imprecise conversion\");return t},qr.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==Wr){if(t!==~~t||t<1||t>Hr)throw Error($r+\"precision\");for(r=zr(new n(r),t,e);r.c.length=n.PE,!!i)},qr.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(Dr+\"valueOf disallowed\");return Jr(t,t.e<=e.NE||t.e>=e.PE,!0)};var Yr=function t(){function e(r){var n=this;if(!(n instanceof e))return r===Wr?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if(\"string\"!=typeof r){if(!0===e.strict&&\"bigint\"!=typeof r)throw TypeError($r+\"value\");r=0===r&&1/r<0?\"-0\":String(r)}!function(t,e){var r,n,i;if(!Xr.test(e))throw Error($r+\"number\");t.s=\"-\"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf(\".\"))>-1&&(e=e.replace(\".\",\"\"));(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length);for(i=e.length,n=0;n0&&\"0\"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=qr,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();const Zr=Yr,Qr=21e14;function tn(t,e=!1){if(\"number\"==typeof t&&!Number.isInteger(t))throw new Error(\"satsToBtc must be called on an integer number\");const r=new Zr(t).div(1e8).toFixed(8);return e?`${r} ${fr.unit}`:r}function en(t){const e=t.split(\".\");if(e.length>1&&e[1].length>8)throw new Error(\"BTC amount is out of range\");const r=new Zr(t).times(1e8);if(r.lt(0)||r.gt(Qr))throw new Error(\"BTC amount is out of range\");return BigInt(r.toFixed(0))}class rn extends wr{}class nn extends wr{}var on,sn,an,cn=r(7612);class un{_dataClient;_options;constructor(t,e){this._dataClient=t,this._options=e}get network(){return this._options.network}async getBalances(t,e){try{if(e.length>1)throw new nn(\"Only one asset is supported\");if(!new Set(Object.values(Fe)).has(e[0])||this.network===cn.o8.testnet&&e[0]!==Fe.TBtc||this.network===cn.o8.bitcoin&&e[0]!==Fe.Btc)throw new nn(\"Invalid asset\");const r=await this._dataClient.getBalances(t);return t.reduce(((t,n)=>(t.balances[n]={[e[0]]:{amount:BigInt(r[n])}},t)),{balances:{}})}catch(t){throw mr(t,nn)}}async getFeeRates(){try{const t=await this._dataClient.getFeeRates();return{fees:Object.entries(t).map((([t,e])=>({type:t,rate:BigInt(e)})))}}catch(t){throw mr(t,nn)}}async getTransactionStatus(t){try{return await this._dataClient.getTransactionStatus(t)}catch(t){throw new nn(t)}}async getDataForTransaction(t){try{return{data:{utxos:await this._dataClient.getUtxos(t)}}}catch(t){throw mr(t,nn)}}async broadcastTransaction(t){try{return{transactionId:await this._dataClient.sendTransaction(t)}}catch(t){throw mr(t,nn)}}listTransactions(){throw new Error(\"Method not implemented.\")}}!function(t){t.Fast=\"fast\",t.Medium=\"medium\",t.Slow=\"slow\"}(on||(on={})),function(t){t.Confirmed=\"confirmed\",t.Pending=\"pending\",t.Failed=\"failed\"}(sn||(sn={}));class fn{_options;constructor(t){this._options=t}get baseUrl(){switch(this._options.network){case cn.o8.bitcoin:return\"https://api.blockchair.com/bitcoin\";case cn.o8.testnet:return\"https://api.blockchair.com/bitcoin/testnet\";default:throw new Error(\"Invalid network\")}}getApiUrl(t){const e=new URL(`${this.baseUrl}${t}`);return this._options.apiKey&&e.searchParams.append(\"key\",this._options.apiKey),e.toString()}async get(t){const e=await fetch(this.getApiUrl(t),{method:\"GET\"});if(!e.ok)throw new Error(`Failed to fetch data from blockchair: ${e.statusText}`);return e.json()}async post(t,e){const r=await fetch(this.getApiUrl(t),{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(e)});if(400==r.status){const t=await r.json();throw new Error(`Failed to post data from blockchair: ${t.context.error}`)}if(!r.ok)throw new Error(`Failed to post data from blockchair: ${r.statusText}`);return r.json()}async getTxDashboardData(t){try{Lr.info(\"[BlockChairClient.getTxDashboardData] start:\");const e=await this.get(`/dashboards/transaction/${t}`);return Lr.info(`[BlockChairClient.getTxDashboardData] response: ${JSON.stringify(e)}`),e}catch(t){throw Lr.info(`[BlockChairClient.getTxDashboardData] error: ${t.message}`),mr(t,rn)}}async getBalances(t){try{Lr.info(`[BlockChairClient.getBalance] start: { addresses : ${JSON.stringify(t)} }`);const e=await this.get(`/addresses/balances?addresses=${t.join(\",\")}`);return Lr.info(`[BlockChairClient.getBalance] response: ${JSON.stringify(e)}`),t.reduce(((t,r)=>(t[r]=e.data[r]??0,t)),{})}catch(t){throw Lr.info(`[BlockChairClient.getBalance] error: ${t.message}`),mr(t,rn)}}async getUtxos(t,e){try{let r=!0,n=0;const i=1e3,o=[];for(;r;){let s=`/dashboards/address/${t}?limit=0,${i}&offset=0,${n}`;e||(s+=\"&state=latest\");const a=await this.get(s);if(Lr.info(`[BlockChairClient.getUtxos] response: ${JSON.stringify(a)}`),!Object.prototype.hasOwnProperty.call(a.data,t))throw new Error(\"Data not avaiable\");a.data[t].utxo.forEach((t=>{o.push({block:t.block_id,txHash:t.transaction_hash,index:t.index,value:t.value})})),n+=1,a.data[t].utxo.lengththis.validateInputs(t,e,r))))throw new dn(\"Invalid signature to sign the PSBT's inputs\")}catch(t){throw mr(t,dn)}}finalize(){try{this._psbt.finalizeAllInputs();const t=this._psbt.extractTransaction().toHex();if(this._psbt.extractTransaction().weight()>4e5)throw new dn(\"Transaction is too large\");return t}catch(t){throw mr(t,dn)}}validateInputs(t,e,r){return xn.fromPublicKey(t).verify(e,r)}}class kn{publicKey;fingerprint;_node;constructor(t,e){this._node=t,this.publicKey=this._node.publicKey,this.fingerprint=e??this._node.fingerprint}derivePath(t){try{let e=t.split(\"/\");\"m\"===e[0]&&(e=e.slice(1));const r=e.reduce(((t,e)=>{let r;return e.endsWith(\"'\")?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this._node);return new kn(r,this.fingerprint)}catch(t){throw new Error(\"Unable to derive path\")}}async sign(t){return this._node.sign(t)}verify(t,e){return this._node.verify(t,e)}}class Pn{sender;_change;_recipients;_outputTotal;_txFee;_feeRate;constructor(t,e){this.feeRate=e,this.txFee=0,this.sender=t,this._recipients=[],this._outputTotal=BigInt(0)}addRecipients(t){for(const e of t)this.addRecipient(e)}addRecipient(t){this._outputTotal+=t.bigIntValue,this._recipients.push({address:t.address,value:t.bigIntValue})}addChange(t){this._change={address:t.address,value:t.bigIntValue}}set txFee(t){this._txFee=\"number\"==typeof t?BigInt(t):t}get txFee(){return this._txFee}set feeRate(t){this._feeRate=\"number\"==typeof t?BigInt(t):t}get feeRate(){return this._feeRate}get total(){return this._outputTotal+(this.change?BigInt(this.change.value):BigInt(0))+this.txFee}get recipients(){return this._recipients}get change(){return this._change}}class Rn{_value;script;txHash;index;block;constructor(t,e){this.script=e,this._value=BigInt(t.value),this.index=t.index,this.txHash=t.txHash,this.block=t.block}get value(){return Number(this._value)}get bigIntValue(){return this._value}}class Bn{_value;script;address;constructor(t,e,r){this.value=t,this.address=e,this.script=r}get value(){return Number(this._value)}set value(t){this._value=\"number\"==typeof t?BigInt(t):t}get bigIntValue(){return this._value}}class Cn{_deriver;_network;constructor(t,e){this._deriver=t,this._network=e}async unlock(t,e){try{const r=this.getAccountCtor(e??an.P2wpkh),n=await this._deriver.getRoot(r.path),i=await this._deriver.getChild(n,t),o=[\"m\",\"0'\",\"0\",`${t}`].join(\"/\");return new r(Sr(n.fingerprint,\"hex\"),t,o,Sr(i.publicKey,\"hex\"),this._network,r.scriptType,`bip122:${r.scriptType.toLowerCase()}`,this.getHdSigner(n))}catch(t){throw mr(t,ln)}}async createTransaction(t,e,r){const n=t.script,{scriptType:i}=t,o=r.utxos.map((t=>new Rn(t,n))),s=e.map((t=>{if(bn(t.value,i))throw new pn(\"Transaction amount too small\");const e=function(t,e){try{return cn.hl.toOutputScript(t,e)}catch(t){throw new Error(\"Destination address has no matching Script\")}}(t.address,this._network);return new Bn(t.value,t.address,e)})),a=Math.max(1,r.fee),c=new Tn(a),u=new Bn(0,t.address,n),f=c.selectCoins(o,s,u),h=new On(this._network);h.addInputs(f.inputs,r.replaceable,t.hdPath,_r(t.pubkey,!1),_r(t.mfp,!1));const l=new Pn(t.address,a);for(const t of f.outputs)h.addOutput(t),l.addRecipient(t);f.change&&(bn(u.value,i)?Lr.warn(\"[BtcWallet.createTransaction] Change is too small, adding to fees\"):(h.addOutput(f.change),l.addChange(f.change)));const p=await h.signDummy(t.signer);return l.txFee=p.getFee(),{tx:h.toBase64(),txInfo:l}}async signTransaction(t,e){const r=On.fromBase64(this._network,e);return await r.signNVerify(t),r.finalize()}getHdSigner(t){return new kn(t,t.fingerprint)}getAccountCtor(t){let e=t;switch(t.includes(\"bip122:\")&&(e=t.split(\":\")[1]),e.toLowerCase()){case an.P2wpkh.toLowerCase():return mn;case an.P2shP2wkh.toLowerCase():return vn;default:throw new ln(\"Invalid script type\")}}}class Nn{static createOnChainServiceProvider(t){var e,r;const n=gn(t),i=new fn({network:n,apiKey:null===(r=fr.onChainService.dataClient.options)||void 0===r||null===(e=r.apiKey)||void 0===e?void 0:e.toString()});return new un(i,{network:n})}static createWallet(t){const e=gn(t);return new Cn(new Sn(e),e)}}class Ln extends Ur{async get(){return super.get().then((t=>(t||(t={walletIds:[],wallets:{}}),t.walletIds||(t.walletIds=[]),t.wallets||(t.wallets={}),t)))}async listAccounts(){try{const t=await this.get();return t.walletIds.map((e=>t.wallets[e].account))}catch(t){throw mr(t,Error)}}async addWallet(t){try{await this.update((async e=>{const{id:r,address:n}=t.account;if(this.isAccountExist(e,r)||this.getAccountByAddress(e,n))throw new Error(`Account address ${n} already exists`);e.wallets[r]=t,e.walletIds.push(r)}))}catch(t){throw mr(t,Error)}}async updateAccount(t){try{await this.update((async e=>{if(!this.isAccountExist(e,t.id))throw new Error(`Account id ${t.id} does not exist`);const r=e.wallets[t.id].account;if(r.address.toLowerCase()!==t.address.toLowerCase()||r.type!==t.type)throw new Error(\"Account address or type is immutable\");e.wallets[t.id].account=t}))}catch(t){throw mr(t,Error)}}async removeAccounts(t){try{await this.update((async e=>{const r=new Set;for(const n of t){if(!this.isAccountExist(e,n))throw new Error(`Account id ${n} does not exist`);r.add(n)}r.forEach((t=>delete e.wallets[t])),e.walletIds=e.walletIds.filter((t=>!r.has(t)))}))}catch(t){throw mr(t,Error)}}async getAccount(t){try{var e;return(null===(e=(await this.get()).wallets[t])||void 0===e?void 0:e.account)??null}catch(t){throw mr(t,Error)}}async getWallet(t){try{return(await this.get()).wallets[t]??null}catch(t){throw mr(t,Error)}}getAccountByAddress(t,e){var r;return(null===(r=Object.values(t.wallets).find((t=>t.account.address.toString()===e.toLowerCase())))||void 0===r?void 0:r.account)??null}isAccountExist(t,e){return Object.prototype.hasOwnProperty.call(t.wallets,e)}}(0,c.object)({scope:Ir});const Un=(0,c.object)({assets:(0,c.array)(Ar),scope:Ir});(0,c.object)({assets:(0,c.record)(Ar,(0,c.object)({amount:Tr,unit:(0,c.enums)([fr.unit])}))});const jn=(0,c.object)({transactionId:(0,c.string)(),scope:Ir}),Mn=(0,c.object)({status:(0,c.enums)(Object.values(sn))});const Hn=(0,c.refine)((0,c.record)(t.BtcP2wpkhAddressStruct,(0,c.string)()),\"TransactionAmountStuct\",(t=>{if(0===Object.entries(t).length)return\"Transaction must have at least one recipient\";for(const e of Object.values(t)){const t=parseFloat(e);if(Number.isNaN(t)||t<=0||!Number.isFinite(t))return\"Invalid amount for send\";try{en(e)}catch(t){return\"Invalid amount for send\"}}return!0})),Fn=(0,c.object)({amounts:Hn,comment:(0,c.string)(),subtractFeeFrom:(0,c.array)(t.BtcP2wpkhAddressStruct),replaceable:(0,c.boolean)(),dryrun:(0,c.optional)((0,c.boolean)()),scope:Ir}),Dn=(0,c.object)({txId:(0,c.nonempty)((0,c.string)()),txHash:(0,c.optional)((0,c.string)())});async function $n(t,e){try{jr(e,Fn);const{dryrun:r,scope:n}=e,i=Nn.createOnChainServiceProvider(n),o=Nn.createWallet(n),s=await i.getFeeRates();if(0===s.fees.length)throw new Error(\"No fee rates available\");const a=Math.max(Number(s.fees[s.fees.length-1].rate),1),c=Object.entries(e.amounts).map((([t,e])=>({address:t,value:en(e)}))),u=await i.getDataForTransaction(t.address),{tx:f,txInfo:h}=await o.createTransaction(t,c,{utxos:u.data.utxos,fee:a,subtractFeeFrom:e.subtractFeeFrom,replaceable:e.replaceable});if(!await async function(t,e,r){const n=\"Send Request\",i=\"Review the request before proceeding. Once the transaction is made, it's irreversible.\",o=\"Recipient\",s=\"Amount\",a=\"Comment\",c=\"Network fee\",u=\"Total\",f=\"Requested by\",h=[be([zt(n),ue(i),pe(f,ue(\"[portfolio.metamask.io](https://portfolio.metamask.io/)\"))]),Wt()],l=t.recipients.length+(t.change?1:0)>1;let p=0;const d=t=>{const e=[];e.push(pe(l?`${o} ${p+1}`:o,ue(`[${function(t){return function(t,e,r,n=\"...\"){return t?`${t.substring(0,e)}${n}${t.substring(t.length-r)}`:t}(t,5,3)}(t.address)}](${function(t,e){switch(e){case He.Mainnet:return fr.explorer[He.Mainnet].replace(\"${address}\",t);case He.Testnet:return fr.explorer[He.Testnet].replace(\"${address}\",t);default:throw new Error(\"Invalid Chain ID\")}}(t.address,r)})`))),e.push(pe(s,ue(tn(t.value,!0),!1))),p+=1,h.push(be(e)),h.push(Wt())};t.recipients.forEach(d),t.change&&[t.change].forEach(d);const y=[];e.trim().length>0&&y.push(pe(a,ue(e.trim(),!1)));return y.push(pe(c,ue(`${tn(t.txFee,!0)}`,!1))),y.push(pe(u,ue(`${tn(t.total,!0)}`,!1))),h.push(be(y)),await async function(t){return snap.request({method:\"snap_dialog\",params:{type:\"confirmation\",content:be(t)}})}(h)}(h,e.comment,n))throw new Mt;const l=await o.signTransaction(t.signer,f);if(r)return{txId:\"\",txHash:l};const p={txId:(await i.broadcastTransaction(l)).transactionId};return Mr(p,Dn),p}catch(t){if(Lr.error(\"Failed to send the transaction\",t),vr(t))throw t;if(t instanceof pn)throw t;throw new Error(\"Failed to send the transaction\")}}const Kn=(0,c.object)({scope:Ir});class Vn{_stateMgr;_options;_methods=[\"btc_sendmany\"];constructor(t,e){this._stateMgr=t,this._options=e}async listAccounts(){try{return await this._stateMgr.listAccounts()}catch(t){throw new Error(t)}}async getAccount(t){try{return await this._stateMgr.getAccount(t)??void 0}catch(t){throw new Error(t)}}async createAccount(e){try{(0,c.assert)(e,Kn);const r=this.getBtcWallet(e.scope),n=this._options.defaultIndex,i=fr.wallet.defaultAccountType,o=await this.discoverAccount(r,n,i);Lr.info(`[BtcKeyring.createAccount] Account unlocked: ${o.address}`);const s=this.newKeyringAccount(o,{scope:e.scope,index:n});return Lr.info(`[BtcKeyring.createAccount] Keyring account data: ${JSON.stringify(s)}`),await this._stateMgr.withTransaction((async()=>{await this._stateMgr.addWallet({account:s,hdPath:o.hdPath,index:o.index,scope:e.scope}),await this.#c(t.KeyringEvent.AccountCreated,{account:s})})),s}catch(t){if(Lr.info(`[BtcKeyring.createAccount] Error: ${t.message}`),t instanceof c.StructError)throw new Error(\"Invalid params to create an account\");throw new Error(t)}}async filterAccountChains(t,e){throw new Error(\"Method not implemented.\")}async updateAccount(e){try{await this._stateMgr.withTransaction((async()=>{await this._stateMgr.updateAccount(e),await this.#c(t.KeyringEvent.AccountUpdated,{account:e})}))}catch(t){throw Lr.info(`[BtcKeyring.updateAccount] Error: ${t.message}`),new Error(t)}}async deleteAccount(e){try{await this._stateMgr.withTransaction((async()=>{await this._stateMgr.removeAccounts([e]),await this.#c(t.KeyringEvent.AccountDeleted,{id:e})}))}catch(t){throw Lr.info(`[BtcKeyring.deleteAccount] Error: ${t.message}`),new Error(t)}}async submitRequest(t){return{pending:!1,result:await this.handleSubmitRequest(t)}}async handleSubmitRequest(t){const{scope:e,account:r}=t,{method:n,params:i}=t.request,o=await this.getWalletData(r);if(o.scope!==e)throw new Error(\"Account's scope does not match with the request's scope\");const s=this.getBtcWallet(o.scope),a=await this.discoverAccount(s,o.index,o.account.type);if(this.verifyIfAccountValid(a,o.account),\"btc_sendmany\"===n)return await $n(a,{...i,scope:o.scope});throw new Ot(n)}async#c(e,r){this._options.emitEvents&&await(0,t.emitSnapKeyringEvent)(snap,e,r)}async getAccountBalances(t,e){try{const r=await this.getWalletData(t),n=this.getBtcWallet(r.scope),i=await this.discoverAccount(n,r.index,r.account.type);return this.verifyIfAccountValid(i,r.account),await async function(t,e){try{jr(e,Un),(0,c.assert)(e,Un);const{assets:r,scope:n}=e,i=Nn.createOnChainServiceProvider(n),o=[t.address],s=new Set(o),a=new Set(r),u=await i.getBalances(o,r),f=Object.entries(u.balances),h=new Map;for(const[t,e]of f)if(s.has(t))for(const t in e){if(!a.has(t))continue;const{amount:r}=e[t];let n=h.get(t);n&&(n+=r),h.set(t,n??r)}const l=Object.fromEntries([...h.entries()].map((([t,e])=>[t,{amount:tn(e),unit:fr.unit}])));return Mr(e,Un),l}catch(t){if(Lr.error(\"Failed to get balances\",t),vr(t))throw t;throw new Error(\"Fail to get the balances\")}}(i,{assets:e,scope:r.scope})}catch(t){throw Lr.info(`[BtcKeyring.getAccountBalances] Error: ${t.message}`),new Error(t)}}async getWalletData(t){const e=await this._stateMgr.getWallet(t);if(!e)throw new Error(\"Account not found\");return e}getBtcWallet(t){return Nn.createWallet(t)}async discoverAccount(t,e,r){return await t.unlock(e,r)}verifyIfAccountValid(t,e){if(!t||t.address!==e.address)throw new Error(\"Account not found\")}newKeyringAccount(t,e){return{type:t.type,id:br(),address:t.address,options:{...e},methods:this._methods}}}var Gn;!function(t){t.GetTransactionStatus=\"chain_getTransactionStatus\",t.CreateAccount=\"chain_createAccount\"}(Gn||(Gn={}));const qn=new Set([t.KeyringRpcMethod.ListAccounts,t.KeyringRpcMethod.GetAccount,t.KeyringRpcMethod.CreateAccount,t.KeyringRpcMethod.FilterAccountChains,t.KeyringRpcMethod.ListRequests,t.KeyringRpcMethod.GetRequest,t.KeyringRpcMethod.ApproveRequest,t.KeyringRpcMethod.RejectRequest,t.KeyringRpcMethod.SubmitRequest,t.KeyringRpcMethod.GetAccountBalances,Gn.GetTransactionStatus]),Wn=new Set([t.KeyringRpcMethod.ListAccounts,t.KeyringRpcMethod.GetAccount,t.KeyringRpcMethod.CreateAccount,t.KeyringRpcMethod.FilterAccountChains,t.KeyringRpcMethod.UpdateAccount,t.KeyringRpcMethod.DeleteAccount,t.KeyringRpcMethod.ListRequests,t.KeyringRpcMethod.GetRequest,t.KeyringRpcMethod.ApproveRequest,t.KeyringRpcMethod.RejectRequest,t.KeyringRpcMethod.SubmitRequest,t.KeyringRpcMethod.GetAccountBalances,Gn.GetTransactionStatus]),Xn=[\"https://portfolio.metamask.io\",\"https://portfolio-builds.metafi-dev.codefi.network\",\"https://dev.portfolio.metamask.io\",\"https://ramps-dev.portfolio.metamask.io\"],zn=new Map([]);for(const t of Xn)zn.set(t,qn);zn.set(\"metamask\",Wn),zn.set(\"http://localhost:3000\",new Set([...qn,Gn.CreateAccount]));const Jn=(t,e)=>{var r;if(!t)throw new Ut(\"Origin not found\");if(!(null===(r=zn.get(t))||void 0===r?void 0:r.has(e)))throw new Ut(\"Permission denied\")},Yn=async({origin:t,request:e})=>{Lr.logLevel=parseInt(fr.logLevel,10);try{const{method:r}=e;switch(Jn(t,r),r){case Gn.CreateAccount:return await async function(t){const e=new Vn(new Ln,{defaultIndex:fr.wallet.defaultAccountIndex,emitEvents:!1});return await e.createAccount({scope:t.scope})}(e.params);case Gn.GetTransactionStatus:return await async function(t){try{jr(t,jn);const{scope:e,transactionId:r}=t,n=Nn.createOnChainServiceProvider(e),i={status:(await n.getTransactionStatus(r)).status};return Mr(i,Mn),i}catch(t){if(Lr.error(\"Failed to get transaction status\",t),vr(t))throw t;throw new Error(\"Fail to get the transaction status\")}}(e.params);default:throw new Ot(r)}}catch(t){let e=t;throw vr(t)||(e=new dt(t)),Lr.error(`onRpcRequest error: ${JSON.stringify(e.toJSON(),null,2)}`),e}},Zn=async({origin:e,request:r})=>{Lr.logLevel=parseInt(fr.logLevel,10);try{Jn(e,r.method);const n=new Vn(new Ln,{defaultIndex:fr.wallet.defaultAccountIndex,emitEvents:!0});return await(0,t.handleKeyringRequest)(n,r)}catch(t){let e=t;throw vr(t)||(e=new dt(t)),Lr.error(`onKeyringRequest error: ${JSON.stringify(e.toJSON(),null,2)}`),e}}})();var i=exports;for(var o in n)i[o]=n[o];n.__esModule&&Object.defineProperty(i,\"__esModule\",{value:!0})})();"}],"removable":false} \ No newline at end of file diff --git a/app/scripts/snaps/preinstalled-snaps.ts b/app/scripts/snaps/preinstalled-snaps.ts index 0a014c350c21..bc3bbab76880 100644 --- a/app/scripts/snaps/preinstalled-snaps.ts +++ b/app/scripts/snaps/preinstalled-snaps.ts @@ -1,8 +1,14 @@ import type { PreinstalledSnap } from '@metamask/snaps-controllers'; import MessageSigningSnap from '@metamask/message-signing-snap/dist/preinstalled-snap.json'; +///: BEGIN:ONLY_INCLUDE_IF(build-flask) +import BitcoinManagerSnap from './bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json'; +///: END:ONLY_INCLUDE_IF const PREINSTALLED_SNAPS: readonly PreinstalledSnap[] = Object.freeze([ MessageSigningSnap as PreinstalledSnap, + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) + BitcoinManagerSnap as PreinstalledSnap, + ///: END:ONLY_INCLUDE_IF ]); export default PREINSTALLED_SNAPS; From 11edb0307bdf8778029ae97bfdb25e5391cd638e Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 11:27:32 +0200 Subject: [PATCH 04/75] refactor(btc): only add btc account menu entry for flask --- .../account-list-menu/account-list-menu.js | 80 +++++++++++-------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index 91807d53ba1a..f50d0b0f3a12 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -22,7 +22,9 @@ import { CreateEthAccount, ImportAccount, AccountListItemMenuTypes, + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) CreateBtcAccount, + ///: END:ONLY_INCLUDE_IF } from '..'; import { AlignItems, @@ -69,8 +71,10 @@ const ACTION_MODES = { MENU: 'menu', // Displays the add account form controls ADD: 'add', + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) // Displays the add account form controls (for bitcoin account) ADD_BITCOIN: 'add-bitcoin', + ///: END:ONLY_INCLUDE_IF // Displays the import account form controls IMPORT: 'import', }; @@ -85,7 +89,9 @@ const ACTION_MODES = { export const getActionTitle = (t, actionMode) => { switch (actionMode) { case ACTION_MODES.ADD: + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) case ACTION_MODES.ADD_BITCOIN: + ///: END:ONLY_INCLUDE_IF case ACTION_MODES.MENU: return t('addAccount'); case ACTION_MODES.IMPORT: @@ -198,19 +204,23 @@ export const AccountListMenu = ({ /> ) : null} - {actionMode === ACTION_MODES.ADD_BITCOIN ? ( - - { - if (confirmed) { - onClose(); - } else { - setActionMode(ACTION_MODES.LIST); - } - }} - /> - - ) : null} + { + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) + actionMode === ACTION_MODES.ADD_BITCOIN ? ( + + { + if (confirmed) { + onClose(); + } else { + setActionMode(ACTION_MODES.LIST); + } + }} + /> + + ) : null + ///: END:ONLY_INCLUDE_IF + } {actionMode === ACTION_MODES.IMPORT ? ( - - { - trackEvent({ - category: MetaMetricsEventCategory.Navigation, - event: MetaMetricsEventName.AccountAddSelected, - properties: { - account_type: MetaMetricsEventAccountType.Default, - location: 'Main Menu', - }, - }); - setActionMode(ACTION_MODES.ADD_BITCOIN); - }} - data-testid="multichain-account-menu-popover-add-account" - > - {t('addNewBitcoinAccount')} - - + { + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) + + { + trackEvent({ + category: MetaMetricsEventCategory.Navigation, + event: MetaMetricsEventName.AccountAddSelected, + properties: { + account_type: MetaMetricsEventAccountType.Default, + location: 'Main Menu', + }, + }); + setActionMode(ACTION_MODES.ADD_BITCOIN); + }} + data-testid="multichain-account-menu-popover-add-account" + > + {t('addNewBitcoinAccount')} + + + ///: END:ONLY_INCLUDE_IF + } Date: Tue, 2 Jul 2024 11:33:05 +0200 Subject: [PATCH 05/75] chore: ignore prettier for app/scripts/snaps/*.json --- .prettierignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierignore b/.prettierignore index e70feef786f9..228f246bc4d0 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,7 @@ dist/**/* builds/**/* test-*/**/* app/vendor/** +app/scripts/snaps/*.json .nyc_output/**/* test/e2e/send-eth-with-private-key-test/**/* *.scss From 2ab28e7492321d33a80221be3ef92b1b1a6ce5e7 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 11:43:30 +0200 Subject: [PATCH 06/75] chore: lint --- ui/components/multichain/account-list-menu/account-list-menu.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index f50d0b0f3a12..48ff055cdd58 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -89,8 +89,10 @@ const ACTION_MODES = { export const getActionTitle = (t, actionMode) => { switch (actionMode) { case ACTION_MODES.ADD: + return t('addAccount'); ///: BEGIN:ONLY_INCLUDE_IF(build-flask) case ACTION_MODES.ADD_BITCOIN: + return t('addAccount'); ///: END:ONLY_INCLUDE_IF case ACTION_MODES.MENU: return t('addAccount'); From f73c4675276b978e106d3ac782fb09d3dfbe1329 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 12:13:54 +0200 Subject: [PATCH 07/75] fix(storybook): fix title for Create{Btc,Eth}Account --- .../multichain/create-btc-account/create-btc-account.stories.js | 2 +- .../multichain/create-eth-account/create-eth-account.stories.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/components/multichain/create-btc-account/create-btc-account.stories.js b/ui/components/multichain/create-btc-account/create-btc-account.stories.js index 70e185b1e503..71c537420eed 100644 --- a/ui/components/multichain/create-btc-account/create-btc-account.stories.js +++ b/ui/components/multichain/create-btc-account/create-btc-account.stories.js @@ -2,7 +2,7 @@ import React from 'react'; import { CreateBtcAccount } from '.'; export default { - title: 'Components/Multichain/CreateAccount', + title: 'Components/Multichain/CreateBtcAccount', component: CreateBtcAccount, }; diff --git a/ui/components/multichain/create-eth-account/create-eth-account.stories.js b/ui/components/multichain/create-eth-account/create-eth-account.stories.js index 992fc33eda3a..255f34368cc0 100644 --- a/ui/components/multichain/create-eth-account/create-eth-account.stories.js +++ b/ui/components/multichain/create-eth-account/create-eth-account.stories.js @@ -2,7 +2,7 @@ import React from 'react'; import { CreateEthAccount } from '.'; export default { - title: 'Components/Multichain/CreateAccount', + title: 'Components/Multichain/CreateEthAccount', component: CreateEthAccount, }; From afc2d35f0e3a216d396ff2b0457654e26a6226a5 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 12:22:26 +0200 Subject: [PATCH 08/75] refactor: use new addAccount value everywhere --- test/e2e/accounts/snap-account-settings.spec.ts | 2 +- test/e2e/tests/account/import-flow.spec.js | 2 +- test/e2e/tests/tokens/nft/import-nft.spec.js | 2 +- .../incoming-transactions/receive native token.csv | 2 +- .../multichain/account-list-menu/account-list-menu.test.js | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/e2e/accounts/snap-account-settings.spec.ts b/test/e2e/accounts/snap-account-settings.spec.ts index 162fae62ec7e..72cfaa48b4e7 100644 --- a/test/e2e/accounts/snap-account-settings.spec.ts +++ b/test/e2e/accounts/snap-account-settings.spec.ts @@ -26,7 +26,7 @@ describe('Add snap account experimental settings', function (this: Suite) { text: 'Add account Snap', tag: 'button', }, - { findElementGuard: { text: 'Add a new account', tag: 'button' } }, // wait for the modal to appear + { findElementGuard: { text: 'Add a new Ethereum account', tag: 'button' } }, // wait for the modal to appear ); await driver.clickElement('.mm-box button[aria-label="Close"]'); diff --git a/test/e2e/tests/account/import-flow.spec.js b/test/e2e/tests/account/import-flow.spec.js index e25174cfa249..6ee6a34e50d9 100644 --- a/test/e2e/tests/account/import-flow.spec.js +++ b/test/e2e/tests/account/import-flow.spec.js @@ -101,7 +101,7 @@ describe('Import flow @no-mmi', function () { await driver.clickElement( '[data-testid="multichain-account-menu-popover-action-button"]', ); - await driver.clickElement({ text: 'Add a new account', tag: 'button' }); + await driver.clickElement({ text: 'Add a new Ethereum account', tag: 'button' }); // set account name await driver.fill('[placeholder="Account 2"]', '2nd account'); diff --git a/test/e2e/tests/tokens/nft/import-nft.spec.js b/test/e2e/tests/tokens/nft/import-nft.spec.js index ed3d9056e599..db311430b4b7 100644 --- a/test/e2e/tests/tokens/nft/import-nft.spec.js +++ b/test/e2e/tests/tokens/nft/import-nft.spec.js @@ -107,7 +107,7 @@ describe('Import NFT', function () { await driver.clickElement( '[data-testid="multichain-account-menu-popover-action-button"]', ); - await driver.clickElement({ text: 'Add a new account', tag: 'button' }); + await driver.clickElement({ text: 'Add a new Ethereum account', tag: 'button' }); // By clicking creating button without filling in the account name // the default name would be set as Account 2 diff --git a/test/manual-scenarios/incoming-transactions/receive native token.csv b/test/manual-scenarios/incoming-transactions/receive native token.csv index c02a6f17180f..a35593205cd0 100644 --- a/test/manual-scenarios/incoming-transactions/receive native token.csv +++ b/test/manual-scenarios/incoming-transactions/receive native token.csv @@ -12,7 +12,7 @@ The selected network is Sepolia.", 7,Close the settings page.,,The overview page is displayed. , 8,Open the Account menu.,,The account menu popover is shown., 9,Click the Add account button.,,The Add account popover is shown., -10,Click the Add a new account button.,,, +10,Click the Add a new Ethereum account button.,,, 11,Specify an account name and create the account.,e.g. Account 2.,The extension switches to Account 2., 12,Open the Account menu.,,The account menu popover is shown., 13,Switch back to the initial account.,e.g. Account 1.,The extension switches to Account 1., diff --git a/ui/components/multichain/account-list-menu/account-list-menu.test.js b/ui/components/multichain/account-list-menu/account-list-menu.test.js index aaeb95e05bfc..0f0eaf52000b 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.test.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.test.js @@ -211,7 +211,7 @@ describe('AccountListMenu', () => { // Click the button to ensure the options and close button display button[0].click(); - expect(getByText('Add a new account')).toBeInTheDocument(); + expect(getByText('Add a new Ethereum account')).toBeInTheDocument(); expect(getByText('Import account')).toBeInTheDocument(); expect(getByText('Add hardware wallet')).toBeInTheDocument(); const header = document.querySelector('header'); @@ -235,7 +235,7 @@ describe('AccountListMenu', () => { ); button.click(); - fireEvent.click(getByText('Add a new account')); + fireEvent.click(getByText('Add a new Ethereum account')); expect(getByText('Create')).toBeInTheDocument(); expect(getByText('Cancel')).toBeInTheDocument(); From c8ca2a775852c75d01785b17bcb3d79ed542e6d6 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 14:35:11 +0200 Subject: [PATCH 09/75] fix(btc): call onActionComplete after account has been created + renamed --- .../create-btc-account/create-btc-account.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ui/components/multichain/create-btc-account/create-btc-account.tsx b/ui/components/multichain/create-btc-account/create-btc-account.tsx index 386487d43ccd..ccca5ff0524f 100644 --- a/ui/components/multichain/create-btc-account/create-btc-account.tsx +++ b/ui/components/multichain/create-btc-account/create-btc-account.tsx @@ -19,12 +19,6 @@ export const CreateBtcAccount = ({ const dispatch = useDispatch(); const onCreateAccount = async (name: string) => { - // We finish the current action to close the popup before starting the account creation. - // - // NOTE: We asssume that at this stage, name validation has already been validated so we - // can safely proceed with the account Snap flow. - await onActionComplete(true); - // Trigger the Snap account creation flow const client = new KeyringClient(new BitcoinManagerSnapSender()); const account = await client.createAccount({ @@ -34,11 +28,12 @@ export const CreateBtcAccount = ({ // TODO: Use the new Snap account creation flow that also include account renaming // For now, we just use the AccountsController to rename the account after being created if (name) { + // NOTE: If the renaming part of this flow fail, the account might still be created, but it + // will be named according the Snap keyring naming logic (Snap Account N). dispatch(setAccountLabel(account.address, name)); } - // NOTE: If the renaming part of this flow fail, the account might still be created, but it - // will be named according the Snap keyring naming logic (Snap Account N). + await onActionComplete(true); }; const getNextAvailableAccountName = async (_accounts: InternalAccount[]) => { From ac85ac7518f7efd8ffbcb9d931eb80402b9d357c Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 14:38:17 +0200 Subject: [PATCH 10/75] test(btc): fix CreateBtcAccount tests --- .../create-btc-account.test.tsx | 57 +++++++++++++++++-- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/ui/components/multichain/create-btc-account/create-btc-account.test.tsx b/ui/components/multichain/create-btc-account/create-btc-account.test.tsx index 75fe1dbac1fc..3502e2931ad4 100644 --- a/ui/components/multichain/create-btc-account/create-btc-account.test.tsx +++ b/ui/components/multichain/create-btc-account/create-btc-account.test.tsx @@ -1,8 +1,14 @@ /* eslint-disable jest/require-top-level-describe */ import React from 'react'; -import { fireEvent, renderWithProvider } from '../../../../test/jest'; +import { JsonRpcRequest } from '@metamask/utils'; +import { + BtcAccountType, + BtcMethod, +} from '@metamask/keyring-api'; +import { fireEvent, renderWithProvider, waitFor } from '../../../../test/jest'; import configureStore from '../../../store/store'; import mockState from '../../../../test/data/mock-state.json'; +import { MultichainNetworks } from '../../../../shared/constants/multichain/networks'; import { CreateBtcAccount } from '.'; const render = (props = { onActionComplete: jest.fn() }) => { @@ -12,22 +18,55 @@ const render = (props = { onActionComplete: jest.fn() }) => { const ACCOUNT_NAME = 'Bitcoin Account'; +const mockBtcAccount = { + type: BtcAccountType.P2wpkh, + id: '8a323a0b-9ff5-4ab6-95e0-d51ec7e09763', + address: 'bc1qwl8399fz829uqvqly9tcatgrgtwp3udnhxfq4k', + options: { + scope: MultichainNetworks.BITCOIN, + index: 0, + }, + methods: [BtcMethod.SendMany], +}; +const mockBitcoinManagerSnapSend = jest.fn().mockReturnValue(mockBtcAccount); +const mockSetAccountLabel = jest.fn().mockReturnValue({ type: 'TYPE' }); + +jest.mock('../../../store/actions', () => ({ + setAccountLabel: (address: string, label: string) => + mockSetAccountLabel(address, label), +})); + +jest.mock( + '../../../../app/scripts/lib/snap-keyring/bitcoin-manager-snap', + () => ({ + BitcoinManagerSnapSender: jest.fn().mockImplementation(() => { + return { + send: (_request: JsonRpcRequest) => { + return mockBitcoinManagerSnapSend(); + }, + }; + }), + }), +); + describe('CreateBtcAccount', () => { afterEach(() => { jest.clearAllMocks(); }); - it('displays account name input and suggests name', () => { + it('displays account name input and suggests name', async () => { const { getByPlaceholderText } = render(); - expect(getByPlaceholderText(ACCOUNT_NAME)).toBeInTheDocument(); + await waitFor(() => + expect(getByPlaceholderText(ACCOUNT_NAME)).toBeInTheDocument(), + ); }); it('fires onActionComplete when clicked', async () => { const onActionComplete = jest.fn(); const { getByText, getByPlaceholderText } = render({ onActionComplete }); - const input = getByPlaceholderText(ACCOUNT_NAME); + const input = await waitFor(() => getByPlaceholderText(ACCOUNT_NAME)); const newAccountName = 'New Account Name'; fireEvent.change(input, { @@ -35,13 +74,19 @@ describe('CreateBtcAccount', () => { }); fireEvent.click(getByText('Create')); - // TODO: Add logic to rename account + await waitFor(() => + expect(mockSetAccountLabel).toHaveBeenCalledWith( + mockBtcAccount.address, + newAccountName, + ), + ); + await waitFor(() => expect(onActionComplete).toHaveBeenCalled()); }); it(`doesn't allow duplicate account names`, async () => { const { getByText, getByPlaceholderText } = render(); - const input = getByPlaceholderText(ACCOUNT_NAME); + const input = await waitFor(() => getByPlaceholderText(ACCOUNT_NAME)); const usedAccountName = mockState.metamask.internalAccounts.accounts[ '07c2cfec-36c9-46c4-8115-3836d3ac9047' From f2ffffe13cd5ce3f1f032b09bdbc98e4de14e8a5 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 14:38:26 +0200 Subject: [PATCH 11/75] chore: lint --- test/e2e/accounts/snap-account-settings.spec.ts | 7 ++++++- test/e2e/tests/account/import-flow.spec.js | 5 ++++- test/e2e/tests/tokens/nft/import-nft.spec.js | 5 ++++- .../create-btc-account/create-btc-account.test.tsx | 5 +---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/test/e2e/accounts/snap-account-settings.spec.ts b/test/e2e/accounts/snap-account-settings.spec.ts index 72cfaa48b4e7..5a27f10f4764 100644 --- a/test/e2e/accounts/snap-account-settings.spec.ts +++ b/test/e2e/accounts/snap-account-settings.spec.ts @@ -26,7 +26,12 @@ describe('Add snap account experimental settings', function (this: Suite) { text: 'Add account Snap', tag: 'button', }, - { findElementGuard: { text: 'Add a new Ethereum account', tag: 'button' } }, // wait for the modal to appear + { + findElementGuard: { + text: 'Add a new Ethereum account', + tag: 'button', + }, + }, // wait for the modal to appear ); await driver.clickElement('.mm-box button[aria-label="Close"]'); diff --git a/test/e2e/tests/account/import-flow.spec.js b/test/e2e/tests/account/import-flow.spec.js index 6ee6a34e50d9..74ac0731086f 100644 --- a/test/e2e/tests/account/import-flow.spec.js +++ b/test/e2e/tests/account/import-flow.spec.js @@ -101,7 +101,10 @@ describe('Import flow @no-mmi', function () { await driver.clickElement( '[data-testid="multichain-account-menu-popover-action-button"]', ); - await driver.clickElement({ text: 'Add a new Ethereum account', tag: 'button' }); + await driver.clickElement({ + text: 'Add a new Ethereum account', + tag: 'button', + }); // set account name await driver.fill('[placeholder="Account 2"]', '2nd account'); diff --git a/test/e2e/tests/tokens/nft/import-nft.spec.js b/test/e2e/tests/tokens/nft/import-nft.spec.js index db311430b4b7..35a34923a26a 100644 --- a/test/e2e/tests/tokens/nft/import-nft.spec.js +++ b/test/e2e/tests/tokens/nft/import-nft.spec.js @@ -107,7 +107,10 @@ describe('Import NFT', function () { await driver.clickElement( '[data-testid="multichain-account-menu-popover-action-button"]', ); - await driver.clickElement({ text: 'Add a new Ethereum account', tag: 'button' }); + await driver.clickElement({ + text: 'Add a new Ethereum account', + tag: 'button', + }); // By clicking creating button without filling in the account name // the default name would be set as Account 2 diff --git a/ui/components/multichain/create-btc-account/create-btc-account.test.tsx b/ui/components/multichain/create-btc-account/create-btc-account.test.tsx index 3502e2931ad4..9bc1b2240c1b 100644 --- a/ui/components/multichain/create-btc-account/create-btc-account.test.tsx +++ b/ui/components/multichain/create-btc-account/create-btc-account.test.tsx @@ -1,10 +1,7 @@ /* eslint-disable jest/require-top-level-describe */ import React from 'react'; import { JsonRpcRequest } from '@metamask/utils'; -import { - BtcAccountType, - BtcMethod, -} from '@metamask/keyring-api'; +import { BtcAccountType, BtcMethod } from '@metamask/keyring-api'; import { fireEvent, renderWithProvider, waitFor } from '../../../../test/jest'; import configureStore from '../../../store/store'; import mockState from '../../../../test/data/mock-state.json'; From 7b0b10b760fc1477483d3c660c68d18f0958ad59 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 16:53:08 +0200 Subject: [PATCH 12/75] fix(btc): fix initial account BTC creation --- .../create-btc-account/create-btc-account.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/components/multichain/create-btc-account/create-btc-account.tsx b/ui/components/multichain/create-btc-account/create-btc-account.tsx index ccca5ff0524f..17faa47f460f 100644 --- a/ui/components/multichain/create-btc-account/create-btc-account.tsx +++ b/ui/components/multichain/create-btc-account/create-btc-account.tsx @@ -4,7 +4,10 @@ import { useDispatch } from 'react-redux'; import { CreateAccount } from '..'; import { MultichainNetworks } from '../../../../shared/constants/multichain/networks'; import { BitcoinManagerSnapSender } from '../../../../app/scripts/lib/snap-keyring/bitcoin-manager-snap'; -import { setAccountLabel } from '../../../store/actions'; +import { + setAccountLabel, + forceUpdateMetamaskState, +} from '../../../store/actions'; type CreateBtcAccountOptions = { /** @@ -28,6 +31,11 @@ export const CreateBtcAccount = ({ // TODO: Use the new Snap account creation flow that also include account renaming // For now, we just use the AccountsController to rename the account after being created if (name) { + // READ THIS CAREFULLY: + // We have to update the redux state here, since we are updating the global state + // from the background during account creation + await forceUpdateMetamaskState(dispatch); + // NOTE: If the renaming part of this flow fail, the account might still be created, but it // will be named according the Snap keyring naming logic (Snap Account N). dispatch(setAccountLabel(account.address, name)); From 93d5ee50c2e696973d2a67c501132ccf24a60623 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 17:20:29 +0200 Subject: [PATCH 13/75] test(btc): add missing mock for forceUpdateMetamaskState --- .../multichain/create-btc-account/create-btc-account.test.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/components/multichain/create-btc-account/create-btc-account.test.tsx b/ui/components/multichain/create-btc-account/create-btc-account.test.tsx index 9bc1b2240c1b..6d7eba4b0a0a 100644 --- a/ui/components/multichain/create-btc-account/create-btc-account.test.tsx +++ b/ui/components/multichain/create-btc-account/create-btc-account.test.tsx @@ -29,6 +29,7 @@ const mockBitcoinManagerSnapSend = jest.fn().mockReturnValue(mockBtcAccount); const mockSetAccountLabel = jest.fn().mockReturnValue({ type: 'TYPE' }); jest.mock('../../../store/actions', () => ({ + forceUpdateMetamaskState: jest.fn(), setAccountLabel: (address: string, label: string) => mockSetAccountLabel(address, label), })); From 34a1e1572e9a53a2cd12182a1160d280eceb961c Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 17:54:59 +0200 Subject: [PATCH 14/75] chore(btc): use bitcoin-manager-snap as a dependency --- ...ager-snap-0.1.4-rc4-preinstalled-snap.json | 1 - app/scripts/snaps/preinstalled-snaps.ts | 2 +- package.json | 1 + yarn.lock | 111 +++++++++++++++++- 4 files changed, 107 insertions(+), 8 deletions(-) delete mode 100644 app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json diff --git a/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json b/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json deleted file mode 100644 index 238392b18ab7..000000000000 --- a/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json +++ /dev/null @@ -1 +0,0 @@ -{"snapId":"npm:@consensys/bitcoin-manager-snap","manifest":{"version":"0.1.4-rc4","description":"A MetaMask snap to manage Bitcoin","proposedName":"Bitcoin Manager","repository":{"type":"git","url":"https://github.com/MetaMask/bitcoin.git"},"source":{"shasum":"QOQ8JIPH6mEZUppVP94GxVdmReCCNGTwwl2wAnLLQaI=","location":{"npm":{"filePath":"dist/bundle.js","iconPath":"images/icon.svg","packageName":"@consensys/bitcoin-manager-snap","registry":"https://registry.npmjs.org/"}}},"initialConnections":{"http://localhost:3000":{},"https://ramps-dev.portfolio.metamask.io":{},"https://portfolio.metamask.io":{},"https://portfolio-builds.metafi-dev.codefi.network":{},"https://dev.portfolio.metamask.io":{}},"initialPermissions":{"endowment:rpc":{"dapps":true,"snaps":false},"endowment:keyring":{"allowedOrigins":["http://localhost:3000","https://ramps-dev.portfolio.metamask.io","https://portfolio.metamask.io","https://portfolio-builds.metafi-dev.codefi.network","https://dev.portfolio.metamask.io"]},"snap_getBip32Entropy":[{"path":["m","84'","0'"],"curve":"secp256k1"},{"path":["m","84'","1'"],"curve":"secp256k1"}],"endowment:network-access":{},"snap_manageAccounts":{},"snap_manageState":{},"snap_dialog":{}},"manifestVersion":"0.1"},"files":[{"path":"images/icon.svg","value":"\n\n\n\n\n\n\n\n\n\n"},{"path":"dist/bundle.js","value":"(()=>{var t={242:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer,i=r(4261),o=r(4347),s=r(7651);var a,c,u=(a=i,c=Object.create(null),a&&Object.keys(a).forEach((function(t){if(\"default\"!==t){var e=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(c,t,e.get?e:{enumerable:!0,get:function(){return a[t]}})}})),c.default=a,Object.freeze(c));const f=\"Expected Private\",h=\"Expected Point\",l=\"Expected Tweak\",p=\"Expected Signature\",d=\"Expected Extra Data (32 bytes)\",y=\"Expected Scalar\";u.utils.hmacSha256Sync=(t,...e)=>o.hmac(s.sha256,t,u.utils.concatBytes(...e)),u.utils.sha256Sync=(...t)=>s.sha256(u.utils.concatBytes(...t));const g=u.utils._normalizePrivateKey,b=32,w=32,m=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),v=32,E=new Uint8Array(32),_=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function S(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]=0)}function T(t){return t instanceof Uint8Array&&64===t.length&&S(t.subarray(0,32),m)<0&&S(t.subarray(32,64),m)<0}function x(t){return t instanceof Uint8Array&&64===t.length&&S(t.subarray(0,32),_)<0}function O(t){return t instanceof Uint8Array&&t.length===b}function k(t){return void 0===t||t instanceof Uint8Array&&t.length===v}function P(t){if(\"string\"!=typeof t)throw new TypeError(\"hexToNumber: expected string, got \"+typeof t);return BigInt(`0x${t}`)}function R(t){let e;if(\"bigint\"==typeof t)e=t;else if(\"number\"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if(\"string\"==typeof t){if(64!==t.length)throw new Error(\"Expected 32 bytes of private scalar\");e=P(t)}else{if(!(t instanceof Uint8Array))throw new TypeError(\"Expected valid private scalar\");if(32!==t.length)throw new Error(\"Expected 32 bytes of private scalar\");r=t,e=P(u.utils.bytesToHex(r))}var r;if(e<0)throw new Error(\"Expected private scalar >= 0\");return e}const B=(t,e,r)=>{const n=u.Point.fromHex(t),i=R(e),o=u.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error(\"Tweaked point at infinity\");return o.toRawBytes(r)};function C(t,e){return void 0===t?void 0===e||j(e):!!t}function N(t){try{return t()}catch(t){return null}}function L(t,e){if(32===t.length!==e)return!1;try{return!!u.Point.fromHex(t)}catch(t){return!1}}function U(t){return L(t,!1)}function j(t){return L(t,!1)&&33===t.length}function M(t){return u.utils.isValidPrivateKey(t)}function H(t){return L(t,!0)}function F(t){if(!U(t))throw new Error(h);return t.slice(1,33)}function D(t,e){if(!M(t))throw new Error(f);return N((()=>u.getPublicKey(t,C(e))))}e.isPoint=U,e.isPointCompressed=j,e.isPrivate=M,e.isXOnlyPoint=H,e.pointAdd=function(t,e,r){if(!U(t)||!U(e))throw new Error(h);return N((()=>{const n=u.Point.fromHex(t),i=u.Point.fromHex(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(C(r,t))}))},e.pointAddScalar=function(t,e,r){if(!U(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>B(t,e,C(r,t))))},e.pointCompress=function(t,e){if(!U(t))throw new Error(h);return u.Point.fromHex(t).toRawBytes(C(e,t))},e.pointFromScalar=D,e.pointMultiply=function(t,e,r){if(!U(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>((t,e,r)=>{const n=u.Point.fromHex(t),i=\"string\"==typeof e?e:u.utils.bytesToHex(e),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)})(t,e,C(r,t))))},e.privateAdd=function(t,e){if(!1===M(t))throw new Error(f);if(!1===I(e))throw new Error(l);return N((()=>((t,e)=>{const r=g(t),n=R(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r+n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.privateNegate=function(t){if(!1===M(t))throw new Error(f);return(t=>{const e=g(t),r=u.utils._bigintTo32Bytes(u.CURVE.n-e);return u.utils.isValidPrivateKey(r)?r:null})(t)},e.privateSub=function(t,e){if(!1===M(t))throw new Error(f);if(!1===I(e))throw new Error(l);return N((()=>((t,e)=>{const r=g(t),n=R(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r-n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.recover=function(t,e,r,n){if(!O(t))throw new Error(\"Expected Hash\");if(!T(e)||!function(t){return!(A(t.subarray(0,32))||A(t.subarray(32,64)))}(e))throw new Error(p);if(2&r&&!x(e))throw new Error(\"Bad Recovery Id\");if(!H(e.subarray(0,32)))throw new Error(p);return u.recoverPublicKey(t,e,r,C(n))},e.sign=function(t,e,r){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);return u.signSync(t,e,{der:!1,extraEntropy:r})},e.signRecoverable=function(t,e,r){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);const[n,i]=u.signSync(t,e,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}},e.signSchnorr=function(t,e,r=n.alloc(32,0)){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);return u.schnorr.signSync(t,e,r)},e.verify=function(t,e,r,n){if(!U(e))throw new Error(h);if(!T(r))throw new Error(p);if(!O(t))throw new Error(y);return u.verify(r,t,e,{strict:n})},e.verifySchnorr=function(t,e,r){if(!H(e))throw new Error(h);if(!T(r))throw new Error(p);if(!O(t))throw new Error(y);return u.schnorr.verifySync(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!H(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>{const r=B(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=F,e.xOnlyPointFromScalar=function(t){if(!M(t))throw new Error(f);return F(D(t))}},4857:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(4857),i=r(9019);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},4347:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(4857),i=r(9019);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),\"function\"!=typeof this.iHash.update)throw new Error(\"Expected instance of class which extends utils.Hash\");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;tnew o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},7651:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(8822),i=r(9019),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},9019:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(4605),i=r(4857);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},8460:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function i(t,...e){if(!((r=t)instanceof Uint8Array||null!=r&&\"object\"==typeof r&&\"Uint8Array\"===r.constructor.name))throw new Error(\"Expected Uint8Array\");var r;if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function o(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function a(t,e){i(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.add=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=e.split=e.fromBig=void 0;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;oBigInt(t>>>0)<>>0);e.toBig=s;const a=(t,e,r)=>t>>>r;e.shrSH=a;const c=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=c;const u=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=u;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const h=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=h;const l=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=l;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<>>32-r;e.rotlSH=y;const g=(t,e,r)=>e<>>32-r;e.rotlSL=g;const b=(t,e,r)=>e<>>64-r;e.rotlBH=b;const w=(t,e,r)=>t<>>64-r;function m(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w,e.add=m;const v=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=v;const E=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=E;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const A=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=A;const I=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=I;const T={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:h,rotrBL:l,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:g,rotlBH:b,rotlBL:w,add:m,add3L:v,add3H:E,add4L:_,add4H:S,add5H:I,add5L:A};e.default=T},6910:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},448:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.shake256=e.shake128=e.keccak_512=e.keccak_384=e.keccak_256=e.keccak_224=e.sha3_512=e.sha3_384=e.sha3_256=e.sha3_224=e.Keccak=e.keccakP=void 0;const n=r(8460),i=r(8081),o=r(9074),[s,a,c]=[[],[],[]],u=BigInt(0),f=BigInt(1),h=BigInt(2),l=BigInt(7),p=BigInt(256),d=BigInt(113);for(let t=0,e=f,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],s.push(2*(5*n+r)),a.push((t+1)*(t+2)/2%64);let i=u;for(let t=0;t<7;t++)e=(e<>l)*d)%p,e&h&&(i^=f<<(f<r>32?(0,i.rotlBH)(t,e,r):(0,i.rotlSH)(t,e,r),w=(t,e,r)=>r>32?(0,i.rotlBL)(t,e,r):(0,i.rotlSL)(t,e,r);function m(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,i=(e+2)%10,o=r[i],s=r[i+1],a=b(o,s,1)^r[n],c=w(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=c}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=a[r],o=b(e,i,n),c=w(e,i,n),u=s[r];e=t[u],i=t[u+1],t[u]=o,t[u+1]=c}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=y[n],t[1]^=g[n]}r.fill(0)}e.keccakP=m;class v extends o.Hash{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,n.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error(\"Sha3 supports only keccak-f1600 function\");this.state=new Uint8Array(200),this.state32=(0,o.u32)(this.state)}keccak(){m(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){(0,n.exists)(this);const{blockLen:e,state:r}=this,i=(t=(0,o.toBytes)(t)).length;for(let n=0;n=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error(\"XOF is not possible for this instance\");return this.writeInto(t)}xof(t){return(0,n.number)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,n.output)(t,this),this.finished)throw new Error(\"digest() was already called\");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return t||(t=new v(e,r,n,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=o,t.destroyed=this.destroyed,t}}e.Keccak=v;const E=(t,e,r)=>(0,o.wrapConstructor)((()=>new v(e,t,r)));e.sha3_224=E(6,144,28),e.sha3_256=E(6,136,32),e.sha3_384=E(6,104,48),e.sha3_512=E(6,72,64),e.keccak_224=E(1,144,28),e.keccak_256=E(1,136,32),e.keccak_384=E(1,104,48),e.keccak_512=E(1,72,64);const _=(t,e,r)=>(0,o.wrapXOFConstructorWithOpts)(((n={})=>new v(e,t,void 0===n.dkLen?r:n.dkLen,!0)));e.shake128=_(31,168,16),e.shake256=_(31,136,32)},9074:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const n=r(6910);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error(\"Non little-endian hardware is not supported\");const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){if(!i(t))throw new Error(\"Uint8Array expected\");let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},4261:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const n=r(2028),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),c=BigInt(8),u=Object.freeze({a:i,b:BigInt(7),P:BigInt(\"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\"),n:BigInt(\"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"),h:o,Gx:BigInt(\"55066263022277343669578718895168534326250603453777594175500187360389116729240\"),Gy:BigInt(\"32670510020758816978083085130507043184471273380659243275938904335757337482424\"),beta:BigInt(\"0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee\")});e.CURVE=u;const f=(t,e)=>(t+e/s)/e,h={beta:BigInt(\"0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee\"),splitScalar(t){const{n:e}=u,r=BigInt(\"0x3086d221a7d46bcde86c90e49284eb15\"),n=-o*BigInt(\"0xe4437ed6010e88286f547fa90abfe4c3\"),i=BigInt(\"0x114ca50f7a8e2f3f657c1108d9d44cfd8\"),s=r,a=BigInt(\"0x100000000000000000000000000000000\"),c=f(s*t,e),h=f(-n*t,e);let l=H(t-c*r-h*i,e),p=H(-c*n-h*s,e);const d=l>a,y=p>a;if(d&&(l=e-l),y&&(p=e-p),l>a||p>a)throw new Error(\"splitScalarEndo: Endomorphism failed, k=\"+t);return{k1neg:d,k1:l,k2neg:y,k2:p}}},l=32,p=32,d=l+1,y=2*l+1;function g(t){const{a:e,b:r}=u,n=H(t*t),i=H(n*t);return H(i+e*t+r)}const b=u.a===i;class w extends Error{constructor(t){super(t)}}function m(t){if(!(t instanceof v))throw new TypeError(\"JacobianPoint expected\")}class v{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof S))throw new TypeError(\"JacobianPoint#fromAffine: expected Point\");return t.equals(S.ZERO)?v.ZERO:new v(t.x,t.y,o)}static toAffineBatch(t){const e=function(t,e=u.P){const r=new Array(t.length),n=t.reduce(((t,n,o)=>n===i?t:(r[o]=t,H(t*n,e))),o),s=D(n,e);return t.reduceRight(((t,n,o)=>n===i?t:(r[o]=H(t*r[o],e),H(t*n,e))),s),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return v.toAffineBatch(t).map(v.fromAffine)}equals(t){m(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:s}=t,a=H(n*n),c=H(s*s),u=H(e*c),f=H(i*a),h=H(H(r*s)*c),l=H(H(o*n)*a);return u===f&&h===l}negate(){return new v(this.x,H(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=H(t*t),i=H(e*e),o=H(i*i),u=t+i,f=H(s*(H(u*u)-n-o)),h=H(a*n),l=H(h*h),p=H(l-s*f),d=H(h*(f-p)-c*o),y=H(s*e*r);return new v(p,d,y)}add(t){m(t);const{x:e,y:r,z:n}=this,{x:o,y:a,z:c}=t;if(o===i||a===i)return this;if(e===i||r===i)return t;const u=H(n*n),f=H(c*c),h=H(e*f),l=H(o*u),p=H(H(r*c)*f),d=H(H(a*n)*u),y=H(l-h),g=H(d-p);if(y===i)return g===i?this.double():v.ZERO;const b=H(y*y),w=H(y*b),E=H(h*b),_=H(g*g-w-s*E),S=H(g*(E-_)-p*w),A=H(n*c*y);return new v(_,S,A)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=v.ZERO;if(\"bigint\"==typeof t&&t===i)return e;let r=M(t);if(r===o)return this;if(!b){let t=e,n=this;for(;r>i;)r&o&&(t=t.add(n)),n=n.double(),r>>=o;return t}let{k1neg:n,k1:s,k2neg:a,k2:c}=h.splitScalar(r),u=e,f=e,l=this;for(;s>i||c>i;)s&o&&(u=u.add(l)),c&o&&(f=f.add(l)),l=l.double(),s>>=o,c>>=o;return n&&(u=u.negate()),a&&(f=f.negate()),f=new v(H(f.x*h.beta),f.y,f.z),u.add(f)}precomputeWindow(t){const e=b?128/t+1:256/t+1,r=[];let n=this,i=n;for(let o=0;o>=h,a>c&&(a-=f,t+=o);const l=r,p=r+Math.abs(a)-1,d=e%2!=0,y=a<0;0===a?s=s.add(E(d,n[l])):i=i.add(E(y,n[p]))}return{p:i,f:s}}multiply(t,e){let r,n,i=M(t);if(b){const{k1neg:t,k1:o,k2neg:s,k2:a}=h.splitScalar(i);let{p:c,f:u}=this.wNAF(o,e),{p:f,f:l}=this.wNAF(a,e);c=E(t,c),f=E(s,f),f=new v(H(f.x*h.beta),f.y,f.z),r=c.add(f),n=u.add(l)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return v.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(v.ZERO);null==t&&(t=i?c:D(n));const s=t,a=H(s*s),u=H(a*s),f=H(e*a),h=H(r*u),l=H(n*s);if(i)return S.ZERO;if(l!==o)throw new Error(\"invZ was invalid\");return new S(f,h)}}function E(t,e){const r=e.negate();return t?r:e}v.BASE=new v(u.Gx,u.Gy,o),v.ZERO=new v(i,o,i);const _=new WeakMap;class S{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,_.delete(this)}hasEvenY(){return this.y%s===i}static fromCompressedHex(t){const e=32===t.length,r=U(e?t:t.subarray(1));if(!W(r))throw new Error(\"Point is not on curve\");let n=function(t){const{P:e}=u,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),c=BigInt(44),f=BigInt(88),h=t*t*t%e,l=h*h*t%e,p=F(l,a)*l%e,d=F(p,a)*l%e,y=F(d,s)*h%e,g=F(y,n)*y%e,b=F(g,i)*g%e,w=F(b,c)*b%e,m=F(w,f)*w%e,v=F(m,c)*b%e,E=F(v,a)*l%e,_=F(E,o)*g%e,S=F(_,r)*h%e,A=F(S,s);if(A*A%e!==t)throw new Error(\"Cannot find square root\");return A}(g(r));const i=(n&o)===o;if(e)i&&(n=H(-n));else{1==(1&t[0])!==i&&(n=H(-n))}const c=new S(r,n);return c.assertValidity(),c}static fromUncompressedHex(t){const e=U(t.subarray(1,l+1)),r=U(t.subarray(l+1,2*l+1)),n=new S(e,r);return n.assertValidity(),n}static fromHex(t){const e=j(t),r=e.length,n=e[0];if(r===l)return this.fromCompressedHex(e);if(r===d&&(2===n||3===n))return this.fromCompressedHex(e);if(r===y&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-${d} compressed bytes or ${y} uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return S.BASE.multiply(z(t))}static fromSignature(t,e,r){const{r:n,s:i}=Y(e);if(![0,1,2,3].includes(r))throw new Error(\"Cannot recover: invalid recovery bit\");const o=$(j(t)),{n:s}=u,a=2===r||3===r?n+s:n,c=D(a,s),f=H(-o*c,s),h=H(i*c,s),l=1&r?\"03\":\"02\",p=S.fromHex(l+R(a)),d=S.BASE.multiplyAndAddUnsafe(p,f,h);if(!d)throw new Error(\"Cannot recover signature: point at infinify\");return d.assertValidity(),d}toRawBytes(t=!1){return L(this.toHex(t))}toHex(t=!1){const e=R(this.x);if(t){return`${this.hasEvenY()?\"02\":\"03\"}${e}`}return`04${e}${R(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t=\"Point is not on elliptic curve\",{x:e,y:r}=this;if(!W(e)||!W(r))throw new Error(t);const n=H(r*r);if(H(n-g(e))!==i)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new S(this.x,H(-this.y))}double(){return v.fromAffine(this).double().toAffine()}add(t){return v.fromAffine(this).add(v.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return v.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=v.fromAffine(this),s=e===i||e===o||this!==S.BASE?n.multiplyUnsafe(e):n.multiply(e),a=v.fromAffine(t).multiplyUnsafe(r),c=s.add(a);return c.equals(v.ZERO)?void 0:c.toAffine()}}function A(t){return Number.parseInt(t[0],16)>=8?\"00\"+t:t}function I(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${k(t)}`);const e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error(\"Invalid signature integer: wrong length\");if(0===r[0]&&r[1]<=127)throw new Error(\"Invalid signature integer: trailing length\");return{data:U(r),left:t.subarray(e+2)}}e.Point=S,S.BASE=new S(u.Gx,u.Gy),S.ZERO=new S(i,i);class T{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,r=\"Signature.fromCompact\";if(\"string\"!=typeof t&&!e)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=e?k(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new T(N(n.slice(0,64)),N(n.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if(\"string\"!=typeof t&&!e)throw new TypeError(\"Signature.fromDER: Expected string or Uint8Array\");const{r,s:n}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${k(t)}`);if(t[1]!==t.length-2)throw new Error(\"Invalid signature: incorrect length\");const{data:e,left:r}=I(t.subarray(2)),{data:n,left:i}=I(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${k(i)}`);return{r:e,s:n}}(e?t:L(t));return new T(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!q(t))throw new Error(\"Invalid Signature: r must be 0 < r < n\");if(!q(e))throw new Error(\"Invalid Signature: s must be 0 < s < n\")}hasHighS(){const t=u.n>>o;return this.s>t}normalizeS(){return this.hasHighS()?new T(this.r,H(-this.s,u.n)):this}toDERRawBytes(){return L(this.toDERHex())}toDERHex(){const t=A(C(this.s)),e=A(C(this.r)),r=t.length/2,n=e.length/2,i=C(r),o=C(n);return`30${C(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return L(this.toCompactHex())}toCompactHex(){return R(this.r)+R(this.s)}}function x(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error(\"Uint8Array list expected\");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;ee.toString(16).padStart(2,\"0\")));function k(t){if(!(t instanceof Uint8Array))throw new Error(\"Expected Uint8Array\");let e=\"\";for(let r=0;r0)return BigInt(t);if(\"bigint\"==typeof t&&q(t))return t;throw new TypeError(\"Expected valid private scalar: 0 < scalar < curve.n\")}function H(t,e=u.P){const r=t%e;return r>=i?r:e+r}function F(t,e){const{P:r}=u;let n=t;for(;e-- >i;)n*=n,n%=r;return n}function D(t,e=u.P){if(t===i||e<=i)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=H(t,e),n=e,s=i,a=o,c=o,f=i;for(;r!==i;){const t=n/r,e=n%r,i=s-c*t,o=a-f*t;n=r,r=e,s=c,a=f,c=i,f=o}if(n!==o)throw new Error(\"invert: does not exist\");return H(s,e)}function $(t,e=!1){const r=function(t){const e=8*t.length-8*p,r=U(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=u;return r>=n?r-n:r}let K,V;class G{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,\"number\"!=typeof t||t<2)throw new Error(\"hashLen must be a number\");if(\"number\"!=typeof e||e<2)throw new Error(\"qByteLen must be a number\");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return e.utils.hmacSha256(this.k,...t)}hmacSync(...t){return V(this.k,...t)}checkSync(){if(\"function\"!=typeof V)throw new w(\"hmacSha256Sync needs to be set\")}incr(){if(this.counter>=1e3)throw new Error(\"Tried 1,000 k values for sign(), all were invalid\");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),0!==t.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),0!==t.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t0)e=BigInt(t);else if(\"string\"==typeof t){if(t.length!==2*p)throw new Error(\"Expected 32 bytes of private key\");e=N(t)}else{if(!(t instanceof Uint8Array))throw new TypeError(\"Expected valid private key\");if(t.length!==p)throw new Error(\"Expected 32 bytes of private key\");e=U(t)}if(!q(e))throw new Error(\"Expected private key: 0 < key < n\");return e}function J(t){return t instanceof S?(t.assertValidity(),t):S.fromHex(t)}function Y(t){if(t instanceof T)return t.assertValidity(),t;try{return T.fromDER(t)}catch(e){return T.fromCompact(t)}}function Z(t){const e=t instanceof Uint8Array,r=\"string\"==typeof t,n=(e||r)&&t.length;return e?n===d||n===y:r?n===2*d||n===2*y:t instanceof S}function Q(t){return U(t.length>l?t.slice(0,l):t)}function tt(t){const e=Q(t),r=H(e,u.n);return et(r{t=j(t);const e=p+8;if(t.length1024)throw new Error(\"Expected valid bytes of private key as per FIPS 186\");return B(H(U(t),u.n-o)+o)},randomBytes:(t=32)=>{if(lt.web)return lt.web.getRandomValues(new Uint8Array(t));if(lt.node){const{randomBytes:e}=lt.node;return Uint8Array.from(e(t))}throw new Error(\"The environment doesn't have randomBytes function\")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(p+8)),precompute(t=8,e=S.BASE){const r=e===S.BASE?e:new S(e.x,e.y);return r._setWindowSize(t),r.multiply(a),r},sha256:async(...t)=>{if(lt.web){const e=await lt.web.subtle.digest(\"SHA-256\",x(...t));return new Uint8Array(e)}if(lt.node){const{createHash:e}=lt.node,r=e(\"sha256\");return t.forEach((t=>r.update(t))),Uint8Array.from(r.digest())}throw new Error(\"The environment doesn't have sha256 function\")},hmacSha256:async(t,...e)=>{if(lt.web){const r=await lt.web.subtle.importKey(\"raw\",t,{name:\"HMAC\",hash:{name:\"SHA-256\"}},!1,[\"sign\"]),n=x(...e),i=await lt.web.subtle.sign(\"HMAC\",r,n);return new Uint8Array(i)}if(lt.node){const{createHmac:r}=lt.node,n=r(\"sha256\",t);return e.forEach((t=>n.update(t))),Uint8Array.from(n.digest())}throw new Error(\"The environment doesn't have hmac-sha256 function\")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...r)=>{let n=dt[t];if(void 0===n){const r=await e.utils.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=x(r,r),dt[t]=n}return e.utils.sha256(n,...r)},taggedHashSync:(t,...e)=>{if(\"function\"!=typeof K)throw new w(\"sha256Sync is undefined, you need to set it\");let r=dt[t];if(void 0===r){const e=K(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=x(e,e),dt[t]=r}return K(r,...e)},_JacobianPoint:v},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get:()=>K,set(t){K||(K=t)}},hmacSha256Sync:{configurable:!1,get:()=>V,set(t){V||(V=t)}}})},6710:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function n(...t){const e=(t,e)=>r=>t(e(r)),r=Array.from(t).reverse().reduce(((t,r)=>t?e(t,r.encode):r.encode),void 0),n=t.reduce(((t,r)=>t?e(t,r.decode):r.decode),void 0);return{encode:r,decode:n}}function i(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&\"number\"!=typeof e[0])throw new Error(\"alphabet.encode input should be an array of numbers\");return e.map((e=>{if(r(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&\"string\"!=typeof e[0])throw new Error(\"alphabet.decode input should be array of strings\");return e.map((e=>{if(\"string\"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: \"${e}\". Allowed: ${t}`);return r}))}}}function o(t=\"\"){if(\"string\"!=typeof t)throw new Error(\"join separator should be string\");return{encode:e=>{if(!Array.isArray(e)||e.length&&\"string\"!=typeof e[0])throw new Error(\"join.encode input should be array of strings\");for(let t of e)if(\"string\"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if(\"string\"!=typeof e)throw new Error(\"join.decode input should be string\");return e.split(t)}}}function s(t,e=\"=\"){if(r(t),\"string\"!=typeof e)throw new Error(\"padding chr should be string\");return{encode(r){if(!Array.isArray(r)||r.length&&\"string\"!=typeof r[0])throw new Error(\"padding.encode input should be array of strings\");for(let t of r)if(\"string\"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&\"string\"!=typeof r[0])throw new Error(\"padding.encode input should be array of strings\");for(let t of r)if(\"string\"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let n=r.length;if(n*t%8)throw new Error(\"Invalid padding: string should have whole number of bytes\");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error(\"Invalid padding: string has too much padding\");return r.slice(0,n)}}}function a(t){if(\"function\"!=typeof t)throw new Error(\"normalize fn should be function\");return{encode:t=>t,decode:e=>t(e)}}function c(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error(\"convertRadix: data should be array\");if(!t.length)return[];let i=0;const o=[],s=Array.from(t);for(s.forEach((t=>{if(r(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)}));;){let t=0,r=!0;for(let o=i;oe?u(e,t%e):t,f=(t,e)=>t+(e-u(t,e));function h(t,e,n,i){if(!Array.isArray(t))throw new Error(\"convertRadix2: data should be array\");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(f(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${f(e,n)}`);let o=0,s=0;const a=2**n-1,c=[];for(const i of t){if(r(i),i>=2**e)throw new Error(`convertRadix2: invalid data word=${i} from=${e}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)c.push((o>>s-n&a)>>>0);o&=2**s-1}if(o=o<=e)throw new Error(\"Excess padding\");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&c.push(o>>>0),c}function l(t){return r(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error(\"radix.encode input should be Uint8Array\");return c(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&\"number\"!=typeof e[0])throw new Error(\"radix.decode input should be array of strings\");return Uint8Array.from(c(e,t,256))}}}function p(t,e=!1){if(r(t),t<=0||t>32)throw new Error(\"radix2: bits should be in (0..32]\");if(f(8,t)>32||f(t,8)>32)throw new Error(\"radix2: carry overflow\");return{encode:r=>{if(!(r instanceof Uint8Array))throw new Error(\"radix2.encode input should be Uint8Array\");return h(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&\"number\"!=typeof r[0])throw new Error(\"radix2.decode input should be array of strings\");return Uint8Array.from(h(r,t,8,e))}}}function d(t){if(\"function\"!=typeof t)throw new Error(\"unsafeWrapper fn should be function\");return function(...e){try{return t.apply(null,e)}catch(t){}}}function y(t,e){if(r(t),\"function\"!=typeof e)throw new Error(\"checksum fn should be function\");return{encode(r){if(!(r instanceof Uint8Array))throw new Error(\"checksum.encode: input should be Uint8Array\");const n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!(r instanceof Uint8Array))throw new Error(\"checksum.decode: input should be Uint8Array\");const n=r.slice(0,-t),i=e(n).slice(0,t),o=r.slice(-t);for(let e=0;et.toUpperCase().replace(/O/g,\"0\").replace(/[IL]/g,\"1\")))),e.base64=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"),s(6),o(\"\")),e.base64url=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\"),s(6),o(\"\")),e.base64urlnopad=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\"),o(\"\"));const g=t=>n(l(58),i(t),o(\"\"));e.base58=g(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\"),e.base58flickr=g(\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"),e.base58xrp=g(\"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz\");const b=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let r=\"\";for(let n=0;nn(y(4,(e=>t(t(e)))),e.base58);const w=n(i(\"qpzry9x8gf2tvdw0s3jn54khce6mua7l\"),o(\"\")),m=[996825010,642813549,513874426,1027748829,705979059];function v(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t>t&1)&&(r^=m[t]);return r}function E(t,e,r=1){const n=t.length;let i=1;for(let e=0;e126)throw new Error(`Invalid prefix (${t})`);i=v(i)^r>>5}i=v(i);for(let e=0;er)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${r})`);const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())throw new Error(\"String must be lowercase or uppercase\");const i=(t=n).lastIndexOf(\"1\");if(0===i||-1===i)throw new Error('Letter \"1\" must be present between prefix and data only');const o=t.slice(0,i),s=t.slice(i+1);if(s.length<6)throw new Error(\"Data must be at least 6 characters long\");const a=w.decode(s).slice(0,-6),c=E(o,a,e);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected \"${c}\"`);return{prefix:o,words:a}}return{encode:function(t,r,n=90){if(\"string\"!=typeof t)throw new Error(\"bech32.encode prefix should be string, not \"+typeof t);if(!Array.isArray(r)||r.length&&\"number\"!=typeof r[0])throw new Error(\"bech32.encode words should be array of numbers, not \"+typeof r);const i=t.length+7+r.length;if(!1!==n&&i>n)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=t.toLowerCase(),s=E(o,r,e);return`${o}1${w.encode(r)}${s}`},decode:s,decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:d(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}e.bech32=_(\"bech32\"),e.bech32m=_(\"bech32m\"),e.utf8={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},e.hex=n(p(4),i(\"0123456789abcdef\"),o(\"\"),a((t=>{if(\"string\"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));const S={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},A=\"Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr\";e.bytesToString=(t,e)=>{if(\"string\"!=typeof t||!S.hasOwnProperty(t))throw new TypeError(A);if(!(e instanceof Uint8Array))throw new TypeError(\"bytesToString() expects Uint8Array\");return S[t].encode(e)},e.str=e.bytesToString;e.stringToBytes=(t,e)=>{if(!S.hasOwnProperty(t))throw new TypeError(A);if(\"string\"!=typeof e)throw new TypeError(\"stringToBytes() expects string\");return S[t].decode(e)},e.bytes=e.stringToBytes},9784:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError(\"Alphabet too long\");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,p=s-1;(0!==h||l>>0,f[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error(\"Non-zero carry\");o=l,r++}for(var d=s-o;d!==s&&0===f[d];)d++;var y=n.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var g=i;d!==s;)y[g++]=f[d++];return y}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError(\"Expected Buffer\");if(0===e.length)return\"\";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var l=e[o],p=0,d=u-1;(0!==l||p>>0,h[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error(\"Non-zero carry\");i=p,o++}for(var y=u-i;y!==u&&0===h[y];)y++;for(var g=c.repeat(r);y{\"use strict\";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],c=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,c)),f=0,h=c>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===c&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===c&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,u=n-i;au?u:a+s));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+\"==\")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\"));return o.join(\"\")};for(var r=[],n=[],i=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,o=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var r=t.indexOf(\"=\");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,n){for(var i,o,s=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join(\"\")}n[\"-\".charCodeAt(0)]=62,n[\"_\".charCodeAt(0)]=63},6586:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.bech32m=e.bech32=void 0;const r=\"qpzry9x8gf2tvdw0s3jn54khce6mua7l\",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r126)return\"Invalid prefix (\"+t+\")\";e=i(e)^n>>5}e=i(e);for(let r=0;r=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)return\"Excess padding\";if(i<r)return\"Exceeds length limit\";const s=t.toLowerCase(),a=t.toUpperCase();if(t!==s&&t!==a)return\"Mixed-case string \"+t;const c=(t=s).lastIndexOf(\"1\");if(-1===c)return\"No separator character for \"+t;if(0===c)return\"Missing prefix for \"+t;const u=t.slice(0,c),f=t.slice(c+1);if(f.length<6)return\"Data too short\";let h=o(u);if(\"string\"==typeof h)return h;const l=[];for(let t=0;t=f.length||l.push(r)}return h!==e?\"Invalid checksum for \"+t:{prefix:u,words:l}}return e=\"bech32\"===t?1:734539939,{decodeUnsafe:function(t,e){const r=s(t,e);if(\"object\"==typeof r)return r},decode:function(t,e){const r=s(t,e);if(\"object\"==typeof r)return r;throw new Error(r)},encode:function(t,n,s){if(s=s||90,t.length+7+n.length>s)throw new TypeError(\"Exceeds length limit\");let a=o(t=t.toLowerCase());if(\"string\"==typeof a)throw new Error(a);let c=t+\"1\";for(let t=0;t>5!=0)throw new Error(\"Non 5-bit word\");a=i(a)^e,c+=r.charAt(e)}for(let t=0;t<6;++t)a=i(a);a^=e;for(let t=0;t<6;++t){c+=r.charAt(a>>5*(5-t)&31)}return c},toWords:a,fromWordsUnsafe:c,fromWords:u}}e.bech32=f(\"bech32\"),e.bech32m=f(\"bech32m\")},3162:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});const n=r(6808);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter((t=>t.key.toString(\"hex\")===n))[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function s(t){const e=new Set;return t.forEach((t=>{const r=t.key.toString(\"hex\");if(e.has(r))throw new Error(\"Combine: KeyValue Map keys should be unique\");e.add(r)})),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),a=t.slice(1);if(0===a.length)throw new Error(\"Combine: Nothing to combine\");const c=o(e);if(void 0===c)throw new Error(\"Combine: Self missing transaction\");const u=s(r.globalKeyVals),f=r.inputKeyVals.map(s),h=r.outputKeyVals.map(s);for(const t of a){const e=o(t);if(void 0===e||!e.toBuffer().equals(c.toBuffer()))throw new Error(\"Combine: One of the Psbts does not have the same transaction.\");const a=n.psbtToKeyVals(t);s(a.globalKeyVals).forEach(i(u,r.globalKeyVals,a.globalKeyVals));a.inputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(f[e],r.inputKeyVals[e],a.inputKeyVals[e]))));a.outputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(h[e],r.outputKeyVals[e],a.outputKeyVals[e]))))}return n.psbtFromKeyVals(c,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},9977:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error(\"Decode Error: could not decode globalXpub with key 0x\"+t.key.toString(\"hex\"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error(\"Decode Error: globalXpub has invalid extended pubkey in key 0x\"+t.key.toString(\"hex\"));if(t.value.length/4%1!=0)throw new Error(\"Decode Error: Global GLOBAL_XPUB value length should be multiple of 4\");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:\"m\"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+=\"/\"+o.toString(10)+(i?\"'\":\"\")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split(\"/\"),s=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e=\"'\"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:r,value:s}},e.expected=\"{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }\",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&\"string\"==typeof i&&!!i.match(/^m(\\/\\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.extendedPubkey.equals(e.extendedPubkey))).length)}},3398:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},6317:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});const n=r(9889),i=r(9977),o=r(3398),s=r(7312),a=r(1661),c=r(8730),u=r(5098),f=r(4474),h=r(9175),l=r(7279),p=r(7544),d=r(241),y=r(3155),g=r(4709),b=r(9574),w=r(6896),m=r(437),v=r(5400),E=r(2751),_=r(9632),S=r(9079),A={unsignedTx:o,globalXpub:i,checkPubkey:m.makeChecker([])};e.globals=A;const I={nonWitnessUtxo:c,partialSig:u,sighashType:h,finalScriptSig:s,finalScriptWitness:a,porCommitment:f,witnessUtxo:g,bip32Derivation:w.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:l,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:E.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:_.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=I;const T={bip32Derivation:w.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:E.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:b,tapInternalKey:_.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},7312:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error(\"Decode Error: could not decode finalScriptSig with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},1661:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error(\"Decode Error: could not decode finalScriptWitness with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},8730:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error(\"Decode Error: could not decode nonWitnessUtxo with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},5098:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error(\"Decode Error: could not decode partialSig with key 0x\"+t.key.toString(\"hex\"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error(\"Decode Error: partialSig has invalid pubkey in key 0x\"+t.key.toString(\"hex\"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected=\"{ pubkey: Buffer; signature: Buffer; }\",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}},4474:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error(\"Decode Error: could not decode porCommitment with key 0x\"+t.key.toString(\"hex\"));return t.value.toString(\"utf8\")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,\"utf8\")}},e.expected=\"string\",e.check=function(t){return\"string\"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}},9175:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error(\"Decode Error: could not decode sighashType with key 0x\"+t.key.toString(\"hex\"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected=\"number\",e.check=function(t){return\"number\"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},7279:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapKeySig with key 0x\"+t.key.toString(\"hex\"));if(!o(t.value))throw new Error(\"Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature\");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected=\"Buffer\",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},7544:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error(\"Decode Error: could not decode tapLeafScript with key 0x\"+t.key.toString(\"hex\"));if((t.key.length-2)%32!=0)throw new Error(\"Decode Error: tapLeafScript has invalid control block in key 0x\"+t.key.toString(\"hex\"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error(\"Decode Error: tapLeafScript bad leaf version in key 0x\"+t.key.toString(\"hex\"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected=\"{ controlBlock: Buffer; leafVersion: number, script: Buffer; }\",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.controlBlock.equals(e.controlBlock))).length)}},241:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapMerkleRoot with key 0x\"+t.key.toString(\"hex\"));if(!o(t.value))throw new Error(\"Decode Error: tapMerkleRoot not a 32-byte hash\");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected=\"Buffer\",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},3155:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error(\"Decode Error: could not decode tapScriptSig with key 0x\"+t.key.toString(\"hex\"));if(65!==t.key.length)throw new Error(\"Decode Error: tapScriptSig has invalid key 0x\"+t.key.toString(\"hex\"));if(64!==t.value.length&&65!==t.value.length)throw new Error(\"Decode Error: tapScriptSig has invalid signature in key 0x\"+t.key.toString(\"hex\"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected=\"{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }\",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString(\"hex\")+e.leafHash.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash))).length)}},4709:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889),o=r(5962),s=r(2715);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error(\"Decode Error: could not decode witnessUtxo with key 0x\"+t.key.toString(\"hex\"));const e=o.readUInt64LE(t.value,0);let r=8;const n=s.decode(t.value,r);r+=s.encodingLength(n);const a=t.value.slice(r);if(a.length!==n)throw new Error(\"Decode Error: WITNESS_UTXO script is not proper length\");return{script:a,value:e}},e.encode=function(t){const{script:e,value:r}=t,a=s.encodingLength(e.length),c=n.allocUnsafe(8+a+e.length);return o.writeUInt64LE(c,r,0),s.encode(e.length,c,8),e.copy(c,8+a),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:c}},e.expected=\"{ script: Buffer; value: number; }\",e.check=function(t){return n.isBuffer(t.script)&&\"number\"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},9574:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889),o=r(2715);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapTree with key 0x\"+t.key.toString(\"hex\"));let e=0;const r=[];for(;e[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script])));return{key:e,value:n.concat(r)}},e.expected=\"{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }\",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every((t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script)))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},6896:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=t=>33===t.length&&[2,3].includes(t[0])||65===t.length&&4===t[0];e.makeConverter=function(t,e=i){return{decode:function(r){if(r.key[0]!==t)throw new Error(\"Decode Error: could not decode bip32Derivation with key 0x\"+r.key.toString(\"hex\"));const n=r.key.slice(1);if(!e(n))throw new Error(\"Decode Error: bip32Derivation has invalid pubkey in key 0x\"+r.key.toString(\"hex\"));if(r.value.length/4%1!=0)throw new Error(\"Decode Error: Input BIP32_DERIVATION value length should be multiple of 4\");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:\"m\"};for(const t of(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+=\"/\"+o.toString(10)+(n?\"'\":\"\")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split(\"/\"),s=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e=\"'\"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:i,value:s}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&\"string\"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:\"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }\",canAddToArray:function(t,e,r){const n=e.pubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}}}},437:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error(\"Format Error: invalid pubkey in key 0x\"+e.key.toString(\"hex\"));return r}}},5400:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error(\"Decode Error: could not decode redeemScript with key 0x\"+e.key.toString(\"hex\"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.redeemScript}}}},2751:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(2715),o=r(6896),s=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,s);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),s=new Array(r);for(let e=0,i=n;en.isBuffer(t)&&32===t.length))&&e.check(t)},expected:\"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }\",canAddToArray:e.canAddToArray}}},9632:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t||1!==e.key.length)throw new Error(\"Decode Error: could not decode tapInternalKey with key 0x\"+e.key.toString(\"hex\"));if(32!==e.value.length)throw new Error(\"Decode Error: tapInternalKey not a 32-byte x-only pubkey\");return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)&&32===t.length},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.tapInternalKey}}}},9079:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error(\"Decode Error: could not decode witnessScript with key 0x\"+e.key.toString(\"hex\"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.witnessScript}}}},5962:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(2715);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),s=i.encodingLength(r),a=n.allocUnsafe(o+e+s+r);return i.encode(e,a,0),t.key.copy(a,o),i.encode(r,a,o+e),t.value.copy(a,o+e+s),a}function s(t,e){if(\"number\"!=typeof t)throw new Error(\"cannot write a non-number as a number\");if(t<0)throw new Error(\"specified a negative value for writing an unsigned value\");if(t>e)throw new Error(\"RangeError: value out of range\");if(Math.floor(t)!==t)throw new Error(\"value has a fractional component\")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError(\"value out of range\")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.encode=function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError(\"buffer must be a Buffer instance\");return i||(i=0),e<253?(r.writeUInt8(e,i),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError(\"buffer must be a Buffer instance\");r||(r=0);const i=e.readUInt8(r);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===i)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),i=4294967296*e.readUInt32LE(r+5)+n;return o(i),i}},e.encodingLength=s},4112:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317),o=r(5962),s=r(2715),a=r(9889);function c(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString(\"hex\")}`)}function u(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const s={unsignedTx:t};let u=0;for(const t of e)switch(t.key[0]){case a.GlobalTypes.UNSIGNED_TX:if(c(\"global\",t.key,a.GlobalTypes.UNSIGNED_TX),u>0)throw new Error(\"Format Error: GlobalMap has multiple UNSIGNED_TX\");u++;break;case a.GlobalTypes.GLOBAL_XPUB:void 0===s.globalXpub&&(s.globalXpub=[]),s.globalXpub.push(i.globals.globalXpub.decode(t));break;default:s.unknownKeyVals||(s.unknownKeyVals=[]),s.unknownKeyVals.push(t)}const f=r.length,h=n.length,l=[],p=[];for(const t of o.range(f)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case a.InputTypes.NON_WITNESS_UTXO:if(c(\"input\",n.key,a.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error(\"Format Error: Input has multiple NON_WITNESS_UTXO\");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case a.InputTypes.WITNESS_UTXO:if(c(\"input\",n.key,a.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error(\"Format Error: Input has multiple WITNESS_UTXO\");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case a.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case a.InputTypes.SIGHASH_TYPE:if(c(\"input\",n.key,a.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error(\"Format Error: Input has multiple SIGHASH_TYPE\");e.sighashType=i.inputs.sighashType.decode(n);break;case a.InputTypes.REDEEM_SCRIPT:if(c(\"input\",n.key,a.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error(\"Format Error: Input has multiple REDEEM_SCRIPT\");e.redeemScript=i.inputs.redeemScript.decode(n);break;case a.InputTypes.WITNESS_SCRIPT:if(c(\"input\",n.key,a.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error(\"Format Error: Input has multiple WITNESS_SCRIPT\");e.witnessScript=i.inputs.witnessScript.decode(n);break;case a.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case a.InputTypes.FINAL_SCRIPTSIG:c(\"input\",n.key,a.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case a.InputTypes.FINAL_SCRIPTWITNESS:c(\"input\",n.key,a.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case a.InputTypes.POR_COMMITMENT:c(\"input\",n.key,a.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case a.InputTypes.TAP_KEY_SIG:c(\"input\",n.key,a.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case a.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case a.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case a.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case a.InputTypes.TAP_INTERNAL_KEY:c(\"input\",n.key,a.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case a.InputTypes.TAP_MERKLE_ROOT:c(\"input\",n.key,a.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}l.push(e)}for(const t of o.range(h)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case a.OutputTypes.REDEEM_SCRIPT:if(c(\"output\",r.key,a.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error(\"Format Error: Output has multiple REDEEM_SCRIPT\");e.redeemScript=i.outputs.redeemScript.decode(r);break;case a.OutputTypes.WITNESS_SCRIPT:if(c(\"output\",r.key,a.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error(\"Format Error: Output has multiple WITNESS_SCRIPT\");e.witnessScript=i.outputs.witnessScript.decode(r);break;case a.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case a.OutputTypes.TAP_INTERNAL_KEY:c(\"output\",r.key,a.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case a.OutputTypes.TAP_TREE:c(\"output\",r.key,a.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case a.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:s,inputs:l,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=s.decode(t,r);r+=s.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function c(){if(r>=t.length)throw new Error(\"Format Error: Unexpected End of PSBT\");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error(\"Format Error: Invalid Magic Number\");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error(\"Format Error: Magic Number must be followed by 0xff separator\");const f=[],h={};for(;!c();){const t=i(),e=t.key.toString(\"hex\");if(h[e])throw new Error(\"Format Error: Keys must be unique for global keymap: key \"+e);h[e]=1,f.push(t)}const l=f.filter((t=>t.key[0]===a.GlobalTypes.UNSIGNED_TX));if(1!==l.length)throw new Error(\"Format Error: Only one UNSIGNED_TX allowed\");const p=e(l[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),g=[],b=[];for(const t of o.range(d)){const e={},r=[];for(;!c();){const n=i(),o=n.key.toString(\"hex\");if(e[o])throw new Error(\"Format Error: Keys must be unique for each input: input index \"+t+\" key \"+o);e[o]=1,r.push(n)}g.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!c();){const n=i(),o=n.key.toString(\"hex\");if(e[o])throw new Error(\"Format Error: Keys must be unique for each output: output index \"+t+\" key \"+o);e[o]=1,r.push(n)}b.push(r)}return u(p,{globalMapKeyVals:f,inputKeyVals:g,outputKeyVals:b})},e.checkKeyBuffer=c,e.psbtFromKeyVals=u},6808:(t,e,r)=>{\"use strict\";function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,\"__esModule\",{value:!0}),n(r(4112)),n(r(2673))},2673:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317),o=r(5962);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:s,outputKeyVals:a}=c({globalMap:t,inputs:e,outputs:r}),u=o.keyValsToBuffer(i),f=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),h=f(s),l=f(a),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,u].concat(h,l))};const s=(t,e)=>t.key.compare(e.key);function a(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if(\"unknownKeyVals\"===n)return t;const o=e[n];if(void 0===o)return t;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((t=>t.key.toString(\"hex\"))).forEach((t=>{if(r.has(t))throw new Error(\"Serialize Error: Duplicate key: \"+t);r.add(t)})),t.concat(s)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString(\"hex\")))):[];return n.concat(i).sort(s)}function c({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:a(t,i.globals),inputKeyVals:e.map((t=>a(t,i.inputs))),outputKeyVals:r.map((t=>a(t,i.outputs)))}}e.psbtToKeyVals=c},7003:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(3162),o=r(6808),s=r(9889),a=r(2431);e.Psbt=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,\"base64\");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,\"hex\");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString(\"base64\")}toHex(){return this.toBuffer().toString(\"hex\")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return a.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=a.checkForInput(this.inputs,t);return a.updateInput(e,r),this}updateOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return a.checkHasKey(t,this.globalMap.unknownKeyVals,a.getEnumLength(s.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=a.checkForInput(this.inputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error(\"unknownKeyVals must be an Array\");return e.forEach((t=>this.addUnknownKeyValToInput(r,t))),a.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error(\"unknownKeyVals must be an Array\");return e.forEach((t=>this.addUnknownKeyValToOutput(r,t))),a.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=a.checkForInput(this.inputs,t);a.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))[\"witnessUtxo\",\"nonWitnessUtxo\",\"finalScriptSig\",\"finalScriptWitness\",\"unknownKeyVals\"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},9889:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),function(t){t[t.UNSIGNED_TX=0]=\"UNSIGNED_TX\",t[t.GLOBAL_XPUB=1]=\"GLOBAL_XPUB\"}(e.GlobalTypes||(e.GlobalTypes={})),e.GLOBAL_TYPE_NAMES=[\"unsignedTx\",\"globalXpub\"],function(t){t[t.NON_WITNESS_UTXO=0]=\"NON_WITNESS_UTXO\",t[t.WITNESS_UTXO=1]=\"WITNESS_UTXO\",t[t.PARTIAL_SIG=2]=\"PARTIAL_SIG\",t[t.SIGHASH_TYPE=3]=\"SIGHASH_TYPE\",t[t.REDEEM_SCRIPT=4]=\"REDEEM_SCRIPT\",t[t.WITNESS_SCRIPT=5]=\"WITNESS_SCRIPT\",t[t.BIP32_DERIVATION=6]=\"BIP32_DERIVATION\",t[t.FINAL_SCRIPTSIG=7]=\"FINAL_SCRIPTSIG\",t[t.FINAL_SCRIPTWITNESS=8]=\"FINAL_SCRIPTWITNESS\",t[t.POR_COMMITMENT=9]=\"POR_COMMITMENT\",t[t.TAP_KEY_SIG=19]=\"TAP_KEY_SIG\",t[t.TAP_SCRIPT_SIG=20]=\"TAP_SCRIPT_SIG\",t[t.TAP_LEAF_SCRIPT=21]=\"TAP_LEAF_SCRIPT\",t[t.TAP_BIP32_DERIVATION=22]=\"TAP_BIP32_DERIVATION\",t[t.TAP_INTERNAL_KEY=23]=\"TAP_INTERNAL_KEY\",t[t.TAP_MERKLE_ROOT=24]=\"TAP_MERKLE_ROOT\"}(e.InputTypes||(e.InputTypes={})),e.INPUT_TYPE_NAMES=[\"nonWitnessUtxo\",\"witnessUtxo\",\"partialSig\",\"sighashType\",\"redeemScript\",\"witnessScript\",\"bip32Derivation\",\"finalScriptSig\",\"finalScriptWitness\",\"porCommitment\",\"tapKeySig\",\"tapScriptSig\",\"tapLeafScript\",\"tapBip32Derivation\",\"tapInternalKey\",\"tapMerkleRoot\"],function(t){t[t.REDEEM_SCRIPT=0]=\"REDEEM_SCRIPT\",t[t.WITNESS_SCRIPT=1]=\"WITNESS_SCRIPT\",t[t.BIP32_DERIVATION=2]=\"BIP32_DERIVATION\",t[t.TAP_INTERNAL_KEY=5]=\"TAP_INTERNAL_KEY\",t[t.TAP_TREE=6]=\"TAP_TREE\",t[t.TAP_BIP32_DERIVATION=7]=\"TAP_BIP32_DERIVATION\"}(e.OutputTypes||(e.OutputTypes={})),e.OUTPUT_TYPE_NAMES=[\"redeemScript\",\"witnessScript\",\"bip32Derivation\",\"tapInternalKey\",\"tapTree\",\"tapBip32Derivation\"]},2431:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function s(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function a(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function c(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:s,canAddToArray:c,check:u,expected:f}=i[t+\"s\"][n]||{};if(u)if(!!c){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(u)||a(t,n,f,o);const e=r[n]||[],i=new Set;if(!o.every((t=>c(e,t,i))))throw new Error(\"Can not add duplicate data to array\");r[n]=e.concat(o)}else{if(u(o)||a(t,n,f,o),!s(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=s,e.checkHasKey=function(t,e,r){if(t.key[0]e.key.equals(t.key))).length)throw new Error(`Duplicate Key: ${t.key.toString(\"hex\")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach((t=>{Number(isNaN(Number(t)))&&e++})),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,s=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=c(\"global\"),e.updateInput=c(\"input\"),e.updateOutput=c(\"output\"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=s(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error(\"Set Version: Invalid Transaction\");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error(\"Set Locktime: Invalid Transaction\");return e.writeUInt32LE(t,e.length-4),e}},3678:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(3678),i=r(1752);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.add=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=e.split=e.fromBig=void 0;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;oBigInt(t>>>0)<>>0);e.toBig=s;const a=(t,e,r)=>t>>>r;e.shrSH=a;const c=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=c;const u=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=u;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const h=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=h;const l=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=l;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<>>32-r;e.rotlSH=y;const g=(t,e,r)=>e<>>32-r;e.rotlSL=g;const b=(t,e,r)=>e<>>64-r;e.rotlBH=b;const w=(t,e,r)=>t<>>64-r;function m(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w,e.add=m;const v=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=v;const E=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=E;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const A=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=A;const I=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=I;const T={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:h,rotrBL:l,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:g,rotlBH:b,rotlBL:w,add:m,add3L:v,add3H:E,add4L:_,add4H:S,add5H:I,add5L:A};e.default=T},8280:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},4966:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(3678),i=r(1752);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),\"function\"!=typeof this.iHash.update)throw new Error(\"Expected instance of class which extends utils.Hash\");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;tnew o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},2985:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(7653),i=r(1752),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),a=s.map((t=>(9*t+5)%16));let c=[s],u=[a];for(let t=0;t<4;t++)for(let e of[c,u])e.push(e[t].map((t=>o[t])));const f=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),l=u.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const g=new Uint32Array(16);class b extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)g[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,a=0|this.h2,f=a,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=p[t],_=d[t],S=c[t],A=u[t],I=h[t],T=l[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,a,b)+g[S[e]]+E,I[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(a,10),a=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,s,f,w)+g[A[t]]+_,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(f,10),f=s,s=r}}this.set(this.h1+a+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+f|0)}roundClean(){g.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=b,e.ripemd160=(0,i.wrapConstructor)((()=>new b))},4458:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(7653),i=r(1752),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},4787:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha384=e.sha512_256=e.sha512_224=e.sha512=e.SHA512=void 0;const n=r(7653),i=r(6079),o=r(1752),[s,a]=i.default.split([\"0x428a2f98d728ae22\",\"0x7137449123ef65cd\",\"0xb5c0fbcfec4d3b2f\",\"0xe9b5dba58189dbbc\",\"0x3956c25bf348b538\",\"0x59f111f1b605d019\",\"0x923f82a4af194f9b\",\"0xab1c5ed5da6d8118\",\"0xd807aa98a3030242\",\"0x12835b0145706fbe\",\"0x243185be4ee4b28c\",\"0x550c7dc3d5ffb4e2\",\"0x72be5d74f27b896f\",\"0x80deb1fe3b1696b1\",\"0x9bdc06a725c71235\",\"0xc19bf174cf692694\",\"0xe49b69c19ef14ad2\",\"0xefbe4786384f25e3\",\"0x0fc19dc68b8cd5b5\",\"0x240ca1cc77ac9c65\",\"0x2de92c6f592b0275\",\"0x4a7484aa6ea6e483\",\"0x5cb0a9dcbd41fbd4\",\"0x76f988da831153b5\",\"0x983e5152ee66dfab\",\"0xa831c66d2db43210\",\"0xb00327c898fb213f\",\"0xbf597fc7beef0ee4\",\"0xc6e00bf33da88fc2\",\"0xd5a79147930aa725\",\"0x06ca6351e003826f\",\"0x142929670a0e6e70\",\"0x27b70a8546d22ffc\",\"0x2e1b21385c26c926\",\"0x4d2c6dfc5ac42aed\",\"0x53380d139d95b3df\",\"0x650a73548baf63de\",\"0x766a0abb3c77b2a8\",\"0x81c2c92e47edaee6\",\"0x92722c851482353b\",\"0xa2bfe8a14cf10364\",\"0xa81a664bbc423001\",\"0xc24b8b70d0f89791\",\"0xc76c51a30654be30\",\"0xd192e819d6ef5218\",\"0xd69906245565a910\",\"0xf40e35855771202a\",\"0x106aa07032bbd1b8\",\"0x19a4c116b8d2d0c8\",\"0x1e376c085141ab53\",\"0x2748774cdf8eeb99\",\"0x34b0bcb5e19b48a8\",\"0x391c0cb3c5c95a63\",\"0x4ed8aa4ae3418acb\",\"0x5b9cca4f7763e373\",\"0x682e6ff3d6b2b8a3\",\"0x748f82ee5defb2fc\",\"0x78a5636f43172f60\",\"0x84c87814a1f0ab72\",\"0x8cc702081a6439ec\",\"0x90befffa23631e28\",\"0xa4506cebde82bde9\",\"0xbef9a3f7b2c67915\",\"0xc67178f2e372532b\",\"0xca273eceea26619c\",\"0xd186b8c721c0c207\",\"0xeada7dd6cde0eb1e\",\"0xf57d4f7fee6ed178\",\"0x06f067aa72176fba\",\"0x0a637dc5a2c898a6\",\"0x113f9804bef90dae\",\"0x1b710b35131c471b\",\"0x28db77f523047d84\",\"0x32caab7b40c72493\",\"0x3c9ebe0a15c9bebc\",\"0x431d67c49c100d4c\",\"0x4cc5d4becb3e42b6\",\"0x597f299cfc657e2a\",\"0x5fcb6fab3ad6faec\",\"0x6c44198c4a475817\"].map((t=>BigInt(t)))),c=new Uint32Array(80),u=new Uint32Array(80);class f extends n.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:f,Fl:h,Gh:l,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,s,a,c,u,f,h,l,p,d,y]}set(t,e,r,n,i,o,s,a,c,u,f,h,l,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|f,this.Fl=0|h,this.Gh=0|l,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)c[r]=t.getUint32(e),u[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|c[t-15],r=0|u[t-15],n=i.default.rotrSH(e,r,1)^i.default.rotrSH(e,r,8)^i.default.shrSH(e,r,7),o=i.default.rotrSL(e,r,1)^i.default.rotrSL(e,r,8)^i.default.shrSL(e,r,7),s=0|c[t-2],a=0|u[t-2],f=i.default.rotrSH(s,a,19)^i.default.rotrBH(s,a,61)^i.default.shrSH(s,a,6),h=i.default.rotrSL(s,a,19)^i.default.rotrBL(s,a,61)^i.default.shrSL(s,a,6),l=i.default.add4L(o,h,u[t-7],u[t-16]),p=i.default.add4H(l,n,f,c[t-7],c[t-16]);c[t]=0|p,u[t]=0|l}let{Ah:r,Al:n,Bh:o,Bl:f,Ch:h,Cl:l,Dh:p,Dl:d,Eh:y,El:g,Fh:b,Fl:w,Gh:m,Gl:v,Hh:E,Hl:_}=this;for(let t=0;t<80;t++){const e=i.default.rotrSH(y,g,14)^i.default.rotrSH(y,g,18)^i.default.rotrBH(y,g,41),S=i.default.rotrSL(y,g,14)^i.default.rotrSL(y,g,18)^i.default.rotrBL(y,g,41),A=y&b^~y&m,I=g&w^~g&v,T=i.default.add5L(_,S,I,a[t],u[t]),x=i.default.add5H(T,E,e,A,s[t],c[t]),O=0|T,k=i.default.rotrSH(r,n,28)^i.default.rotrBH(r,n,34)^i.default.rotrBH(r,n,39),P=i.default.rotrSL(r,n,28)^i.default.rotrBL(r,n,34)^i.default.rotrBL(r,n,39),R=r&o^r&h^o&h,B=n&f^n&l^f&l;E=0|m,_=0|v,m=0|b,v=0|w,b=0|y,w=0|g,({h:y,l:g}=i.default.add(0|p,0|d,0|x,0|O)),p=0|h,d=0|l,h=0|o,l=0|f,o=0|r,f=0|n;const C=i.default.add3L(O,P,B);r=i.default.add3H(C,x,k,R),n=0|C}({h:r,l:n}=i.default.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:f}=i.default.add(0|this.Bh,0|this.Bl,0|o,0|f)),({h,l}=i.default.add(0|this.Ch,0|this.Cl,0|h,0|l)),({h:p,l:d}=i.default.add(0|this.Dh,0|this.Dl,0|p,0|d)),({h:y,l:g}=i.default.add(0|this.Eh,0|this.El,0|y,0|g)),({h:b,l:w}=i.default.add(0|this.Fh,0|this.Fl,0|b,0|w)),({h:m,l:v}=i.default.add(0|this.Gh,0|this.Gl,0|m,0|v)),({h:E,l:_}=i.default.add(0|this.Hh,0|this.Hl,0|E,0|_)),this.set(r,n,o,f,h,l,p,d,y,g,b,w,m,v,E,_)}roundClean(){c.fill(0),u.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}e.SHA512=f;class h extends f{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class l extends f{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class p extends f{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}e.sha512=(0,o.wrapConstructor)((()=>new f)),e.sha512_224=(0,o.wrapConstructor)((()=>new h)),e.sha512_256=(0,o.wrapConstructor)((()=>new l)),e.sha384=(0,o.wrapConstructor)((()=>new p))},1752:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(8280),i=r(3678);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},3803:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.BIP32Factory=void 0;const i=r(1772),o=r(8899),s=r(6710),a=r(4458),c=r(973),u=r(6952),f=(0,s.base58check)(a.sha256),h=t=>f.encode(Uint8Array.from(t)),l=t=>n.from(f.decode(t));e.BIP32Factory=function(t){(0,o.testEcc)(t);const e=c.BufferN(32),r=c.compile({wif:c.UInt8,bip32:{public:c.UInt32,private:c.UInt32}}),s={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},a=2147483648,f=Math.pow(2,31)-1;function p(t){return c.String(t)&&null!==t.match(/^(m\\/)?(\\d+'?\\/)*\\d+'?$/)}function d(t){return c.UInt32(t)&&t<=f}class y{constructor(t,e){this.__D=t,this.__Q=e,this.lowR=!1}get publicKey(){return void 0===this.__Q&&(this.__Q=n.from(t.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error(\"Missing private key\");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.privateKey));{let r=n.from(t.sign(e,this.privateKey));const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=n.from(t.sign(e,this.privateKey,i));return r}}signSchnorr(e){if(!this.privateKey)throw new Error(\"Missing private key\");if(!t.signSchnorr)throw new Error(\"signSchnorr not supported by ecc library\");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error(\"verifySchnorr not supported by ecc library\");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}}class g extends y{constructor(t,e,n,i,o=0,s=0,a=0){super(t,e),this.chainCode=n,this.network=i,this.__DEPTH=o,this.__INDEX=s,this.__PARENT_FINGERPRINT=a,c(r,i)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return i.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return m(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=n.allocUnsafe(78);return r.writeUInt32BE(e,0),r.writeUInt8(this.depth,4),r.writeUInt32BE(this.parentFingerprint,5),r.writeUInt32BE(this.index,9),this.chainCode.copy(r,13),this.isNeutered()?this.publicKey.copy(r,45):(r.writeUInt8(0,45),this.privateKey.copy(r,46)),h(r)}toWIF(){if(!this.privateKey)throw new TypeError(\"Missing private key\");return u.encode(this.network.wif,this.privateKey,!0)}derive(e){c(c.UInt32,e);const r=e>=a,o=n.allocUnsafe(37);if(r){if(this.isNeutered())throw new TypeError(\"Missing private key for hardened child key\");o[0]=0,this.privateKey.copy(o,1),o.writeUInt32BE(e,33)}else this.publicKey.copy(o,0),o.writeUInt32BE(e,33);const s=i.hmacSHA512(this.chainCode,o),u=s.slice(0,32),f=s.slice(32);if(!t.isPrivate(u))return this.derive(e+1);let h;if(this.isNeutered()){const r=n.from(t.pointAddScalar(this.publicKey,u,!0));if(null===r)return this.derive(e+1);h=m(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}else{const r=n.from(t.privateAdd(this.privateKey,u));if(null==r)return this.derive(e+1);h=w(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}return h}deriveHardened(t){return c(d,t),this.derive(t+a)}derivePath(t){c(p,t);let e=t.split(\"/\");if(\"m\"===e[0]){if(this.parentFingerprint)throw new TypeError(\"Expected master, got child\");e=e.slice(1)}return e.reduce(((t,e)=>{let r;return\"'\"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error(\"xOnlyPointAddTweak not supported by ecc library\");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error(\"Cannot tweak public key!\");const s=n.from([0===o.parity?2:3]),a=n.concat([s,o.xOnlyPubkey]);return new y(void 0,a)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&1==(1&this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error(\"privateNegate not supported by ecc library\")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error(\"Invalid tweaked private key!\");return new y(n.from(o),void 0)}}function b(t,e,r){return w(t,e,r)}function w(r,n,i,o,a,u){if(c({privateKey:e,chainCode:e},{privateKey:r,chainCode:n}),i=i||s,!t.isPrivate(r))throw new TypeError(\"Private key not in range [1, n)\");return new g(r,void 0,n,i,o,a,u)}function m(r,n,i,o,a,u){if(c({publicKey:c.BufferN(33),chainCode:e},{publicKey:r,chainCode:n}),i=i||s,!t.isPoint(r))throw new TypeError(\"Point is not on the curve\");return new g(void 0,r,n,i,o,a,u)}return{fromSeed:function(t,e){if(c(c.Buffer,t),t.length<16)throw new TypeError(\"Seed should be at least 128 bits\");if(t.length>64)throw new TypeError(\"Seed should be at most 512 bits\");e=e||s;const r=i.hmacSHA512(n.from(\"Bitcoin seed\",\"utf8\"),t);return b(r.slice(0,32),r.slice(32),e)},fromBase58:function(t,e){const r=l(t);if(78!==r.length)throw new TypeError(\"Invalid buffer length\");e=e||s;const n=r.readUInt32BE(0);if(n!==e.bip32.private&&n!==e.bip32.public)throw new TypeError(\"Invalid network version\");const i=r[4],o=r.readUInt32BE(5);if(0===i&&0!==o)throw new TypeError(\"Invalid parent fingerprint\");const a=r.readUInt32BE(9);if(0===i&&0!==a)throw new TypeError(\"Invalid index\");const c=r.slice(13,45);let u;if(n===e.bip32.private){if(0!==r.readUInt8(45))throw new TypeError(\"Invalid private key\");u=w(r.slice(46,78),c,e,i,a,o)}else{u=m(r.slice(45,78),c,e,i,a,o)}return u},fromPublicKey:function(t,e,r){return m(t,e,r)},fromPrivateKey:b}}},1772:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmacSHA512=e.hash160=void 0;const i=r(4966),o=r(2985),s=r(4458),a=r(4787);e.hash160=function(t){const e=(0,s.sha256)(Uint8Array.from(t));return n.from((0,o.ripemd160)(e))},e.hmacSHA512=function(t,e){return n.from((0,i.hmac)(a.sha512,t,e))}},3553:(t,e,r)=>{\"use strict\";e.Pr=void 0;var n=r(3803);Object.defineProperty(e,\"Pr\",{enumerable:!0,get:function(){return n.BIP32Factory}})},8899:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,\"hex\");function o(t){if(!t)throw new Error(\"ecc library invalid\")}e.testEcc=function(t){if(o(t.isPoint(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(!t.isPoint(i(\"030000000000000000000000000000000000000000000000000000000000000005\"))),o(t.isPrivate(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(!t.isPrivate(i(\"0000000000000000000000000000000000000000000000000000000000000000\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142\"))),o(n.from(t.pointFromScalar(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99\"))),t.xOnlyPointAddTweak){o(null===t.xOnlyPointAddTweak(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\")));let e=t.xOnlyPointAddTweak(i(\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\"),i(\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\"));o(n.from(e.xOnlyPubkey).equals(i(\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"))&&1===e.parity),e=t.xOnlyPointAddTweak(i(\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\"),i(\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\"))}o(n.from(t.pointAddScalar(i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"0000000000000000000000000000000000000000000000000000000000000003\"))).equals(i(\"02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\"))),o(n.from(t.privateAdd(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"),i(\"0000000000000000000000000000000000000000000000000000000000000002\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),t.privateNegate&&(o(n.from(t.privateNegate(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(n.from(t.privateNegate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateNegate(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792\")))),o(n.from(t.sign(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))).equals(i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),o(t.verify(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),t.signSchnorr&&o(n.from(t.signSchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9\"),i(\"c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906\"))).equals(i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\"))),t.verifySchnorr&&o(t.verifySchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8\"),i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\")))}},3877:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(3877),i=r(775);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},742:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(1810),i=r(775),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),a=s.map((t=>(9*t+5)%16));let c=[s],u=[a];for(let t=0;t<4;t++)for(let e of[c,u])e.push(e[t].map((t=>o[t])));const f=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),l=u.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const g=new Uint32Array(16);class b extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)g[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,a=0|this.h2,f=a,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=p[t],_=d[t],S=c[t],A=u[t],I=h[t],T=l[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,a,b)+g[S[e]]+E,I[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(a,10),a=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,s,f,w)+g[A[t]]+_,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(f,10),f=s,s=r}}this.set(this.h1+a+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+f|0)}roundClean(){g.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=b,e.ripemd160=(0,i.wrapConstructor)((()=>new b))},3293:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha1=void 0;const n=r(1810),i=r(775),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),s=new Uint32Array(80);class a extends n.HashMD{constructor(){super(64,20,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4]}get(){const{A:t,B:e,C:r,D:n,E:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)s[t]=(0,i.rotl)(s[t-3]^s[t-8]^s[t-14]^s[t-16],1);let{A:r,B:o,C:a,D:c,E:u}=this;for(let t=0;t<80;t++){let e,f;t<20?(e=(0,n.Chi)(o,a,c),f=1518500249):t<40?(e=o^a^c,f=1859775393):t<60?(e=(0,n.Maj)(o,a,c),f=2400959708):(e=o^a^c,f=3395469782);const h=(0,i.rotl)(r,5)+e+u+f+s[t]|0;u=c,c=a,a=(0,i.rotl)(o,30),o=r,r=h}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,c=c+this.D|0,u=u+this.E|0,this.set(r,o,a,c,u)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.sha1=(0,i.wrapConstructor)((()=>new a))},5743:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(1810),i=r(775),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},775:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(8713),i=r(3877);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},7748:t=>{\"use strict\";t.exports=function(t){if(t.length>=255)throw new TypeError(\"Alphabet too long\");for(var e=new Uint8Array(256),r=0;r>>0,u=new Uint8Array(o);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,l=o-1;(0!==f||h>>0,u[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error(\"Non-zero carry\");i=h,r++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var d=new Uint8Array(n+(o-p)),y=n;p!==o;)d[y++]=u[p++];return d}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError(\"Expected Uint8Array\");if(0===e.length)return\"\";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var c=(o-i)*u+1>>>0,f=new Uint8Array(c);i!==o;){for(var h=e[i],l=0,p=c-1;(0!==h||l>>0,f[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error(\"Non-zero carry\");n=l,i++}for(var d=c-n;d!==c&&0===f[d];)d++;for(var y=a.repeat(r);d{const n=r(7748);t.exports=n(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\")},5940:(t,e,r)=>{\"use strict\";var n=r(8155);t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),i=t(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error(\"Invalid checksum\");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},7329:(t,e,r)=>{\"use strict\";var{sha256:n}=r(5743),i=r(5940);t.exports=i((function(t){return n(n(t))}))},3348:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.toOutputScript=e.fromOutputScript=e.toBech32=e.toBase58Check=e.fromBech32=e.fromBase58Check=void 0;const i=r(2529),o=r(8614),s=r(4009),a=r(5593),c=r(6586),u=r(7329),f=40,h=2,l=16,p=2,d=80,y=\"WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.\";function g(t){const e=n.from(u.decode(t));if(e.length<21)throw new TypeError(t+\" is too short\");if(e.length>21)throw new TypeError(t+\" is too long\");return{version:e.readUInt8(0),hash:e.slice(1)}}function b(t){let e,r;try{e=c.bech32.decode(t)}catch(t){}if(e){if(r=e.words[0],0!==r)throw new TypeError(t+\" uses wrong encoding\")}else if(e=c.bech32m.decode(t),r=e.words[0],0===r)throw new TypeError(t+\" uses wrong encoding\");const i=c.bech32.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:n.from(i)}}function w(t,e,r){const n=c.bech32.toWords(t);return n.unshift(e),0===e?c.bech32.encode(r,n):c.bech32m.encode(r,n)}e.fromBase58Check=g,e.fromBech32=b,e.toBase58Check=function(t,e){(0,a.typeforce)((0,a.tuple)(a.Hash160bit,a.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),u.encode(r)},e.toBech32=w,e.fromOutputScript=function(t,e){e=e||i.bitcoin;try{return o.p2pkh({output:t,network:e}).address}catch(t){}try{return o.p2sh({output:t,network:e}).address}catch(t){}try{return o.p2wpkh({output:t,network:e}).address}catch(t){}try{return o.p2wsh({output:t,network:e}).address}catch(t){}try{return o.p2tr({output:t,network:e}).address}catch(t){}try{return function(t,e){const r=t.slice(2);if(r.lengthf)throw new TypeError(\"Invalid program length for segwit address\");const n=t[0]-d;if(nl)throw new TypeError(\"Invalid version for segwit address\");if(t[1]!==r.length)throw new TypeError(\"Invalid script for segwit address\");return console.warn(y),w(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(s.toASM(t)+\" has no matching Address\")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=g(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===e.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=b(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+\" has an invalid prefix\");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=p&&n.version<=l&&n.data.length>=h&&n.data.length<=f)return console.warn(y),s.compile([n.version+d,n.data])}}throw new Error(t+\" has no matching Script\")}},195:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=e.check=void 0,e.check=function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;const e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;const r=t[5+e];return 0!==r&&(6+e+r===t.length&&(!(128&t[4])&&(!(e>1&&0===t[4]&&!(128&t[5]))&&(!(128&t[e+6])&&!(r>1&&0===t[e+6]&&!(128&t[e+7]))))))},e.decode=function(t){if(t.length<8)throw new Error(\"DER sequence length is too short\");if(t.length>72)throw new Error(\"DER sequence length is too long\");if(48!==t[0])throw new Error(\"Expected DER sequence\");if(t[1]!==t.length-2)throw new Error(\"DER sequence length is invalid\");if(2!==t[2])throw new Error(\"Expected DER integer\");const e=t[3];if(0===e)throw new Error(\"R length is zero\");if(5+e>=t.length)throw new Error(\"R length is too long\");if(2!==t[4+e])throw new Error(\"Expected DER integer (2)\");const r=t[5+e];if(0===r)throw new Error(\"S length is zero\");if(6+e+r!==t.length)throw new Error(\"S length is invalid\");if(128&t[4])throw new Error(\"R value is negative\");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error(\"R value excessively padded\");if(128&t[e+6])throw new Error(\"S value is negative\");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error(\"S value excessively padded\");return{r:t.slice(4,4+e),s:t.slice(6+e)}},e.encode=function(t,e){const r=t.length,i=e.length;if(0===r)throw new Error(\"R length is zero\");if(0===i)throw new Error(\"S length is zero\");if(r>33)throw new Error(\"R length is too long\");if(i>33)throw new Error(\"S length is too long\");if(128&t[0])throw new Error(\"R value is negative\");if(128&e[0])throw new Error(\"S value is negative\");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error(\"R value excessively padded\");if(i>1&&0===e[0]&&!(128&e[1]))throw new Error(\"S value excessively padded\");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=t.length,t.copy(o,4),o[4+r]=2,o[5+r]=e.length,e.copy(o,6+r),o}},1169:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Block=void 0;const i=r(3831),o=r(6891),s=r(7992),a=r(3063),c=r(5593),{typeforce:u}=c,f=new TypeError(\"Cannot compute merkle root for zero transactions\"),h=new TypeError(\"Cannot compute witness commit for non-segwit block\");class l{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(t){if(t.length<80)throw new Error(\"Buffer too small (< 80 bytes)\");const e=new i.BufferReader(t),r=new l;if(r.version=e.readInt32(),r.prevHash=e.readSlice(32),r.merkleRoot=e.readSlice(32),r.timestamp=e.readUInt32(),r.bits=e.readUInt32(),r.nonce=e.readUInt32(),80===t.length)return r;const n=()=>{const t=a.Transaction.fromBuffer(e.buffer.slice(e.offset),!0);return e.offset+=t.byteLength(),t},o=e.readVarInt();r.transactions=[];for(let t=0;t>24)-3,r=8388607&t,i=n.alloc(32,0);return i.writeUIntBE(r,29-e,3),i}static calculateMerkleRoot(t,e){if(u([{getHash:c.Function}],t),0===t.length)throw f;if(e&&!p(t))throw h;const r=t.map((t=>t.getHash(e))),i=(0,s.fastMerkleRoot)(r,o.hash256);return e?o.hash256(n.concat([i,t[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!p(this.transactions))return null;const t=this.transactions[0].outs.filter((t=>t.script.slice(0,6).equals(n.from(\"6a24aa21a9ed\",\"hex\")))).map((t=>t.script.slice(6,38)));if(0===t.length)return null;const e=t[t.length-1];return e instanceof n&&32===e.length?e:null}hasWitnessCommit(){return this.witnessCommit instanceof n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(t=this.transactions)instanceof Array&&t.some((t=>\"object\"==typeof t&&t.ins instanceof Array&&t.ins.some((t=>\"object\"==typeof t&&t.witness instanceof Array&&t.witness.length>0))));var t}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(t,e=!0){return t||!this.transactions?80:80+i.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((t,r)=>t+r.byteLength(e)),0)}getHash(){return o.hash256(this.toBuffer(!0))}getId(){return(0,i.reverseBuffer)(this.getHash()).toString(\"hex\")}getUTCDate(){const t=new Date(0);return t.setUTCSeconds(this.timestamp),t}toBuffer(t){const e=n.allocUnsafe(this.byteLength(t)),r=new i.BufferWriter(e);return r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),t||!this.transactions||(i.varuint.encode(this.transactions.length,e,r.offset),r.offset+=i.varuint.encode.bytes,this.transactions.forEach((t=>{const n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}toHex(t){return this.toBuffer(t).toString(\"hex\")}checkTxRoots(){const t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&(this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit()))}checkProofOfWork(){const t=(0,i.reverseBuffer)(this.getHash()),e=l.calculateTarget(this.bits);return t.compare(e)<=0}__checkMerkleRoot(){if(!this.transactions)throw f;const t=l.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw f;if(!this.hasWitnessCommit())throw h;const t=l.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}function p(t){return t instanceof Array&&t[0]&&t[0].ins&&t[0].ins instanceof Array&&t[0].ins[0]&&t[0].ins[0].witness&&t[0].ins[0].witness instanceof Array&&t[0].ins[0].witness.length>0}e.Block=l},3831:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.BufferReader=e.BufferWriter=e.cloneBuffer=e.reverseBuffer=e.writeUInt64LE=e.readUInt64LE=e.varuint=void 0;const i=r(5593),{typeforce:o}=i,s=r(7820);function a(t,e){if(\"number\"!=typeof t)throw new Error(\"cannot write a non-number as a number\");if(t<0)throw new Error(\"specified a negative value for writing an unsigned value\");if(t>e)throw new Error(\"RangeError: value out of range\");if(Math.floor(t)!==t)throw new Error(\"value has a fractional component\")}function c(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r}function u(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}e.varuint=s,e.readUInt64LE=c,e.writeUInt64LE=u,e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;nthis.writeVarSlice(t)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}e.BufferWriter=f;e.BufferReader=class{constructor(t,e=0){this.buffer=t,this.offset=e,o(i.tuple(i.Buffer,i.UInt32),[t,e])}readUInt8(){const t=this.buffer.readUInt8(this.offset);return this.offset++,t}readInt32(){const t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}readUInt32(){const t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}readUInt64(){const t=c(this.buffer,this.offset);return this.offset+=8,t}readVarInt(){const t=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,t}readSlice(t){if(this.buffer.length{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const i=r(742),o=r(3293),s=r(5743);function a(t){return n.from((0,s.sha256)(Uint8Array.from(t)))}e.ripemd160=function(t){return n.from((0,i.ripemd160)(Uint8Array.from(t)))},e.sha1=function(t){return n.from((0,o.sha1)(Uint8Array.from(t)))},e.sha256=a,e.hash160=function(t){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(t))))},e.TAGS=[\"BIP0340/challenge\",\"BIP0340/aux\",\"BIP0340/nonce\",\"TapLeaf\",\"TapBranch\",\"TapSighash\",\"TapTweak\",\"KeyAgg list\",\"KeyAgg coefficient\"],e.TAGGED_HASH_PREFIXES={\"BIP0340/challenge\":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),\"BIP0340/aux\":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),\"BIP0340/nonce\":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),\"KeyAgg list\":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),\"KeyAgg coefficient\":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},e.taggedHash=function(t,r){return a(n.concat([e.TAGGED_HASH_PREFIXES[t],r]))}},6313:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.getEccLib=e.initEccLib=void 0;const i={};e.initEccLib=function(t){var e;t?t!==i.eccLib&&(s(\"function\"==typeof(e=t).isXOnlyPoint),s(e.isXOnlyPoint(o(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),s(e.isXOnlyPoint(o(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e\"))),s(e.isXOnlyPoint(o(\"f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9\"))),s(e.isXOnlyPoint(o(\"0000000000000000000000000000000000000000000000000000000000000001\"))),s(!e.isXOnlyPoint(o(\"0000000000000000000000000000000000000000000000000000000000000000\"))),s(!e.isXOnlyPoint(o(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\"))),s(\"function\"==typeof e.xOnlyPointAddTweak),a.forEach((t=>{const r=e.xOnlyPointAddTweak(o(t.pubkey),o(t.tweak));null===t.result?s(null===r):(s(null!==r),s(r.parity===t.parity),s(n.from(r.xOnlyPubkey).equals(o(t.result))))})),i.eccLib=t):i.eccLib=t},e.getEccLib=function(){if(!i.eccLib)throw new Error(\"No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance\");return i.eccLib};const o=t=>n.from(t,\"hex\");function s(t){if(!t)throw new Error(\"ecc library invalid\")}const a=[{pubkey:\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\",tweak:\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\",parity:-1,result:null},{pubkey:\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\",tweak:\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\",parity:1,result:\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"},{pubkey:\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\",tweak:\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\",parity:0,result:\"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c\"}]},7612:(t,e,r)=>{\"use strict\";e.ZX=e.iL=e.KT=e.o8=e.hl=void 0;const n=r(3348);e.hl=n;r(6891);const i=r(2529);e.o8=i;const o=r(8614);e.KT=o;r(4009);var s=r(1169);var a=r(6689);Object.defineProperty(e,\"iL\",{enumerable:!0,get:function(){return a.Psbt}});var c=r(8156);var u=r(3063);Object.defineProperty(e,\"ZX\",{enumerable:!0,get:function(){return u.Transaction}});var f=r(6313)},7992:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.fastMerkleRoot=void 0,e.fastMerkleRoot=function(t,e){if(!Array.isArray(t))throw TypeError(\"Expected values Array\");if(\"function\"!=typeof e)throw TypeError(\"Expected digest Function\");let r=t.length;const i=t.concat();for(;r>1;){let t=0;for(let o=0;o{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.testnet=e.regtest=e.bitcoin=void 0,e.bitcoin={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.regtest={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bcrt\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},e.testnet={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"tb\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},8156:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.REVERSE_OPS=e.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};e.OPS=r;const n={};e.REVERSE_OPS=n;for(const t of Object.keys(r)){n[r[t]]=t}},5247:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(1048),i=r(6313),o=r(6891),s=r(3831),a=r(5593);e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128;function c(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return o.taggedHash(\"TapLeaf\",n.Buffer.concat([n.Buffer.from([r]),h(t.output)]))}function u(t,e){return o.taggedHash(\"TapTweak\",n.Buffer.concat(e?[t,e]:[t]))}function f(t,e){return o.taggedHash(\"TapBranch\",n.Buffer.concat([t,e]))}function h(t){const e=s.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return s.varuint.encode(t.length,r),n.Buffer.concat([r,t])}e.rootHashFromPath=function(t,e){if(t.length<33)throw new TypeError(`The control-block length is too small. Got ${t.length}, expected min 33.`);const r=(t.length-33)/32;let n=e;for(let e=0;et.hash.compare(e.hash)));const[n,i]=r;return{hash:f(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function t(e,r){if(\"left\"in(n=e)&&\"right\"in n){const n=t(e.left,r);if(void 0!==n)return[...n,e.right.hash];const i=t(e.right,r);if(void 0!==i)return[...i,e.left.hash]}else if(e.hash.equals(r))return[];var n},e.tapleafHash=c,e.tapTweakHash=u,e.tweakKey=function(t,e){if(!n.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;const r=u(t,e),o=(0,i.getEccLib)().xOnlyPointAddTweak(t,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},271:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2data=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;e.p2data=function(t,e){if(!t.data&&!t.output)throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},t);const r={name:\"embed\",network:t.network||n.bitcoin};if(s.prop(r,\"output\",(()=>{if(t.data)return i.compile([a.OP_RETURN].concat(t.data))})),s.prop(r,\"data\",(()=>{if(t.output)return i.decompile(t.output).slice(1)})),e.validate&&t.output){const e=i.decompile(t.output);if(e[0]!==a.OP_RETURN)throw new TypeError(\"Output is invalid\");if(!e.slice(1).every(o.typeforce.Buffer))throw new TypeError(\"Output is invalid\");if(t.data&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.data,r.data))throw new TypeError(\"Data mismatch\")}return Object.assign(r,t)}},8614:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const n=r(271);Object.defineProperty(e,\"embed\",{enumerable:!0,get:function(){return n.p2data}});const i=r(2810);Object.defineProperty(e,\"p2ms\",{enumerable:!0,get:function(){return i.p2ms}});const o=r(5643);Object.defineProperty(e,\"p2pk\",{enumerable:!0,get:function(){return o.p2pk}});const s=r(9379);Object.defineProperty(e,\"p2pkh\",{enumerable:!0,get:function(){return s.p2pkh}});const a=r(2129);Object.defineProperty(e,\"p2sh\",{enumerable:!0,get:function(){return a.p2sh}});const c=r(7090);Object.defineProperty(e,\"p2wpkh\",{enumerable:!0,get:function(){return c.p2wpkh}});const u=r(2366);Object.defineProperty(e,\"p2wsh\",{enumerable:!0,get:function(){return u.p2wsh}});const f=r(1992);Object.defineProperty(e,\"p2tr\",{enumerable:!0,get:function(){return f.p2tr}})},9158:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.value=e.prop=void 0,e.prop=function(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){const t=r.call(this);return this[e]=t,t},set(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})},e.value=function(t){let e;return()=>(void 0!==e||(e=t()),e)}},2810:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2ms=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS,c=a.OP_RESERVED;function u(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}e.p2ms=function(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError(\"Not enough data\");function r(t){return i.isCanonicalScriptSignature(t)||void 0!==(e.allowIncomplete&&t===a.OP_0)}e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const f={network:t.network||n.bitcoin};let h=[],l=!1;function p(t){l||(l=!0,h=i.decompile(t),f.m=h[0]-c,f.n=h[h.length-2]-c,f.pubkeys=h.slice(1,-2))}if(s.prop(f,\"output\",(()=>{if(t.m&&f.n&&t.pubkeys)return i.compile([].concat(c+t.m,t.pubkeys,c+f.n,a.OP_CHECKMULTISIG))})),s.prop(f,\"m\",(()=>{if(f.output)return p(f.output),f.m})),s.prop(f,\"n\",(()=>{if(f.pubkeys)return f.pubkeys.length})),s.prop(f,\"pubkeys\",(()=>{if(t.output)return p(t.output),f.pubkeys})),s.prop(f,\"signatures\",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),s.prop(f,\"input\",(()=>{if(t.signatures)return i.compile([a.OP_0].concat(t.signatures))})),s.prop(f,\"witness\",(()=>{if(f.input)return[]})),s.prop(f,\"name\",(()=>{if(f.m&&f.n)return`p2ms(${f.m} of ${f.n})`})),e.validate){if(t.output){if(p(t.output),!o.typeforce.Number(h[0]))throw new TypeError(\"Output is invalid\");if(!o.typeforce.Number(h[h.length-2]))throw new TypeError(\"Output is invalid\");if(h[h.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError(\"Output is invalid\");if(f.m<=0||f.n>16||f.m>f.n||f.n!==h.length-3)throw new TypeError(\"Output is invalid\");if(!f.pubkeys.every((t=>(0,o.isPoint)(t))))throw new TypeError(\"Output is invalid\");if(void 0!==t.m&&t.m!==f.m)throw new TypeError(\"m mismatch\");if(void 0!==t.n&&t.n!==f.n)throw new TypeError(\"n mismatch\");if(t.pubkeys&&!u(t.pubkeys,f.pubkeys))throw new TypeError(\"Pubkeys mismatch\")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError(\"Pubkey count mismatch\");if(f.n=t.pubkeys.length,f.nf.m)throw new TypeError(\"Too many signatures provided\")}if(t.input){if(t.input[0]!==a.OP_0)throw new TypeError(\"Input is invalid\");if(0===f.signatures.length||!f.signatures.every(r))throw new TypeError(\"Input has invalid signature(s)\");if(t.signatures&&!u(t.signatures,f.signatures))throw new TypeError(\"Signature mismatch\");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError(\"Signature count mismatch\")}}return Object.assign(f,t)}},5643:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2pk=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;e.p2pk=function(t,e){if(!(t.input||t.output||t.pubkey||t.input||t.signature))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const r=s.value((()=>i.decompile(t.input))),c={name:\"p2pk\",network:t.network||n.bitcoin};if(s.prop(c,\"output\",(()=>{if(t.pubkey)return i.compile([t.pubkey,a.OP_CHECKSIG])})),s.prop(c,\"pubkey\",(()=>{if(t.output)return t.output.slice(1,-1)})),s.prop(c,\"signature\",(()=>{if(t.input)return r()[0]})),s.prop(c,\"input\",(()=>{if(t.signature)return i.compile([t.signature])})),s.prop(c,\"witness\",(()=>{if(c.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==a.OP_CHECKSIG)throw new TypeError(\"Output is invalid\");if(!(0,o.isPoint)(c.pubkey))throw new TypeError(\"Output pubkey is invalid\");if(t.pubkey&&!t.pubkey.equals(c.pubkey))throw new TypeError(\"Pubkey mismatch\")}if(t.signature&&t.input&&!t.input.equals(c.input))throw new TypeError(\"Signature mismatch\");if(t.input){if(1!==r().length)throw new TypeError(\"Input is invalid\");if(!i.isCanonicalScriptSignature(c.signature))throw new TypeError(\"Input has invalid signature\")}}return Object.assign(c,t)}},9379:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2pkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(7329),f=s.OPS;e.p2pkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(25)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),input:a.typeforce.maybe(a.typeforce.Buffer)},t);const r=c.value((()=>{const e=n.from(u.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),h=c.value((()=>s.decompile(t.input))),l=t.network||o.bitcoin,p={name:\"p2pkh\",network:l};if(c.prop(p,\"address\",(()=>{if(!p.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(l.pubKeyHash,0),p.hash.copy(t,1),u.encode(t)})),c.prop(p,\"hash\",(()=>t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),c.prop(p,\"output\",(()=>{if(p.hash)return s.compile([f.OP_DUP,f.OP_HASH160,p.hash,f.OP_EQUALVERIFY,f.OP_CHECKSIG])})),c.prop(p,\"pubkey\",(()=>{if(t.input)return h()[1]})),c.prop(p,\"signature\",(()=>{if(t.input)return h()[0]})),c.prop(p,\"input\",(()=>{if(t.pubkey&&t.signature)return s.compile([t.signature,t.pubkey])})),c.prop(p,\"witness\",(()=>{if(p.input)return[]})),e.validate){let e=n.from([]);if(t.address){if(r().version!==l.pubKeyHash)throw new TypeError(\"Invalid version or Network mismatch\");if(20!==r().hash.length)throw new TypeError(\"Invalid address\");e=r().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==f.OP_DUP||t.output[1]!==f.OP_HASH160||20!==t.output[2]||t.output[23]!==f.OP_EQUALVERIFY||t.output[24]!==f.OP_CHECKSIG)throw new TypeError(\"Output is invalid\");const r=t.output.slice(3,23);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.input){const r=h();if(2!==r.length)throw new TypeError(\"Input is invalid\");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError(\"Input has invalid signature\");if(!(0,a.isPoint)(r[1]))throw new TypeError(\"Input has invalid pubkey\");if(t.signature&&!t.signature.equals(r[0]))throw new TypeError(\"Signature mismatch\");if(t.pubkey&&!t.pubkey.equals(r[1]))throw new TypeError(\"Pubkey mismatch\");const n=i.hash160(r[1]);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\")}}return Object.assign(p,t)}},2129:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2sh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(7329),f=s.OPS;e.p2sh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(23)),redeem:a.typeforce.maybe({network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||o.bitcoin);const h={network:r},l=c.value((()=>{const e=n.from(u.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),p=c.value((()=>s.decompile(t.input))),d=c.value((()=>{const e=p(),i=e[e.length-1];return{network:r,output:i===f.OP_FALSE?n.from([]):i,input:s.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(c.prop(h,\"address\",(()=>{if(!h.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(h.network.scriptHash,0),h.hash.copy(t,1),u.encode(t)})),c.prop(h,\"hash\",(()=>t.output?t.output.slice(2,22):t.address?l().hash:h.redeem&&h.redeem.output?i.hash160(h.redeem.output):void 0)),c.prop(h,\"output\",(()=>{if(h.hash)return s.compile([f.OP_HASH160,h.hash,f.OP_EQUAL])})),c.prop(h,\"redeem\",(()=>{if(t.input)return d()})),c.prop(h,\"input\",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return s.compile([].concat(s.decompile(t.redeem.input),t.redeem.output))})),c.prop(h,\"witness\",(()=>h.redeem&&h.redeem.witness?h.redeem.witness:h.input?[]:void 0)),c.prop(h,\"name\",(()=>{const t=[\"p2sh\"];return void 0!==h.redeem&&void 0!==h.redeem.name&&t.push(h.redeem.name),t.join(\"-\")})),e.validate){let e=n.from([]);if(t.address){if(l().version!==r.scriptHash)throw new TypeError(\"Invalid version or Network mismatch\");if(20!==l().hash.length)throw new TypeError(\"Invalid address\");e=l().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==f.OP_HASH160||20!==t.output[1]||t.output[22]!==f.OP_EQUAL)throw new TypeError(\"Output is invalid\");const r=t.output.slice(2,22);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}const o=t=>{if(t.output){const r=s.decompile(t.output);if(!r||r.length<1)throw new TypeError(\"Redeem.output too short\");if(t.output.byteLength>520)throw new TypeError(\"Redeem.output unspendable if larger than 520 bytes\");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError(\"Redeem.output unspendable with more than 201 non-push ops\");const n=i.hash160(t.output);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\");e=n}if(t.input){const e=t.input.length>0,r=t.witness&&t.witness.length>0;if(!e&&!r)throw new TypeError(\"Empty input\");if(e&&r)throw new TypeError(\"Input and witness provided\");if(e){const e=s.decompile(t.input);if(!s.isPushOnly(e))throw new TypeError(\"Non push-only scriptSig\")}}};if(t.input){const t=p();if(!t||t.length<1)throw new TypeError(\"Input too short\");if(!n.isBuffer(d().output))throw new TypeError(\"Input is invalid\");o(d())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError(\"Network mismatch\");if(t.input){const e=d();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError(\"Redeem.output mismatch\");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError(\"Redeem.input mismatch\")}o(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,t.witness))throw new TypeError(\"Witness and redeem.witness mismatch\")}return Object.assign(h,t)}},1992:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2tr=void 0;const n=r(1048),i=r(2529),o=r(4009),s=r(5593),a=r(6313),c=r(5247),u=r(9158),f=r(6586),h=o.OPS;e.p2tr=function(t,e){if(!(t.address||t.output||t.pubkey||t.internalPubkey||t.witness&&t.witness.length>1))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},t);const r=u.value((()=>{const e=f.bech32m.decode(t.address),r=e.words.shift(),i=f.bech32m.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.Buffer.from(i)}})),l=u.value((()=>{if(t.witness&&t.witness.length)return t.witness.length>=2&&80===t.witness[t.witness.length-1][0]?t.witness.slice(0,-1):t.witness.slice()})),p=u.value((()=>t.scriptTree?(0,c.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),d=t.network||i.bitcoin,y={name:\"p2tr\",network:d};if(u.prop(y,\"address\",(()=>{if(!y.pubkey)return;const t=f.bech32m.toWords(y.pubkey);return t.unshift(1),f.bech32m.encode(d.bech32,t)})),u.prop(y,\"hash\",(()=>{const t=p();if(t)return t.hash;const e=l();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&s.TAPLEAF_VERSION_MASK,n=e[e.length-2],i=(0,c.tapleafHash)({output:n,version:r});return(0,c.rootHashFromPath)(t,i)}return null})),u.prop(y,\"output\",(()=>{if(y.pubkey)return o.compile([h.OP_1,y.pubkey])})),u.prop(y,\"redeemVersion\",(()=>t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:c.LEAF_VERSION_TAPSCRIPT)),u.prop(y,\"redeem\",(()=>{const t=l();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&s.TAPLEAF_VERSION_MASK}})),u.prop(y,\"pubkey\",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(y.internalPubkey){const t=(0,c.tweakKey)(y.internalPubkey,y.hash);if(t)return t.x}})),u.prop(y,\"internalPubkey\",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=l();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),u.prop(y,\"signature\",(()=>{if(t.signature)return t.signature;const e=l();return e&&1===e.length?e[0]:void 0})),u.prop(y,\"witness\",(()=>{if(t.witness)return t.witness;const e=p();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,c.tapleafHash)({output:t.redeem.output,version:y.redeemVersion}),i=(0,c.findScriptPath)(e,r);if(!i)return;const o=(0,c.tweakKey)(t.internalPubkey,e.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([y.redeemVersion|o.parity]),t.internalPubkey].concat(i));return[t.redeem.output,s]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(d&&d.bech32!==r().prefix)throw new TypeError(\"Invalid prefix or Network mismatch\");if(1!==r().version)throw new TypeError(\"Invalid address version\");if(32!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.pubkey){if(e.length>0&&!e.equals(t.pubkey))throw new TypeError(\"Pubkey mismatch\");e=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==h.OP_1||32!==t.output[1])throw new TypeError(\"Output is invalid\");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError(\"Pubkey mismatch\");e=t.output.slice(2)}if(t.internalPubkey){const r=(0,c.tweakKey)(t.internalPubkey,y.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError(\"Pubkey mismatch\");e=r.x}if(e&&e.length&&!(0,a.getEccLib)().isXOnlyPoint(e))throw new TypeError(\"Invalid pubkey for p2tr\");const i=p();if(t.hash&&i&&!t.hash.equals(i.hash))throw new TypeError(\"Hash mismatch\");if(t.redeem&&t.redeem.output&&i){const e=(0,c.tapleafHash)({output:t.redeem.output,version:y.redeemVersion});if(!(0,c.findScriptPath)(i,e))throw new TypeError(\"Redeem script not in tree\")}const u=l();if(t.redeem&&y.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==y.redeem.redeemVersion)throw new TypeError(\"Redeem.redeemVersion and witness mismatch\");if(t.redeem.output){if(0===o.decompile(t.redeem.output).length)throw new TypeError(\"Redeem.output is invalid\");if(y.redeem.output&&!t.redeem.output.equals(y.redeem.output))throw new TypeError(\"Redeem.output and witness mismatch\")}if(t.redeem.witness&&y.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,y.redeem.witness))throw new TypeError(\"Redeem.witness and witness mismatch\")}if(u&&u.length)if(1===u.length){if(t.signature&&!t.signature.equals(u[0]))throw new TypeError(\"Signature mismatch\")}else{const r=u[u.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(i))throw new TypeError(\"Internal pubkey mismatch\");if(!(0,a.getEccLib)().isXOnlyPoint(i))throw new TypeError(\"Invalid internalPubkey for p2tr witness\");const o=r[0]&s.TAPLEAF_VERSION_MASK,f=u[u.length-2],h=(0,c.tapleafHash)({output:f,version:o}),l=(0,c.rootHashFromPath)(r,h),p=(0,c.tweakKey)(i,l);if(!p)throw new TypeError(\"Invalid outputKey for p2tr witness\");if(e.length&&!e.equals(p.x))throw new TypeError(\"Pubkey mismatch for p2tr witness\");if(p.parity!==(1&r[0]))throw new Error(\"Incorrect parity\")}}return Object.assign(y,t)}},7090:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2wpkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(6586),f=s.OPS,h=n.alloc(0);e.p2wpkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(22)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=c.value((()=>{const e=u.bech32.decode(t.address),r=e.words.shift(),i=u.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),l=t.network||o.bitcoin,p={name:\"p2wpkh\",network:l};if(c.prop(p,\"address\",(()=>{if(!p.hash)return;const t=u.bech32.toWords(p.hash);return t.unshift(0),u.bech32.encode(l.bech32,t)})),c.prop(p,\"hash\",(()=>t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),c.prop(p,\"output\",(()=>{if(p.hash)return s.compile([f.OP_0,p.hash])})),c.prop(p,\"pubkey\",(()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0)),c.prop(p,\"signature\",(()=>{if(t.witness)return t.witness[0]})),c.prop(p,\"input\",(()=>{if(p.witness)return h})),c.prop(p,\"witness\",(()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){let e=n.from([]);if(t.address){if(l&&l.bech32!==r().prefix)throw new TypeError(\"Invalid prefix or Network mismatch\");if(0!==r().version)throw new TypeError(\"Invalid address version\");if(20!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==f.OP_0||20!==t.output[1])throw new TypeError(\"Output is invalid\");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError(\"Hash mismatch\");e=t.output.slice(2)}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");if(e=r,!(0,a.isPoint)(t.pubkey)||33!==t.pubkey.length)throw new TypeError(\"Invalid pubkey for p2wpkh\")}if(t.witness){if(2!==t.witness.length)throw new TypeError(\"Witness is invalid\");if(!s.isCanonicalScriptSignature(t.witness[0]))throw new TypeError(\"Witness has invalid signature\");if(!(0,a.isPoint)(t.witness[1])||33!==t.witness[1].length)throw new TypeError(\"Witness has invalid pubkey\");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError(\"Signature mismatch\");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError(\"Pubkey mismatch\");const r=i.hash160(t.witness[1]);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\")}}return Object.assign(p,t)}},2366:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2wsh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(6586),f=s.OPS,h=n.alloc(0);function l(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,a.isPoint)(t))}e.p2wsh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),output:a.typeforce.maybe(a.typeforce.BufferN(34)),redeem:a.typeforce.maybe({input:a.typeforce.maybe(a.typeforce.Buffer),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.BufferN(0)),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=c.value((()=>{const e=u.bech32.decode(t.address),r=e.words.shift(),i=u.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),p=c.value((()=>s.decompile(t.redeem.input)));let d=t.network;d||(d=t.redeem&&t.redeem.network||o.bitcoin);const y={network:d};if(c.prop(y,\"address\",(()=>{if(!y.hash)return;const t=u.bech32.toWords(y.hash);return t.unshift(0),u.bech32.encode(d.bech32,t)})),c.prop(y,\"hash\",(()=>t.output?t.output.slice(2):t.address?r().data:y.redeem&&y.redeem.output?i.sha256(y.redeem.output):void 0)),c.prop(y,\"output\",(()=>{if(y.hash)return s.compile([f.OP_0,y.hash])})),c.prop(y,\"redeem\",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:h,witness:t.witness.slice(0,-1)}})),c.prop(y,\"input\",(()=>{if(y.witness)return h})),c.prop(y,\"witness\",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=s.toStack(p());return y.redeem=Object.assign({witness:e},t.redeem),y.redeem.input=h,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),c.prop(y,\"name\",(()=>{const t=[\"p2wsh\"];return void 0!==y.redeem&&void 0!==y.redeem.name&&t.push(y.redeem.name),t.join(\"-\")})),e.validate){let e=n.from([]);if(t.address){if(r().prefix!==d.bech32)throw new TypeError(\"Invalid prefix or Network mismatch\");if(0!==r().version)throw new TypeError(\"Invalid address version\");if(32!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==f.OP_0||32!==t.output[1])throw new TypeError(\"Output is invalid\");const r=t.output.slice(2);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.redeem){if(t.redeem.network&&t.redeem.network!==d)throw new TypeError(\"Network mismatch\");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError(\"Ambiguous witness source\");if(t.redeem.output){const r=s.decompile(t.redeem.output);if(!r||r.length<1)throw new TypeError(\"Redeem.output is invalid\");if(t.redeem.output.byteLength>3600)throw new TypeError(\"Redeem.output unspendable if larger than 3600 bytes\");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError(\"Redeem.output unspendable with more than 201 non-push ops\");const n=i.sha256(t.redeem.output);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\");e=n}if(t.redeem.input&&!s.isPushOnly(p()))throw new TypeError(\"Non push-only scriptSig\");if(t.witness&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.witness,t.redeem.witness))throw new TypeError(\"Witness and redeem.witness mismatch\");if(t.redeem.input&&p().some(l)||t.redeem.output&&(s.decompile(t.redeem.output)||[]).some(l))throw new TypeError(\"redeem.input or redeem.output contains uncompressed pubkey\")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError(\"Witness and redeem.output mismatch\");if(t.witness.some(l)||(s.decompile(e)||[]).some(l))throw new TypeError(\"Witness contains uncompressed pubkey\")}}return Object.assign(y,t)}},6689:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Psbt=void 0;const i=r(7003),o=r(2715),s=r(2431),a=r(3348),c=r(3831),u=r(2529),f=r(8614),h=r(5247),l=r(4009),p=r(3063),d=r(6412),y=r(8990),g={network:u.bitcoin,maximumFeeRate:5e3};class b{static fromBase64(t,e={}){const r=n.from(t,\"base64\");return this.fromBuffer(r,e)}static fromHex(t,e={}){const r=n.from(t,\"hex\");return this.fromBuffer(r,e)}static fromBuffer(t,e={}){const r=i.Psbt.fromBuffer(t,w),n=new b(e,r);var o,s;return o=n.__CACHE.__TX,s=n.__CACHE,o.ins.forEach((t=>{x(s,t)})),n}constructor(t={},e=new i.Psbt(new m)){this.data=e,this.opts=Object.assign({},g,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(t,e,r,n)=>Object.defineProperty(t,e,{enumerable:r,writable:n});r(this,\"__CACHE\",!1,!0),r(this,\"opts\",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map((t=>({hash:(0,c.cloneBuffer)(t.hash),index:t.index,sequence:t.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((t=>{let e;try{e=(0,a.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,c.cloneBuffer)(t.script),value:t.value,address:e}}))}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){const t=b.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){A(t),this.opts.maximumFeeRate=t}setVersion(t){A(t),I(this.data.inputs,\"setVersion\");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){A(t),I(this.data.inputs,\"setLocktime\");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){A(e),I(this.data.inputs,\"setInputSequence\");const r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error(\"Input index too high\");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach((t=>this.addInput(t))),this}addInput(t){if(arguments.length>1||!t||void 0===t.hash||void 0===t.index)throw new Error(\"Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]\");(0,d.checkTaprootInputFields)(t,t,\"addInput\"),I(this.data.inputs,\"addInput\"),t.witnessScript&&X(t.witnessScript);const e=this.__CACHE;this.data.addInput(t);x(e,e.__TX.ins[e.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&D(this.__CACHE,n,r),e.__FEE=void 0,e.__FEE_RATE=void 0,e.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach((t=>this.addOutput(t))),this}addOutput(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error(\"Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]\");I(this.data.inputs,\"addOutput\");const{address:e}=t;if(\"string\"==typeof e){const{network:r}=this.opts,n=(0,a.toOutputScript)(e,r);t=Object.assign(t,{script:n})}(0,d.checkTaprootOutputFields)(t,t,\"addOutput\");const r=this.__CACHE;return this.data.addOutput(t),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(_))throw new Error(\"Not finalized\");const e=this.__CACHE;if(t||function(t,e,r){const n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,e,this.opts),e.__EXTRACTED_TX)return e.__EXTRACTED_TX;const r=e.__TX.clone();return $(this.data.inputs,r,e,!0),r}getFeeRate(){return R(\"__FEE_RATE\",\"fee rate\",this.data.inputs,this.__CACHE)}getFee(){return R(\"__FEE\",\"fee\",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,s.checkForInput)(this.data.inputs,0),J(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(r)?this._finalizeTaprootInput(t,r,void 0,e):this._finalizeInput(t,r,e)}finalizeTaprootInput(t,e,r=d.tapScriptFinalizer){const n=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,e,r=B){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(t,e,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){const o=K(r,e,t),s=n.ins[t].index;i.script=o.outs[s].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);(e.witnessScript||(0,y.isP2WPKH)(i.script))&&(i.isSegwit=!0);return i}(t,e,this.__CACHE);if(!n)throw new Error(`No script found for input #${t}`);!function(t){if(!t.sighashType||!t.partialSig)return;const{partialSig:e,sighashType:r}=t;e.forEach((t=>{const{hashType:e}=l.signature.decode(t.signature);if(r!==e)throw new Error(\"Signature sighash does not match input sighash type\")}))}(e);const{finalScriptSig:a,finalScriptWitness:c}=r(t,e,n,s,i,o);if(a&&this.data.updateInput(t,{finalScriptSig:a}),c&&this.data.updateInput(t,{finalScriptWitness:c}),!a&&!c)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,e,r,n=d.tapScriptFinalizer){if(!e.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(e.tapKeySig){const r=f.p2tr({output:e.witnessUtxo.script,signature:e.tapKeySig}),n=(0,y.witnessStackToScriptWitness)(r.witness);this.data.updateInput(t,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(t,e,r);this.data.updateInput(t,{finalScriptWitness:i})}return this.data.clearFinalizedInput(t),this}getInputType(t){const e=(0,s.checkForInput)(this.data.inputs,t),r=W(V(t,e,this.__CACHE),t,\"input\",e.redeemScript||function(t){if(!t)return;const e=l.decompile(t);if(!e)return;const r=e[e.length-1];if(!n.isBuffer(r)||q(r)||(i=r,l.isCanonicalScriptSignature(i)))return;var i;if(!l.decompile(r))return;return r}(e.finalScriptSig),e.witnessScript||function(t){if(!t)return;const e=F(t),r=e[e.length-1];if(q(r))return;if(!l.decompile(r))return;return r}(e.finalScriptWitness));return(\"raw\"===r.type?\"\":r.type+\"-\")+z(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=V(r,e,n),{meaningfulScript:o}=W(i,r,\"input\",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,s.checkForInput)(this.data.inputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(t,e){return function(t,e,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=W(i,r,\"output\",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,s.checkForOutput)(this.data.outputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){(0,s.checkForInput)(this.data.inputs,0);return J(this.data.inputs.length).map((e=>this.validateSignaturesOfInput(e,t))).reduce(((t,e)=>!0===e&&t),!0)}validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t];return(0,d.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}_validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error(\"No signatures to validate\");if(\"function\"!=typeof e)throw new Error(\"Need validator function to validate signatures\");const o=r?i.filter((t=>t.pubkey.equals(r))):i;if(o.length<1)throw new Error(\"No signatures for this pubkey\");const s=[];let a,c,u;for(const r of o){const i=l.signature.decode(r.signature),{hash:o,script:f}=u!==i.hashType?N(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:c};u=i.hashType,a=o,c=f,T(r.pubkey,f,\"verify\"),s.push(e(r.pubkey,o,i.signature))}return s.every((t=>!0===t))}validateSignaturesOfTaprootInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error(\"No signatures to validate\");if(\"function\"!=typeof e)throw new Error(\"Need validator function to validate signatures\");const s=(r=r&&(0,d.toXOnly)(r))?j(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=L(t,e,n);r&&i.push(r)}if(e.tapScriptSig){const t=e.tapScriptSig.map((t=>t.pubkey));i.push(...t)}const o=i.map((i=>j(t,e,r,i,n)));return o.flat()}(t,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error(\"No signatures for this pubkey\");const a=s.find((t=>!t.leafHash));let c=0;if(i&&a){if(!e(a.pubkey,a.hash,U(i)))return!1;c++}if(o)for(const t of o){const r=s.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,U(t.signature)))return!1;c++}}return c>0}signAllInputsHD(t,e=[p.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error(\"Need HDSigner to sign input\");const r=[];for(const n of J(this.data.inputs.length))try{this.signInputHD(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error(\"No inputs were signed\");return this}signAllInputsHDAsync(t,e=[p.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!t||!t.publicKey||!t.fingerprint)return n(new Error(\"Need HDSigner to sign input\"));const i=[],o=[];for(const r of J(this.data.inputs.length))o.push(this.signInputHDAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error(\"No inputs were signed\"));r()}))}))}signInputHD(t,e,r=[p.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error(\"Need HDSigner to sign input\");return H(t,this.data.inputs,e).forEach((e=>this.signInput(t,e,r))),this}signInputHDAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!e||!e.publicKey||!e.fingerprint)return i(new Error(\"Need HDSigner to sign input\"));const o=H(t,this.data.inputs,e).map((e=>this.signInputAsync(t,e,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(t,e){if(!t||!t.publicKey)throw new Error(\"Need Signer to sign input\");const r=[];for(const n of J(this.data.inputs.length))try{this.signInput(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error(\"No inputs were signed\");return this}signAllInputsAsync(t,e){return new Promise(((r,n)=>{if(!t||!t.publicKey)return n(new Error(\"Need Signer to sign input\"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error(\"No inputs were signed\"));r()}))}))}signInput(t,e,r){if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}signTaprootInput(t,e,r,n){if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInput(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=C(this.data.inputs,t,e.publicKey,this.__CACHE,r),o=[{pubkey:e.publicKey,signature:l.signature.encode(e.sign(n),i)}];return this.data.updateInput(t,{partialSig:o}),this}_signTaprootInput(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=o.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],a=o.filter((t=>!!t.leafHash)).map((t=>({pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash})));return s&&this.data.updateInput(t,{tapKeySig:s}),a.length&&this.data.updateInput(t,{tapScriptSig:a}),this}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInputAsync(t,n,e,void 0,r):this._signInputAsync(t,e,r)}))}signTaprootInputAsync(t,e,r,n){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInputAsync(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}))}_signInputAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=C(this.data.inputs,t,e.publicKey,this.__CACHE,r);return Promise.resolve(e.sign(n)).then((r=>{const n=[{pubkey:e.publicKey,signature:l.signature.encode(r,i)}];this.data.updateInput(t,{partialSig:n})}))}async _signTaprootInputAsync(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=[],a=o.filter((t=>!t.leafHash))[0];if(a){const t=Promise.resolve(r.signSchnorr(a.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));s.push(t)}const c=o.filter((t=>!!t.leafHash));if(c.length){const t=c.map((t=>Promise.resolve(r.signSchnorr(t.hash)).then((n=>({tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]})))));s.push(...t)}return Promise.all(s).then((e=>{e.forEach((e=>this.data.updateInput(t,e)))}))}checkTaprootHashesForSig(t,e,r,n,i){if(\"function\"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const o=j(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${t} with the key ${r.publicKey.toString(\"hex\")}`);return o}toBuffer(){return v(this.__CACHE),this.data.toBuffer()}toHex(){return v(this.__CACHE),this.data.toHex()}toBase64(){return v(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&X(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,\"updateInput\"),this.data.updateInput(t,e),e.nonWitnessUtxo&&D(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,e){const r=this.data.outputs[t];return(0,d.checkTaprootOutputFields)(r,e,\"updateOutput\"),this.data.updateOutput(t,e),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,e){return this.data.addUnknownKeyValToInput(t,e),this}addUnknownKeyValToOutput(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}e.Psbt=b;const w=t=>new m(t);class m{constructor(t=n.from([2,0,0,0,0,0,0,0,0,0])){this.tx=p.Transaction.fromBuffer(t),function(t){if(!t.ins.every((t=>t.script&&0===t.script.length&&t.witness&&0===t.witness.length)))throw new Error(\"Format Error: Transaction ScriptSigs are not empty\")}(this.tx),Object.defineProperty(this,\"tx\",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!n.isBuffer(t.hash)&&\"string\"!=typeof t.hash||\"number\"!=typeof t.index)throw new Error(\"Error adding input.\");const e=\"string\"==typeof t.hash?(0,c.reverseBuffer)(n.from(t.hash,\"hex\")):t.hash;this.tx.addInput(e,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!n.isBuffer(t.script)||\"number\"!=typeof t.value)throw new Error(\"Error adding output.\");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function v(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error(\"Not BIP174 compliant, can not export\")}function E(t,e,r){if(!e)return!1;let n;if(n=r?r.map((t=>{const r=function(t){if(65===t.length){const e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((t=>t.pubkey.equals(r)))})).filter((t=>!!t)):e,n.length>t)throw new Error(\"Too many signatures\");return n.length===t}function _(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function S(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function A(t){if(\"number\"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error(\"Invalid 32 bit integer\")}function I(t,e){t.forEach((t=>{if((0,d.isTaprootInput)(t)?(0,d.checkTaprootInputForSigs)(t,e):(0,y.checkInputForSig)(t,e))throw new Error(\"Can not modify transaction, signatures exist.\")}))}function T(t,e,r){if(!(0,y.pubkeyInScript)(t,e))throw new Error(`Can not ${r} for this input with the key ${t.toString(\"hex\")}`)}function x(t,e){const r=(0,c.reverseBuffer)(n.from(e.hash)).toString(\"hex\")+\":\"+e.index;if(t.__TX_IN_CACHE[r])throw new Error(\"Duplicate input detected.\");t.__TX_IN_CACHE[r]=1}function O(t,e){return(r,n,i,o)=>{const s=t({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${e} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const k=O(f.p2sh,\"Redeem script\"),P=O(f.p2wsh,\"Witness script\");function R(t,e,r,n){if(!r.every(_))throw new Error(`PSBT must be finalized to calculate ${e}`);if(\"__FEE_RATE\"===t&&n.__FEE_RATE)return n.__FEE_RATE;if(\"__FEE\"===t&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),$(r,i,n,o),\"__FEE_RATE\"===t?n.__FEE_RATE:\"__FEE\"===t?n.__FEE:void 0}function B(t,e,r,n,i,o){const s=z(r);if(!function(t,e,r){switch(r){case\"pubkey\":case\"pubkeyhash\":case\"witnesspubkeyhash\":return E(1,t.partialSig);case\"multisig\":const r=f.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,s))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,o){let s,a;const c=function(t,e,r){let n;switch(e){case\"multisig\":const e=function(t,e){const r=f.p2ms({output:t});return r.pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=f.p2ms({output:t,signatures:e});break;case\"pubkey\":n=f.p2pk({output:t,signature:r[0].signature});break;case\"pubkeyhash\":n=f.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case\"witnesspubkeyhash\":n=f.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),u=o?f.p2wsh({redeem:c}):null,h=i?f.p2sh({redeem:u||c}):null;n?(a=u?(0,y.witnessStackToScriptWitness)(u.witness):(0,y.witnessStackToScriptWitness)(c.witness),h&&(s=h.input)):s=h?h.input:c.input;return{finalScriptSig:s,finalScriptWitness:a}}(r,s,e.partialSig,n,i,o)}function C(t,e,r,n,i){const o=(0,s.checkForInput)(t,e),{hash:a,sighashType:c,script:u}=N(e,o,n,!1,i);return T(r,u,\"sign\"),{hash:a,sighashType:c}}function N(t,e,r,n,i){const o=r.__TX,s=e.sighashType||p.Transaction.SIGHASH_ALL;let a,c;if(M(s,i),e.nonWitnessUtxo){const n=K(r,e,t),i=o.ins[t].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const a=o.ins[t].index;c=n.outs[a]}else{if(!e.witnessUtxo)throw new Error(\"Need a Utxo input item for signing\");c=e.witnessUtxo}const{meaningfulScript:u,type:h}=W(c.script,t,\"input\",e.redeemScript,e.witnessScript);if([\"p2sh-p2wsh\",\"p2wsh\"].indexOf(h)>=0)a=o.hashForWitnessV0(t,u,c.value,s);else if((0,y.isP2WPKH)(u)){const e=f.p2pkh({hash:u.slice(2)}).output;a=o.hashForWitnessV0(t,e,c.value,s)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${t} has witnessUtxo but non-segwit script: ${u.toString(\"hex\")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn(\"Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecesor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\\n*********************\\nPROCEED WITH CAUTION!\\n*********************\"),a=o.hashForSignature(t,u,s)}return{script:u,sighashType:s,hash:a}}function L(t,e,r){const{script:n}=G(t,e,r);return(0,y.isP2TR)(n)?n.subarray(2,34):null}function U(t){return 64===t.length?t:t.subarray(0,64)}function j(t,e,r,i,o,s,a){const c=o.__TX,u=e.sighashType||p.Transaction.SIGHASH_DEFAULT;M(u,a);const f=r.map(((t,e)=>G(e,t,o))),l=f.map((t=>t.script)),g=f.map((t=>t.value)),b=[];if(e.tapInternalKey&&!s){const r=L(t,e,o)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=c.hashForWitnessV1(t,l,g,u);b.push({pubkey:i,hash:e})}}const w=(e.tapLeafScript||[]).filter((t=>(0,y.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,h.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!s||s.equals(t.hash))).map((e=>{const r=c.hashForWitnessV1(t,l,g,p.Transaction.SIGHASH_DEFAULT,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return b.concat(w)}function M(t,e){if(e&&e.indexOf(t)<0){const e=function(t){let e=t&p.Transaction.SIGHASH_ANYONECANPAY?\"SIGHASH_ANYONECANPAY | \":\"\";switch(31&t){case p.Transaction.SIGHASH_ALL:e+=\"SIGHASH_ALL\";break;case p.Transaction.SIGHASH_SINGLE:e+=\"SIGHASH_SINGLE\";break;case p.Transaction.SIGHASH_NONE:e+=\"SIGHASH_NONE\"}return e}(t);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${e}`)}}function H(t,e,r){const n=(0,s.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error(\"Need bip32Derivation to sign with HD\");const i=n.bip32Derivation.map((t=>t.masterFingerprint.equals(r.fingerprint)?t:void 0)).filter((t=>!!t));if(0===i.length)throw new Error(\"Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint\");return i.map((t=>{const e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error(\"pubkey did not match bip32Derivation\");return e}))}function F(t){let e=0;function r(){const r=o.decode(t,e);return e+=o.decode.bytes,r}function n(){return n=r(),e+=n,t.slice(e-n,e);var n}return function(){const t=r(),e=[];for(let r=0;r{if(n&&t.finalScriptSig&&(e.ins[o].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[o].witness=F(t.finalScriptWitness)),t.witnessUtxo)i+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=K(r,t,o),s=e.ins[o].index,a=n.outs[s];i+=a.value}}));const o=e.outs.reduce(((t,e)=>t+e.value),0),s=i-o;if(s<0)throw new Error(\"Outputs are spending more than Inputs\");const a=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/a)}function K(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||D(t,e,r),n[r]}function V(t,e,r){const{script:n}=G(t,e,r);return n}function G(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=K(r,e,t).outs[r.__TX.ins[t].index];return{script:n.script,value:n.value}}throw new Error(\"Can't find pubkey in input without Utxo data\")}function q(t){return 33===t.length&&l.isCanonicalPubKey(t)}function W(t,e,r,n,i){const o=(0,y.isP2SHScript)(t),s=o&&n&&(0,y.isP2WSHScript)(n),a=(0,y.isP2WSHScript)(t);if(o&&void 0===n)throw new Error(\"scriptPubkey is P2SH but redeemScript missing\");if((a||s)&&void 0===i)throw new Error(\"scriptPubkey or redeemScript is P2WSH but witnessScript missing\");let c;return s?(c=i,k(e,t,n,r),P(e,n,i,r),X(c)):a?(c=i,P(e,t,i,r),X(c)):o?(c=n,k(e,t,n,r)):c=t,{meaningfulScript:c,type:s?\"p2sh-p2wsh\":o?\"p2sh\":a?\"p2wsh\":\"raw\"}}function X(t){if((0,y.isP2WPKH)(t)||(0,y.isP2SHScript)(t))throw new Error(\"P2WPKH or P2SH can not be contained within P2WSH\")}function z(t){return(0,y.isP2WPKH)(t)?\"witnesspubkeyhash\":(0,y.isP2PKH)(t)?\"pubkeyhash\":(0,y.isP2MS)(t)?\"multisig\":(0,y.isP2PK)(t)?\"pubkey\":\"nonstandard\"}function J(t){return[...Array(t).keys()]}},6412:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.checkTaprootInputForSigs=e.tapTreeFromList=e.tapTreeToList=e.tweakInternalPubKey=e.checkTaprootOutputFields=e.checkTaprootInputFields=e.isTaprootOutput=e.isTaprootInput=e.serializeTaprootSignature=e.tapScriptFinalizer=e.toXOnly=void 0;const i=r(5593),o=r(3063),s=r(8990),a=r(5247),c=r(8614),u=r(8990);function f(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,s.isP2TR)(t.witnessUtxo.script))}function h(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,s.isP2TR)(e))}function l(t=[]){return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){let e;for(const r of t)if(e=y(r,e),!e)throw new Error(\"No room left to insert tapleaf in tree\");return e}(t)}function p(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function d(t,e=[],r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error(\"Max taptree depth exceeded.\");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||a.LEAF_VERSION_TAPSCRIPT,script:t.output}),e):(t[0]&&d(t[0],e,r+1),t[1]&&d(t[1],e,r+1),e):[]}function y(t,e,r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error(\"Max taptree depth exceeded.\");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if((0,i.isTapleaf)(e))return;const n=y(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];const o=y(t,e&&e[1],r+1);return o?[e&&e[0],o]:void 0}function g(t,e){if(!e)return!0;const r=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(0,a.rootHashFromPath)(t.controlBlock,r).equals(e)}function b(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}e.toXOnly=t=>32===t.length?t:t.slice(1,33),e.tapScriptFinalizer=function(t,e,r){const n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${e}. No tapleaf script signature provided.`);const n=(t.tapLeafScript||[]).sort(((t,e)=>t.controlBlock.length-e.controlBlock.length)).find((e=>function(t,e,r){const n=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((t=>t.leafHash.equals(n)))}(e,t.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`);return n}(e,t,r);try{const t=function(t,e){const r=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((t=>t.leafHash.equals(r))).map((t=>function(t,e){return Object.assign({positionInScript:(0,s.pubkeyPositionInScript)(e.pubkey,t)},e)}(e.script,t))).sort(((t,e)=>e.positionInScript-t.positionInScript)).map((t=>t.signature))}(e,n),r=t.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,s.witnessStackToScriptWitness)(r)}}catch(e){throw new Error(`Can not finalize taproot input #${t}: ${e}`)}},e.serializeTaprootSignature=function(t,e){const r=e?n.from([e]):n.from([]);return n.concat([t,r])},e.isTaprootInput=f,e.isTaprootOutput=h,e.checkTaprootInputFields=function(t,e,r){!function(t,e,r){const n=f(t)&&b(e),i=b(t)&&f(e),o=t===e&&f(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot){if(!(e.tapLeafScript||[]).every((e=>g(e,t.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}}(t,e,r)},e.checkTaprootOutputFields=function(t,e,r){!function(t,e,r){const n=h(t)&&b(e),i=b(t)&&h(e),o=t===e&&h(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e){if(!e.tapTree&&!e.tapInternalKey)return;const r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){const{script:e}=t,i=function(t,e){const r=e&&l(e.leaves),{output:n}=(0,c.p2tr)({internalPubkey:t,scriptTree:r});return n}(r,n);if(e&&!e.equals(i))throw new Error(\"Error adding output. Script or address missmatch.\")}}(t,e)},e.tweakInternalPubKey=function(t,e){const r=e.tapInternalKey,n=r&&(0,a.tweakKey)(r,e.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${t}. Public key: ${r&&r.toString(\"hex\")}`);return n.x},e.tapTreeToList=function(t){if(!(0,i.isTaptree)(t))throw new Error(\"Cannot convert taptree to tapleaf list. Expecting a tapree structure.\");return d(t)},e.tapTreeFromList=l,e.checkTaprootInputForSigs=function(t,e){return function(t){const e=[];t.tapKeySig&&e.push(t.tapKeySig);t.tapScriptSig&&e.push(...t.tapScriptSig.map((t=>t.signature)));if(!e.length){const r=function(t){if(!t)return;const e=t.slice(2);if(64===e.length||65===e.length)return e}(t.finalScriptWitness);r&&e.push(r)}return e}(t).some((t=>(0,u.signatureBlocksAction)(t,p,e)))}},8990:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.signatureBlocksAction=e.checkInputForSig=e.pubkeyInScript=e.pubkeyPositionInScript=e.witnessStackToScriptWitness=e.isP2TR=e.isP2SHScript=e.isP2WSHScript=e.isP2WPKH=e.isP2PKH=e.isP2PK=e.isP2MS=void 0;const i=r(2715),o=r(4009),s=r(3063),a=r(6891),c=r(8614);function u(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function f(t,e){const r=(0,a.hash160)(t),n=t.slice(1,33),i=o.decompile(e);if(null===i)throw new Error(\"Unknown script error\");return i.findIndex((e=>\"number\"!=typeof e&&(e.equals(t)||e.equals(r)||e.equals(n))))}function h(t,e,r){const{hashType:n}=e(t),i=[];n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push(\"addInput\");switch(31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push(\"addOutput\"),i.push(\"setInputSequence\")}return-1===i.indexOf(r)}e.isP2MS=u(c.p2ms),e.isP2PK=u(c.p2pk),e.isP2PKH=u(c.p2pkh),e.isP2WPKH=u(c.p2wpkh),e.isP2WSHScript=u(c.p2wsh),e.isP2SHScript=u(c.p2sh),e.isP2TR=u(c.p2tr),e.witnessStackToScriptWitness=function(t){let e=n.allocUnsafe(0);function r(t){const r=e.length,o=i.encodingLength(t);e=n.concat([e,n.allocUnsafe(o)]),i.encode(t,e,r)}function o(t){r(t.length),function(t){e=n.concat([e,n.from(t)])}(t)}var s;return r((s=t).length),s.forEach(o),e},e.pubkeyPositionInScript=f,e.pubkeyInScript=function(t,e){return-1!==f(t,e)},e.checkInputForSig=function(t,e){return function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){const e=t.finalScriptSig&&o.decompile(t.finalScriptSig)||[],r=t.finalScriptWitness&&o.decompile(t.finalScriptWitness)||[];return e.concat(r).filter((t=>n.isBuffer(t)&&o.isCanonicalScriptSignature(t))).map((t=>({signature:t})))}(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t).some((t=>h(t,o.signature.decode,e)))},e.signatureBlocksAction=h},1213:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.decode=e.encode=e.encodingLength=void 0;const n=r(8156);function i(t){return tt.length)return null;i=t.readUInt8(e+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(e+3>t.length)return null;i=t.readUInt16LE(e+1),o=3}else{if(e+5>t.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error(\"Unexpected opcode\");i=t.readUInt32LE(e+1),o=5}return{opcode:r,number:i,size:o}}},4009:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const i=r(195),o=r(8156);Object.defineProperty(e,\"OPS\",{enumerable:!0,get:function(){return o.OPS}});const s=r(1213),a=r(5333),c=r(1108),u=r(5593),{typeforce:f}=u,h=o.OPS.OP_RESERVED;function l(t){return u.Buffer(t)||function(t){return u.Number(t)&&(t===o.OPS.OP_0||t>=o.OPS.OP_1&&t<=o.OPS.OP_16||t===o.OPS.OP_1NEGATE)}(t)}function p(t){return u.Array(t)&&t.every(l)}function d(t){return 0===t.length?o.OPS.OP_0:1===t.length?t[0]>=1&&t[0]<=16?h+t[0]:129===t[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(t){return n.isBuffer(t)}function g(t){return n.isBuffer(t)}function b(t){if(y(t))return t;f(u.Array,t);const e=t.reduce(((t,e)=>g(e)?1===e.length&&void 0!==d(e)?t+1:t+s.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(g(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=s.encode(r,t.length,i),t.copy(r,i),i+=t.length}else r.writeUInt8(t,i),i+=1})),i!==r.length)throw new Error(\"Could not decode chunks\");return r}function w(t){if(e=t,u.Array(e))return t;var e;f(u.Buffer,t);const r=[];let n=0;for(;no.OPS.OP_0&&e<=o.OPS.OP_PUSHDATA4){const e=s.decode(t,n);if(null===e)return null;if(n+=e.size,n+e.number>t.length)return null;const i=t.slice(n,n+e.number);n+=e.number;const o=d(i);void 0!==o?r.push(o):r.push(i)}else r.push(e),n+=1}return r}function m(t){const e=-129&t;return e>0&&e<4}e.isPushOnly=p,e.countNonPushOnlyOPs=function(t){return t.length-t.filter(l).length},e.compile=b,e.decompile=w,e.toASM=function(t){return y(t)&&(t=w(t)),t.map((t=>{if(g(t)){const e=d(t);if(void 0===e)return t.toString(\"hex\");t=e}return o.REVERSE_OPS[t]})).join(\" \")},e.fromASM=function(t){return f(u.String,t),b(t.split(\" \").map((t=>void 0!==o.OPS[t]?o.OPS[t]:(f(u.Hex,t),n.from(t,\"hex\")))))},e.toStack=function(t){return t=w(t),f(p,t),t.map((t=>g(t)?t:t===o.OPS.OP_0?n.allocUnsafe(0):a.encode(t-h)))},e.isCanonicalPubKey=function(t){return u.isPoint(t)},e.isDefinedHashType=m,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&(!!m(t[t.length-1])&&i.check(t.slice(0,-1)))},e.number=a,e.signature=c},5333:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=void 0,e.decode=function(t,e,r){e=e||4,r=void 0===r||r;const n=t.length;if(0===n)return 0;if(n>e)throw new TypeError(\"Script number overflow\");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error(\"Non-minimally encoded script number\");if(5===n){const e=t.readUInt32LE(0),r=t.readUInt8(4);return 128&r?-(4294967296*(-129&r)+e):4294967296*r+e}let i=0;for(let e=0;e2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),i=n.allocUnsafe(r),o=t<0;for(let t=0;t>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i}},1108:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=void 0;const i=r(195),o=r(5593),{typeforce:s}=o,a=n.alloc(1,0);function c(t){let e=0;for(;0===t[e];)++e;return e===t.length?a:128&(t=t.slice(e))[0]?n.concat([a,t],1+t.length):t}function u(t){0===t[0]&&(t=t.slice(1));const e=n.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}e.decode=function(t){const e=t.readUInt8(t.length-1),r=-129&e;if(r<=0||r>=4)throw new Error(\"Invalid hashType \"+e);const o=i.decode(t.slice(0,-1)),s=u(o.r),a=u(o.s);return{signature:n.concat([s,a],64),hashType:e}},e.encode=function(t,e){s({signature:o.BufferN(64),hashType:o.UInt8},{signature:t,hashType:e});const r=-129&e;if(r<=0||r>=4)throw new Error(\"Invalid hashType \"+e);const a=n.allocUnsafe(1);a.writeUInt8(e,0);const u=c(t.slice(0,32)),f=c(t.slice(32,64));return n.concat([i.encode(u,f),a])}},3063:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Transaction=void 0;const i=r(3831),o=r(6891),s=r(4009),a=r(4009),c=r(5593),{typeforce:u}=c;function f(t){const e=t.length;return i.varuint.encodingLength(e)+e}const h=n.allocUnsafe(0),l=[],p=n.from(\"0000000000000000000000000000000000000000000000000000000000000000\",\"hex\"),d=n.from(\"0000000000000000000000000000000000000000000000000000000000000001\",\"hex\"),y=n.from(\"ffffffffffffffff\",\"hex\"),g={script:h,valueBuffer:y};class b{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,e){const r=new i.BufferReader(t),n=new b;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let a=!1;o===b.ADVANCED_TRANSACTION_MARKER&&s===b.ADVANCED_TRANSACTION_FLAG?a=!0:r.offset-=2;const c=r.readVarInt();for(let t=0;t0!==t.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const e=t&&this.hasWitnesses();return(e?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce(((t,e)=>t+40+f(e.script)),0)+this.outs.reduce(((t,e)=>t+8+f(e.script)),0)+(e?this.ins.reduce(((t,e)=>t+function(t){const e=t.length;return i.varuint.encodingLength(e)+t.reduce(((t,e)=>t+f(e)),0)}(e.witness)),0):0)}clone(){const t=new b;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((t=>({hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}))),t.outs=this.outs.map((t=>({script:t.script,value:t.value}))),t}hashForSignature(t,e,r){if(u(c.tuple(c.UInt32,c.Buffer,c.Number),arguments),t>=this.ins.length)return d;const i=s.compile(s.decompile(e).filter((t=>t!==a.OPS.OP_CODESEPARATOR))),f=this.clone();if((31&r)===b.SIGHASH_NONE)f.outs=[],f.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===b.SIGHASH_SINGLE){if(t>=this.outs.length)return d;f.outs.length=t+1;for(let e=0;e{r!==t&&(e.sequence=0)}))}r&b.SIGHASH_ANYONECANPAY?(f.ins=[f.ins[t]],f.ins[0].script=i):(f.ins.forEach((t=>{t.script=h})),f.ins[t].script=i);const l=n.allocUnsafe(f.byteLength(!1)+4);return l.writeInt32LE(r,l.length-4),f.__toBuffer(l,0,!1),o.hash256(l)}hashForWitnessV1(t,e,r,s,a,l){if(u(c.tuple(c.UInt32,u.arrayOf(c.Buffer),u.arrayOf(c.Satoshi),c.UInt32),arguments),r.length!==this.ins.length||e.length!==this.ins.length)throw new Error(\"Must supply prevout script and value for all inputs\");const p=s===b.SIGHASH_DEFAULT?b.SIGHASH_ALL:s&b.SIGHASH_OUTPUT_MASK,d=(s&b.SIGHASH_INPUT_MASK)===b.SIGHASH_ANYONECANPAY,y=p===b.SIGHASH_NONE,g=p===b.SIGHASH_SINGLE;let w=h,m=h,v=h,E=h,_=h;if(!d){let t=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((e=>{t.writeSlice(e.hash),t.writeUInt32(e.index)})),w=o.sha256(t.end()),t=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach((e=>t.writeUInt64(e))),m=o.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(f).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),v=o.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),E=o.sha256(t.end())}if(y||g){if(g&&t8+f(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),_=o.sha256(e.end())}const S=(a?2:0)+(l?1:0),A=174-(d?49:0)-(y?32:0)+(l?32:0)+(a?37:0),I=i.BufferWriter.withCapacity(A);if(I.writeUInt8(s),I.writeInt32(this.version),I.writeUInt32(this.locktime),I.writeSlice(w),I.writeSlice(m),I.writeSlice(v),I.writeSlice(E),y||g||I.writeSlice(_),I.writeUInt8(S),d){const n=this.ins[t];I.writeSlice(n.hash),I.writeUInt32(n.index),I.writeUInt64(r[t]),I.writeVarSlice(e[t]),I.writeUInt32(n.sequence)}else I.writeUInt32(t);if(l){const t=i.BufferWriter.withCapacity(f(l));t.writeVarSlice(l),I.writeSlice(o.sha256(t.end()))}return g&&I.writeSlice(_),a&&(I.writeSlice(a),I.writeUInt8(0),I.writeUInt32(4294967295)),o.taggedHash(\"TapSighash\",n.concat([n.from([0]),I.end()]))}hashForWitnessV0(t,e,r,s){u(c.tuple(c.UInt32,c.Buffer,c.Satoshi,c.UInt32),arguments);let a,h=n.from([]),l=p,d=p,y=p;if(s&b.SIGHASH_ANYONECANPAY||(h=n.allocUnsafe(36*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeSlice(t.hash),a.writeUInt32(t.index)})),d=o.hash256(h)),s&b.SIGHASH_ANYONECANPAY||(31&s)===b.SIGHASH_SINGLE||(31&s)===b.SIGHASH_NONE||(h=n.allocUnsafe(4*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeUInt32(t.sequence)})),y=o.hash256(h)),(31&s)!==b.SIGHASH_SINGLE&&(31&s)!==b.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+f(e.script)),0);h=n.allocUnsafe(t),a=new i.BufferWriter(h,0),this.outs.forEach((t=>{a.writeUInt64(t.value),a.writeVarSlice(t.script)})),l=o.hash256(h)}else if((31&s)===b.SIGHASH_SINGLE&&t{o.writeSlice(t.hash),o.writeUInt32(t.index),o.writeVarSlice(t.script),o.writeUInt32(t.sequence)})),o.writeVarInt(this.outs.length),this.outs.forEach((t=>{void 0!==t.value?o.writeUInt64(t.value):o.writeSlice(t.valueBuffer),o.writeVarSlice(t.script)})),s&&this.ins.forEach((t=>{o.writeVector(t.witness)})),o.writeUInt32(this.locktime),void 0!==e?t.slice(e,o.offset):t}}e.Transaction=b,b.DEFAULT_SEQUENCE=4294967295,b.SIGHASH_DEFAULT=0,b.SIGHASH_ALL=1,b.SIGHASH_NONE=2,b.SIGHASH_SINGLE=3,b.SIGHASH_ANYONECANPAY=128,b.SIGHASH_OUTPUT_MASK=3,b.SIGHASH_INPUT_MASK=128,b.ADVANCED_TRANSACTION_MARKER=0,b.ADVANCED_TRANSACTION_FLAG=1},5593:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const n=r(1048);e.typeforce=r(973);const i=n.Buffer.alloc(32,0),o=n.Buffer.from(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\",\"hex\");e.isPoint=function(t){if(!n.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;const e=t[0],r=t.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;const s=t.slice(33);return 0!==s.compare(i)&&(!(s.compare(o)>=0)&&(4===e&&65===t.length))};const s=Math.pow(2,31)-1;function a(t){return e.typeforce.String(t)&&!!t.match(/^(m\\/)?(\\d+'?\\/)*\\d+'?$/)}e.UInt31=function(t){return e.typeforce.UInt32(t)&&t<=s},e.BIP32Path=a,a.toJSON=()=>\"BIP32 derivation path\",e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||\"function\"==typeof t.getPublicKey)&&\"function\"==typeof t.sign};function c(t){return!(!t||!(\"output\"in t))&&(!!n.Buffer.isBuffer(t.output)&&(void 0===t.version||(t.version&e.TAPLEAF_VERSION_MASK)===t.version))}e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.ECPoint=e.typeforce.quacksLike(\"Point\"),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=c,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):c(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf},9216:(t,e,r)=>{var n=r(9784);t.exports=n(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\")},7639:(t,e,r)=>{\"use strict\";var n=r(9216),i=r(5636).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error(\"Invalid checksum\");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},9848:(t,e,r)=>{\"use strict\";var n=r(3257),i=r(7639);t.exports=i((function(t){var e=n(\"sha256\").update(t).digest();return n(\"sha256\").update(e).digest()}))},1048:(t,e,r)=>{\"use strict\";const n=r(7991),i=r(9318),o=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null;e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if(\"number\"==typeof t){if(\"string\"==typeof e)throw new TypeError('The \"string\" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,e,r){if(\"string\"==typeof t)return function(t,e){\"string\"==typeof e&&\"\"!==e||(e=\"utf8\");if(!c.isEncoding(e))throw new TypeError(\"Unknown encoding: \"+e);const r=0|y(t,e);let n=a(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(z(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof t);if(z(t,ArrayBuffer)||t&&z(t.buffer,ArrayBuffer))return p(t,e,r);if(\"undefined\"!=typeof SharedArrayBuffer&&(z(t,SharedArrayBuffer)||t&&z(t.buffer,SharedArrayBuffer)))return p(t,e,r);if(\"number\"==typeof t)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return c.from(n,e,r);const i=function(t){if(c.isBuffer(t)){const e=0|d(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return\"number\"!=typeof t.length||J(t.length)?a(0):l(t);if(\"Buffer\"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(i)return i;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive](\"string\"),e,r);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof t)}function f(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be of type number');if(t<0)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"')}function h(t){return f(t),a(t<0?0:0|d(t))}function l(t){const e=t.length<0?0:0|d(t.length),r=a(e);for(let n=0;n=s)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+s.toString(16)+\" bytes\");return 0|t}function y(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||z(t,ArrayBuffer))return t.byteLength;if(\"string\"!=typeof t)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case\"ascii\":case\"latin1\":case\"binary\":return r;case\"utf8\":case\"utf-8\":return q(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*r;case\"hex\":return r>>>1;case\"base64\":return W(t).length;default:if(i)return n?-1:q(t).length;e=(\"\"+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return\"\";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return\"\";if((r>>>=0)<=(e>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return P(this,e,r);case\"utf8\":case\"utf-8\":return T(this,e,r);case\"ascii\":return O(this,e,r);case\"latin1\":case\"binary\":return k(this,e,r);case\"base64\":return I(this,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return R(this,e,r);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if(\"string\"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if(\"string\"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if(\"number\"==typeof e)return e&=255,\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function m(t,e,r,n,i){let o,s=1,a=t.length,c=e.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;ni&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function I(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(o=c));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r=\"\",n=0;for(;nn.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!c.isBuffer(e))throw new TypeError('\"list\" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},c.byteLength=y,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let e=0;er&&(t+=\" ... \"),\"\"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(t,e,r,n,i){if(z(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),u=this.slice(n,i),f=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n=\"utf8\")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let o=!1;for(;;)switch(n){case\"hex\":return v(this,t,e,r);case\"utf8\":case\"utf-8\":return E(this,t,e,r);case\"ascii\":case\"latin1\":case\"binary\":return _(this,t,e,r);case\"base64\":return S(this,t,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return A(this,t,e,r);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function O(t,e,r){let n=\"\";r=Math.min(t.length,r);for(let i=e;in)&&(r=n);let i=\"\";for(let n=e;nr)throw new RangeError(\"Trying to access beyond buffer length\")}function C(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError(\"Index out of range\")}function N(t,e,r,n,i){$(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function L(t,e,r,n,i){$(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError(\"Index out of range\");if(r<0)throw new RangeError(\"Index out of range\")}function j(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=Z((function(t){K(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o=i&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=Z((function(t){K(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){C(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,!n){C(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=Z((function(t,e=0){return N(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeBigUInt64BE=Z((function(t,e=0){return L(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=Z((function(t,e=0){return N(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeBigInt64BE=Z((function(t,e=0){return L(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError(\"argument should be a Buffer\");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),\"number\"==typeof t)for(i=e;i=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function $(t,e,r,n,i,o){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new H.ERR_OUT_OF_RANGE(\"value\",i,t)}!function(t,e,r){K(e,\"offset\"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(n,i,o)}function K(t,e){if(\"number\"!=typeof t)throw new H.ERR_INVALID_ARG_TYPE(e,\"number\",t)}function V(t,e,r){if(Math.floor(t)!==t)throw K(t,r),new H.ERR_OUT_OF_RANGE(r||\"offset\",\"an integer\",t);if(e<0)throw new H.ERR_BUFFER_OUT_OF_BOUNDS;throw new H.ERR_OUT_OF_RANGE(r||\"offset\",`>= ${r?1:0} and <= ${e}`,t)}F(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(t){return t?`${t} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),F(\"ERR_INVALID_ARG_TYPE\",(function(t,e){return`The \"${t}\" argument must be of type number. Received type ${typeof e}`}),TypeError),F(\"ERR_OUT_OF_RANGE\",(function(t,e,r){let n=`The value of \"${t}\" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):\"bigint\"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+=\"n\"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error(\"Invalid code point\");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function W(t){return n.toByteArray(function(t){if((t=(t=t.split(\"=\")[0]).trim().replace(G,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}(t))}function X(t,e,r,n){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Y=function(){const t=\"0123456789abcdef\",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Z(t){return\"undefined\"==typeof BigInt?Q:t}function Q(){throw new Error(\"BigInt not supported\")}},7589:(t,e,r)=>{var n=r(5636).Buffer,i=r(1983).Transform,o=r(8888).I;function s(t){i.call(this),this.hashMode=\"string\"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(5615)(s,i),s.prototype.update=function(t,e,r){\"string\"==typeof t&&(t=n.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error(\"trying to get auth tag in unsupported state\")},s.prototype.setAuthTag=function(){throw new Error(\"trying to set auth tag in unsupported state\")},s.prototype.setAAD=function(){throw new Error(\"trying to set aad in unsupported state\")},s.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error(\"can't switch encodings\");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=s},7232:(t,e,r)=>{var n=r(366);t.exports=function(t,e,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],e),o=0,s=[],a=n.sumOrNaN(e),c=0;cu.value){if(c===t.length-1)return{fee:r*(i+f)}}else if(i+=f,o+=l,s.push(u),!(o{var n=r(366);t.exports=function(t,e,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],e),o=0,s=[],a=n.sumOrNaN(e),c=n.dustThreshold({},r),u=0;ua+l+c)&&(i+=h,o+=p,s.push(f),!(o{var n=r(7232),i=r(2379),o=r(366);function s(t,e){return t.value-e*o.inputBytes(t)}t.exports=function(t,e,r){t=t.concat().sort((function(t,e){return s(e,r)-s(t,r)}));var o=i(t,e,r);return o.inputs?o:n(t,e,r)}},366:t=>{var e=10,r=41,n=107,i=9,o=25;function s(t){return r+(t.script?t.script.length:n)}function a(t){return i+(t.script?t.script.length:o)}function c(t,e){return s({})*e}function u(t,r){return e+t.reduce((function(t,e){return t+s(e)}),0)+r.reduce((function(t,e){return t+a(e)}),0)}function f(t){return\"number\"!=typeof t?NaN:isFinite(t)?Math.floor(t)!==t||t<0?NaN:t:NaN}function h(t){return t.reduce((function(t,e){return t+f(e.value)}),0)}var l=a({});t.exports={dustThreshold:c,finalize:function(t,e,r){var n=u(t,e),i=r*(n+l),o=h(t)-(h(e)+i);o>c(0,r)&&(e=e.concat({value:o}));var s=h(t)-h(e);return isFinite(s)?{inputs:t,outputs:e,fee:s}:{fee:r*n}},inputBytes:s,outputBytes:a,sumOrNaN:h,sumForgiving:function(t){return t.reduce((function(t,e){return t+(isFinite(e.value)?e.value:0)}),0)},transactionBytes:u,uintOrNaN:f}},3257:(t,e,r)=>{\"use strict\";var n=r(5615),i=r(3275),o=r(5586),s=r(3229),a=r(7589);function c(t){a.call(this,\"digest\"),this._hash=t}n(c,a),c.prototype._update=function(t){this._hash.update(t)},c.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return\"md5\"===(t=t.toLowerCase())?new i:\"rmd160\"===t||\"ripemd160\"===t?new o:new c(s(t))}},8437:t=>{var e=1e3,r=60*e,n=60*r,i=24*n,o=7*i,s=365.25*i;function a(t,e,r,n){var i=e>=1.5*r;return Math.round(t/r)+\" \"+n+(i?\"s\":\"\")}t.exports=function(t,c){c=c||{};var u=typeof t;if(\"string\"===u&&t.length>0)return function(t){if((t=String(t)).length>100)return;var a=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return c*s;case\"weeks\":case\"week\":case\"w\":return c*o;case\"days\":case\"day\":case\"d\":return c*i;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return c*n;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return c*r;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return c*e;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return c;default:return}}(t);if(\"number\"===u&&isFinite(t))return c.long?function(t){var o=Math.abs(t);if(o>=i)return a(t,o,i,\"day\");if(o>=n)return a(t,o,n,\"hour\");if(o>=r)return a(t,o,r,\"minute\");if(o>=e)return a(t,o,e,\"second\");return t+\" ms\"}(t):function(t){var o=Math.abs(t);if(o>=i)return Math.round(t/i)+\"d\";if(o>=n)return Math.round(t/n)+\"h\";if(o>=r)return Math.round(t/r)+\"m\";if(o>=e)return Math.round(t/e)+\"s\";return t+\"ms\"}(t);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(t))}},124:(t,e,r)=>{e.formatArgs=function(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+t.exports.humanize(this.diff),!this.useColors)return;const r=\"color: \"+this.color;e.splice(1,0,r,\"color: inherit\");let n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(t=>{\"%%\"!==t&&(n++,\"%c\"===t&&(i=n))})),e.splice(i,0,r)},e.save=function(t){try{t?e.storage.setItem(\"debug\",t):e.storage.removeItem(\"debug\")}catch(t){}},e.load=function(){let t;try{t=e.storage.getItem(\"debug\")}catch(t){}!t&&\"undefined\"!=typeof process&&\"env\"in process&&(t=\"false\");return t},e.useColors=function(){if(\"undefined\"!=typeof window&&window.process&&(\"renderer\"===window.process.type||window.process.__nwjs))return!0;if(\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))return!1;return\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),e.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],e.log=console.debug||console.log||(()=>{}),t.exports=r(7891)(e);const{formatters:n}=t.exports;n.j=function(t){try{return JSON.stringify(t)}catch(t){return\"[UnexpectedJSONParseError]: \"+t.message}}},7891:(t,e,r)=>{t.exports=function(t){function e(t){let r,i,o,s=null;function a(...t){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,t[0]=e.coerce(t[0]),\"string\"!=typeof t[0]&&t.unshift(\"%O\");let s=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if(\"%%\"===r)return\"%\";s++;const o=e.formatters[i];if(\"function\"==typeof o){const e=t[s];r=o.call(n,e),t.splice(s,1),s--}return r})),e.formatArgs.call(n,t);(n.log||e.log).apply(n,t)}return a.namespace=t,a.useColors=e.useColors(),a.color=e.selectColor(t),a.extend=n,a.destroy=e.destroy,Object.defineProperty(a,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==e.namespaces&&(i=e.namespaces,o=e.enabled(t)),o),set:t=>{s=t}}),\"function\"==typeof e.init&&e.init(a),a}function n(t,r){const n=e(this.namespace+(void 0===r?\":\":r)+t);return n.log=this.log,n}function i(t){return t.toString().substring(2,t.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return e.debug=e,e.default=e,e.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},e.disable=function(){const t=[...e.names.map(i),...e.skips.map(i).map((t=>\"-\"+t))].join(\",\");return e.enable(\"\"),t},e.enable=function(t){let r;e.save(t),e.namespaces=t,e.names=[],e.skips=[];const n=(\"string\"==typeof t?t:\"\").split(/[\\s,]+/),i=n.length;for(r=0;r{e[r]=t[r]})),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let r=0;for(let e=0;e{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(3540);e.networks=i;const o=r(146),s=r(2644),a=r(6952),c=r(5581),u=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError(\"Private key not in range [1, n)\");return o.typeforce(u,r),new f(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(u,r),new f(void 0,e,r)}(0,c.testEcc)(t);class f{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error(\"Missing private key\");return a.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error(\"Missing private key\");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error(\"Missing private key\");if(!t.signSchnorr)throw new Error(\"signSchnorr not supported by ecc library\");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error(\"verifySchnorr not supported by ecc library\");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const s=t.xOnlyPointAddTweak(i,e);if(!s||null===s.xOnlyPubkey)throw new Error(\"Cannot tweak public key!\");const a=n.from([0===s.parity?2:3]);return r(n.concat([a,s.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3===this.publicKey[0]||4===this.publicKey[0]&&1==(1&this.publicKey[64])?t.privateNegate(this.privateKey):this.privateKey,o=t.privateAdd(i,r);if(!o)throw new Error(\"Invalid tweaked private key!\");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=a.decode(t),s=n.version;if(o.Array(r)){if(!(r=r.filter((t=>s===t.wif)).pop()))throw new Error(\"Unknown network version\")}else if(r=r||i.bitcoin,s!==r.wif)throw new Error(\"Invalid network version\");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(u,r),void 0===r&&(r={});const n=r.rng||s;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},1075:(t,e,r)=>{\"use strict\";e.Ay=void 0;var n=r(2239);Object.defineProperty(e,\"Ay\",{enumerable:!0,get:function(){return n.ECPairFactory}})},3540:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"tb\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},5581:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,\"hex\");function o(t){if(!t)throw new Error(\"ecc library invalid\")}e.testEcc=function(t){o(t.isPoint(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(!t.isPoint(i(\"030000000000000000000000000000000000000000000000000000000000000005\"))),o(t.isPrivate(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(!t.isPrivate(i(\"0000000000000000000000000000000000000000000000000000000000000000\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142\"))),o(n.from(t.privateAdd(i(\"0000000000000000000000000000000000000000000000000000000000000001\"),i(\"0000000000000000000000000000000000000000000000000000000000000000\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))),o(null===t.privateAdd(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"),i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateAdd(i(\"e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500\"),i(\"b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665\"))).equals(i(\"9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24\"))),o(n.from(t.privateNegate(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(n.from(t.privateNegate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateNegate(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792\"))),o(n.from(t.pointCompress(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"),!0)).equals(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(n.from(t.pointCompress(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"),!1)).equals(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"))),o(n.from(t.pointCompress(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),!0)).equals(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(n.from(t.pointCompress(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),!1)).equals(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"))),o(n.from(t.pointFromScalar(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99\"))),o(null===t.xOnlyPointAddTweak(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\")));let e=t.xOnlyPointAddTweak(i(\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\"),i(\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\"));o(n.from(e.xOnlyPubkey).equals(i(\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"))&&1===e.parity),e=t.xOnlyPointAddTweak(i(\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\"),i(\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\")),o(n.from(e.xOnlyPubkey).equals(i(\"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c\"))&&0===e.parity),o(n.from(t.sign(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))).equals(i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),o(t.verify(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),t.signSchnorr&&o(n.from(t.signSchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9\"),i(\"c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906\"))).equals(i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\"))),t.verifySchnorr&&o(t.verifySchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8\"),i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\")))}},146:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(973),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},46:t=>{\"use strict\";var e,r=\"object\"==typeof Reflect?Reflect:null,n=r&&\"function\"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&\"function\"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){\"function\"==typeof t.removeListener&&t.removeListener(\"error\",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),\"error\"!==e&&function(t,e,r){\"function\"==typeof t.on&&y(t,\"error\",e,r)}(t,i,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if(\"function\"!=typeof t)throw new TypeError('The \"listener\" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var i,o,s,u;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit(\"newListener\",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if(\"function\"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(t))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error(\"Possible EventEmitter memory leak detected. \"+s.length+\" \"+String(e)+\" listeners added. Use emitter.setMaxListeners() to increase limit\");f.name=\"MaxListenersExceededWarning\",f.emitter=t,f.type=e,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function l(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:\"function\"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(s=e[0]),s instanceof Error)throw s;var a=new Error(\"Unhandled error.\"+(s?\" (\"+s.message+\")\":\"\"));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if(\"function\"==typeof c)n(c,this,e);else{var u=c.length,f=d(c,u);for(r=0;r=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return l(this,t,!0)},o.prototype.rawListeners=function(t){return l(this,t,!1)},o.listenerCount=function(t,e){return\"function\"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},282:t=>{t.exports=s,s.default=s,s.stable=f,s.stableStringify=f;var e=\"[...]\",r=\"[Circular]\",n=[],i=[];function o(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function s(t,e,r,s){var a;void 0===s&&(s=o()),c(t,\"\",0,[],void 0,0,s);try{a=0===i.length?JSON.stringify(t,e,r):JSON.stringify(t,l(e),r)}catch(t){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function a(t,e,r,o){var s=Object.getOwnPropertyDescriptor(o,r);void 0!==s.get?s.configurable?(Object.defineProperty(o,r,{value:t}),n.push([o,r,e,s])):i.push([e,r,t]):(o[r]=t,n.push([o,r,e]))}function c(t,n,i,o,s,u,f){var h;if(u+=1,\"object\"==typeof t&&null!==t){for(h=0;hf.depthLimit)return void a(e,t,n,s);if(void 0!==f.edgesLimit&&i+1>f.edgesLimit)return void a(e,t,n,s);if(o.push(t),Array.isArray(t))for(h=0;he?1:0}function f(t,e,r,s){void 0===s&&(s=o());var a,c=h(t,\"\",0,[],void 0,0,s)||t;try{a=0===i.length?JSON.stringify(c,e,r):JSON.stringify(c,l(e),r)}catch(t){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function h(t,i,o,s,c,f,l){var p;if(f+=1,\"object\"==typeof t&&null!==t){for(p=0;pl.depthLimit)return void a(e,t,i,c);if(void 0!==l.edgesLimit&&o+1>l.edgesLimit)return void a(e,t,i,c);if(s.push(t),Array.isArray(t))for(p=0;p0)for(var n=0;n{\"use strict\";const n=r(919),i=r(6226),o=r(5181);t.exports={XMLParser:i,XMLValidator:n,XMLBuilder:o}},1209:(t,e)=>{\"use strict\";const r=\":A-Za-z_\\\\u00C0-\\\\u00D6\\\\u00D8-\\\\u00F6\\\\u00F8-\\\\u02FF\\\\u0370-\\\\u037D\\\\u037F-\\\\u1FFF\\\\u200C-\\\\u200D\\\\u2070-\\\\u218F\\\\u2C00-\\\\u2FEF\\\\u3001-\\\\uD7FF\\\\uF900-\\\\uFDCF\\\\uFDF0-\\\\uFFFD\",n=\"[\"+r+\"][\"+(r+\"\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040\")+\"]*\",i=new RegExp(\"^\"+n+\"$\");e.isExist=function(t){return void 0!==t},e.isEmptyObject=function(t){return 0===Object.keys(t).length},e.merge=function(t,e,r){if(e){const n=Object.keys(e),i=n.length;for(let o=0;o{\"use strict\";const n=r(1209),i={allowBooleanAttributes:!1,unpairedTags:[]};function o(t){return\" \"===t||\"\\t\"===t||\"\\n\"===t||\"\\r\"===t}function s(t,e){const r=e;for(;e5&&\"xml\"===n)return d(\"InvalidXml\",\"XML declaration allowed only at the start of the document.\",g(t,e));if(\"?\"==t[e]&&\">\"==t[e+1]){e++;break}}return e}function a(t,e){if(t.length>e+5&&\"-\"===t[e+1]&&\"-\"===t[e+2]){for(e+=3;e\"===t[e+2]){e+=2;break}}else if(t.length>e+8&&\"D\"===t[e+1]&&\"O\"===t[e+2]&&\"C\"===t[e+3]&&\"T\"===t[e+4]&&\"Y\"===t[e+5]&&\"P\"===t[e+6]&&\"E\"===t[e+7]){let r=1;for(e+=8;e\"===t[e]&&(r--,0===r))break}else if(t.length>e+9&&\"[\"===t[e+1]&&\"C\"===t[e+2]&&\"D\"===t[e+3]&&\"A\"===t[e+4]&&\"T\"===t[e+5]&&\"A\"===t[e+6]&&\"[\"===t[e+7])for(e+=8;e\"===t[e+2]){e+=2;break}return e}e.validate=function(t,e){e=Object.assign({},i,e);const r=[];let c=!1,u=!1;\"\\ufeff\"===t[0]&&(t=t.substr(1));for(let i=0;i\"!==t[i]&&\" \"!==t[i]&&\"\\t\"!==t[i]&&\"\\n\"!==t[i]&&\"\\r\"!==t[i];i++)w+=t[i];if(w=w.trim(),\"/\"===w[w.length-1]&&(w=w.substring(0,w.length-1),i--),h=w,!n.isName(h)){let e;return e=0===w.trim().length?\"Invalid space after '<'.\":\"Tag '\"+w+\"' is an invalid name.\",d(\"InvalidTag\",e,g(t,i))}const m=f(t,i);if(!1===m)return d(\"InvalidAttr\",\"Attributes for '\"+w+\"' have open quote.\",g(t,i));let v=m.value;if(i=m.index,\"/\"===v[v.length-1]){const r=i-v.length;v=v.substring(0,v.length-1);const n=l(v,e);if(!0!==n)return d(n.err.code,n.err.msg,g(t,r+n.err.line));c=!0}else if(b){if(!m.tagClosed)return d(\"InvalidTag\",\"Closing tag '\"+w+\"' doesn't have proper closing.\",g(t,i));if(v.trim().length>0)return d(\"InvalidTag\",\"Closing tag '\"+w+\"' can't have attributes or invalid starting.\",g(t,y));{const e=r.pop();if(w!==e.tagName){let r=g(t,e.tagStartPos);return d(\"InvalidTag\",\"Expected closing tag '\"+e.tagName+\"' (opened in line \"+r.line+\", col \"+r.col+\") instead of closing tag '\"+w+\"'.\",g(t,y))}0==r.length&&(u=!0)}}else{const n=l(v,e);if(!0!==n)return d(n.err.code,n.err.msg,g(t,i-v.length+n.err.line));if(!0===u)return d(\"InvalidXml\",\"Multiple possible root nodes found.\",g(t,i));-1!==e.unpairedTags.indexOf(w)||r.push({tagName:w,tagStartPos:y}),c=!0}for(i++;i0)||d(\"InvalidXml\",\"Invalid '\"+JSON.stringify(r.map((t=>t.tagName)),null,4).replace(/\\r?\\n/g,\"\")+\"' found.\",{line:1,col:1}):d(\"InvalidXml\",\"Start tag expected.\",1)};const c='\"',u=\"'\";function f(t,e){let r=\"\",n=\"\",i=!1;for(;e\"===t[e]&&\"\"===n){i=!0;break}r+=t[e]}return\"\"===n&&{value:r,index:e,tagClosed:i}}const h=new RegExp(\"(\\\\s*)([^\\\\s=]+)(\\\\s*=)?(\\\\s*(['\\\"])(([\\\\s\\\\S])*?)\\\\5)?\",\"g\");function l(t,e){const r=n.getAllMatches(t,h),i={};for(let t=0;t{\"use strict\";const n=r(4655),i={attributeNamePrefix:\"@_\",attributesGroupName:!1,textNodeName:\"#text\",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:\" \",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp(\"&\",\"g\"),val:\"&\"},{regex:new RegExp(\">\",\"g\"),val:\">\"},{regex:new RegExp(\"<\",\"g\"),val:\"<\"},{regex:new RegExp(\"'\",\"g\"),val:\"'\"},{regex:new RegExp('\"',\"g\"),val:\""\"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function o(t){this.options=Object.assign({},i,t),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=c),this.processTextOrObjNode=s,this.options.format?(this.indentate=a,this.tagEndChar=\">\\n\",this.newLine=\"\\n\"):(this.indentate=function(){return\"\"},this.tagEndChar=\">\",this.newLine=\"\")}function s(t,e,r){const n=this.j2x(t,r+1);return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,r):this.buildObjectNode(n.val,e,n.attrStr,r)}function a(t){return this.options.indentBy.repeat(t)}function c(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}o.prototype.build=function(t){return this.options.preserveOrder?n(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0).val)},o.prototype.j2x=function(t,e){let r=\"\",n=\"\";for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i))if(void 0===t[i])this.isAttribute(i)&&(n+=\"\");else if(null===t[i])this.isAttribute(i)?n+=\"\":\"?\"===i[0]?n+=this.indentate(e)+\"<\"+i+\"?\"+this.tagEndChar:n+=this.indentate(e)+\"<\"+i+\"/\"+this.tagEndChar;else if(t[i]instanceof Date)n+=this.buildTextValNode(t[i],i,\"\",e);else if(\"object\"!=typeof t[i]){const o=this.isAttribute(i);if(o)r+=this.buildAttrPairStr(o,\"\"+t[i]);else if(i===this.options.textNodeName){let e=this.options.tagValueProcessor(i,\"\"+t[i]);n+=this.replaceEntitiesValue(e)}else n+=this.buildTextValNode(t[i],i,\"\",e)}else if(Array.isArray(t[i])){const r=t[i].length;let o=\"\";for(let s=0;s\"+t+i}},o.prototype.closeTag=function(t){let e=\"\";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e=\"/\"):e=this.options.suppressEmptyNode?\"/\":`>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(n)+`\\x3c!--${t}--\\x3e`+this.newLine;if(\"?\"===e[0])return this.indentate(n)+\"<\"+e+r+\"?\"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),\"\"===i?this.indentate(n)+\"<\"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(n)+\"<\"+e+r+\">\"+i+\"0&&this.options.processEntities)for(let e=0;e{function e(t,s,a,c){let u=\"\",f=!1;for(let h=0;h`,f=!1;continue}if(p===s.commentPropName){u+=c+`\\x3c!--${l[p][0][s.textNodeName]}--\\x3e`,f=!0;continue}if(\"?\"===p[0]){const t=n(l[\":@\"],s),e=\"?xml\"===p?\"\":c;let r=l[p][0][s.textNodeName];r=0!==r.length?\" \"+r:\"\",u+=e+`<${p}${r}${t}?>`,f=!0;continue}let y=c;\"\"!==y&&(y+=s.indentBy);const g=c+`<${p}${n(l[\":@\"],s)}`,b=e(l[p],s,d,y);-1!==s.unpairedTags.indexOf(p)?s.suppressUnpairedNode?u+=g+\">\":u+=g+\"/>\":b&&0!==b.length||!s.suppressEmptyNode?b&&b.endsWith(\">\")?u+=g+`>${b}${c}`:(u+=g+\">\",b&&\"\"!==c&&(b.includes(\"/>\")||b.includes(\"`):u+=g+\"/>\",f=!0}return u}function r(t){const e=Object.keys(t);for(let r=0;r0&&e.processEntities)for(let r=0;r0&&(n=\"\\n\"),e(t,r,\"\",n)}},3233:(t,e,r)=>{const n=r(1209);function i(t,e){let r=\"\";for(;e\"===t[e]){if(l?\"-\"===t[e-1]&&\"-\"===t[e-2]&&(l=!1,n--):n--,0===n)break}else\"[\"===t[e]?h=!0:p+=t[e];else{if(h&&s(t,e))e+=7,[entityName,val,e]=i(t,e+1),-1===val.indexOf(\"&\")&&(r[f(entityName)]={regx:RegExp(`&${entityName};`,\"g\"),val});else if(h&&a(t,e))e+=8;else if(h&&c(t,e))e+=8;else if(h&&u(t,e))e+=9;else{if(!o)throw new Error(\"Invalid DOCTYPE\");l=!0}n++,p=\"\"}if(0!==n)throw new Error(\"Unclosed DOCTYPE\")}return{entities:r,i:e}}},7063:(t,e)=>{const r={preserveOrder:!1,attributeNamePrefix:\"@_\",attributesGroupName:!1,textNodeName:\"#text\",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t}};e.buildOptions=function(t){return Object.assign({},r,t)},e.defaultOptions=r},5139:(t,e,r)=>{\"use strict\";const n=r(1209),i=r(5381),o=r(3233),s=r(8262);function a(t){const e=Object.keys(t);for(let r=0;r0)){s||(t=this.replaceEntitiesValue(t));const n=this.options.tagValueProcessor(e,t,r,i,o);if(null==n)return t;if(typeof n!=typeof t||n!==t)return n;if(this.options.trimValues)return v(t,this.options.parseTagValue,this.options.numberParseOptions);return t.trim()===t?v(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function u(t){if(this.options.removeNSPrefix){const e=t.split(\":\"),r=\"/\"===t.charAt(0)?\"/\":\"\";if(\"xmlns\"===e[0])return\"\";2===e.length&&(t=r+e[1])}return t}const f=new RegExp(\"([^\\\\s=]+)\\\\s*(=\\\\s*(['\\\"])([\\\\s\\\\S]*?)\\\\3)?\",\"gm\");function h(t,e,r){if(!this.options.ignoreAttributes&&\"string\"==typeof t){const r=n.getAllMatches(t,f),i=r.length,o={};for(let t=0;t\",a,\"Closing Tag is not closed.\");let i=t.substring(a+2,e).trim();if(this.options.removeNSPrefix){const t=i.indexOf(\":\");-1!==t&&(i=i.substr(t+1))}this.options.transformTagName&&(i=this.options.transformTagName(i)),r&&(n=this.saveTextToParentTag(n,r,s));const o=s.substring(s.lastIndexOf(\".\")+1);if(i&&-1!==this.options.unpairedTags.indexOf(i))throw new Error(`Unpaired tag can not be used as closing tag: `);let c=0;o&&-1!==this.options.unpairedTags.indexOf(o)?(c=s.lastIndexOf(\".\",s.lastIndexOf(\".\")-1),this.tagsNodeStack.pop()):c=s.lastIndexOf(\".\"),s=s.substring(0,c),r=this.tagsNodeStack.pop(),n=\"\",a=e}else if(\"?\"===t[a+1]){let e=w(t,a,!1,\"?>\");if(!e)throw new Error(\"Pi Tag is not closed.\");if(n=this.saveTextToParentTag(n,r,s),this.options.ignoreDeclaration&&\"?xml\"===e.tagName||this.options.ignorePiTags);else{const t=new i(e.tagName);t.add(this.options.textNodeName,\"\"),e.tagName!==e.tagExp&&e.attrExpPresent&&(t[\":@\"]=this.buildAttributesMap(e.tagExp,s,e.tagName)),this.addChild(r,t,s)}a=e.closeIndex+1}else if(\"!--\"===t.substr(a+1,3)){const e=b(t,\"--\\x3e\",a+4,\"Comment is not closed.\");if(this.options.commentPropName){const i=t.substring(a+4,e-2);n=this.saveTextToParentTag(n,r,s),r.add(this.options.commentPropName,[{[this.options.textNodeName]:i}])}a=e}else if(\"!D\"===t.substr(a+1,2)){const e=o(t,a);this.docTypeEntities=e.entities,a=e.i}else if(\"![\"===t.substr(a+1,2)){const e=b(t,\"]]>\",a,\"CDATA is not closed.\")-2,i=t.substring(a+9,e);n=this.saveTextToParentTag(n,r,s);let o=this.parseTextData(i,r.tagname,s,!0,!1,!0,!0);null==o&&(o=\"\"),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:i}]):r.add(this.options.textNodeName,o),a=e+2}else{let o=w(t,a,this.options.removeNSPrefix),c=o.tagName;const u=o.rawTagName;let f=o.tagExp,h=o.attrExpPresent,l=o.closeIndex;this.options.transformTagName&&(c=this.options.transformTagName(c)),r&&n&&\"!xml\"!==r.tagname&&(n=this.saveTextToParentTag(n,r,s,!1));const p=r;if(p&&-1!==this.options.unpairedTags.indexOf(p.tagname)&&(r=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf(\".\"))),c!==e.tagname&&(s+=s?\".\"+c:c),this.isItStopNode(this.options.stopNodes,s,c)){let e=\"\";if(f.length>0&&f.lastIndexOf(\"/\")===f.length-1)a=o.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(c))a=o.closeIndex;else{const r=this.readStopNodeData(t,u,l+1);if(!r)throw new Error(`Unexpected end of ${u}`);a=r.i,e=r.tagContent}const n=new i(c);c!==f&&h&&(n[\":@\"]=this.buildAttributesMap(f,s,c)),e&&(e=this.parseTextData(e,c,s,!0,h,!0,!0)),s=s.substr(0,s.lastIndexOf(\".\")),n.add(this.options.textNodeName,e),this.addChild(r,n,s)}else{if(f.length>0&&f.lastIndexOf(\"/\")===f.length-1){\"/\"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),f=c):f=f.substr(0,f.length-1),this.options.transformTagName&&(c=this.options.transformTagName(c));const t=new i(c);c!==f&&h&&(t[\":@\"]=this.buildAttributesMap(f,s,c)),this.addChild(r,t,s),s=s.substr(0,s.lastIndexOf(\".\"))}else{const t=new i(c);this.tagsNodeStack.push(r),c!==f&&h&&(t[\":@\"]=this.buildAttributesMap(f,s,c)),this.addChild(r,t,s),r=t}n=\"\",a=l}}else n+=t[a]}return e.child};function p(t,e,r){const n=this.options.updateTag(e.tagname,r,e[\":@\"]);!1===n||(\"string\"==typeof n?(e.tagname=n,t.addChild(e)):t.addChild(e))}const d=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const r=this.docTypeEntities[e];t=t.replace(r.regx,r.val)}for(let e in this.lastEntities){const r=this.lastEntities[e];t=t.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const r=this.htmlEntities[e];t=t.replace(r.regex,r.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function y(t,e,r,n){return t&&(void 0===n&&(n=0===Object.keys(e.child).length),void 0!==(t=this.parseTextData(t,e.tagname,r,!1,!!e[\":@\"]&&0!==Object.keys(e[\":@\"]).length,n))&&\"\"!==t&&e.add(this.options.textNodeName,t),t=\"\"),t}function g(t,e,r){const n=\"*.\"+r;for(const r in t){const i=t[r];if(n===i||e===i)return!0}return!1}function b(t,e,r,n){const i=t.indexOf(e,r);if(-1===i)throw new Error(n);return i+e.length-1}function w(t,e,r,n=\">\"){const i=function(t,e,r=\">\"){let n,i=\"\";for(let o=e;o\",r,`${e} is not closed`);if(t.substring(r+2,o).trim()===e&&(i--,0===i))return{tagContent:t.substring(n,r),i:o};r=o}else if(\"?\"===t[r+1]){r=b(t,\"?>\",r+1,\"StopNode is not closed.\")}else if(\"!--\"===t.substr(r+1,3)){r=b(t,\"--\\x3e\",r+3,\"StopNode is not closed.\")}else if(\"![\"===t.substr(r+1,2)){r=b(t,\"]]>\",r,\"StopNode is not closed.\")-2}else{const n=w(t,r,\">\");if(n){(n&&n.tagName)===e&&\"/\"!==n.tagExp[n.tagExp.length-1]&&i++,r=n.closeIndex}}}function v(t,e,r){if(e&&\"string\"==typeof t){const e=t.trim();return\"true\"===e||\"false\"!==e&&s(t,r)}return n.isExist(t)?t:\"\"}t.exports=class{constructor(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:\"'\"},gt:{regex:/&(gt|#62|#x3E);/g,val:\">\"},lt:{regex:/&(lt|#60|#x3C);/g,val:\"<\"},quot:{regex:/&(quot|#34|#x22);/g,val:'\"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:\"&\"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:\" \"},cent:{regex:/&(cent|#162);/g,val:\"¢\"},pound:{regex:/&(pound|#163);/g,val:\"£\"},yen:{regex:/&(yen|#165);/g,val:\"¥\"},euro:{regex:/&(euro|#8364);/g,val:\"€\"},copyright:{regex:/&(copy|#169);/g,val:\"©\"},reg:{regex:/&(reg|#174);/g,val:\"®\"},inr:{regex:/&(inr|#8377);/g,val:\"₹\"}},this.addExternalEntities=a,this.parseXml=l,this.parseTextData=c,this.resolveNameSpace=u,this.buildAttributesMap=h,this.isItStopNode=g,this.replaceEntitiesValue=d,this.readStopNodeData=m,this.saveTextToParentTag=y,this.addChild=p}}},6226:(t,e,r)=>{const{buildOptions:n}=r(7063),i=r(5139),{prettify:o}=r(896),s=r(919);t.exports=class{constructor(t){this.externalEntities={},this.options=n(t)}parse(t,e){if(\"string\"==typeof t);else{if(!t.toString)throw new Error(\"XML data is accepted in String or Bytes[] form.\");t=t.toString()}if(e){!0===e&&(e={});const r=s.validate(t,e);if(!0!==r)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const r=new i(this.options);r.addExternalEntities(this.externalEntities);const n=r.parseXml(t);return this.options.preserveOrder||void 0===n?n:o(n,this.options)}addEntity(t,e){if(-1!==e.indexOf(\"&\"))throw new Error(\"Entity value can't have '&'\");if(-1!==t.indexOf(\"&\")||-1!==t.indexOf(\";\"))throw new Error(\"An entity must be set without '&' and ';'. Eg. use '#xD' for ' '\");if(\"&\"===e)throw new Error(\"An entity with value '&' is not permitted\");this.externalEntities[t]=e}}},896:(t,e)=>{\"use strict\";function r(t,e,s){let a;const c={};for(let u=0;u0&&(c[e.textNodeName]=a):void 0!==a&&(c[e.textNodeName]=a),c}function n(t){const e=Object.keys(t);for(let t=0;t{\"use strict\";t.exports=class{constructor(t){this.tagname=t,this.child=[],this[\":@\"]={}}add(t,e){\"__proto__\"===t&&(t=\"#__proto__\"),this.child.push({[t]:e})}addChild(t){\"__proto__\"===t.tagname&&(t.tagname=\"#__proto__\"),t[\":@\"]&&Object.keys(t[\":@\"]).length>0?this.child.push({[t.tagname]:t.child,\":@\":t[\":@\"]}):this.child.push({[t.tagname]:t.child})}}},9467:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=r(4156).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(5615)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t,e){if(!n.isBuffer(t)&&\"string\"!=typeof t)throw new TypeError(e+\" must be a string or a buffer\")}(t,\"Data\"),this._finalized)throw new Error(\"Digest already called\");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error(\"_update is not implemented\")},o.prototype.digest=function(t){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error(\"_digest is not implemented\")},t.exports=o},9318:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,c=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=u}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,u-=8);t[r+p-d]|=128*y}},5615:t=>{\"function\"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},3624:(t,e,r)=>{\"use strict\";const n=r(222),i=Symbol(\"max\"),o=Symbol(\"length\"),s=Symbol(\"lengthCalculator\"),a=Symbol(\"allowStale\"),c=Symbol(\"maxAge\"),u=Symbol(\"dispose\"),f=Symbol(\"noDisposeOnSet\"),h=Symbol(\"lruList\"),l=Symbol(\"cache\"),p=Symbol(\"updateAgeOnGet\"),d=()=>1;const y=(t,e,r)=>{const n=t[l].get(e);if(n){const e=n.value;if(g(t,e)){if(w(t,n),!t[a])return}else r&&(t[p]&&(n.value.now=Date.now()),t[h].unshiftNode(n));return e.value}},g=(t,e)=>{if(!e||!e.maxAge&&!t[c])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[c]&&r>t[c]},b=t=>{if(t[o]>t[i])for(let e=t[h].tail;t[o]>t[i]&&null!==e;){const r=e.prev;w(t,e),e=r}},w=(t,e)=>{if(e){const r=e.value;t[u]&&t[u](r.key,r.value),t[o]-=r.length,t[l].delete(r.key),t[h].removeNode(e)}};class m{constructor(t,e,r,n,i){this.key=t,this.value=e,this.length=r,this.now=n,this.maxAge=i||0}}const v=(t,e,r,n)=>{let i=r.value;g(t,i)&&(w(t,r),t[a]||(i=void 0)),i&&e.call(n,i.value,i.key,t)};t.exports=class{constructor(t){if(\"number\"==typeof t&&(t={max:t}),t||(t={}),t.max&&(\"number\"!=typeof t.max||t.max<0))throw new TypeError(\"max must be a non-negative number\");this[i]=t.max||1/0;const e=t.length||d;if(this[s]=\"function\"!=typeof e?d:e,this[a]=t.stale||!1,t.maxAge&&\"number\"!=typeof t.maxAge)throw new TypeError(\"maxAge must be a number\");this[c]=t.maxAge||0,this[u]=t.dispose,this[f]=t.noDisposeOnSet||!1,this[p]=t.updateAgeOnGet||!1,this.reset()}set max(t){if(\"number\"!=typeof t||t<0)throw new TypeError(\"max must be a non-negative number\");this[i]=t||1/0,b(this)}get max(){return this[i]}set allowStale(t){this[a]=!!t}get allowStale(){return this[a]}set maxAge(t){if(\"number\"!=typeof t)throw new TypeError(\"maxAge must be a non-negative number\");this[c]=t,b(this)}get maxAge(){return this[c]}set lengthCalculator(t){\"function\"!=typeof t&&(t=d),t!==this[s]&&(this[s]=t,this[o]=0,this[h].forEach((t=>{t.length=this[s](t.value,t.key),this[o]+=t.length}))),b(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[h].length}rforEach(t,e){e=e||this;for(let r=this[h].tail;null!==r;){const n=r.prev;v(this,t,r,e),r=n}}forEach(t,e){e=e||this;for(let r=this[h].head;null!==r;){const n=r.next;v(this,t,r,e),r=n}}keys(){return this[h].toArray().map((t=>t.key))}values(){return this[h].toArray().map((t=>t.value))}reset(){this[u]&&this[h]&&this[h].length&&this[h].forEach((t=>this[u](t.key,t.value))),this[l]=new Map,this[h]=new n,this[o]=0}dump(){return this[h].map((t=>!g(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[h]}set(t,e,r){if((r=r||this[c])&&\"number\"!=typeof r)throw new TypeError(\"maxAge must be a number\");const n=r?Date.now():0,a=this[s](e,t);if(this[l].has(t)){if(a>this[i])return w(this,this[l].get(t)),!1;const s=this[l].get(t).value;return this[u]&&(this[f]||this[u](t,s.value)),s.now=n,s.maxAge=r,s.value=e,this[o]+=a-s.length,s.length=a,this.get(t),b(this),!0}const p=new m(t,e,a,n,r);return p.length>this[i]?(this[u]&&this[u](t,e),!1):(this[o]+=p.length,this[h].unshift(p),this[l].set(t,this[h].head),b(this),!0)}has(t){if(!this[l].has(t))return!1;const e=this[l].get(t).value;return!g(this,e)}get(t){return y(this,t,!0)}peek(t){return y(this,t,!1)}pop(){const t=this[h].tail;return t?(w(this,t),t.value):null}del(t){w(this,this[l].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const n=t[r],i=n.e||0;if(0===i)this.set(n.k,n.v);else{const t=i-e;t>0&&this.set(n.k,n.v,t)}}}prune(){this[l].forEach(((t,e)=>y(this,e,!1)))}}},3275:(t,e,r)=>{\"use strict\";var n=r(5615),i=r(9467),o=r(5636).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return c(t+(e&r|~e&n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return c(t+(e&n|r&~n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return c(t+(e^r^n)+i+o|0,s)+e|0}function l(t,e,r,n,i,o,s){return c(t+(r^(e|~n))+i+o|0,s)+e|0}n(a,i),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,o=this._d;r=u(r,n,i,o,t[0],3614090360,7),o=u(o,r,n,i,t[1],3905402710,12),i=u(i,o,r,n,t[2],606105819,17),n=u(n,i,o,r,t[3],3250441966,22),r=u(r,n,i,o,t[4],4118548399,7),o=u(o,r,n,i,t[5],1200080426,12),i=u(i,o,r,n,t[6],2821735955,17),n=u(n,i,o,r,t[7],4249261313,22),r=u(r,n,i,o,t[8],1770035416,7),o=u(o,r,n,i,t[9],2336552879,12),i=u(i,o,r,n,t[10],4294925233,17),n=u(n,i,o,r,t[11],2304563134,22),r=u(r,n,i,o,t[12],1804603682,7),o=u(o,r,n,i,t[13],4254626195,12),i=u(i,o,r,n,t[14],2792965006,17),r=f(r,n=u(n,i,o,r,t[15],1236535329,22),i,o,t[1],4129170786,5),o=f(o,r,n,i,t[6],3225465664,9),i=f(i,o,r,n,t[11],643717713,14),n=f(n,i,o,r,t[0],3921069994,20),r=f(r,n,i,o,t[5],3593408605,5),o=f(o,r,n,i,t[10],38016083,9),i=f(i,o,r,n,t[15],3634488961,14),n=f(n,i,o,r,t[4],3889429448,20),r=f(r,n,i,o,t[9],568446438,5),o=f(o,r,n,i,t[14],3275163606,9),i=f(i,o,r,n,t[3],4107603335,14),n=f(n,i,o,r,t[8],1163531501,20),r=f(r,n,i,o,t[13],2850285829,5),o=f(o,r,n,i,t[2],4243563512,9),i=f(i,o,r,n,t[7],1735328473,14),r=h(r,n=f(n,i,o,r,t[12],2368359562,20),i,o,t[5],4294588738,4),o=h(o,r,n,i,t[8],2272392833,11),i=h(i,o,r,n,t[11],1839030562,16),n=h(n,i,o,r,t[14],4259657740,23),r=h(r,n,i,o,t[1],2763975236,4),o=h(o,r,n,i,t[4],1272893353,11),i=h(i,o,r,n,t[7],4139469664,16),n=h(n,i,o,r,t[10],3200236656,23),r=h(r,n,i,o,t[13],681279174,4),o=h(o,r,n,i,t[0],3936430074,11),i=h(i,o,r,n,t[3],3572445317,16),n=h(n,i,o,r,t[6],76029189,23),r=h(r,n,i,o,t[9],3654602809,4),o=h(o,r,n,i,t[12],3873151461,11),i=h(i,o,r,n,t[15],530742520,16),r=l(r,n=h(n,i,o,r,t[2],3299628645,23),i,o,t[0],4096336452,6),o=l(o,r,n,i,t[7],1126891415,10),i=l(i,o,r,n,t[14],2878612391,15),n=l(n,i,o,r,t[5],4237533241,21),r=l(r,n,i,o,t[12],1700485571,6),o=l(o,r,n,i,t[3],2399980690,10),i=l(i,o,r,n,t[10],4293915773,15),n=l(n,i,o,r,t[1],2240044497,21),r=l(r,n,i,o,t[8],1873313359,6),o=l(o,r,n,i,t[15],4264355552,10),i=l(i,o,r,n,t[6],2734768916,15),n=l(n,i,o,r,t[13],1309151649,21),r=l(r,n,i,o,t[4],4149444226,6),o=l(o,r,n,i,t[11],3174756917,10),i=l(i,o,r,n,t[2],718787259,15),n=l(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=o.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},9756:(t,e,r)=>{\"use strict\";const{ErrorWithCause:n}=r(4525),{findCauseByReference:i,getErrorCause:o,messageWithCauses:s,stackWithCauses:a}=r(2197);t.exports={ErrorWithCause:n,findCauseByReference:i,getErrorCause:o,stackWithCauses:a,messageWithCauses:s}},4525:t=>{\"use strict\";class e extends Error{constructor(t,{cause:r}={}){super(t),this.name=e.name,r&&(this.cause=r),this.message=t}}t.exports={ErrorWithCause:e}},2197:t=>{\"use strict\";const e=t=>{if(t&&\"object\"==typeof t&&\"cause\"in t){if(\"function\"==typeof t.cause){const e=t.cause();return e instanceof Error?e:void 0}return t.cause instanceof Error?t.cause:void 0}},r=(t,n)=>{if(!(t instanceof Error))return\"\";const i=t.stack||\"\";if(n.has(t))return i+\"\\ncauses have become circular...\";const o=e(t);return o?(n.add(t),i+\"\\ncaused by: \"+r(o,n)):i},n=(t,r,i)=>{if(!(t instanceof Error))return\"\";const o=i?\"\":t.message||\"\";if(r.has(t))return o+\": ...\";const s=e(t);if(s){r.add(t);const e=\"cause\"in t&&\"function\"==typeof t.cause;return o+(e?\"\":\": \")+n(s,r,e)}return o};t.exports={findCauseByReference:(t,r)=>{if(!t||!r)return;if(!(t instanceof Error))return;if(!(r.prototype instanceof Error)&&r!==Error)return;const n=new Set;let i=t;for(;i&&!n.has(i);){if(n.add(i),i instanceof r)return i;i=e(i)}},getErrorCause:e,stackWithCauses:t=>r(t,new Set),messageWithCauses:t=>n(t,new Set)}},2644:(t,e,r)=>{\"use strict\";var n=65536,i=4294967295;var o=r(5636).Buffer,s=r.g.crypto||r.g.msCrypto;s&&s.getRandomValues?t.exports=function(t,e){if(t>i)throw new RangeError(\"requested too many random bytes\");var r=o.allocUnsafe(t);if(t>0)if(t>n)for(var a=0;a{\"use strict\";var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return\"string\"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?\"one of \".concat(e,\" \").concat(t.slice(0,r-1).join(\", \"),\", or \")+t[r-1]:2===r?\"one of \".concat(e,\" \").concat(t[0],\" or \").concat(t[1]):\"of \".concat(e,\" \").concat(t[0])}return\"of \".concat(e,\" \").concat(String(t))}r(\"ERR_INVALID_OPT_VALUE\",(function(t,e){return'The value \"'+e+'\" is invalid for option \"'+t+'\"'}),TypeError),r(\"ERR_INVALID_ARG_TYPE\",(function(t,e,r){var i,o,s,a;if(\"string\"==typeof e&&(o=\"not \",e.substr(!s||s<0?0:+s,o.length)===o)?(i=\"must not be\",e=e.replace(/^not /,\"\")):i=\"must be\",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t,\" argument\"))a=\"The \".concat(t,\" \").concat(i,\" \").concat(n(e,\"type\"));else{var c=function(t,e,r){return\"number\"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,\".\")?\"property\":\"argument\";a='The \"'.concat(t,'\" ').concat(c,\" \").concat(i,\" \").concat(n(e,\"type\"))}return a+=\". Received type \".concat(typeof r)}),TypeError),r(\"ERR_STREAM_PUSH_AFTER_EOF\",\"stream.push() after EOF\"),r(\"ERR_METHOD_NOT_IMPLEMENTED\",(function(t){return\"The \"+t+\" method is not implemented\"})),r(\"ERR_STREAM_PREMATURE_CLOSE\",\"Premature close\"),r(\"ERR_STREAM_DESTROYED\",(function(t){return\"Cannot call \"+t+\" after a stream was destroyed\"})),r(\"ERR_MULTIPLE_CALLBACK\",\"Callback called multiple times\"),r(\"ERR_STREAM_CANNOT_PIPE\",\"Cannot pipe, not readable\"),r(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\"),r(\"ERR_STREAM_NULL_VALUES\",\"May not write null values to stream\",TypeError),r(\"ERR_UNKNOWN_ENCODING\",(function(t){return\"Unknown encoding: \"+t}),TypeError),r(\"ERR_STREAM_UNSHIFT_AFTER_END_EVENT\",\"stream.unshift() after end event\"),t.exports.F=e},1265:(t,e,r)=>{\"use strict\";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=u;var i=r(8199),o=r(5291);r(5615)(u,i);for(var s=n(o.prototype),a=0;a{\"use strict\";t.exports=i;var n=r(9415);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(5615)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},8199:(t,e,r)=>{\"use strict\";var n;t.exports=A,A.ReadableState=S;r(46).EventEmitter;var i=function(t,e){return t.listeners(e).length},o=r(4856),s=r(1048).Buffer,a=(void 0!==r.g?r.g:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var c,u=r(3951);c=u&&u.debuglog?u.debuglog(\"stream\"):function(){};var f,h,l,p=r(82),d=r(6527),y=r(9952).getHighWaterMark,g=r(5699).F,b=g.ERR_INVALID_ARG_TYPE,w=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,v=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(5615)(A,o);var E=d.errorOrDestroy,_=[\"error\",\"close\",\"destroy\",\"pause\",\"resume\"];function S(t,e,i){n=n||r(1265),t=t||{},\"boolean\"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,\"readableHighWaterMark\",i),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(8888).I),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function A(t){if(n=n||r(1265),!(this instanceof A))return new A(t);var e=this instanceof n;this._readableState=new S(t,this,e),this.readable=!0,t&&(\"function\"==typeof t.read&&(this._read=t.read),\"function\"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function I(t,e,r,n,i){c(\"readableAddChunk\",e);var o,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(c(\"onEofChunk\"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?k(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,P(t)))}(t,u);else if(i||(o=function(t,e){var r;n=e,s.isBuffer(n)||n instanceof a||\"string\"==typeof e||void 0===e||t.objectMode||(r=new b(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],e));var n;return r}(u,e)),o)E(t,o);else if(u.objectMode||e&&e.length>0)if(\"string\"==typeof e||u.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),n)u.endEmitted?E(t,new v):T(t,u,e,!0);else if(u.ended)E(t,new w);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!r?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):R(t,u)):T(t,u,e,!1)}else n||(u.reading=!1,R(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function k(t){var e=t._readableState;c(\"emitReadable\",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c(\"emitReadable\",e.flowing),e.emittedReadable=!0,process.nextTick(P,t))}function P(t){var e=t._readableState;c(\"emitReadable_\",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit(\"readable\"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,U(t)}function R(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(B,t,e))}function B(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount(\"data\")>0&&t.resume()}function N(t){c(\"readable nexttick read 0\"),t.read(0)}function L(t,e){c(\"resume\",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit(\"resume\"),U(t),e.flowing&&!e.reading&&t.read(0)}function U(t){var e=t._readableState;for(c(\"flow\",e.flowing);e.flowing&&null!==t.read(););}function j(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(\"\"):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function M(t){var e=t._readableState;c(\"endReadable\",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(H,e,t))}function H(t,e){if(c(\"endReadableNT\",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit(\"end\"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function F(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return c(\"read: emitReadable\",e.length,e.ended),0===e.length&&e.ended?M(this):k(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,i=e.needReadable;return c(\"need readable\",i),(0===e.length||e.length-t0?j(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit(\"data\",n),n},A.prototype._read=function(t){E(this,new m(\"_read()\"))},A.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,c(\"pipe count=%d opts=%j\",n.pipesCount,e);var o=(!e||!1!==e.end)&&t!==process.stdout&&t!==process.stderr?a:y;function s(e,i){c(\"onunpipe\"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,c(\"cleanup\"),t.removeListener(\"close\",p),t.removeListener(\"finish\",d),t.removeListener(\"drain\",u),t.removeListener(\"error\",l),t.removeListener(\"unpipe\",s),r.removeListener(\"end\",a),r.removeListener(\"end\",y),r.removeListener(\"data\",h),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}function a(){c(\"onend\"),t.end()}n.endEmitted?process.nextTick(o):r.once(\"end\",o),t.on(\"unpipe\",s);var u=function(t){return function(){var e=t._readableState;c(\"pipeOnDrain\",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,\"data\")&&(e.flowing=!0,U(t))}}(r);t.on(\"drain\",u);var f=!1;function h(e){c(\"ondata\");var i=t.write(e);c(\"dest.write\",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==F(n.pipes,t))&&!f&&(c(\"false write response, pause\",n.awaitDrain),n.awaitDrain++),r.pause())}function l(e){c(\"onerror\",e),y(),t.removeListener(\"error\",l),0===i(t,\"error\")&&E(t,e)}function p(){t.removeListener(\"finish\",d),y()}function d(){c(\"onfinish\"),t.removeListener(\"close\",p),y()}function y(){c(\"unpipe\"),r.unpipe(t)}return r.on(\"data\",h),function(t,e,r){if(\"function\"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,\"error\",l),t.once(\"close\",p),t.once(\"finish\",d),t.emit(\"pipe\",r),n.flowing||(c(\"pipe resume\"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit(\"unpipe\",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==n.flowing&&this.resume()):\"readable\"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,c(\"on readable\",n.length,n.reading),n.length?k(this):n.reading||process.nextTick(N,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,e){var r=o.prototype.removeListener.call(this,t,e);return\"readable\"===t&&process.nextTick(C,this),r},A.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return\"readable\"!==t&&void 0!==t||process.nextTick(C,this),e},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(c(\"resume\"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(L,t,e))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return c(\"call pause flowing=%j\",this._readableState.flowing),!1!==this._readableState.flowing&&(c(\"pause\"),this._readableState.flowing=!1,this.emit(\"pause\")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on(\"end\",(function(){if(c(\"wrapped end\"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on(\"data\",(function(i){(c(\"wrapped data\"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&\"function\"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o<_.length;o++)t.on(_[o],this.emit.bind(this,_[o]));return this._read=function(e){c(\"wrapped _read\",e),n&&(n=!1,t.resume())},this},\"function\"==typeof Symbol&&(A.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(534)),h(this)}),Object.defineProperty(A.prototype,\"readableHighWaterMark\",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(A.prototype,\"readableBuffer\",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(A.prototype,\"readableFlowing\",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),A._fromList=j,Object.defineProperty(A.prototype,\"readableLength\",{enumerable:!1,get:function(){return this._readableState.length}}),\"function\"==typeof Symbol&&(A.from=function(t,e){return void 0===l&&(l=r(1260)),l(A,t,e)})},9415:(t,e,r)=>{\"use strict\";t.exports=f;var n=r(5699).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,c=r(1265);function u(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit(\"error\",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{\"use strict\";function n(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;t.entry=null;for(;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}var i;t.exports=A,A.WritableState=S;var o={deprecate:r(6732)},s=r(4856),a=r(1048).Buffer,c=(void 0!==r.g?r.g:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var u,f=r(6527),h=r(9952).getHighWaterMark,l=r(5699).F,p=l.ERR_INVALID_ARG_TYPE,d=l.ERR_METHOD_NOT_IMPLEMENTED,y=l.ERR_MULTIPLE_CALLBACK,g=l.ERR_STREAM_CANNOT_PIPE,b=l.ERR_STREAM_DESTROYED,w=l.ERR_STREAM_NULL_VALUES,m=l.ERR_STREAM_WRITE_AFTER_END,v=l.ERR_UNKNOWN_ENCODING,E=f.errorOrDestroy;function _(){}function S(t,e,o){i=i||r(1265),t=t||{},\"boolean\"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,\"writableHighWaterMark\",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(\"function\"!=typeof i)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(P,t,e),t._writableState.errorEmitted=!0,E(t,n)):(i(n),t._writableState.errorEmitted=!0,E(t,n),P(t,e))}(t,r,n,e,i);else{var o=O(r)||t.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||x(t,r),n?process.nextTick(T,t,r,o,i):T(t,r,o,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function A(t){var e=this instanceof(i=i||r(1265));if(!e&&!u.call(A,this))return new A(t);this._writableState=new S(t,this,e),this.writable=!0,t&&(\"function\"==typeof t.write&&(this._write=t.write),\"function\"==typeof t.writev&&(this._writev=t.writev),\"function\"==typeof t.destroy&&(this._destroy=t.destroy),\"function\"==typeof t.final&&(this._final=t.final)),s.call(this)}function I(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b(\"write\")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function T(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit(\"drain\"))}(t,e),e.pendingcb--,n(),P(t,e)}function x(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,o=new Array(i),s=e.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)o[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;o.allBuffers=c,I(t,e,!0,e.length,o,\"\",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new n(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(I(t,e,!1,e.objectMode?1:u.length,u,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function O(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function k(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit(\"prefinish\"),P(t,e)}))}function P(t,e){var r=O(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||(\"function\"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit(\"prefinish\")):(e.pendingcb++,e.finalCalled=!0,process.nextTick(k,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit(\"finish\"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(5615)(A,s),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,\"buffer\",{get:o.deprecate((function(){return this.getBuffer()}),\"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.\",\"DEP0003\")})}catch(t){}}(),\"function\"==typeof Symbol&&Symbol.hasInstance&&\"function\"==typeof Function.prototype[Symbol.hasInstance]?(u=Function.prototype[Symbol.hasInstance],Object.defineProperty(A,Symbol.hasInstance,{value:function(t){return!!u.call(this,t)||this===A&&(t&&t._writableState instanceof S)}})):u=function(t){return t instanceof this},A.prototype.pipe=function(){E(this,new g)},A.prototype.write=function(t,e,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=t,a.isBuffer(n)||n instanceof c);return s&&!a.isBuffer(t)&&(t=function(t){return a.from(t)}(t)),\"function\"==typeof e&&(r=e,e=null),s?e=\"buffer\":e||(e=i.defaultEncoding),\"function\"!=typeof r&&(r=_),i.ending?function(t,e){var r=new m;E(t,r),process.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var i;return null===r?i=new w:\"string\"==typeof r||e.objectMode||(i=new p(\"chunk\",[\"string\",\"Buffer\"],r)),!i||(E(t,i),process.nextTick(n,i),!1)}(this,i,t,r))&&(i.pendingcb++,o=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||\"string\"!=typeof e||(e=a.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i=\"buffer\",n=s)}var c=e.objectMode?1:n.length;e.length+=c;var u=e.length-1))throw new v(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(A.prototype,\"writableBuffer\",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(t,e,r){r(new d(\"_write()\"))},A.prototype._writev=null,A.prototype.end=function(t,e,r){var n=this._writableState;return\"function\"==typeof t?(r=t,t=null,e=null):\"function\"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,P(t,e),r&&(e.finished?process.nextTick(r):t.once(\"finish\",r));e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(A.prototype,\"writableLength\",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,\"destroyed\",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),A.prototype.destroy=f.destroy,A.prototype._undestroy=f.undestroy,A.prototype._destroy=function(t,e){e(t)}},534:(t,e,r)=>{\"use strict\";var n;function i(t,e,r){return(e=function(t){var e=function(t,e){if(\"object\"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||\"default\");if(\"object\"!=typeof n)return n;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===e?String:Number)(t)}(t,\"string\");return\"symbol\"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=r(4869),s=Symbol(\"lastResolve\"),a=Symbol(\"lastReject\"),c=Symbol(\"error\"),u=Symbol(\"ended\"),f=Symbol(\"lastPromise\"),h=Symbol(\"handlePromise\"),l=Symbol(\"stream\");function p(t,e){return{value:t,done:e}}function d(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(p(r,!1)))}}function y(t){process.nextTick(d,t)}var g=Object.getPrototypeOf((function(){})),b=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(p(void 0,!0));if(this[l].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[c]?r(t[c]):e(p(void 0,!0))}))}));var r,n=this[f];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[u]?r(p(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var i=this[l].read();if(null!==i)return Promise.resolve(p(i,!1));r=new Promise(this[h])}return this[f]=r,r}},Symbol.asyncIterator,(function(){return this})),i(n,\"return\",(function(){var t=this;return new Promise((function(e,r){t[l].destroy(null,(function(t){t?r(t):e(p(void 0,!0))}))}))})),n),g);t.exports=function(t){var e,r=Object.create(b,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,c,{value:null,writable:!0}),i(e,u,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var n=r[l].read();n?(r[f]=null,r[s]=null,r[a]=null,t(p(n,!1))):(r[s]=t,r[a]=e)},writable:!0}),e));return r[f]=null,o(t,(function(t){if(t&&\"ERR_STREAM_PREMATURE_CLOSE\"!==t.code){var e=r[a];return null!==e&&(r[f]=null,r[s]=null,r[a]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[f]=null,r[s]=null,r[a]=null,n(p(void 0,!0))),r[u]=!0})),t.on(\"readable\",y.bind(null,r)),r}},82:(t,e,r)=>{\"use strict\";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:\"unshift\",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:\"shift\",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:\"clear\",value:function(){this.head=this.tail=null,this.length=0}},{key:\"join\",value:function(t){if(0===this.length)return\"\";for(var e=this.head,r=\"\"+e.data;e=e.next;)r+=t+e.data;return r}},{key:\"concat\",value:function(t){if(0===this.length)return c.alloc(0);for(var e,r,n,i=c.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,c.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:\"consume\",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:\"_getBuffer\",value:function(t){var e=c.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return u(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&s(e.prototype,r),n&&s(e,n),Object.defineProperty(e,\"prototype\",{writable:!1}),t}()},6527:t=>{\"use strict\";function e(t,e){n(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit(\"close\")}function n(t,e){t.emit(\"error\",e)}t.exports={destroy:function(t,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?o._writableState?o._writableState.errorEmitted?process.nextTick(r,o):(o._writableState.errorEmitted=!0,process.nextTick(e,o,t)):process.nextTick(e,o,t):i?(process.nextTick(r,o),i(t)):process.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit(\"error\",e)}}},4869:(t,e,r)=>{\"use strict\";var n=r(5699).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if(\"function\"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i{t.exports=function(){throw new Error(\"Readable.from is not available in the browser\")}},6815:(t,e,r)=>{\"use strict\";var n;var i=r(5699).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function c(t){t()}function u(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){f||(f=t),t&&l.forEach(c),o||(l.forEach(c),h(f))}))}));return e.reduce(u)}},9952:(t,e,r)=>{\"use strict\";var n=r(5699).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:\"highWaterMark\",o);return Math.floor(o)}return t.objectMode?16:16384}}},4856:(t,e,r)=>{t.exports=r(46).EventEmitter},4156:(t,e,r)=>{(e=t.exports=r(8199)).Stream=e,e.Readable=e,e.Writable=r(5291),e.Duplex=r(1265),e.Transform=r(9415),e.PassThrough=r(4421),e.finished=r(4869),e.pipeline=r(6815)},5586:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer,i=r(5615),o=r(9467),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],c=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],l=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function y(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function w(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}i(p,o),p.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,v=0|this._a,E=0|this._b,_=0|this._c,S=0|this._d,A=0|this._e,I=0;I<80;I+=1){var T,x;I<16?(T=y(r,n,i,o,p,t[a[I]],h[0],u[I]),x=m(v,E,_,S,A,t[c[I]],l[0],f[I])):I<32?(T=g(r,n,i,o,p,t[a[I]],h[1],u[I]),x=w(v,E,_,S,A,t[c[I]],l[1],f[I])):I<48?(T=b(r,n,i,o,p,t[a[I]],h[2],u[I]),x=b(v,E,_,S,A,t[c[I]],l[2],f[I])):I<64?(T=w(r,n,i,o,p,t[a[I]],h[3],u[I]),x=g(v,E,_,S,A,t[c[I]],l[3],f[I])):(T=m(r,n,i,o,p,t[a[I]],h[4],u[I]),x=y(v,E,_,S,A,t[c[I]],l[4],f[I])),r=p,p=o,o=d(i,10),i=n,n=T,v=A,A=S,S=d(_,10),_=E,E=x}var O=this._b+i+S|0;this._b=this._c+o+A|0,this._c=this._d+p+v|0,this._d=this._e+r+E|0,this._e=this._a+n+_|0,this._a=O},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},5636:(t,e,r)=>{var n=r(1048),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if(\"number\"==typeof t)throw new TypeError(\"Argument must not be a number\");return i(t,e,r)},s.alloc=function(t,e,r){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");var n=i(t);return void 0!==e?\"string\"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return i(t)},s.allocUnsafeSlow=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return n.SlowBuffer(t)}},1565:(t,e,r)=>{const n=Symbol(\"SemVer ANY\");class i{static get ANY(){return n}constructor(t,e){if(e=o(e),t instanceof i){if(t.loose===!!e.loose)return t;t=t.value}t=t.trim().split(/\\s+/).join(\" \"),u(\"comparator\",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===n?this.value=\"\":this.value=this.operator+this.semver.version,u(\"comp\",this)}parse(t){const e=this.options.loose?s[a.COMPARATORLOOSE]:s[a.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==r[1]?r[1]:\"\",\"=\"===this.operator&&(this.operator=\"\"),r[2]?this.semver=new f(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(t){if(u(\"Comparator.test\",t,this.options.loose),this.semver===n||t===n)return!0;if(\"string\"==typeof t)try{t=new f(t,this.options)}catch(t){return!1}return c(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof i))throw new TypeError(\"a Comparator is required\");return\"\"===this.operator?\"\"===this.value||new h(t.value,e).test(this.value):\"\"===t.operator?\"\"===t.value||new h(this.value,e).test(t.semver):(!(e=o(e)).includePrerelease||\"<0.0.0-0\"!==this.value&&\"<0.0.0-0\"!==t.value)&&(!(!e.includePrerelease&&(this.value.startsWith(\"<0.0.0\")||t.value.startsWith(\"<0.0.0\")))&&(!(!this.operator.startsWith(\">\")||!t.operator.startsWith(\">\"))||(!(!this.operator.startsWith(\"<\")||!t.operator.startsWith(\"<\"))||(!(this.semver.version!==t.semver.version||!this.operator.includes(\"=\")||!t.operator.includes(\"=\"))||(!!(c(this.semver,\"<\",t.semver,e)&&this.operator.startsWith(\">\")&&t.operator.startsWith(\"<\"))||!!(c(this.semver,\">\",t.semver,e)&&this.operator.startsWith(\"<\")&&t.operator.startsWith(\">\")))))))}}t.exports=i;const o=r(3990),{safeRe:s,t:a}=r(2841),c=r(4004),u=r(1361),f=r(4517),h=r(7476)},7476:(t,e,r)=>{class n{constructor(t,e){if(e=o(e),t instanceof n)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new n(t.raw,e);if(t instanceof s)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t.trim().split(/\\s+/).join(\" \"),this.set=this.raw.split(\"||\").map((t=>this.parseRange(t.trim()))).filter((t=>t.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const t=this.set[0];if(this.set=this.set.filter((t=>!g(t[0]))),0===this.set.length)this.set=[t];else if(this.set.length>1)for(const t of this.set)if(1===t.length&&b(t[0])){this.set=[t];break}}this.format()}format(){return this.range=this.set.map((t=>t.join(\" \").trim())).join(\"||\").trim(),this.range}toString(){return this.range}parseRange(t){const e=((this.options.includePrerelease&&d)|(this.options.loose&&y))+\":\"+t,r=i.get(e);if(r)return r;const n=this.options.loose,o=n?u[f.HYPHENRANGELOOSE]:u[f.HYPHENRANGE];t=t.replace(o,k(this.options.includePrerelease)),a(\"hyphen replace\",t),t=t.replace(u[f.COMPARATORTRIM],h),a(\"comparator trim\",t),t=t.replace(u[f.TILDETRIM],l),a(\"tilde trim\",t),t=t.replace(u[f.CARETTRIM],p),a(\"caret trim\",t);let c=t.split(\" \").map((t=>m(t,this.options))).join(\" \").split(/\\s+/).map((t=>O(t,this.options)));n&&(c=c.filter((t=>(a(\"loose invalid filter\",t,this.options),!!t.match(u[f.COMPARATORLOOSE]))))),a(\"range list\",c);const b=new Map,w=c.map((t=>new s(t,this.options)));for(const t of w){if(g(t))return[t];b.set(t.value,t)}b.size>1&&b.has(\"\")&&b.delete(\"\");const v=[...b.values()];return i.set(e,v),v}intersects(t,e){if(!(t instanceof n))throw new TypeError(\"a Range is required\");return this.set.some((r=>w(r,e)&&t.set.some((t=>w(t,e)&&r.every((r=>t.every((t=>r.intersects(t,e)))))))))}test(t){if(!t)return!1;if(\"string\"==typeof t)try{t=new c(t,this.options)}catch(t){return!1}for(let e=0;e\"<0.0.0-0\"===t.value,b=t=>\"\"===t.value,w=(t,e)=>{let r=!0;const n=t.slice();let i=n.pop();for(;r&&n.length;)r=n.every((t=>i.intersects(t,e))),i=n.pop();return r},m=(t,e)=>(a(\"comp\",t,e),t=S(t,e),a(\"caret\",t),t=E(t,e),a(\"tildes\",t),t=I(t,e),a(\"xrange\",t),t=x(t,e),a(\"stars\",t),t),v=t=>!t||\"x\"===t.toLowerCase()||\"*\"===t,E=(t,e)=>t.trim().split(/\\s+/).map((t=>_(t,e))).join(\" \"),_=(t,e)=>{const r=e.loose?u[f.TILDELOOSE]:u[f.TILDE];return t.replace(r,((e,r,n,i,o)=>{let s;return a(\"tilde\",t,e,r,n,i,o),v(r)?s=\"\":v(n)?s=`>=${r}.0.0 <${+r+1}.0.0-0`:v(i)?s=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:o?(a(\"replaceTilde pr\",o),s=`>=${r}.${n}.${i}-${o} <${r}.${+n+1}.0-0`):s=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,a(\"tilde return\",s),s}))},S=(t,e)=>t.trim().split(/\\s+/).map((t=>A(t,e))).join(\" \"),A=(t,e)=>{a(\"caret\",t,e);const r=e.loose?u[f.CARETLOOSE]:u[f.CARET],n=e.includePrerelease?\"-0\":\"\";return t.replace(r,((e,r,i,o,s)=>{let c;return a(\"caret\",t,e,r,i,o,s),v(r)?c=\"\":v(i)?c=`>=${r}.0.0${n} <${+r+1}.0.0-0`:v(o)?c=\"0\"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:s?(a(\"replaceCaret pr\",s),c=\"0\"===r?\"0\"===i?`>=${r}.${i}.${o}-${s} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}-${s} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o}-${s} <${+r+1}.0.0-0`):(a(\"no pr\"),c=\"0\"===r?\"0\"===i?`>=${r}.${i}.${o}${n} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o} <${+r+1}.0.0-0`),a(\"caret return\",c),c}))},I=(t,e)=>(a(\"replaceXRanges\",t,e),t.split(/\\s+/).map((t=>T(t,e))).join(\" \")),T=(t,e)=>{t=t.trim();const r=e.loose?u[f.XRANGELOOSE]:u[f.XRANGE];return t.replace(r,((r,n,i,o,s,c)=>{a(\"xRange\",t,r,n,i,o,s,c);const u=v(i),f=u||v(o),h=f||v(s),l=h;return\"=\"===n&&l&&(n=\"\"),c=e.includePrerelease?\"-0\":\"\",u?r=\">\"===n||\"<\"===n?\"<0.0.0-0\":\"*\":n&&l?(f&&(o=0),s=0,\">\"===n?(n=\">=\",f?(i=+i+1,o=0,s=0):(o=+o+1,s=0)):\"<=\"===n&&(n=\"<\",f?i=+i+1:o=+o+1),\"<\"===n&&(c=\"-0\"),r=`${n+i}.${o}.${s}${c}`):f?r=`>=${i}.0.0${c} <${+i+1}.0.0-0`:h&&(r=`>=${i}.${o}.0${c} <${i}.${+o+1}.0-0`),a(\"xRange return\",r),r}))},x=(t,e)=>(a(\"replaceStars\",t,e),t.trim().replace(u[f.STAR],\"\")),O=(t,e)=>(a(\"replaceGTE0\",t,e),t.trim().replace(u[e.includePrerelease?f.GTE0PRE:f.GTE0],\"\")),k=t=>(e,r,n,i,o,s,a,c,u,f,h,l,p)=>`${r=v(n)?\"\":v(i)?`>=${n}.0.0${t?\"-0\":\"\"}`:v(o)?`>=${n}.${i}.0${t?\"-0\":\"\"}`:s?`>=${r}`:`>=${r}${t?\"-0\":\"\"}`} ${c=v(u)?\"\":v(f)?`<${+u+1}.0.0-0`:v(h)?`<${u}.${+f+1}.0-0`:l?`<=${u}.${f}.${h}-${l}`:t?`<${u}.${f}.${+h+1}-0`:`<=${c}`}`.trim(),P=(t,e,r)=>{for(let r=0;r0){const n=t[r].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}},4517:(t,e,r)=>{const n=r(1361),{MAX_LENGTH:i,MAX_SAFE_INTEGER:o}=r(9543),{safeRe:s,t:a}=r(2841),c=r(3990),{compareIdentifiers:u}=r(3806);class f{constructor(t,e){if(e=c(e),t instanceof f){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(\"string\"!=typeof t)throw new TypeError(`Invalid version. Must be a string. Got type \"${typeof t}\".`);if(t.length>i)throw new TypeError(`version is longer than ${i} characters`);n(\"SemVer\",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;const r=t.trim().match(e.loose?s[a.LOOSE]:s[a.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>o||this.major<0)throw new TypeError(\"Invalid major version\");if(this.minor>o||this.minor<0)throw new TypeError(\"Invalid minor version\");if(this.patch>o||this.patch<0)throw new TypeError(\"Invalid patch version\");r[4]?this.prerelease=r[4].split(\".\").map((t=>{if(/^[0-9]+$/.test(t)){const e=+t;if(e>=0&&e=0;)\"number\"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(e===this.prerelease.join(\".\")&&!1===r)throw new Error(\"invalid increment argument: identifier already exists\");this.prerelease.push(t)}}if(e){let n=[e,t];!1===r&&(n=[e]),0===u(this.prerelease[0],e)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(\".\")}`),this}}t.exports=f},2281:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t.trim().replace(/^[=v]+/,\"\"),e);return r?r.version:null}},4004:(t,e,r)=>{const n=r(8848),i=r(8220),o=r(9761),s=r(2386),a=r(1262),c=r(9639);t.exports=(t,e,r,u)=>{switch(e){case\"===\":return\"object\"==typeof t&&(t=t.version),\"object\"==typeof r&&(r=r.version),t===r;case\"!==\":return\"object\"==typeof t&&(t=t.version),\"object\"==typeof r&&(r=r.version),t!==r;case\"\":case\"=\":case\"==\":return n(t,r,u);case\"!=\":return i(t,r,u);case\">\":return o(t,r,u);case\">=\":return s(t,r,u);case\"<\":return a(t,r,u);case\"<=\":return c(t,r,u);default:throw new TypeError(`Invalid operator: ${e}`)}}},6783:(t,e,r)=>{const n=r(4517),i=r(3955),{safeRe:o,t:s}=r(2841);t.exports=(t,e)=>{if(t instanceof n)return t;if(\"number\"==typeof t&&(t=String(t)),\"string\"!=typeof t)return null;let r=null;if((e=e||{}).rtl){const n=e.includePrerelease?o[s.COERCERTLFULL]:o[s.COERCERTL];let i;for(;(i=n.exec(t))&&(!r||r.index+r[0].length!==t.length);)r&&i.index+i[0].length===r.index+r[0].length||(r=i),n.lastIndex=i.index+i[1].length+i[2].length;n.lastIndex=-1}else r=t.match(e.includePrerelease?o[s.COERCEFULL]:o[s.COERCE]);if(null===r)return null;const a=r[2],c=r[3]||\"0\",u=r[4]||\"0\",f=e.includePrerelease&&r[5]?`-${r[5]}`:\"\",h=e.includePrerelease&&r[6]?`+${r[6]}`:\"\";return i(`${a}.${c}.${u}${f}${h}`,e)}},6106:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r)=>{const i=new n(t,r),o=new n(e,r);return i.compare(o)||i.compareBuild(o)}},2132:(t,e,r)=>{const n=r(7851);t.exports=(t,e)=>n(t,e,!0)},7851:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r)=>new n(t,r).compare(new n(e,r))},3269:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,null,!0),i=n(e,null,!0),o=r.compare(i);if(0===o)return null;const s=o>0,a=s?r:i,c=s?i:r,u=!!a.prerelease.length;if(!!c.prerelease.length&&!u)return c.patch||c.minor?a.patch?\"patch\":a.minor?\"minor\":\"major\":\"major\";const f=u?\"pre\":\"\";return r.major!==i.major?f+\"major\":r.minor!==i.minor?f+\"minor\":r.patch!==i.patch?f+\"patch\":\"prerelease\"}},8848:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>0===n(t,e,r)},9761:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)>0},2386:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)>=0},8868:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r,i,o)=>{\"string\"==typeof r&&(o=i,i=r,r=void 0);try{return new n(t instanceof n?t.version:t,r).inc(e,i,o).version}catch(t){return null}}},1262:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)<0},9639:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)<=0},6381:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).major},1353:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).minor},8220:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>0!==n(t,e,r)},3955:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r=!1)=>{if(t instanceof n)return t;try{return new n(t,e)}catch(t){if(!r)return null;throw t}}},6082:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).patch},9428:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,e);return r&&r.prerelease.length?r.prerelease:null}},7555:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(e,t,r)},3810:(t,e,r)=>{const n=r(6106);t.exports=(t,e)=>t.sort(((t,r)=>n(r,t,e)))},7229:(t,e,r)=>{const n=r(7476);t.exports=(t,e,r)=>{try{e=new n(e,r)}catch(t){return!1}return e.test(t)}},4042:(t,e,r)=>{const n=r(6106);t.exports=(t,e)=>t.sort(((t,r)=>n(t,r,e)))},8474:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,e);return r?r.version:null}},2722:(t,e,r)=>{const n=r(2841),i=r(9543),o=r(4517),s=r(3806),a=r(3955),c=r(8474),u=r(2281),f=r(8868),h=r(3269),l=r(6381),p=r(1353),d=r(6082),y=r(9428),g=r(7851),b=r(7555),w=r(2132),m=r(6106),v=r(4042),E=r(3810),_=r(9761),S=r(1262),A=r(8848),I=r(8220),T=r(2386),x=r(9639),O=r(4004),k=r(6783),P=r(1565),R=r(7476),B=r(7229),C=r(6364),N=r(5039),L=r(5357),U=r(1280),j=r(7403),M=r(8854),H=r(7226),F=r(7183),D=r(8623),$=r(6486),K=r(583);t.exports={parse:a,valid:c,clean:u,inc:f,diff:h,major:l,minor:p,patch:d,prerelease:y,compare:g,rcompare:b,compareLoose:w,compareBuild:m,sort:v,rsort:E,gt:_,lt:S,eq:A,neq:I,gte:T,lte:x,cmp:O,coerce:k,Comparator:P,Range:R,satisfies:B,toComparators:C,maxSatisfying:N,minSatisfying:L,minVersion:U,validRange:j,outside:M,gtr:H,ltr:F,intersects:D,simplifyRange:$,subset:K,SemVer:o,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers}},9543:t=>{const e=Number.MAX_SAFE_INTEGER||9007199254740991;t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:[\"major\",\"premajor\",\"minor\",\"preminor\",\"patch\",\"prepatch\",\"prerelease\"],SEMVER_SPEC_VERSION:\"2.0.0\",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},1361:t=>{const e=\"object\"==typeof process&&process.env&&/\\bsemver\\b/i.test(\"false\")?(...t)=>console.error(\"SEMVER\",...t):()=>{};t.exports=e},3806:t=>{const e=/^[0-9]+$/,r=(t,r)=>{const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:tr(e,t)}},3990:t=>{const e=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=t=>t?\"object\"!=typeof t?e:t:r},2841:(t,e,r)=>{const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:o}=r(9543),s=r(1361),a=(e=t.exports={}).re=[],c=e.safeRe=[],u=e.src=[],f=e.t={};let h=0;const l=\"[a-zA-Z0-9-]\",p=[[\"\\\\s\",1],[\"\\\\d\",o],[l,i]],d=(t,e,r)=>{const n=(t=>{for(const[e,r]of p)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t})(e),i=h++;s(t,i,e),f[t]=i,u[i]=e,a[i]=new RegExp(e,r?\"g\":void 0),c[i]=new RegExp(n,r?\"g\":void 0)};d(\"NUMERICIDENTIFIER\",\"0|[1-9]\\\\d*\"),d(\"NUMERICIDENTIFIERLOOSE\",\"\\\\d+\"),d(\"NONNUMERICIDENTIFIER\",`\\\\d*[a-zA-Z-]${l}*`),d(\"MAINVERSION\",`(${u[f.NUMERICIDENTIFIER]})\\\\.(${u[f.NUMERICIDENTIFIER]})\\\\.(${u[f.NUMERICIDENTIFIER]})`),d(\"MAINVERSIONLOOSE\",`(${u[f.NUMERICIDENTIFIERLOOSE]})\\\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),d(\"PRERELEASEIDENTIFIER\",`(?:${u[f.NUMERICIDENTIFIER]}|${u[f.NONNUMERICIDENTIFIER]})`),d(\"PRERELEASEIDENTIFIERLOOSE\",`(?:${u[f.NUMERICIDENTIFIERLOOSE]}|${u[f.NONNUMERICIDENTIFIER]})`),d(\"PRERELEASE\",`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\\\.${u[f.PRERELEASEIDENTIFIER]})*))`),d(\"PRERELEASELOOSE\",`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),d(\"BUILDIDENTIFIER\",`${l}+`),d(\"BUILD\",`(?:\\\\+(${u[f.BUILDIDENTIFIER]}(?:\\\\.${u[f.BUILDIDENTIFIER]})*))`),d(\"FULLPLAIN\",`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),d(\"FULL\",`^${u[f.FULLPLAIN]}$`),d(\"LOOSEPLAIN\",`[v=\\\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),d(\"LOOSE\",`^${u[f.LOOSEPLAIN]}$`),d(\"GTLT\",\"((?:<|>)?=?)\"),d(\"XRANGEIDENTIFIERLOOSE\",`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\\\*`),d(\"XRANGEIDENTIFIER\",`${u[f.NUMERICIDENTIFIER]}|x|X|\\\\*`),d(\"XRANGEPLAIN\",`[v=\\\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\\\.(${u[f.XRANGEIDENTIFIER]})(?:\\\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),d(\"XRANGEPLAINLOOSE\",`[v=\\\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),d(\"XRANGE\",`^${u[f.GTLT]}\\\\s*${u[f.XRANGEPLAIN]}$`),d(\"XRANGELOOSE\",`^${u[f.GTLT]}\\\\s*${u[f.XRANGEPLAINLOOSE]}$`),d(\"COERCEPLAIN\",`(^|[^\\\\d])(\\\\d{1,${n}})(?:\\\\.(\\\\d{1,${n}}))?(?:\\\\.(\\\\d{1,${n}}))?`),d(\"COERCE\",`${u[f.COERCEPLAIN]}(?:$|[^\\\\d])`),d(\"COERCEFULL\",u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?`+`(?:${u[f.BUILD]})?(?:$|[^\\\\d])`),d(\"COERCERTL\",u[f.COERCE],!0),d(\"COERCERTLFULL\",u[f.COERCEFULL],!0),d(\"LONETILDE\",\"(?:~>?)\"),d(\"TILDETRIM\",`(\\\\s*)${u[f.LONETILDE]}\\\\s+`,!0),e.tildeTrimReplace=\"$1~\",d(\"TILDE\",`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),d(\"TILDELOOSE\",`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),d(\"LONECARET\",\"(?:\\\\^)\"),d(\"CARETTRIM\",`(\\\\s*)${u[f.LONECARET]}\\\\s+`,!0),e.caretTrimReplace=\"$1^\",d(\"CARET\",`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),d(\"CARETLOOSE\",`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),d(\"COMPARATORLOOSE\",`^${u[f.GTLT]}\\\\s*(${u[f.LOOSEPLAIN]})$|^$`),d(\"COMPARATOR\",`^${u[f.GTLT]}\\\\s*(${u[f.FULLPLAIN]})$|^$`),d(\"COMPARATORTRIM\",`(\\\\s*)${u[f.GTLT]}\\\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=\"$1$2$3\",d(\"HYPHENRANGE\",`^\\\\s*(${u[f.XRANGEPLAIN]})\\\\s+-\\\\s+(${u[f.XRANGEPLAIN]})\\\\s*$`),d(\"HYPHENRANGELOOSE\",`^\\\\s*(${u[f.XRANGEPLAINLOOSE]})\\\\s+-\\\\s+(${u[f.XRANGEPLAINLOOSE]})\\\\s*$`),d(\"STAR\",\"(<|>)?=?\\\\s*\\\\*\"),d(\"GTE0\",\"^\\\\s*>=\\\\s*0\\\\.0\\\\.0\\\\s*$\"),d(\"GTE0PRE\",\"^\\\\s*>=\\\\s*0\\\\.0\\\\.0-0\\\\s*$\")},7226:(t,e,r)=>{const n=r(8854);t.exports=(t,e,r)=>n(t,e,\">\",r)},8623:(t,e,r)=>{const n=r(7476);t.exports=(t,e,r)=>(t=new n(t,r),e=new n(e,r),t.intersects(e,r))},7183:(t,e,r)=>{const n=r(8854);t.exports=(t,e,r)=>n(t,e,\"<\",r)},5039:(t,e,r)=>{const n=r(4517),i=r(7476);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new i(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&-1!==s.compare(t)||(o=t,s=new n(o,r)))})),o}},5357:(t,e,r)=>{const n=r(4517),i=r(7476);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new i(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&1!==s.compare(t)||(o=t,s=new n(o,r)))})),o}},1280:(t,e,r)=>{const n=r(4517),i=r(7476),o=r(9761);t.exports=(t,e)=>{t=new i(t,e);let r=new n(\"0.0.0\");if(t.test(r))return r;if(r=new n(\"0.0.0-0\"),t.test(r))return r;r=null;for(let e=0;e{const e=new n(t.semver.version);switch(t.operator){case\">\":0===e.prerelease.length?e.patch++:e.prerelease.push(0),e.raw=e.format();case\"\":case\">=\":s&&!o(e,s)||(s=e);break;case\"<\":case\"<=\":break;default:throw new Error(`Unexpected operation: ${t.operator}`)}})),!s||r&&!o(r,s)||(r=s)}return r&&t.test(r)?r:null}},8854:(t,e,r)=>{const n=r(4517),i=r(1565),{ANY:o}=i,s=r(7476),a=r(7229),c=r(9761),u=r(1262),f=r(9639),h=r(2386);t.exports=(t,e,r,l)=>{let p,d,y,g,b;switch(t=new n(t,l),e=new s(e,l),r){case\">\":p=c,d=f,y=u,g=\">\",b=\">=\";break;case\"<\":p=u,d=h,y=c,g=\"<\",b=\"<=\";break;default:throw new TypeError('Must provide a hilo val of \"<\" or \">\"')}if(a(t,e,l))return!1;for(let r=0;r{t.semver===o&&(t=new i(\">=0.0.0\")),s=s||t,a=a||t,p(t.semver,s.semver,l)?s=t:y(t.semver,a.semver,l)&&(a=t)})),s.operator===g||s.operator===b)return!1;if((!a.operator||a.operator===g)&&d(t,a.semver))return!1;if(a.operator===b&&y(t,a.semver))return!1}return!0}},6486:(t,e,r)=>{const n=r(7229),i=r(7851);t.exports=(t,e,r)=>{const o=[];let s=null,a=null;const c=t.sort(((t,e)=>i(t,e,r)));for(const t of c){n(t,e,r)?(a=t,s||(s=t)):(a&&o.push([s,a]),a=null,s=null)}s&&o.push([s,null]);const u=[];for(const[t,e]of o)t===e?u.push(t):e||t!==c[0]?e?t===c[0]?u.push(`<=${e}`):u.push(`${t} - ${e}`):u.push(`>=${t}`):u.push(\"*\");const f=u.join(\" || \"),h=\"string\"==typeof e.raw?e.raw:String(e);return f.length{const n=r(7476),i=r(1565),{ANY:o}=i,s=r(7229),a=r(7851),c=[new i(\">=0.0.0-0\")],u=[new i(\">=0.0.0\")],f=(t,e,r)=>{if(t===e)return!0;if(1===t.length&&t[0].semver===o){if(1===e.length&&e[0].semver===o)return!0;t=r.includePrerelease?c:u}if(1===e.length&&e[0].semver===o){if(r.includePrerelease)return!0;e=u}const n=new Set;let i,f,p,d,y,g,b;for(const e of t)\">\"===e.operator||\">=\"===e.operator?i=h(i,e,r):\"<\"===e.operator||\"<=\"===e.operator?f=l(f,e,r):n.add(e.semver);if(n.size>1)return null;if(i&&f){if(p=a(i.semver,f.semver,r),p>0)return null;if(0===p&&(\">=\"!==i.operator||\"<=\"!==f.operator))return null}for(const t of n){if(i&&!s(t,String(i),r))return null;if(f&&!s(t,String(f),r))return null;for(const n of e)if(!s(t,String(n),r))return!1;return!0}let w=!(!f||r.includePrerelease||!f.semver.prerelease.length)&&f.semver,m=!(!i||r.includePrerelease||!i.semver.prerelease.length)&&i.semver;w&&1===w.prerelease.length&&\"<\"===f.operator&&0===w.prerelease[0]&&(w=!1);for(const t of e){if(b=b||\">\"===t.operator||\">=\"===t.operator,g=g||\"<\"===t.operator||\"<=\"===t.operator,i)if(m&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===m.major&&t.semver.minor===m.minor&&t.semver.patch===m.patch&&(m=!1),\">\"===t.operator||\">=\"===t.operator){if(d=h(i,t,r),d===t&&d!==i)return!1}else if(\">=\"===i.operator&&!s(i.semver,String(t),r))return!1;if(f)if(w&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===w.major&&t.semver.minor===w.minor&&t.semver.patch===w.patch&&(w=!1),\"<\"===t.operator||\"<=\"===t.operator){if(y=l(f,t,r),y===t&&y!==f)return!1}else if(\"<=\"===f.operator&&!s(f.semver,String(t),r))return!1;if(!t.operator&&(f||i)&&0!==p)return!1}return!(i&&g&&!f&&0!==p)&&(!(f&&b&&!i&&0!==p)&&(!m&&!w))},h=(t,e,r)=>{if(!t)return e;const n=a(t.semver,e.semver,r);return n>0?t:n<0||\">\"===e.operator&&\">=\"===t.operator?e:t},l=(t,e,r)=>{if(!t)return e;const n=a(t.semver,e.semver,r);return n<0?t:n>0||\"<\"===e.operator&&\"<=\"===t.operator?e:t};t.exports=(t,e,r={})=>{if(t===e)return!0;t=new n(t,r),e=new n(e,r);let i=!1;t:for(const n of t.set){for(const t of e.set){const e=f(n,t,r);if(i=i||null!==e,e)continue t}if(i)return!1}return!0}},6364:(t,e,r)=>{const n=r(7476);t.exports=(t,e)=>new n(t,e).set.map((t=>t.map((t=>t.value)).join(\" \").trim().split(\" \")))},7403:(t,e,r)=>{const n=r(7476);t.exports=(t,e)=>{try{return new n(t,e).range||\"*\"}catch(t){return null}}},1229:(t,e,r)=>{var n=r(5636).Buffer;function i(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){\"string\"==typeof t&&(e=e||\"utf8\",t=n.from(t,e));for(var r=this._block,i=this._blockSize,o=t.length,s=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error(\"_update must be implemented by subclass\")},t.exports=i},3229:(t,e,r)=>{var n=t.exports=function(t){t=t.toLowerCase();var e=n[t];if(!e)throw new Error(t+\" is not supported (we accept pull requests)\");return new e};n.sha=r(3675),n.sha1=r(8980),n.sha224=r(947),n.sha256=r(2826),n.sha384=r(9922),n.sha512=r(6080)},3675:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var p=~~(l/20),d=0|((e=n)<<5|e>>>27)+f(p,i,o,a)+c+r[l]+s[p];c=a,a=o,o=u(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=c},8980:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function f(t){return t<<30|t>>>2}function h(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var p=0;p<80;++p){var d=~~(p/20),y=u(n)+h(d,i,o,a)+c+r[p]+s[d]|0;c=a,a=o,o=f(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=c},947:(t,e,r)=>{var n=r(5615),i=r(2826),o=r(1229),s=r(5636).Buffer,a=new Array(64);function c(){this.init(),this._w=a,o.call(this,64,56)}n(c,i),c.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},c.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=c},2826:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=new Array(64);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function h(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function l(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(c,i),c.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,d=0|this._f,y=0|this._g,g=0|this._h,b=0;b<16;++b)r[b]=t.readInt32BE(4*b);for(;b<64;++b)r[b]=0|(((e=r[b-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[b-7]+p(r[b-15])+r[b-16];for(var w=0;w<64;++w){var m=g+l(c)+u(c,d,y)+s[w]+r[w]|0,v=h(n)+f(n,i,o)|0;g=y,y=d,d=c,c=a+m|0,a=o,o=i,i=n,n=m+v|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0,this._f=d+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},c.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=c},9922:(t,e,r)=>{var n=r(5615),i=r(6080),o=r(1229),s=r(5636).Buffer,a=new Array(160);function c(){this.init(),this._w=a,o.call(this,128,112)}n(c,i),c.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},c.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=c},6080:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function c(){this.init(),this._w=a,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function h(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function l(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0>>0?1:0}n(c,i),c.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},c.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,c=0|this._fh,w=0|this._gh,m=0|this._hh,v=0|this._al,E=0|this._bl,_=0|this._cl,S=0|this._dl,A=0|this._el,I=0|this._fl,T=0|this._gl,x=0|this._hl,O=0;O<32;O+=2)e[O]=t.readInt32BE(4*O),e[O+1]=t.readInt32BE(4*O+4);for(;O<160;O+=2){var k=e[O-30],P=e[O-30+1],R=p(k,P),B=d(P,k),C=y(k=e[O-4],P=e[O-4+1]),N=g(P,k),L=e[O-14],U=e[O-14+1],j=e[O-32],M=e[O-32+1],H=B+U|0,F=R+L+b(H,B)|0;F=(F=F+C+b(H=H+N|0,N)|0)+j+b(H=H+M|0,M)|0,e[O]=F,e[O+1]=H}for(var D=0;D<160;D+=2){F=e[D],H=e[D+1];var $=f(r,n,i),K=f(v,E,_),V=h(r,v),G=h(v,r),q=l(a,A),W=l(A,a),X=s[D],z=s[D+1],J=u(a,c,w),Y=u(A,I,T),Z=x+W|0,Q=m+q+b(Z,x)|0;Q=(Q=(Q=Q+J+b(Z=Z+Y|0,Y)|0)+X+b(Z=Z+z|0,z)|0)+F+b(Z=Z+H|0,H)|0;var tt=G+K|0,et=V+$+b(tt,G)|0;m=w,x=T,w=c,T=I,c=a,I=A,a=o+Q+b(A=S+Z|0,S)|0,o=i,S=_,i=n,_=E,n=r,E=v,r=Q+et+b(v=Z+tt|0,Z)|0}this._al=this._al+v|0,this._bl=this._bl+E|0,this._cl=this._cl+_|0,this._dl=this._dl+S|0,this._el=this._el+A|0,this._fl=this._fl+I|0,this._gl=this._gl+T|0,this._hl=this._hl+x|0,this._ah=this._ah+r+b(this._al,v)|0,this._bh=this._bh+n+b(this._bl,E)|0,this._ch=this._ch+i+b(this._cl,_)|0,this._dh=this._dh+o+b(this._dl,S)|0,this._eh=this._eh+a+b(this._el,A)|0,this._fh=this._fh+c+b(this._fl,I)|0,this._gh=this._gh+w+b(this._gl,T)|0,this._hh=this._hh+m+b(this._hl,x)|0},c.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=c},1983:(t,e,r)=>{t.exports=i;var n=r(46).EventEmitter;function i(){n.call(this)}r(5615)(i,n),i.Readable=r(8199),i.Writable=r(5291),i.Duplex=r(1265),i.Transform=r(9415),i.PassThrough=r(4421),i.finished=r(4869),i.pipeline=r(6815),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on(\"data\",i),t.on(\"drain\",o),t._isStdio||e&&!1===e.end||(r.on(\"end\",a),r.on(\"close\",c));var s=!1;function a(){s||(s=!0,t.end())}function c(){s||(s=!0,\"function\"==typeof t.destroy&&t.destroy())}function u(t){if(f(),0===n.listenerCount(this,\"error\"))throw t}function f(){r.removeListener(\"data\",i),t.removeListener(\"drain\",o),r.removeListener(\"end\",a),r.removeListener(\"close\",c),r.removeListener(\"error\",u),t.removeListener(\"error\",u),r.removeListener(\"end\",f),r.removeListener(\"close\",f),t.removeListener(\"close\",f)}return r.on(\"error\",u),t.on(\"error\",u),r.on(\"end\",f),r.on(\"close\",f),t.on(\"close\",f),t.emit(\"pipe\",r),t}},8888:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=n.isEncoding||function(t){switch((t=\"\"+t)&&t.toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":case\"raw\":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return\"utf8\";for(var e;;)switch(t){case\"utf8\":case\"utf-8\":return\"utf8\";case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return\"utf16le\";case\"latin1\":case\"binary\":return\"latin1\";case\"base64\":case\"ascii\":case\"hex\":return t;default:if(e)return;t=(\"\"+t).toLowerCase(),e=!0}}(t);if(\"string\"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error(\"Unknown encoding: \"+t);return e||t}(t),this.encoding){case\"utf16le\":this.text=c,this.end=u,e=4;break;case\"utf8\":this.fillLast=a,e=4;break;case\"base64\":this.text=f,this.end=h,e=3;break;default:return this.write=l,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,\"�\";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,\"�\";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,\"�\"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function c(t,e){if((t.length-e)%2==0){var r=t.toString(\"utf16le\",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString(\"utf16le\",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):\"\";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString(\"utf16le\",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString(\"base64\",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString(\"base64\",e,t.length-r))}function h(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+this.lastChar.toString(\"base64\",0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):\"\"}e.I=o,o.prototype.write=function(t){if(0===t.length)return\"\";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return\"\";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString(\"utf8\",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString(\"utf8\",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},8262:t=>{const e=/^[-+]?0x[a-fA-F0-9]+$/,r=/^([\\-\\+])?(0*)(\\.[0-9]+([eE]\\-?[0-9]+)?|[0-9]+(\\.[0-9]+([eE]\\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const n={hex:!0,leadingZeros:!0,decimalPoint:\".\",eNotation:!0};t.exports=function(t,i={}){if(i=Object.assign({},n,i),!t||\"string\"!=typeof t)return t;let o=t.trim();if(void 0!==i.skipLike&&i.skipLike.test(o))return t;if(i.hex&&e.test(o))return Number.parseInt(o,16);{const e=r.exec(o);if(e){const r=e[1],n=e[2];let s=function(t){if(t&&-1!==t.indexOf(\".\"))return\".\"===(t=t.replace(/0+$/,\"\"))?t=\"0\":\".\"===t[0]?t=\"0\"+t:\".\"===t[t.length-1]&&(t=t.substr(0,t.length-1)),t;return t}(e[3]);const a=e[4]||e[6];if(!i.leadingZeros&&n.length>0&&r&&\".\"!==o[2])return t;if(!i.leadingZeros&&n.length>0&&!r&&\".\"!==o[1])return t;{const e=Number(o),c=\"\"+e;return-1!==c.search(/[eE]/)||a?i.eNotation?e:t:-1!==o.indexOf(\".\")?\"0\"===c&&\"\"===s||c===s||r&&c===\"-\"+s?e:t:n?s===c||r+s===c?e:t:o===c||o===r+c?e:t}}return t}}},4322:(t,e,r)=>{var n=r(2890);function i(t){return t.name||t.toString().match(/function (.*?)\\s*\\(/)[1]}function o(t){return n.Nil(t)?\"\":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?\"Array\":t&&n.Object(t)?\"Object\":void 0!==t?t:\"\"}function c(t,e,r){var i=function(t){return n.Function(t)?\"\":n.String(t)?JSON.stringify(t):t&&n.Object(t)?\"\":t}(e);return\"Expected \"+a(t)+\", got\"+(\"\"!==r?\" \"+r:\"\")+(\"\"!==i?\" \"+i:\"\")}function u(t,e,r){r=r||o(e),this.message=c(t,e,r),s(this,u),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='\" of type ';return\"key\"===e&&(o='\" with key type '),c('property \"'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property \"'+e+'\"',s(this,u),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,f.prototype=Object.create(Error.prototype),f.prototype.constructor=u,t.exports={TfTypeError:u,TfPropertyTypeError:f,tfCustomError:function(t,e){return new u(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+\".\"+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof u&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},315:(t,e,r)=>{var n=r(1048).Buffer,i=r(2890),o=r(4322);function s(t){return n.isBuffer(t)}function a(t){return\"string\"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function c(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+\"(Length: \"+e+\")\",r+\"(Length: \"+n.length+\")\")}return n.toJSON=function(){return r},n}var u=c.bind(null,i.Array),f=c.bind(null,s),h=c.bind(null,a),l=c.bind(null,i.String);var p=Math.pow(2,53)-1;var d={ArrayN:u,Buffer:s,BufferN:f,Finite:function(t){return\"number\"==typeof t&&isFinite(t)},Hex:a,HexN:h,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return\"number\"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n>>0===t},UInt53:function(t){return\"number\"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},973:(t,e,r)=>{var n=r(4322),i=r(2890),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,u=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return l(t,e,n)}catch(t){throw c(t,r)}}))))))}return t=h(t),e=e||{},r.toJSON=function(){var r=\"[\"+o(t)+\"]\";return void 0!==e.length?r+=\"{\"+e.length+\"}\":void 0===e.minLength&&void 0===e.maxLength||(r+=\"{\"+(void 0===e.minLength?0:e.minLength)+\",\"+(void 0===e.maxLength?1/0:e.maxLength)+\"}\"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return\"?\"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw c(t,o,\"key\")}try{var s=r[o];l(t,s,n)}catch(t){throw c(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return\"{\"+o(e)+\": \"+o(t)+\"}\"}:function(){return\"{\"+o(t)+\"}\"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw c(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some((function(t){try{return l(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(\"|\")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every((function(t){try{return l(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(\" & \")},e},quacksLike:function(t){function e(e){return t===u(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every((function(t,n){try{return l(t,e[n],r)}catch(t){throw c(t,n)}}))))}return e.toJSON=function(){return\"(\"+t.map(o).join(\", \")+\")\"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return\"?\"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError(\"Expected compile() parameter of type Array of length 1\");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var p in f.oneOf=f.anyOf,i)l[p]=i[p];for(p in f)l[p]=f[p];var d=r(315);for(p in d)l[p]=d[p];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,t.exports=l},2890:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return\"boolean\"==typeof t},Function:function(t){return\"function\"==typeof t},Nil:function(t){return null==t},Number:function(t){return\"number\"==typeof t},Object:function(t){return\"object\"==typeof t},String:function(t){return\"string\"==typeof t},\"\":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},6732:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&\"true\"===String(e).toLowerCase()}t.exports=function(t,e){if(n(\"noDeprecation\"))return t;var r=!1;return function(){if(!r){if(n(\"throwDeprecation\"))throw new Error(e);n(\"traceDeprecation\")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},4596:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),Object.defineProperty(e,\"NIL\",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(e,\"parse\",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(e,\"stringify\",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(e,\"v1\",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,\"v3\",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,\"v4\",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,\"v5\",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,\"validate\",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,\"version\",{enumerable:!0,get:function(){return c.default}});var n=l(r(4603)),i=l(r(9917)),o=l(r(2712)),s=l(r(3423)),a=l(r(5911)),c=l(r(4072)),u=l(r(4564)),f=l(r(6585)),h=l(r(9975));function l(t){return t&&t.__esModule?t:{default:t}}},2668:(t,e)=>{\"use strict\";function r(t){return 14+(t+64>>>9<<4)+1}function n(t,e){const r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function i(t,e,r,i,o,s){return n((a=n(n(e,t),n(i,s)))<<(c=o)|a>>>32-c,r);var a,c}function o(t,e,r,n,o,s,a){return i(e&r|~e&n,t,e,o,s,a)}function s(t,e,r,n,o,s,a){return i(e&n|r&~n,t,e,o,s,a)}function a(t,e,r,n,o,s,a){return i(e^r^n,t,e,o,s,a)}function c(t,e,r,n,o,s,a){return i(r^(e|~n),t,e,o,s,a)}Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var u=function(t){if(\"string\"==typeof t){const e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(let r=0;r>5]>>>i%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(15&r),16);e.push(o)}return e}(function(t,e){t[e>>5]|=128<>5]|=(255&t[r/8])<{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var r={randomUUID:\"undefined\"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};e.default=r},5911:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;e.default=\"00000000-0000-0000-0000-000000000000\"},9975:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};var o=function(t){if(!(0,i.default)(t))throw TypeError(\"Invalid UUID\");let e;const r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=255&e,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=255&e,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=255&e,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=255&e,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=255&e,r};e.default=o},6635:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;e.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},4089:(t,e)=>{\"use strict\";let r;Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=function(){if(!r&&(r=\"undefined\"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!r))throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");return r(n)};const n=new Uint8Array(16)},4271:(t,e)=>{\"use strict\";function r(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function n(t,e){return t<>>32-e}Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var i=function(t){const e=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520];if(\"string\"==typeof t){const e=unescape(encodeURIComponent(t));t=[];for(let r=0;r>>0;h=f,f=u,u=n(c,30)>>>0,c=s,s=a}i[0]=i[0]+s>>>0,i[1]=i[1]+c>>>0,i[2]=i[2]+u>>>0,i[3]=i[3]+f>>>0,i[4]=i[4]+h>>>0}return[i[0]>>24&255,i[0]>>16&255,i[0]>>8&255,255&i[0],i[1]>>24&255,i[1]>>16&255,i[1]>>8&255,255&i[1],i[2]>>24&255,i[2]>>16&255,i[2]>>8&255,255&i[2],i[3]>>24&255,i[3]>>16&255,i[3]>>8&255,255&i[3],i[4]>>24&255,i[4]>>16&255,i[4]>>8&255,255&i[4]]};e.default=i},6585:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0,e.unsafeStringify=s;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};const o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));function s(t,e=0){return o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+\"-\"+o[t[e+4]]+o[t[e+5]]+\"-\"+o[t[e+6]]+o[t[e+7]]+\"-\"+o[t[e+8]]+o[t[e+9]]+\"-\"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]}var a=function(t,e=0){const r=s(t,e);if(!(0,i.default)(r))throw TypeError(\"Stringified UUID is invalid\");return r};e.default=a},4603:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4089))&&n.__esModule?n:{default:n},o=r(6585);let s,a,c=0,u=0;var f=function(t,e,r){let n=e&&r||0;const f=e||new Array(16);let h=(t=t||{}).node||s,l=void 0!==t.clockseq?t.clockseq:a;if(null==h||null==l){const e=t.random||(t.rng||i.default)();null==h&&(h=s=[1|e[0],e[1],e[2],e[3],e[4],e[5]]),null==l&&(l=a=16383&(e[6]<<8|e[7]))}let p=void 0!==t.msecs?t.msecs:Date.now(),d=void 0!==t.nsecs?t.nsecs:u+1;const y=p-c+(d-u)/1e4;if(y<0&&void 0===t.clockseq&&(l=l+1&16383),(y<0||p>c)&&void 0===t.nsecs&&(d=0),d>=1e4)throw new Error(\"uuid.v1(): Can't create more than 10M uuids/sec\");c=p,u=d,a=l,p+=122192928e5;const g=(1e4*(268435455&p)+d)%4294967296;f[n++]=g>>>24&255,f[n++]=g>>>16&255,f[n++]=g>>>8&255,f[n++]=255&g;const b=p/4294967296*1e4&268435455;f[n++]=b>>>8&255,f[n++]=255&b,f[n++]=b>>>24&15|16,f[n++]=b>>>16&255,f[n++]=l>>>8|128,f[n++]=255&l;for(let t=0;t<6;++t)f[n+t]=h[t];return e||(0,o.unsafeStringify)(f)};e.default=f},9917:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=o(r(4782)),i=o(r(2668));function o(t){return t&&t.__esModule?t:{default:t}}var s=(0,n.default)(\"v3\",48,i.default);e.default=s},4782:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.URL=e.DNS=void 0,e.default=function(t,e,r){function n(t,n,s,a){var c;if(\"string\"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));const e=[];for(let r=0;r{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=s(r(193)),i=s(r(4089)),o=r(6585);function s(t){return t&&t.__esModule?t:{default:t}}var a=function(t,e,r){if(n.default.randomUUID&&!e&&!t)return n.default.randomUUID();const s=(t=t||{}).random||(t.rng||i.default)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e){r=r||0;for(let t=0;t<16;++t)e[r+t]=s[t];return e}return(0,o.unsafeStringify)(s)};e.default=a},3423:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=o(r(4782)),i=o(r(4271));function o(t){return t&&t.__esModule?t:{default:t}}var s=(0,n.default)(\"v5\",80,i.default);e.default=s},4564:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(6635))&&n.__esModule?n:{default:n};var o=function(t){return\"string\"==typeof t&&i.default.test(t)};e.default=o},4072:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};var o=function(t){if(!(0,i.default)(t))throw TypeError(\"Invalid UUID\");return parseInt(t.slice(14,15),16)};e.default=o},7820:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError(\"value out of range\")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError(\"buffer must be a Buffer instance\");return i||(i=0),e<253?(r.writeUInt8(e,i),t.bytes=1):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),t.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),t.bytes=9),r},decode:function t(e,r){if(!n.isBuffer(e))throw new TypeError(\"buffer must be a Buffer instance\");r||(r=0);var i=e.readUInt8(r);if(i<253)return t.bytes=1,i;if(253===i)return t.bytes=3,e.readUInt16LE(r+1);if(254===i)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var s=e.readUInt32LE(r+1),a=4294967296*e.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},6952:(t,e,r)=>{var n=r(1048).Buffer,i=r(9848);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error(\"Invalid network version\");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error(\"Invalid WIF length\");if(1!==t[33])throw new Error(\"Invalid compression flag\");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function s(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return\"number\"==typeof t?i.encode(s(t,e,r)):i.encode(s(t.version,t.privateKey,t.compressed))},encodeRaw:s}},7047:t=>{\"use strict\";t.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},222:(t,e,r)=>{\"use strict\";function n(t){var e=this;if(e instanceof n||(e=new n),e.tail=null,e.head=null,e.length=0,t&&\"function\"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,i=arguments.length;r1)r=e;else{if(!this.head)throw new TypeError(\"Reduce of empty list with no initial value\");n=this.head.next,r=this.head.value}for(var i=0;null!==n;i++)r=t(r,n.value,i),n=n.next;return r},n.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError(\"Reduce of empty list with no initial value\");n=this.tail.prev,r=this.tail.value}for(var i=this.length-1;null!==n;i--)r=t(r,n.value,i),n=n.prev;return r},n.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},n.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},n.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new n;if(ethis.length&&(e=this.length);for(var i=0,o=this.head;null!==o&&ithis.length&&(e=this.length);for(var i=this.length,o=this.tail;null!==o&&i>e;i--)o=o.prev;for(;null!==o&&i>t;i--,o=o.prev)r.push(o.value);return r},n.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var n=0,o=this.head;null!==o&&n{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.JsonRpcRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(4520);e.JsonRpcRequestStruct=(0,o.object)({jsonrpc:(0,i.literal)(\"2.0\"),id:(0,i.union)([(0,i.string)(),(0,i.number)(),(0,i.literal)(null)]),method:(0,i.string)(),params:(0,o.exactOptional)((0,i.union)([(0,i.array)(n.JsonStruct),(0,i.record)((0,i.string)(),n.JsonStruct)]))})},1236:function(t,e,r){\"use strict\";var n,i,o,s=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if(\"m\"===n)throw new TypeError(\"Private method is not writable\");if(\"a\"===n&&!i)throw new TypeError(\"Private accessor was defined without a setter\");if(\"function\"==typeof e?t!==e||!i:!e.has(t))throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");return\"a\"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},a=this&&this.__classPrivateFieldGet||function(t,e,r,n){if(\"a\"===r&&!n)throw new TypeError(\"Private accessor was defined without a getter\");if(\"function\"==typeof e?t!==e||!n:!e.has(t))throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");return\"m\"===r?n:\"a\"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringClient=void 0;const c=r(7251),u=r(4596),f=r(2582),h=r(1925),l=r(4520);e.KeyringClient=class{constructor(t){n.add(this),i.set(this,void 0),s(this,i,t,\"f\")}async listAccounts(){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ListAccounts}),f.ListAccountsResponseStruct)}async getAccount(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetAccount,params:{id:t}}),f.GetAccountResponseStruct)}async getAccountBalances(t,e){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetAccountBalances,params:{id:t,assets:e}}),f.GetAccountBalancesResponseStruct)}async createAccount(t={}){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.CreateAccount,params:{options:t}}),f.CreateAccountResponseStruct)}async filterAccountChains(t,e){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.FilterAccountChains,params:{id:t,chains:e}}),f.FilterAccountChainsResponseStruct)}async updateAccount(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.UpdateAccount,params:{account:t}}),f.UpdateAccountResponseStruct)}async deleteAccount(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.DeleteAccount,params:{id:t}}),f.DeleteAccountResponseStruct)}async exportAccount(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ExportAccount,params:{id:t}}),f.ExportAccountResponseStruct)}async listRequests(){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ListRequests}),f.ListRequestsResponseStruct)}async getRequest(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetRequest,params:{id:t}}),f.GetRequestResponseStruct)}async submitRequest(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.SubmitRequest,params:t}),f.SubmitRequestResponseStruct)}async approveRequest(t,e={}){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ApproveRequest,params:{id:t,data:e}}),f.ApproveRequestResponseStruct)}async rejectRequest(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.RejectRequest,params:{id:t}}),f.RejectRequestResponseStruct)}},i=new WeakMap,n=new WeakSet,o=async function(t){return a(this,i,\"f\").send({jsonrpc:\"2.0\",id:(0,u.v4)(),...t})}},4071:function(t,e,r){\"use strict\";var n,i,o=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if(\"m\"===n)throw new TypeError(\"Private method is not writable\");if(\"a\"===n&&!i)throw new TypeError(\"Private accessor was defined without a setter\");if(\"function\"==typeof e?t!==e||!i:!e.has(t))throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");return\"a\"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},s=this&&this.__classPrivateFieldGet||function(t,e,r,n){if(\"a\"===r&&!n)throw new TypeError(\"Private accessor was defined without a getter\");if(\"function\"==typeof e?t!==e||!n:!e.has(t))throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");return\"m\"===r?n:\"a\"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringSnapRpcClient=e.SnapRpcSender=void 0;const a=r(1236);class c{constructor(t,e){n.set(this,void 0),i.set(this,void 0),o(this,n,t,\"f\"),o(this,i,e,\"f\")}async send(t){return s(this,i,\"f\").request({method:\"wallet_invokeKeyring\",params:{snapId:s(this,n,\"f\"),request:t}})}}e.SnapRpcSender=c,n=new WeakMap,i=new WeakMap;class u extends a.KeyringClient{constructor(t,e){super(new c(t,e))}}e.KeyringSnapRpcClient=u},1950:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringAccountStruct=e.BtcAccountType=e.EthAccountType=void 0;const n=r(2049),i=r(7251),o=r(4520),s=r(6580);var a,c;!function(t){t.Eoa=\"eip155:eoa\",t.Erc4337=\"eip155:erc4337\"}(a=e.EthAccountType||(e.EthAccountType={})),function(t){t.P2wpkh=\"bip122:p2wpkh\"}(c=e.BtcAccountType||(e.BtcAccountType={})),e.KeyringAccountStruct=(0,o.object)({id:s.UuidStruct,type:(0,i.enums)([`${a.Eoa}`,`${a.Erc4337}`,`${c.P2wpkh}`]),address:(0,i.string)(),options:(0,i.record)((0,i.string)(),n.JsonStruct),methods:(0,i.array)((0,i.string)())})},3433:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.BalanceStruct=void 0;const n=r(7251),i=r(4520),o=r(6580);e.BalanceStruct=(0,i.object)({amount:o.StringNumberStruct,unit:(0,n.string)()})},8588:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.isCaipAssetId=e.isCaipAssetType=e.CaipAssetIdStruct=e.CaipAssetTypeStruct=void 0;const n=r(7251),i=r(4520);e.CaipAssetTypeStruct=(0,i.definePattern)(\"CaipAssetType\",/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})$/u),e.CaipAssetIdStruct=(0,i.definePattern)(\"CaipAssetId\",/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})\\/(?[-.%a-zA-Z0-9]{1,78})$/u),e.isCaipAssetType=function(t){return(0,n.is)(t,e.CaipAssetTypeStruct)},e.isCaipAssetId=function(t){return(0,n.is)(t,e.CaipAssetIdStruct)}},4015:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringAccountDataStruct=void 0;const n=r(2049),i=r(7251);e.KeyringAccountDataStruct=(0,i.record)((0,i.string)(),n.JsonStruct)},5417:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(1950),e),i(r(3433),e),i(r(8588),e),i(r(4015),e),i(r(5444),e),i(r(7884),e),i(r(6142),e)},5444:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},7884:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(4520),s=r(6580);e.KeyringRequestStruct=(0,o.object)({id:s.UuidStruct,scope:(0,i.string)(),account:s.UuidStruct,request:(0,o.object)({method:(0,i.string)(),params:(0,o.exactOptional)((0,i.union)([(0,i.array)(n.JsonStruct),(0,i.record)((0,i.string)(),n.JsonStruct)]))})})},6142:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringResponseStruct=void 0;const n=r(2049),i=r(7251),o=r(4520);e.KeyringResponseStruct=(0,i.union)([(0,o.object)({pending:(0,i.literal)(!0),redirect:(0,o.exactOptional)((0,o.object)({message:(0,o.exactOptional)((0,i.string)()),url:(0,o.exactOptional)((0,i.string)())}))}),(0,o.object)({pending:(0,i.literal)(!1),result:n.JsonStruct})])},5238:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(5787),e)},5787:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.BtcP2wpkhAccountStruct=e.BtcMethod=e.BtcP2wpkhAddressStruct=void 0;const n=r(6586),i=r(7251),o=r(5417),s=r(4520);var a;e.BtcP2wpkhAddressStruct=(0,i.refine)((0,i.string)(),\"BtcP2wpkhAddressStruct\",(t=>{try{n.bech32.decode(t)}catch(t){return new Error(`Could not decode P2WPKH address: ${t.message}`)}return!0})),function(t){t.SendMany=\"btc_sendmany\"}(a=e.BtcMethod||(e.BtcMethod={})),e.BtcP2wpkhAccountStruct=(0,s.object)({...o.KeyringAccountStruct.schema,address:e.BtcP2wpkhAddressStruct,type:(0,i.literal)(`${o.BtcAccountType.P2wpkh}`),methods:(0,i.array)((0,i.enums)([`${a.SendMany}`]))})},1360:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},322:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(4943),e)},4943:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.EthUserOperationPatchStruct=e.EthBaseUserOperationStruct=e.EthBaseTransactionStruct=e.EthUserOperationStruct=void 0;const n=r(4520),i=r(6580),o=r(6879);e.EthUserOperationStruct=(0,n.object)({sender:o.EthAddressStruct,nonce:o.EthUint256Struct,initCode:o.EthBytesStruct,callData:o.EthBytesStruct,callGasLimit:o.EthUint256Struct,verificationGasLimit:o.EthUint256Struct,preVerificationGas:o.EthUint256Struct,maxFeePerGas:o.EthUint256Struct,maxPriorityFeePerGas:o.EthUint256Struct,paymasterAndData:o.EthBytesStruct,signature:o.EthBytesStruct}),e.EthBaseTransactionStruct=(0,n.object)({to:o.EthAddressStruct,value:o.EthUint256Struct,data:o.EthBytesStruct}),e.EthBaseUserOperationStruct=(0,n.object)({nonce:o.EthUint256Struct,initCode:o.EthBytesStruct,callData:o.EthBytesStruct,gasLimits:(0,n.exactOptional)((0,n.object)({callGasLimit:o.EthUint256Struct,verificationGasLimit:o.EthUint256Struct,preVerificationGas:o.EthUint256Struct})),dummyPaymasterAndData:o.EthBytesStruct,dummySignature:o.EthBytesStruct,bundlerUrl:i.UrlStruct}),e.EthUserOperationPatchStruct=(0,n.object)({paymasterAndData:o.EthBytesStruct,callGasLimit:(0,n.exactOptional)(o.EthUint256Struct),verificationGasLimit:(0,n.exactOptional)(o.EthUint256Struct),preVerificationGas:(0,n.exactOptional)(o.EthUint256Struct)})},6034:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(322),e),i(r(6879),e),i(r(1267),e)},6879:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.EthErc4337AccountStruct=e.EthEoaAccountStruct=e.EthMethod=e.EthUint256Struct=e.EthAddressStruct=e.EthBytesStruct=void 0;const n=r(7251),i=r(5417),o=r(4520);var s;e.EthBytesStruct=(0,o.definePattern)(\"EthBytes\",/^0x[0-9a-f]*$/iu),e.EthAddressStruct=(0,o.definePattern)(\"EthAddress\",/^0x[0-9a-f]{40}$/iu),e.EthUint256Struct=(0,o.definePattern)(\"EthUint256\",/^0x([1-9a-f][0-9a-f]*|0)$/iu),function(t){t.PersonalSign=\"personal_sign\",t.Sign=\"eth_sign\",t.SignTransaction=\"eth_signTransaction\",t.SignTypedDataV1=\"eth_signTypedData_v1\",t.SignTypedDataV3=\"eth_signTypedData_v3\",t.SignTypedDataV4=\"eth_signTypedData_v4\",t.PrepareUserOperation=\"eth_prepareUserOperation\",t.PatchUserOperation=\"eth_patchUserOperation\",t.SignUserOperation=\"eth_signUserOperation\"}(s=e.EthMethod||(e.EthMethod={})),e.EthEoaAccountStruct=(0,o.object)({...i.KeyringAccountStruct.schema,address:e.EthAddressStruct,type:(0,n.literal)(`${i.EthAccountType.Eoa}`),methods:(0,n.array)((0,n.enums)([`${s.PersonalSign}`,`${s.Sign}`,`${s.SignTransaction}`,`${s.SignTypedDataV1}`,`${s.SignTypedDataV3}`,`${s.SignTypedDataV4}`]))}),e.EthErc4337AccountStruct=(0,o.object)({...i.KeyringAccountStruct.schema,address:e.EthAddressStruct,type:(0,n.literal)(`${i.EthAccountType.Erc4337}`),methods:(0,n.array)((0,n.enums)([`${s.PersonalSign}`,`${s.Sign}`,`${s.SignTypedDataV1}`,`${s.SignTypedDataV3}`,`${s.SignTypedDataV4}`,`${s.PrepareUserOperation}`,`${s.PatchUserOperation}`,`${s.SignUserOperation}`]))})},1267:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.isEvmAccountType=void 0;const n=r(5417);e.isEvmAccountType=function(t){return t===n.EthAccountType.Eoa||t===n.EthAccountType.Erc4337}},4433:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringEvent=void 0,function(t){t.AccountCreated=\"notify:accountCreated\",t.AccountUpdated=\"notify:accountUpdated\",t.AccountDeleted=\"notify:accountDeleted\",t.RequestApproved=\"notify:requestApproved\",t.RequestRejected=\"notify:requestRejected\"}(e.KeyringEvent||(e.KeyringEvent={}))},7962:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(5417),e),i(r(5238),e),i(r(1360),e),i(r(6034),e),i(r(4433),e),i(r(7470),e),i(r(1236),e),i(r(4071),e),i(r(3060),e),i(r(5524),e),i(r(4520),e)},2582:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.RejectRequestResponseStruct=e.RejectRequestRequestStruct=e.ApproveRequestResponseStruct=e.ApproveRequestRequestStruct=e.SubmitRequestResponseStruct=e.SubmitRequestRequestStruct=e.GetRequestResponseStruct=e.GetRequestRequestStruct=e.ListRequestsResponseStruct=e.ListRequestsRequestStruct=e.ExportAccountResponseStruct=e.ExportAccountRequestStruct=e.DeleteAccountResponseStruct=e.DeleteAccountRequestStruct=e.UpdateAccountResponseStruct=e.UpdateAccountRequestStruct=e.FilterAccountChainsResponseStruct=e.FilterAccountChainsStruct=e.GetAccountBalancesResponseStruct=e.GetAccountBalancesRequestStruct=e.CreateAccountResponseStruct=e.CreateAccountRequestStruct=e.GetAccountResponseStruct=e.GetAccountRequestStruct=e.ListAccountsResponseStruct=e.ListAccountsRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(5417),s=r(4520),a=r(6580),c=r(1925),u={jsonrpc:(0,i.literal)(\"2.0\"),id:(0,i.union)([(0,i.string)(),(0,i.number)(),(0,i.literal)(null)])};e.ListAccountsRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_listAccounts\")}),e.ListAccountsResponseStruct=(0,i.array)(o.KeyringAccountStruct),e.GetAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_getAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.GetAccountResponseStruct=o.KeyringAccountStruct,e.CreateAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_createAccount\"),params:(0,s.object)({options:(0,i.record)((0,i.string)(),n.JsonStruct)})}),e.CreateAccountResponseStruct=o.KeyringAccountStruct,e.GetAccountBalancesRequestStruct=(0,s.object)({...u,method:(0,i.literal)(`${c.KeyringRpcMethod.GetAccountBalances}`),params:(0,s.object)({id:a.UuidStruct,assets:(0,i.array)(o.CaipAssetTypeStruct)})}),e.GetAccountBalancesResponseStruct=(0,i.record)(o.CaipAssetTypeStruct,o.BalanceStruct),e.FilterAccountChainsStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_filterAccountChains\"),params:(0,s.object)({id:a.UuidStruct,chains:(0,i.array)((0,i.string)())})}),e.FilterAccountChainsResponseStruct=(0,i.array)((0,i.string)()),e.UpdateAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_updateAccount\"),params:(0,s.object)({account:o.KeyringAccountStruct})}),e.UpdateAccountResponseStruct=(0,i.literal)(null),e.DeleteAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_deleteAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.DeleteAccountResponseStruct=(0,i.literal)(null),e.ExportAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_exportAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.ExportAccountResponseStruct=o.KeyringAccountDataStruct,e.ListRequestsRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_listRequests\")}),e.ListRequestsResponseStruct=(0,i.array)(o.KeyringRequestStruct),e.GetRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_getRequest\"),params:(0,s.object)({id:a.UuidStruct})}),e.GetRequestResponseStruct=o.KeyringRequestStruct,e.SubmitRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_submitRequest\"),params:o.KeyringRequestStruct}),e.SubmitRequestResponseStruct=o.KeyringResponseStruct,e.ApproveRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_approveRequest\"),params:(0,s.object)({id:a.UuidStruct,data:(0,i.record)((0,i.string)(),n.JsonStruct)})}),e.ApproveRequestResponseStruct=(0,i.literal)(null),e.RejectRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_rejectRequest\"),params:(0,s.object)({id:a.UuidStruct})}),e.RejectRequestResponseStruct=(0,i.literal)(null)},6796:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},7841:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(6796),e)},3005:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.RequestRejectedEventStruct=e.RequestApprovedEventStruct=e.AccountDeletedEventStruct=e.AccountUpdatedEventStruct=e.AccountCreatedEventStruct=void 0;const n=r(2049),i=r(7251),o=r(5417),s=r(4433),a=r(4520),c=r(6580);e.AccountCreatedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountCreated}`),params:(0,a.object)({account:o.KeyringAccountStruct,accountNameSuggestion:(0,a.exactOptional)((0,i.string)()),displayConfirmation:(0,a.exactOptional)((0,i.boolean)())})}),e.AccountUpdatedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountUpdated}`),params:(0,a.object)({account:o.KeyringAccountStruct})}),e.AccountDeletedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountDeleted}`),params:(0,a.object)({id:c.UuidStruct})}),e.RequestApprovedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.RequestApproved}`),params:(0,a.object)({id:c.UuidStruct,result:n.JsonStruct})}),e.RequestRejectedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.RequestRejected}`),params:(0,a.object)({id:c.UuidStruct})})},7470:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(2582),e),i(r(7841),e),i(r(3005),e),i(r(1925),e),i(r(3699),e)},1925:(t,e)=>{\"use strict\";var r;Object.defineProperty(e,\"__esModule\",{value:!0}),e.isKeyringRpcMethod=e.KeyringRpcMethod=void 0,function(t){t.ListAccounts=\"keyring_listAccounts\",t.GetAccount=\"keyring_getAccount\",t.CreateAccount=\"keyring_createAccount\",t.GetAccountBalances=\"keyring_getAccountBalances\",t.FilterAccountChains=\"keyring_filterAccountChains\",t.UpdateAccount=\"keyring_updateAccount\",t.DeleteAccount=\"keyring_deleteAccount\",t.ExportAccount=\"keyring_exportAccount\",t.ListRequests=\"keyring_listRequests\",t.GetRequest=\"keyring_getRequest\",t.SubmitRequest=\"keyring_submitRequest\",t.ApproveRequest=\"keyring_approveRequest\",t.RejectRequest=\"keyring_rejectRequest\"}(r=e.KeyringRpcMethod||(e.KeyringRpcMethod={})),e.isKeyringRpcMethod=function(t){return Object.values(r).includes(t)}},3699:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.InternalAccountStruct=e.InternalAccountStructs=e.InternalBtcP2wpkhAccountStruct=e.InternalEthErc4337AccountStruct=e.InternalEthEoaAccountStruct=e.InternalAccountMetadataStruct=void 0;const n=r(7251),i=r(5417),o=r(5787),s=r(6879),a=r(4520);function c(t){return(0,a.object)({...t.schema,...e.InternalAccountMetadataStruct.schema})}e.InternalAccountMetadataStruct=(0,a.object)({metadata:(0,a.object)({name:(0,n.string)(),snap:(0,a.exactOptional)((0,a.object)({id:(0,n.string)(),enabled:(0,n.boolean)(),name:(0,n.string)()})),lastSelected:(0,a.exactOptional)((0,n.number)()),importTime:(0,n.number)(),keyring:(0,a.object)({type:(0,n.string)()})})}),e.InternalEthEoaAccountStruct=c(s.EthEoaAccountStruct),e.InternalEthErc4337AccountStruct=c(s.EthErc4337AccountStruct),e.InternalBtcP2wpkhAccountStruct=c(o.BtcP2wpkhAccountStruct),e.InternalAccountStructs={[`${i.EthAccountType.Eoa}`]:e.InternalEthEoaAccountStruct,[`${i.EthAccountType.Erc4337}`]:e.InternalEthErc4337AccountStruct,[`${i.BtcAccountType.P2wpkh}`]:e.InternalBtcP2wpkhAccountStruct},e.InternalAccountStruct=(0,a.object)({...i.KeyringAccountStruct.schema,...e.InternalAccountMetadataStruct.schema})},3060:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.handleKeyringRequest=e.MethodNotSupportedError=void 0;const n=r(7251),i=r(2582),o=r(1925),s=r(5978);class a extends Error{constructor(t){super(`Method not supported: ${t}`)}}e.MethodNotSupportedError=a,e.handleKeyringRequest=async function(t,e){try{return await async function(t,e){switch((0,n.assert)(e,s.JsonRpcRequestStruct),e.method){case o.KeyringRpcMethod.ListAccounts:return(0,n.assert)(e,i.ListAccountsRequestStruct),t.listAccounts();case o.KeyringRpcMethod.GetAccount:return(0,n.assert)(e,i.GetAccountRequestStruct),t.getAccount(e.params.id);case o.KeyringRpcMethod.CreateAccount:return(0,n.assert)(e,i.CreateAccountRequestStruct),t.createAccount(e.params.options);case o.KeyringRpcMethod.GetAccountBalances:if(void 0===t.getAccountBalances)throw new a(e.method);return(0,n.assert)(e,i.GetAccountBalancesRequestStruct),t.getAccountBalances(e.params.id,e.params.assets);case o.KeyringRpcMethod.FilterAccountChains:return(0,n.assert)(e,i.FilterAccountChainsStruct),t.filterAccountChains(e.params.id,e.params.chains);case o.KeyringRpcMethod.UpdateAccount:return(0,n.assert)(e,i.UpdateAccountRequestStruct),t.updateAccount(e.params.account);case o.KeyringRpcMethod.DeleteAccount:return(0,n.assert)(e,i.DeleteAccountRequestStruct),t.deleteAccount(e.params.id);case o.KeyringRpcMethod.ExportAccount:if(void 0===t.exportAccount)throw new a(e.method);return(0,n.assert)(e,i.ExportAccountRequestStruct),t.exportAccount(e.params.id);case o.KeyringRpcMethod.ListRequests:if(void 0===t.listRequests)throw new a(e.method);return(0,n.assert)(e,i.ListRequestsRequestStruct),t.listRequests();case o.KeyringRpcMethod.GetRequest:if(void 0===t.getRequest)throw new a(e.method);return(0,n.assert)(e,i.GetRequestRequestStruct),t.getRequest(e.params.id);case o.KeyringRpcMethod.SubmitRequest:return(0,n.assert)(e,i.SubmitRequestRequestStruct),t.submitRequest(e.params);case o.KeyringRpcMethod.ApproveRequest:if(void 0===t.approveRequest)throw new a(e.method);return(0,n.assert)(e,i.ApproveRequestRequestStruct),t.approveRequest(e.params.id,e.params.data);case o.KeyringRpcMethod.RejectRequest:if(void 0===t.rejectRequest)throw new a(e.method);return(0,n.assert)(e,i.RejectRequestRequestStruct),t.rejectRequest(e.params.id);default:throw new a(e.method)}}(t,e)}catch(t){const e=t instanceof Error&&\"string\"==typeof t.message?t.message:\"An unknown error occurred while handling the keyring request\";throw new Error(e)}}},5524:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.emitSnapKeyringEvent=void 0,e.emitSnapKeyringEvent=async function(t,e,r){await t.request({method:\"snap_manageAccounts\",params:{method:e,params:{...r}}})}},4520:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.strictMask=e.definePattern=e.exactOptional=e.object=void 0;const n=r(7251);function i(t){return t.path[t.path.length-1]in t.branch[t.branch.length-2]}e.object=function(t){return(0,n.object)(t)},e.exactOptional=function(t){return new n.Struct({...t,validator:(e,r)=>!i(r)||t.validator(e,r),refiner:(e,r)=>!i(r)||t.refiner(e,r)})},e.definePattern=function(t,e){return(0,n.define)(t,(t=>\"string\"==typeof t&&e.test(t)))},e.strictMask=function(t,e,r){return(0,n.assert)(t,e,r),t}},6580:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(8401),e),i(r(7765),e)},8401:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.StringNumberStruct=e.UrlStruct=e.UuidStruct=void 0;const n=r(7251),i=r(4520);e.UuidStruct=(0,i.definePattern)(\"UuidV4\",/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu),e.UrlStruct=(0,n.define)(\"Url\",(t=>{try{const e=new URL(t);return\"http:\"===e.protocol||\"https:\"===e.protocol}catch(t){return!1}})),e.StringNumberStruct=(0,i.definePattern)(\"StringNumber\",/^\\d+(\\.\\d+)?$/u)},7765:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.expectTrue=void 0,e.expectTrue=function(){}},1275:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n,i=r(124),o=((n=i)&&n.__esModule?n:{default:n}).default.call(void 0,\"metamask\");e.createProjectLogger=function(t){return o.extend(t)},e.createModuleLogger=function(t,e){return t.extend(e)}},5244:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r=(t,e,r)=>{if(!e.has(t))throw TypeError(\"Cannot \"+r)};e.__privateGet=(t,e,n)=>(r(t,e,\"read from private field\"),n?n.call(t):e.get(t)),e.__privateAdd=(t,e,r)=>{if(e.has(t))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(t):e.set(t,r)},e.__privateSet=(t,e,n,i)=>(r(t,e,\"write to private field\"),i?i.call(t,n):e.set(t,n),n)},3631:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(932),i=r(2722),o=r(7251),s=o.refine.call(void 0,o.string.call(void 0),\"Version\",(t=>null!==i.valid.call(void 0,t)||`Expected SemVer version, got \"${t}\"`)),a=o.refine.call(void 0,o.string.call(void 0),\"Version range\",(t=>null!==i.validRange.call(void 0,t)||`Expected SemVer range, got \"${t}\"`));e.VersionStruct=s,e.VersionRangeStruct=a,e.isValidSemVerVersion=function(t){return o.is.call(void 0,t,s)},e.isValidSemVerRange=function(t){return o.is.call(void 0,t,a)},e.assertIsSemVerVersion=function(t){n.assertStruct.call(void 0,t,s)},e.assertIsSemVerRange=function(t){n.assertStruct.call(void 0,t,a)},e.gtVersion=function(t,e){return i.gt.call(void 0,t,e)},e.gtRange=function(t,e){return i.gtr.call(void 0,t,e)},e.satisfiesVersionRange=function(t,e){return i.satisfies.call(void 0,t,e,{includePrerelease:!0})}},9116:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r,n=((r=n||{})[r.Millisecond=1]=\"Millisecond\",r[r.Second=1e3]=\"Second\",r[r.Minute=6e4]=\"Minute\",r[r.Hour=36e5]=\"Hour\",r[r.Day=864e5]=\"Day\",r[r.Week=6048e5]=\"Week\",r[r.Year=31536e6]=\"Year\",r),i=(t,e)=>{if(!(t=>Number.isInteger(t)&&t>=0)(t))throw new Error(`\"${e}\" must be a non-negative integer. Received: \"${t}\".`)};e.Duration=n,e.inMilliseconds=function(t,e){return i(t,\"count\"),t*e},e.timeSince=function(t){return i(t,\"timestamp\"),Date.now()-t}},7982:()=>{},1848:(t,e,r)=>{\"use strict\";function n(t,e){return null!=t?t:e()}Object.defineProperty(e,\"__esModule\",{value:!0});var i=r(932),o=r(7251);e.base64=(t,e={})=>{const r=n(e.paddingRequired,(()=>!1)),s=n(e.characterSet,(()=>\"base64\"));let a,c;return\"base64\"===s?a=String.raw`[A-Za-z0-9+\\/]`:(i.assert.call(void 0,\"base64url\"===s),a=String.raw`[-_A-Za-z0-9]`),c=r?new RegExp(`^(?:${a}{4})*(?:${a}{3}=|${a}{2}==)?$`,\"u\"):new RegExp(`^(?:${a}{4})*(?:${a}{2,3}|${a}{3}=|${a}{2}==)?$`,\"u\"),o.pattern.call(void 0,t,c)}},932:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(1486),i=r(7251);function o(t,e){return Boolean(\"string\"==typeof function(t){let e,r=t[0],n=1;for(;nr.call(e,...t))),e=void 0)}return r}([t,\"optionalAccess\",t=>t.prototype,\"optionalAccess\",t=>t.constructor,\"optionalAccess\",t=>t.name]))?new t({message:e}):t({message:e})}var s=class extends Error{constructor(t){super(t.message),this.code=\"ERR_ASSERTION\"}};e.AssertionError=s,e.assert=function(t,e=\"Assertion failed.\",r=s){if(!t){if(e instanceof Error)throw e;throw o(r,e)}},e.assertStruct=function(t,e,r=\"Assertion failed\",a=s){try{i.assert.call(void 0,t,e)}catch(t){throw o(a,`${r}: ${function(t){return n.getErrorMessage.call(void 0,t).replace(/\\.$/u,\"\")}(t)}.`)}},e.assertExhaustive=function(t){throw new Error(\"Invalid branch reached. Should be detected during compilation.\")}},9705:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.createDeferredPromise=function({suppressUnhandledRejection:t=!1}={}){let e,r;const n=new Promise(((t,n)=>{e=t,r=n}));return t&&n.catch((t=>{})),{promise:n,resolve:e,reject:r}}},1203:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(5363),i=r(932),o=r(7251),s=o.union.call(void 0,[o.number.call(void 0),o.bigint.call(void 0),o.string.call(void 0),n.StrictHexStruct]),a=o.coerce.call(void 0,o.number.call(void 0),s,Number),c=o.coerce.call(void 0,o.bigint.call(void 0),s,BigInt),u=(o.union.call(void 0,[n.StrictHexStruct,o.instance.call(void 0,Uint8Array)]),o.coerce.call(void 0,o.instance.call(void 0,Uint8Array),o.union.call(void 0,[n.StrictHexStruct]),n.hexToBytes)),f=o.coerce.call(void 0,n.StrictHexStruct,o.instance.call(void 0,Uint8Array),n.bytesToHex);e.createNumber=function(t){try{const e=o.create.call(void 0,t,a);return i.assert.call(void 0,Number.isFinite(e),`Expected a number-like value, got \"${t}\".`),e}catch(e){if(e instanceof o.StructError)throw new Error(`Expected a number-like value, got \"${t}\".`);throw e}},e.createBigInt=function(t){try{return o.create.call(void 0,t,c)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a number-like value, got \"${String(t.value)}\".`);throw t}},e.createBytes=function(t){if(\"string\"==typeof t&&\"0x\"===t.toLowerCase())return new Uint8Array;try{return o.create.call(void 0,t,u)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a bytes-like value, got \"${String(t.value)}\".`);throw t}},e.createHex=function(t){if(t instanceof Uint8Array&&0===t.length||\"string\"==typeof t&&\"0x\"===t.toLowerCase())return\"0x\";try{return o.create.call(void 0,t,f)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a bytes-like value, got \"${String(t.value)}\".`);throw t}}},1508:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(1848),i=r(7251),o=i.size.call(void 0,n.base64.call(void 0,i.string.call(void 0),{paddingRequired:!0}),44,44);e.ChecksumStruct=o},1423:()=>{},1486:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(6526),i=r(9756);function o(t){return\"object\"==typeof t&&null!==t&&\"code\"in t}function s(t){return\"object\"==typeof t&&null!==t&&\"message\"in t}e.isErrorWithCode=o,e.isErrorWithMessage=s,e.isErrorWithStack=function(t){return\"object\"==typeof t&&null!==t&&\"stack\"in t},e.getErrorMessage=function(t){return s(t)&&\"string\"==typeof t.message?t.message:n.isNullOrUndefined.call(void 0,t)?\"\":String(t)},e.wrapError=function(t,e){if((r=t)instanceof Error||n.isObject.call(void 0,r)&&\"Error\"===r.constructor.name){let r;return r=2===Error.length?new Error(e,{cause:t}):new(0,i.ErrorWithCause)(e,{cause:t}),o(t)&&(r.code=t.code),r}var r;return e.length>0?new Error(`${String(t)}: ${e}`):new Error(String(t))}},8383:()=>{},7427:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(932),i=r(6526),o=r(7251),s=t=>o.object.call(void 0,t);function a({path:t,branch:e}){const r=t[t.length-1];return i.hasProperty.call(void 0,e[e.length-2],r)}function c(t){return new(0,o.Struct)({...t,type:`optional ${t.type}`,validator:(e,r)=>!a(r)||t.validator(e,r),refiner:(e,r)=>!a(r)||t.refiner(e,r)})}var u=o.union.call(void 0,[o.literal.call(void 0,null),o.boolean.call(void 0),o.define.call(void 0,\"finite number\",(t=>o.is.call(void 0,t,o.number.call(void 0))&&Number.isFinite(t))),o.string.call(void 0),o.array.call(void 0,o.lazy.call(void 0,(()=>u))),o.record.call(void 0,o.string.call(void 0),o.lazy.call(void 0,(()=>u)))]),f=o.coerce.call(void 0,u,o.any.call(void 0),(t=>(n.assertStruct.call(void 0,t,u),JSON.parse(JSON.stringify(t,((t,e)=>{if(\"__proto__\"!==t&&\"constructor\"!==t)return e}))))));function h(t){return o.create.call(void 0,t,f)}var l=o.literal.call(void 0,\"2.0\"),p=o.nullable.call(void 0,o.union.call(void 0,[o.number.call(void 0),o.string.call(void 0)])),d=s({code:o.integer.call(void 0),message:o.string.call(void 0),data:c(f),stack:c(o.string.call(void 0))}),y=o.union.call(void 0,[o.record.call(void 0,o.string.call(void 0),f),o.array.call(void 0,f)]),g=s({id:p,jsonrpc:l,method:o.string.call(void 0),params:c(y)}),b=s({jsonrpc:l,method:o.string.call(void 0),params:c(y)});var w=o.object.call(void 0,{id:p,jsonrpc:l,result:o.optional.call(void 0,o.unknown.call(void 0)),error:o.optional.call(void 0,d)}),m=s({id:p,jsonrpc:l,result:f}),v=s({id:p,jsonrpc:l,error:d}),E=o.union.call(void 0,[m,v]);e.object=s,e.exactOptional=c,e.UnsafeJsonStruct=u,e.JsonStruct=f,e.isValidJson=function(t){try{return h(t),!0}catch(t){return!1}},e.getSafeJson=h,e.getJsonSize=function(t){n.assertStruct.call(void 0,t,f,\"Invalid JSON value\");const e=JSON.stringify(t);return(new TextEncoder).encode(e).byteLength},e.jsonrpc2=\"2.0\",e.JsonRpcVersionStruct=l,e.JsonRpcIdStruct=p,e.JsonRpcErrorStruct=d,e.JsonRpcParamsStruct=y,e.JsonRpcRequestStruct=g,e.JsonRpcNotificationStruct=b,e.isJsonRpcNotification=function(t){return o.is.call(void 0,t,b)},e.assertIsJsonRpcNotification=function(t,e){n.assertStruct.call(void 0,t,b,\"Invalid JSON-RPC notification\",e)},e.isJsonRpcRequest=function(t){return o.is.call(void 0,t,g)},e.assertIsJsonRpcRequest=function(t,e){n.assertStruct.call(void 0,t,g,\"Invalid JSON-RPC request\",e)},e.PendingJsonRpcResponseStruct=w,e.JsonRpcSuccessStruct=m,e.JsonRpcFailureStruct=v,e.JsonRpcResponseStruct=E,e.isPendingJsonRpcResponse=function(t){return o.is.call(void 0,t,w)},e.assertIsPendingJsonRpcResponse=function(t,e){n.assertStruct.call(void 0,t,w,\"Invalid pending JSON-RPC response\",e)},e.isJsonRpcResponse=function(t){return o.is.call(void 0,t,E)},e.assertIsJsonRpcResponse=function(t,e){n.assertStruct.call(void 0,t,E,\"Invalid JSON-RPC response\",e)},e.isJsonRpcSuccess=function(t){return o.is.call(void 0,t,m)},e.assertIsJsonRpcSuccess=function(t,e){n.assertStruct.call(void 0,t,m,\"Invalid JSON-RPC success response\",e)},e.isJsonRpcFailure=function(t){return o.is.call(void 0,t,v)},e.assertIsJsonRpcFailure=function(t,e){n.assertStruct.call(void 0,t,v,\"Invalid JSON-RPC failure response\",e)},e.isJsonRpcError=function(t){return o.is.call(void 0,t,d)},e.assertIsJsonRpcError=function(t,e){n.assertStruct.call(void 0,t,d,\"Invalid JSON-RPC error\",e)},e.getJsonRpcIdValidator=function(t){const{permitEmptyString:e,permitFractions:r,permitNull:n}={permitEmptyString:!0,permitFractions:!1,permitNull:!0,...t};return t=>Boolean(\"number\"==typeof t&&(r||Number.isInteger(t))||\"string\"==typeof t&&(e||t.length>0)||n&&null===t)}},5363:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});var i=r(932),o=r(448),s=r(7251),a=r(6710),c=48,u=58,f=87;var h=function(){const t=[];return()=>{if(0===t.length)for(let e=0;e<256;e++)t.push(e.toString(16).padStart(2,\"0\"));return t}}();function l(t){return t instanceof Uint8Array}function p(t){i.assert.call(void 0,l(t),\"Value must be a Uint8Array.\")}function d(t){if(p(t),0===t.length)return\"0x\";const e=h(),r=new Array(t.length);for(let n=0;nr.call(e,...t))),e=void 0)}return r}([t,\"optionalAccess\",t=>t.toLowerCase,\"optionalCall\",t=>t()]))return new Uint8Array;x(t);const e=R(t).toLowerCase(),r=e.length%2==0?e:`0${e}`,n=new Uint8Array(r.length/2);for(let t=0;t=BigInt(0),\"Value must be a non-negative bigint.\");return g(t.toString(16))}function w(t){i.assert.call(void 0,\"number\"==typeof t,\"Value must be a number.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative number.\"),i.assert.call(void 0,Number.isSafeInteger(t),\"Value is not a safe integer. Use `bigIntToBytes` instead.\");return g(t.toString(16))}function m(t){return i.assert.call(void 0,\"string\"==typeof t,\"Value must be a string.\"),(new TextEncoder).encode(t)}function v(t){if(\"bigint\"==typeof t)return b(t);if(\"number\"==typeof t)return w(t);if(\"string\"==typeof t)return t.startsWith(\"0x\")?g(t):m(t);if(l(t))return t;throw new TypeError(`Unsupported value type: \"${typeof t}\".`)}var E=s.pattern.call(void 0,s.string.call(void 0),/^(?:0x)?[0-9a-f]+$/iu),_=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-f]+$/iu),S=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-f]{40}$/u),A=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-fA-F]{40}$/u);function I(t){return s.is.call(void 0,t,E)}function T(t){return s.is.call(void 0,t,_)}function x(t){i.assert.call(void 0,I(t),\"Value must be a hexadecimal string.\")}function O(t){i.assert.call(void 0,s.is.call(void 0,t,A),\"Invalid hex address.\");const e=R(t.toLowerCase()),r=R(d(o.keccak_256.call(void 0,e)));return`0x${e.split(\"\").map(((t,e)=>{const n=r[e];return i.assert.call(void 0,s.is.call(void 0,n,s.string.call(void 0)),\"Hash shorter than address.\"),parseInt(n,16)>7?t.toUpperCase():t})).join(\"\")}`}function k(t){return!!s.is.call(void 0,t,A)&&O(t)===t}function P(t){return t.startsWith(\"0x\")?t:t.startsWith(\"0X\")?`0x${t.substring(2)}`:`0x${t}`}function R(t){return t.startsWith(\"0x\")||t.startsWith(\"0X\")?t.substring(2):t}e.HexStruct=E,e.StrictHexStruct=_,e.HexAddressStruct=S,e.HexChecksumAddressStruct=A,e.isHexString=I,e.isStrictHexString=T,e.assertIsHexString=x,e.assertIsStrictHexString=function(t){i.assert.call(void 0,T(t),'Value must be a hexadecimal string, starting with \"0x\".')},e.isValidHexAddress=function(t){return s.is.call(void 0,t,S)||k(t)},e.getChecksumAddress=O,e.isValidChecksumAddress=k,e.add0x=P,e.remove0x=R,e.isBytes=l,e.assertIsBytes=p,e.bytesToHex=d,e.bytesToBigInt=y,e.bytesToSignedBigInt=function(t){p(t);let e=BigInt(0);for(const r of t)e=(e<0,\"Byte length must be greater than 0.\"),i.assert.call(void 0,function(t,e){i.assert.call(void 0,e>0);const r=t>>BigInt(31);return!((~t&r)+(t&~r)>>BigInt(8*e-1))}(t,e),\"Byte length is too small to represent the given value.\");let r=t;const n=new Uint8Array(e);for(let t=0;t>=BigInt(8);return n.reverse()},e.numberToBytes=w,e.stringToBytes=m,e.base64ToBytes=function(t){return i.assert.call(void 0,\"string\"==typeof t,\"Value must be a string.\"),a.base64.decode(t)},e.valueToBytes=v,e.concatBytes=function(t){const e=new Array(t.length);let r=0;for(let n=0;n{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r,n=((r=n||{})[r.Null=4]=\"Null\",r[r.Comma=1]=\"Comma\",r[r.Wrapper=1]=\"Wrapper\",r[r.True=4]=\"True\",r[r.False=5]=\"False\",r[r.Quote=1]=\"Quote\",r[r.Colon=1]=\"Colon\",r[r.Date=24]=\"Date\",r),i=/\"|\\\\|\\n|\\r|\\t/gu;function o(t){return t.charCodeAt(0)<=127}e.isNonEmptyArray=function(t){return Array.isArray(t)&&t.length>0},e.isNullOrUndefined=function(t){return null==t},e.isObject=function(t){return Boolean(t)&&\"object\"==typeof t&&!Array.isArray(t)},e.hasProperty=(t,e)=>Object.hasOwnProperty.call(t,e),e.getKnownPropertyNames=function(t){return Object.getOwnPropertyNames(t)},e.JsonSize=n,e.ESCAPE_CHARACTERS_REGEXP=i,e.isPlainObject=function(t){if(\"object\"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}},e.isASCII=o,e.calculateStringSize=function(t){return t.split(\"\").reduce(((t,e)=>o(e)?t+1:t+2),0)+(e=t.match(i),r=()=>[],null!=e?e:r()).length;var e,r},e.calculateNumberSize=function(t){return t.toString().length}},1305:()=>{},3207:()=>{},1535:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(5363),i=r(932);e.numberToHex=t=>(i.assert.call(void 0,\"number\"==typeof t,\"Value must be a number.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative number.\"),i.assert.call(void 0,Number.isSafeInteger(t),\"Value is not a safe integer. Use `bigIntToHex` instead.\"),n.add0x.call(void 0,t.toString(16))),e.bigIntToHex=t=>(i.assert.call(void 0,\"bigint\"==typeof t,\"Value must be a bigint.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative bigint.\"),n.add0x.call(void 0,t.toString(16))),e.hexToNumber=t=>{n.assertIsHexString.call(void 0,t);const e=parseInt(t,16);return i.assert.call(void 0,Number.isSafeInteger(e),\"Value is not a safe integer. Use `hexToBigInt` instead.\"),e},e.hexToBigInt=t=>(n.assertIsHexString.call(void 0,t),BigInt(n.add0x.call(void 0,t)))},2489:(t,e,r)=>{\"use strict\";function n(t){let e,r=t[0],n=1;for(;nr.call(e,...t))),e=void 0)}return r}Object.defineProperty(e,\"__esModule\",{value:!0});var i,o=r(7251),s=/^(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})$/u,a=/^[-a-z0-9]{3,8}$/u,c=/^[-_a-zA-Z0-9]{1,32}$/u,u=/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})):(?[-.%a-zA-Z0-9]{1,128})$/u,f=/^[-.%a-zA-Z0-9]{1,128}$/u,h=o.pattern.call(void 0,o.string.call(void 0),s),l=o.pattern.call(void 0,o.string.call(void 0),a),p=o.pattern.call(void 0,o.string.call(void 0),c),d=o.pattern.call(void 0,o.string.call(void 0),u),y=o.pattern.call(void 0,o.string.call(void 0),f),g=((i=g||{}).Eip155=\"eip155\",i);function b(t){return o.is.call(void 0,t,l)}function w(t){return o.is.call(void 0,t,p)}e.CAIP_CHAIN_ID_REGEX=s,e.CAIP_NAMESPACE_REGEX=a,e.CAIP_REFERENCE_REGEX=c,e.CAIP_ACCOUNT_ID_REGEX=u,e.CAIP_ACCOUNT_ADDRESS_REGEX=f,e.CaipChainIdStruct=h,e.CaipNamespaceStruct=l,e.CaipReferenceStruct=p,e.CaipAccountIdStruct=d,e.CaipAccountAddressStruct=y,e.KnownCaipNamespace=g,e.isCaipChainId=function(t){return o.is.call(void 0,t,h)},e.isCaipNamespace=b,e.isCaipReference=w,e.isCaipAccountId=function(t){return o.is.call(void 0,t,d)},e.isCaipAccountAddress=function(t){return o.is.call(void 0,t,y)},e.parseCaipChainId=function(t){const e=s.exec(t);if(!n([e,\"optionalAccess\",t=>t.groups]))throw new Error(\"Invalid CAIP chain ID.\");return{namespace:e.groups.namespace,reference:e.groups.reference}},e.parseCaipAccountId=function(t){const e=u.exec(t);if(!n([e,\"optionalAccess\",t=>t.groups]))throw new Error(\"Invalid CAIP account ID.\");return{address:e.groups.accountAddress,chainId:e.groups.chainId,chain:{namespace:e.groups.namespace,reference:e.groups.reference}}},e.toCaipChainId=function(t,e){if(!b(t))throw new Error(`Invalid \"namespace\", must match: ${a.toString()}`);if(!w(e))throw new Error(`Invalid \"reference\", must match: ${c.toString()}`);return`${t}:${e}`}},1584:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n,i,o=r(5244),s=class{constructor(t){o.__privateAdd.call(void 0,this,n,void 0),o.__privateSet.call(void 0,this,n,new Map(t)),Object.freeze(this)}get size(){return o.__privateGet.call(void 0,this,n).size}[Symbol.iterator](){return o.__privateGet.call(void 0,this,n)[Symbol.iterator]()}entries(){return o.__privateGet.call(void 0,this,n).entries()}forEach(t,e){return o.__privateGet.call(void 0,this,n).forEach(((r,n,i)=>t.call(e,r,n,this)))}get(t){return o.__privateGet.call(void 0,this,n).get(t)}has(t){return o.__privateGet.call(void 0,this,n).has(t)}keys(){return o.__privateGet.call(void 0,this,n).keys()}values(){return o.__privateGet.call(void 0,this,n).values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map((([t,e])=>`${String(t)} => ${String(e)}`)).join(\", \")} `:\"\"}}`}};n=new WeakMap;var a=class{constructor(t){o.__privateAdd.call(void 0,this,i,void 0),o.__privateSet.call(void 0,this,i,new Set(t)),Object.freeze(this)}get size(){return o.__privateGet.call(void 0,this,i).size}[Symbol.iterator](){return o.__privateGet.call(void 0,this,i)[Symbol.iterator]()}entries(){return o.__privateGet.call(void 0,this,i).entries()}forEach(t,e){return o.__privateGet.call(void 0,this,i).forEach(((r,n,i)=>t.call(e,r,n,this)))}has(t){return o.__privateGet.call(void 0,this,i).has(t)}keys(){return o.__privateGet.call(void 0,this,i).keys()}values(){return o.__privateGet.call(void 0,this,i).values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map((t=>String(t))).join(\", \")} `:\"\"}}`}};i=new WeakMap,Object.freeze(s),Object.freeze(s.prototype),Object.freeze(a),Object.freeze(a.prototype),e.FrozenMap=s,e.FrozenSet=a},2049:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),r(7982);var n=r(1535);r(8383);var i=r(9705),o=r(9116);r(3207);var s=r(3631),a=r(7427);r(1305);var c=r(1275),u=r(2489),f=r(1508),h=r(1848),l=r(1203),p=r(5363),d=r(932),y=r(1486),g=r(6526),b=r(1584);r(5244),r(1423),e.AssertionError=d.AssertionError,e.CAIP_ACCOUNT_ADDRESS_REGEX=u.CAIP_ACCOUNT_ADDRESS_REGEX,e.CAIP_ACCOUNT_ID_REGEX=u.CAIP_ACCOUNT_ID_REGEX,e.CAIP_CHAIN_ID_REGEX=u.CAIP_CHAIN_ID_REGEX,e.CAIP_NAMESPACE_REGEX=u.CAIP_NAMESPACE_REGEX,e.CAIP_REFERENCE_REGEX=u.CAIP_REFERENCE_REGEX,e.CaipAccountAddressStruct=u.CaipAccountAddressStruct,e.CaipAccountIdStruct=u.CaipAccountIdStruct,e.CaipChainIdStruct=u.CaipChainIdStruct,e.CaipNamespaceStruct=u.CaipNamespaceStruct,e.CaipReferenceStruct=u.CaipReferenceStruct,e.ChecksumStruct=f.ChecksumStruct,e.Duration=o.Duration,e.ESCAPE_CHARACTERS_REGEXP=g.ESCAPE_CHARACTERS_REGEXP,e.FrozenMap=b.FrozenMap,e.FrozenSet=b.FrozenSet,e.HexAddressStruct=p.HexAddressStruct,e.HexChecksumAddressStruct=p.HexChecksumAddressStruct,e.HexStruct=p.HexStruct,e.JsonRpcErrorStruct=a.JsonRpcErrorStruct,e.JsonRpcFailureStruct=a.JsonRpcFailureStruct,e.JsonRpcIdStruct=a.JsonRpcIdStruct,e.JsonRpcNotificationStruct=a.JsonRpcNotificationStruct,e.JsonRpcParamsStruct=a.JsonRpcParamsStruct,e.JsonRpcRequestStruct=a.JsonRpcRequestStruct,e.JsonRpcResponseStruct=a.JsonRpcResponseStruct,e.JsonRpcSuccessStruct=a.JsonRpcSuccessStruct,e.JsonRpcVersionStruct=a.JsonRpcVersionStruct,e.JsonSize=g.JsonSize,e.JsonStruct=a.JsonStruct,e.KnownCaipNamespace=u.KnownCaipNamespace,e.PendingJsonRpcResponseStruct=a.PendingJsonRpcResponseStruct,e.StrictHexStruct=p.StrictHexStruct,e.UnsafeJsonStruct=a.UnsafeJsonStruct,e.VersionRangeStruct=s.VersionRangeStruct,e.VersionStruct=s.VersionStruct,e.add0x=p.add0x,e.assert=d.assert,e.assertExhaustive=d.assertExhaustive,e.assertIsBytes=p.assertIsBytes,e.assertIsHexString=p.assertIsHexString,e.assertIsJsonRpcError=a.assertIsJsonRpcError,e.assertIsJsonRpcFailure=a.assertIsJsonRpcFailure,e.assertIsJsonRpcNotification=a.assertIsJsonRpcNotification,e.assertIsJsonRpcRequest=a.assertIsJsonRpcRequest,e.assertIsJsonRpcResponse=a.assertIsJsonRpcResponse,e.assertIsJsonRpcSuccess=a.assertIsJsonRpcSuccess,e.assertIsPendingJsonRpcResponse=a.assertIsPendingJsonRpcResponse,e.assertIsSemVerRange=s.assertIsSemVerRange,e.assertIsSemVerVersion=s.assertIsSemVerVersion,e.assertIsStrictHexString=p.assertIsStrictHexString,e.assertStruct=d.assertStruct,e.base64=h.base64,e.base64ToBytes=p.base64ToBytes,e.bigIntToBytes=p.bigIntToBytes,e.bigIntToHex=n.bigIntToHex,e.bytesToBase64=p.bytesToBase64,e.bytesToBigInt=p.bytesToBigInt,e.bytesToHex=p.bytesToHex,e.bytesToNumber=p.bytesToNumber,e.bytesToSignedBigInt=p.bytesToSignedBigInt,e.bytesToString=p.bytesToString,e.calculateNumberSize=g.calculateNumberSize,e.calculateStringSize=g.calculateStringSize,e.concatBytes=p.concatBytes,e.createBigInt=l.createBigInt,e.createBytes=l.createBytes,e.createDataView=p.createDataView,e.createDeferredPromise=i.createDeferredPromise,e.createHex=l.createHex,e.createModuleLogger=c.createModuleLogger,e.createNumber=l.createNumber,e.createProjectLogger=c.createProjectLogger,e.exactOptional=a.exactOptional,e.getChecksumAddress=p.getChecksumAddress,e.getErrorMessage=y.getErrorMessage,e.getJsonRpcIdValidator=a.getJsonRpcIdValidator,e.getJsonSize=a.getJsonSize,e.getKnownPropertyNames=g.getKnownPropertyNames,e.getSafeJson=a.getSafeJson,e.gtRange=s.gtRange,e.gtVersion=s.gtVersion,e.hasProperty=g.hasProperty,e.hexToBigInt=n.hexToBigInt,e.hexToBytes=p.hexToBytes,e.hexToNumber=n.hexToNumber,e.inMilliseconds=o.inMilliseconds,e.isASCII=g.isASCII,e.isBytes=p.isBytes,e.isCaipAccountAddress=u.isCaipAccountAddress,e.isCaipAccountId=u.isCaipAccountId,e.isCaipChainId=u.isCaipChainId,e.isCaipNamespace=u.isCaipNamespace,e.isCaipReference=u.isCaipReference,e.isErrorWithCode=y.isErrorWithCode,e.isErrorWithMessage=y.isErrorWithMessage,e.isErrorWithStack=y.isErrorWithStack,e.isHexString=p.isHexString,e.isJsonRpcError=a.isJsonRpcError,e.isJsonRpcFailure=a.isJsonRpcFailure,e.isJsonRpcNotification=a.isJsonRpcNotification,e.isJsonRpcRequest=a.isJsonRpcRequest,e.isJsonRpcResponse=a.isJsonRpcResponse,e.isJsonRpcSuccess=a.isJsonRpcSuccess,e.isNonEmptyArray=g.isNonEmptyArray,e.isNullOrUndefined=g.isNullOrUndefined,e.isObject=g.isObject,e.isPendingJsonRpcResponse=a.isPendingJsonRpcResponse,e.isPlainObject=g.isPlainObject,e.isStrictHexString=p.isStrictHexString,e.isValidChecksumAddress=p.isValidChecksumAddress,e.isValidHexAddress=p.isValidHexAddress,e.isValidJson=a.isValidJson,e.isValidSemVerRange=s.isValidSemVerRange,e.isValidSemVerVersion=s.isValidSemVerVersion,e.jsonrpc2=a.jsonrpc2,e.numberToBytes=p.numberToBytes,e.numberToHex=n.numberToHex,e.object=a.object,e.parseCaipAccountId=u.parseCaipAccountId,e.parseCaipChainId=u.parseCaipChainId,e.remove0x=p.remove0x,e.satisfiesVersionRange=s.satisfiesVersionRange,e.signedBigIntToBytes=p.signedBigIntToBytes,e.stringToBytes=p.stringToBytes,e.timeSince=o.timeSince,e.toCaipChainId=u.toCaipChainId,e.valueToBytes=p.valueToBytes,e.wrapError=y.wrapError},2028:()=>{},3011:()=>{},3951:()=>{},7251:(t,e,r)=>{\"use strict\";r.r(e),r.d(e,{Struct:()=>f,StructError:()=>n,any:()=>I,array:()=>T,assert:()=>h,assign:()=>g,bigint:()=>x,boolean:()=>O,coerce:()=>J,create:()=>l,date:()=>k,defaulted:()=>Y,define:()=>b,deprecated:()=>w,dynamic:()=>m,empty:()=>Q,enums:()=>P,func:()=>R,instance:()=>B,integer:()=>C,intersection:()=>N,is:()=>d,lazy:()=>v,literal:()=>L,map:()=>U,mask:()=>p,max:()=>et,min:()=>rt,never:()=>j,nonempty:()=>nt,nullable:()=>M,number:()=>H,object:()=>F,omit:()=>E,optional:()=>D,partial:()=>_,pattern:()=>it,pick:()=>S,record:()=>$,refine:()=>st,regexp:()=>K,set:()=>V,size:()=>ot,string:()=>G,struct:()=>A,trimmed:()=>Z,tuple:()=>q,type:()=>W,union:()=>X,unknown:()=>z,validate:()=>y});class n extends TypeError{constructor(t,e){let r;const{message:n,explanation:i,...o}=t,{path:s}=t,a=0===s.length?n:`At path: ${s.join(\".\")} -- ${n}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function i(t){return\"object\"==typeof t&&null!=t}function o(t){if(\"[object Object]\"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function s(t){return\"symbol\"==typeof t?t.toString():\"string\"==typeof t?JSON.stringify(t):`${t}`}function a(t,e,r,n){if(!0===t)return;!1===t?t={}:\"string\"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:a}=r,{refinement:c,message:u=`Expected a value of type \\`${a}\\`${c?` with refinement \\`${c}\\``:\"\"}, but received: \\`${s(n)}\\``}=t;return{value:n,type:a,refinement:c,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*c(t,e,r,n){var o;i(o=t)&&\"function\"==typeof o[Symbol.iterator]||(t=[t]);for(const i of t){const t=a(i,e,r,n);t&&(yield t)}}function*u(t,e,r={}){const{path:n=[],branch:o=[t],coerce:s=!1,mask:a=!1}=r,c={path:n,branch:o};if(s&&(t=e.coercer(t,c),a&&\"type\"!==e.type&&i(e.schema)&&i(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let f=\"valid\";for(const n of e.validator(t,c))n.explanation=r.message,f=\"not_valid\",yield[n,void 0];for(let[h,l,p]of e.entries(t,c)){const e=u(l,p,{path:void 0===h?n:[...n,h],branch:void 0===h?o:[...o,l],coerce:s,mask:a,message:r.message});for(const r of e)r[0]?(f=null!=r[0].refinement?\"not_refined\":\"not_valid\",yield[r[0],void 0]):s&&(l=r[1],void 0===h?t=l:t instanceof Map?t.set(h,l):t instanceof Set?t.add(l):i(t)&&(void 0!==l||h in t)&&(t[h]=l))}if(\"not_valid\"!==f)for(const n of e.refiner(t,c))n.explanation=r.message,f=\"not_refined\",yield[n,void 0];\"valid\"===f&&(yield[void 0,t])}class f{constructor(t){const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>c(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>c(i(t,e),e,this,t):()=>[]}assert(t,e){return h(t,this,e)}create(t,e){return l(t,this,e)}is(t){return d(t,this)}mask(t,e){return p(t,this,e)}validate(t,e={}){return y(t,this,e)}}function h(t,e,r){const n=y(t,e,{message:r});if(n[0])throw n[0]}function l(t,e,r){const n=y(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function p(t,e,r){const n=y(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function d(t,e){return!y(t,e)[0]}function y(t,e,r={}){const i=u(t,e,r),o=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(i);if(o[0]){return[new n(o[0],(function*(){for(const t of i)t[0]&&(yield t[0])})),void 0]}return[void 0,o[1]]}function g(...t){const e=\"type\"===t[0].type,r=t.map((t=>t.schema)),n=Object.assign({},...r);return e?W(n):F(n)}function b(t,e){return new f({type:t,schema:null,validator:e})}function w(t,e){return new f({...t,refiner:(e,r)=>void 0===e||t.refiner(e,r),validator:(r,n)=>void 0===r||(e(r,n),t.validator(r,n))})}function m(t){return new f({type:\"dynamic\",schema:null,*entries(e,r){const n=t(e,r);yield*n.entries(e,r)},validator:(e,r)=>t(e,r).validator(e,r),coercer:(e,r)=>t(e,r).coercer(e,r),refiner:(e,r)=>t(e,r).refiner(e,r)})}function v(t){let e;return new f({type:\"lazy\",schema:null,*entries(r,n){e??(e=t()),yield*e.entries(r,n)},validator:(r,n)=>(e??(e=t()),e.validator(r,n)),coercer:(r,n)=>(e??(e=t()),e.coercer(r,n)),refiner:(r,n)=>(e??(e=t()),e.refiner(r,n))})}function E(t,e){const{schema:r}=t,n={...r};for(const t of e)delete n[t];return\"type\"===t.type?W(n):F(n)}function _(t){const e=t instanceof f?{...t.schema}:{...t};for(const t in e)e[t]=D(e[t]);return F(e)}function S(t,e){const{schema:r}=t,n={};for(const t of e)n[t]=r[t];return F(n)}function A(t,e){return console.warn(\"superstruct@0.11 - The `struct` helper has been renamed to `define`.\"),b(t,e)}function I(){return b(\"any\",(()=>!0))}function T(t){return new f({type:\"array\",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||`Expected an array value, but received: ${s(t)}`})}function x(){return b(\"bigint\",(t=>\"bigint\"==typeof t))}function O(){return b(\"boolean\",(t=>\"boolean\"==typeof t))}function k(){return b(\"date\",(t=>t instanceof Date&&!isNaN(t.getTime())||`Expected a valid \\`Date\\` object, but received: ${s(t)}`))}function P(t){const e={},r=t.map((t=>s(t))).join();for(const r of t)e[r]=r;return new f({type:\"enums\",schema:e,validator:e=>t.includes(e)||`Expected one of \\`${r}\\`, but received: ${s(e)}`})}function R(){return b(\"func\",(t=>\"function\"==typeof t||`Expected a function, but received: ${s(t)}`))}function B(t){return b(\"instance\",(e=>e instanceof t||`Expected a \\`${t.name}\\` instance, but received: ${s(e)}`))}function C(){return b(\"integer\",(t=>\"number\"==typeof t&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${s(t)}`))}function N(t){return new f({type:\"intersection\",schema:null,*entries(e,r){for(const n of t)yield*n.entries(e,r)},*validator(e,r){for(const n of t)yield*n.validator(e,r)},*refiner(e,r){for(const n of t)yield*n.refiner(e,r)}})}function L(t){const e=s(t),r=typeof t;return new f({type:\"literal\",schema:\"string\"===r||\"number\"===r||\"boolean\"===r?t:null,validator:r=>r===t||`Expected the literal \\`${e}\\`, but received: ${s(r)}`})}function U(t,e){return new f({type:\"map\",schema:null,*entries(r){if(t&&e&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,t],yield[n,i,e]},coercer:t=>t instanceof Map?new Map(t):t,validator:t=>t instanceof Map||`Expected a \\`Map\\` object, but received: ${s(t)}`})}function j(){return b(\"never\",(()=>!1))}function M(t){return new f({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function H(){return b(\"number\",(t=>\"number\"==typeof t&&!isNaN(t)||`Expected a number, but received: ${s(t)}`))}function F(t){const e=t?Object.keys(t):[],r=j();return new f({type:\"object\",schema:t||null,*entries(n){if(t&&i(n)){const i=new Set(Object.keys(n));for(const r of e)i.delete(r),yield[r,n[r],t[r]];for(const t of i)yield[t,n[t],r]}},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`,coercer:t=>i(t)?{...t}:t})}function D(t){return new f({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function $(t,e){return new f({type:\"record\",schema:null,*entries(r){if(i(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`})}function K(){return b(\"regexp\",(t=>t instanceof RegExp))}function V(t){return new f({type:\"set\",schema:null,*entries(e){if(t&&e instanceof Set)for(const r of e)yield[r,r,t]},coercer:t=>t instanceof Set?new Set(t):t,validator:t=>t instanceof Set||`Expected a \\`Set\\` object, but received: ${s(t)}`})}function G(){return b(\"string\",(t=>\"string\"==typeof t||`Expected a string, but received: ${s(t)}`))}function q(t){const e=j();return new f({type:\"tuple\",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;iArray.isArray(t)||`Expected an array, but received: ${s(t)}`})}function W(t){const e=Object.keys(t);return new f({type:\"type\",schema:t,*entries(r){if(i(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`,coercer:t=>i(t)?{...t}:t})}function X(t){const e=t.map((t=>t.type)).join(\" | \");return new f({type:\"union\",schema:null,coercer(e){for(const r of t){const[t,n]=r.validate(e,{coerce:!0});if(!t)return n}return e},validator(r,n){const i=[];for(const e of t){const[...t]=u(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return[`Expected the value to satisfy a union of \\`${e}\\`, but received: ${s(r)}`,...i]}})}function z(){return b(\"unknown\",(()=>!0))}function J(t,e,r){return new f({...t,coercer:(n,i)=>d(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}function Y(t,e,r={}){return J(t,z(),(t=>{const n=\"function\"==typeof e?e():e;if(void 0===t)return n;if(!r.strict&&o(t)&&o(n)){const e={...t};let r=!1;for(const t in n)void 0===e[t]&&(e[t]=n[t],r=!0);if(r)return e}return t}))}function Z(t){return J(t,G(),(t=>t.trim()))}function Q(t){return st(t,\"empty\",(e=>{const r=tt(e);return 0===r||`Expected an empty ${t.type} but received one with a size of \\`${r}\\``}))}function tt(t){return t instanceof Map||t instanceof Set?t.size:t.length}function et(t,e,r={}){const{exclusive:n}=r;return st(t,\"max\",(r=>n?rn?r>e:r>=e||`Expected a ${t.type} greater than ${n?\"\":\"or equal to \"}${e} but received \\`${r}\\``))}function nt(t){return st(t,\"nonempty\",(e=>tt(e)>0||`Expected a nonempty ${t.type} but received an empty one`))}function it(t,e){return st(t,\"pattern\",(r=>e.test(r)||`Expected a ${t.type} matching \\`/${e.source}/\\` but received \"${r}\"`))}function ot(t,e,r=e){const n=`Expected a ${t.type}`,i=e===r?`of \\`${e}\\``:`between \\`${e}\\` and \\`${r}\\``;return st(t,\"size\",(t=>{if(\"number\"==typeof t||t instanceof Date)return e<=t&&t<=r||`${n} ${i} but received \\`${t}\\``;if(t instanceof Map||t instanceof Set){const{size:o}=t;return e<=o&&o<=r||`${n} with a size ${i} but received one with a size of \\`${o}\\``}{const{length:o}=t;return e<=o&&o<=r||`${n} with a length ${i} but received one with a length of \\`${o}\\``}}))}function st(t,e,r){return new f({...t,*refiner(n,i){yield*t.refiner(n,i);const o=c(r(n,i),i,t,n);for(const t of o)yield{...t,refinement:e}}})}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if(\"object\"==typeof globalThis)return globalThis;try{return this||new Function(\"return this\")()}catch(t){if(\"object\"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})};var n={};(()=>{\"use strict\";r.r(n),r.d(n,{onKeyringRequest:()=>Zn,onRpcRequest:()=>Yn,validateOrigin:()=>Jn});var t=r(7962);function e(t){return Boolean(t)&&\"object\"==typeof t&&!Array.isArray(t)}var i=(t,e)=>Object.hasOwnProperty.call(t,e);var o,s=((o=s||{})[o.Null=4]=\"Null\",o[o.Comma=1]=\"Comma\",o[o.Wrapper=1]=\"Wrapper\",o[o.True=4]=\"True\",o[o.False=5]=\"False\",o[o.Quote=1]=\"Quote\",o[o.Colon=1]=\"Colon\",o[o.Date=24]=\"Date\",o);function a(t){if(\"object\"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}}Error;var c=r(7251);function u(t){return function(t){return function(t){return\"object\"==typeof t&&null!==t&&\"message\"in t}(t)&&\"string\"==typeof t.message?t.message:null==t?\"\":String(t)}(t).replace(/\\.$/u,\"\")}function f(t,e){return r=t,Boolean(\"string\"==typeof r?.prototype?.constructor?.name)?new t({message:e}):t({message:e});var r}var h=class extends Error{constructor(t){super(t.message),this.code=\"ERR_ASSERTION\"}};function l(t,e=\"Assertion failed.\",r=h){if(!t){if(e instanceof Error)throw e;throw f(r,e)}}function p(t,e,r=\"Assertion failed\",n=h){try{(0,c.assert)(t,e)}catch(t){throw f(n,`${r}: ${u(t)}.`)}}var d=t=>(0,c.object)(t);function y({path:t,branch:e}){const r=t[t.length-1];return i(e[e.length-2],r)}function g(t){return new c.Struct({...t,type:`optional ${t.type}`,validator:(e,r)=>!y(r)||t.validator(e,r),refiner:(e,r)=>!y(r)||t.refiner(e,r)})}var b=(0,c.union)([(0,c.literal)(null),(0,c.boolean)(),(0,c.define)(\"finite number\",(t=>(0,c.is)(t,(0,c.number)())&&Number.isFinite(t))),(0,c.string)(),(0,c.array)((0,c.lazy)((()=>b))),(0,c.record)((0,c.string)(),(0,c.lazy)((()=>b)))]),w=(0,c.coerce)(b,(0,c.any)(),(t=>(p(t,b),JSON.parse(JSON.stringify(t,((t,e)=>{if(\"__proto__\"!==t&&\"constructor\"!==t)return e}))))));function m(t){try{return function(t){(0,c.create)(t,w)}(t),!0}catch{return!1}}var v=(0,c.literal)(\"2.0\"),E=(0,c.nullable)((0,c.union)([(0,c.number)(),(0,c.string)()])),_=d({code:(0,c.integer)(),message:(0,c.string)(),data:g(w),stack:g((0,c.string)())}),S=(0,c.union)([(0,c.record)((0,c.string)(),w),(0,c.array)(w)]);d({id:E,jsonrpc:v,method:(0,c.string)(),params:g(S)}),d({jsonrpc:v,method:(0,c.string)(),params:g(S)});(0,c.object)({id:E,jsonrpc:v,result:(0,c.optional)((0,c.unknown)()),error:(0,c.optional)(_)});var A=d({id:E,jsonrpc:v,result:w}),I=d({id:E,jsonrpc:v,error:_});(0,c.union)([A,I]);var T=r(2763),x={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},O={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},k={\"-32700\":{standard:\"JSON RPC 2.0\",message:\"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.\"},\"-32600\":{standard:\"JSON RPC 2.0\",message:\"The JSON sent is not a valid Request object.\"},\"-32601\":{standard:\"JSON RPC 2.0\",message:\"The method does not exist / is not available.\"},\"-32602\":{standard:\"JSON RPC 2.0\",message:\"Invalid method parameter(s).\"},\"-32603\":{standard:\"JSON RPC 2.0\",message:\"Internal JSON-RPC error.\"},\"-32000\":{standard:\"EIP-1474\",message:\"Invalid input.\"},\"-32001\":{standard:\"EIP-1474\",message:\"Resource not found.\"},\"-32002\":{standard:\"EIP-1474\",message:\"Resource unavailable.\"},\"-32003\":{standard:\"EIP-1474\",message:\"Transaction rejected.\"},\"-32004\":{standard:\"EIP-1474\",message:\"Method not supported.\"},\"-32005\":{standard:\"EIP-1474\",message:\"Request limit exceeded.\"},4001:{standard:\"EIP-1193\",message:\"User rejected the request.\"},4100:{standard:\"EIP-1193\",message:\"The requested account and/or method has not been authorized by the user.\"},4200:{standard:\"EIP-1193\",message:\"The requested method is not supported by this Ethereum provider.\"},4900:{standard:\"EIP-1193\",message:\"The provider is disconnected from all chains.\"},4901:{standard:\"EIP-1193\",message:\"The provider is disconnected from the specified chain.\"}},P=x.internal,R=\"Unspecified error message. This is a bug, please report it.\",B=(C(P),\"Unspecified server error.\");function C(t,e=R){if(function(t){return Number.isInteger(t)}(t)){const e=t.toString();if(i(k,e))return k[e].message;if(function(t){return t>=-32099&&t<=-32e3}(t))return B}return e}function N(t){return Array.isArray(t)?t.map((t=>m(t)?t:e(t)?L(t):null)):e(t)?L(t):m(t)?t:null}function L(t){return Object.getOwnPropertyNames(t).reduce(((e,r)=>{const n=t[r];return m(n)&&(e[r]=n),e}),{})}var U=r(282),j=class extends Error{constructor(t,e,r){if(!Number.isInteger(t))throw new Error('\"code\" must be an integer.');if(!e||\"string\"!=typeof e)throw new Error('\"message\" must be a non-empty string.');super(e),this.code=t,void 0!==r&&(this.data=r)}serialize(){const t={code:this.code,message:this.message};return void 0!==this.data&&(t.data=this.data,a(this.data)&&(t.data.cause=N(this.data.cause))),this.stack&&(t.stack=this.stack),t}toString(){return U(this.serialize(),H,2)}},M=class extends j{constructor(t,e,r){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('\"code\" must be an integer such that: 1000 <= code <= 4999');super(t,e,r)}};function H(t,e){if(\"[Circular]\"!==e)return e}var F=t=>rt(x.parse,t),D=t=>rt(x.invalidRequest,t),$=t=>rt(x.invalidParams,t),K=t=>rt(x.methodNotFound,t),V=t=>rt(x.internal,t),G=t=>rt(x.invalidInput,t),q=t=>rt(x.resourceNotFound,t),W=t=>rt(x.resourceUnavailable,t),X=t=>rt(x.transactionRejected,t),z=t=>rt(x.methodNotSupported,t),J=t=>rt(x.limitExceeded,t),Y=t=>nt(O.userRejectedRequest,t),Z=t=>nt(O.unauthorized,t),Q=t=>nt(O.unsupportedMethod,t),tt=t=>nt(O.disconnected,t),et=t=>nt(O.chainDisconnected,t);function rt(t,e){const[r,n]=it(e);return new j(t,r??C(t),n)}function nt(t,e){const[r,n]=it(e);return new M(t,r??C(t),n)}function it(t){if(t){if(\"string\"==typeof t)return[t];if(\"object\"==typeof t&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&\"string\"!=typeof e)throw new Error(\"Must specify string message.\");return[e??void 0,r]}}return[]}r(1048).Buffer;!function(){const t=[]}();(0,c.pattern)((0,c.string)(),/^(?:0x)?[0-9a-f]+$/iu),(0,c.pattern)((0,c.string)(),/^0x[0-9a-f]+$/iu),(0,c.pattern)((0,c.string)(),/^0x[0-9a-f]{40}$/u);var ot=(0,c.pattern)((0,c.string)(),/^0x[0-9a-fA-F]{40}$/u);var st,at,ct,ut,ft=(t,e,r)=>{if(!e.has(t))throw TypeError(\"Cannot \"+r)},ht=(t,e,r)=>(ft(t,e,\"read from private field\"),r?r.call(t):e.get(t)),lt=(t,e,r)=>{if(e.has(t))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(t):e.set(t,r)},pt=(t,e,r,n)=>(ft(t,e,\"write to private field\"),n?n.call(t,r):e.set(t,r),r),dt=class extends Error{constructor(t,r={}){const n=function(t){if(e(t)&&i(t,\"message\")&&\"string\"==typeof t.message)return t.message;return String(t)}(t);super(n),lt(this,st,void 0),lt(this,at,void 0),lt(this,ct,void 0),lt(this,ut,void 0),pt(this,at,n),pt(this,st,function(t){if(e(t)&&i(t,\"code\")&&\"number\"==typeof t.code&&Number.isInteger(t.code))return t.code;return-32603}(t));const o={...wt(t),...r};Object.keys(o).length>0&&pt(this,ct,o),pt(this,ut,super.stack)}get name(){return\"SnapError\"}get code(){return ht(this,st)}get message(){return ht(this,at)}get data(){return ht(this,ct)}get stack(){return ht(this,ut)}toJSON(){return{code:gt,message:bt,data:{cause:{code:this.code,message:this.message,stack:this.stack,...this.data?{data:this.data}:{}}}}}serialize(){return this.toJSON()}};function yt(t){return class extends dt{constructor(e,r){if(\"object\"==typeof e){const r=t();return void super({code:r.code,message:r.message,data:e})}const n=t(e);super({code:n.code,message:n.message,data:r})}}}st=new WeakMap,at=new WeakMap,ct=new WeakMap,ut=new WeakMap;var gt=-31002,bt=\"Snap Error\";function wt(t){return e(t)&&i(t,\"data\")&&\"object\"==typeof t.data&&null!==t.data&&m(t.data)&&!Array.isArray(t.data)?t.data:{}}function mt(t){return(0,c.define)(JSON.stringify(t),(0,c.literal)(t).validator)}function vt(t){return mt(t)}function Et(t){return function([t,...e]){const r=(0,c.union)([t,...e]);return new c.Struct({...r,schema:[t,...e]})}(t)}function _t(t){try{return function(t){try{const r=t.trim();l(r.length>0);const n=new T.XMLParser({ignoreAttributes:!1,parseAttributeValue:!0}).parse(r,!0);return l(i(n,\"svg\")),e(n.svg)?n.svg:{}}catch{throw new Error(\"Snap icon must be a valid SVG.\")}}(t),!0}catch{return!1}}var St=yt(V),At=yt(G),It=yt($),Tt=yt(D),xt=yt(J),Ot=yt(K),kt=yt(z),Pt=yt(F),Rt=yt(q),Bt=yt(W),Ct=yt(X),Nt=yt(et),Lt=yt(tt),Ut=yt(Z),jt=yt(Q),Mt=yt(Y);function Ht(t,e,r=[]){return(...n)=>{if(1===n.length&&a(n[0])){const r={...n[0],type:t};return p(r,e,`Invalid ${t} component`),r}const i=r.reduce(((t,e,r)=>void 0!==n[r]?{...t,[e]:n[r]}:t),{type:t});return p(i,e,`Invalid ${t} component`),i}}var Ft,Dt=((Ft=Dt||{}).Copyable=\"copyable\",Ft.Divider=\"divider\",Ft.Heading=\"heading\",Ft.Panel=\"panel\",Ft.Spinner=\"spinner\",Ft.Text=\"text\",Ft.Image=\"image\",Ft.Row=\"row\",Ft.Address=\"address\",Ft.Button=\"button\",Ft.Input=\"input\",Ft.Form=\"form\",Ft),$t=(0,c.object)({type:(0,c.string)()}),Kt=(0,c.assign)($t,(0,c.object)({value:(0,c.unknown)()})),Vt=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"address\"),value:ot})),Gt=(Ht(\"address\",Vt,[\"value\"]),(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"copyable\"),value:(0,c.string)(),sensitive:(0,c.optional)((0,c.boolean)())}))),qt=(Ht(\"copyable\",Gt,[\"value\",\"sensitive\"]),(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"divider\")}))),Wt=Ht(\"divider\",qt),Xt=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"heading\"),value:(0,c.string)()})),zt=Ht(\"heading\",Xt,[\"value\"]);var Jt,Yt,Zt,Qt,te=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"image\"),value:(0,c.refine)((0,c.string)(),\"SVG\",(t=>!!_t(t)||\"Value is not a valid SVG.\"))})),ee=(Ht(\"image\",te,[\"value\"]),(Jt=ee||{}).Primary=\"primary\",Jt.Secondary=\"secondary\",Jt),re=((Yt=re||{}).Button=\"button\",Yt.Submit=\"submit\",Yt),ne=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"button\"),value:(0,c.string)(),variant:(0,c.optional)((0,c.union)([vt(\"primary\"),vt(\"secondary\")])),buttonType:(0,c.optional)((0,c.union)([vt(\"button\"),vt(\"submit\")])),name:(0,c.optional)((0,c.string)())})),ie=(Ht(\"button\",ne,[\"value\",\"buttonType\",\"name\",\"variant\"]),(Zt=ie||{}).Text=\"text\",Zt.Number=\"number\",Zt.Password=\"password\",Zt),oe=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"input\"),value:(0,c.optional)((0,c.string)()),name:(0,c.string)(),inputType:(0,c.optional)((0,c.union)([vt(\"text\"),vt(\"password\"),vt(\"number\")])),placeholder:(0,c.optional)((0,c.string)()),label:(0,c.optional)((0,c.string)()),error:(0,c.optional)((0,c.string)())})),se=(Ht(\"input\",oe,[\"name\",\"inputType\",\"placeholder\",\"value\",\"label\"]),(0,c.union)([oe,ne])),ae=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"form\"),children:(0,c.array)(se),name:(0,c.string)()})),ce=(Ht(\"form\",ae,[\"name\",\"children\"]),(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"text\"),value:(0,c.string)(),markdown:(0,c.optional)((0,c.boolean)())}))),ue=Ht(\"text\",ce,[\"value\",\"markdown\"]),fe=((Qt=fe||{}).Default=\"default\",Qt.Critical=\"critical\",Qt.Warning=\"warning\",Qt),he=(0,c.union)([te,ce,Vt]),le=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"row\"),variant:(0,c.optional)((0,c.union)([vt(\"default\"),vt(\"critical\"),vt(\"warning\")])),label:(0,c.string)(),value:he})),pe=Ht(\"row\",le,[\"label\",\"value\",\"variant\"]),de=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"spinner\")})),ye=(Ht(\"spinner\",de),(0,c.assign)($t,(0,c.object)({children:(0,c.array)((0,c.lazy)((()=>we)))}))),ge=(0,c.assign)(ye,(0,c.object)({type:(0,c.literal)(\"panel\")})),be=Ht(\"panel\",ge,[\"children\"]),we=(0,c.union)([Gt,qt,Xt,te,ge,de,ce,le,Vt,oe,ae,ne]);var me,ve,Ee,_e,Se,Ae,Ie=((me=Ie||{}).Critical=\"critical\",me),Te=((ve=Te||{}).ButtonClickEvent=\"ButtonClickEvent\",ve.FormSubmitEvent=\"FormSubmitEvent\",ve.InputChangeEvent=\"InputChangeEvent\",ve),xe=(0,c.object)({type:(0,c.string)(),name:(0,c.optional)((0,c.string)())}),Oe=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"ButtonClickEvent\"),name:(0,c.optional)((0,c.string)())})),ke=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"FormSubmitEvent\"),value:(0,c.record)((0,c.string)(),(0,c.nullable)((0,c.string)())),name:(0,c.string)()})),Pe=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"InputChangeEvent\"),name:(0,c.string)(),value:(0,c.string)()})),Re=((0,c.union)([Oe,ke,Pe]),(Ee=Re||{}).Alert=\"alert\",Ee.Confirmation=\"confirmation\",Ee.Prompt=\"prompt\",Ee),Be=((_e=Be||{}).Base64=\"base64\",_e.Hex=\"hex\",_e.Utf8=\"utf8\",_e),Ce=((Se=Ce||{}).ClearState=\"clear\",Se.GetState=\"get\",Se.UpdateState=\"update\",Se),Ne=((Ae=Ne||{}).InApp=\"inApp\",Ae.Native=\"native\",Ae),Le=Et([(0,c.string)(),(0,c.number)()]),Ue=je((0,c.string)());(0,c.object)({type:(0,c.string)(),props:(0,c.record)((0,c.string)(),w),key:(0,c.nullable)(Le)});function je(t){return Et([t,(0,c.array)(t)])}function Me(t,e={}){return(0,c.object)({type:mt(t),props:(0,c.object)(e),key:(0,c.nullable)(Le)})}var He,Fe,De=Me(\"Button\",{children:Ue,name:(0,c.optional)((0,c.string)()),type:(0,c.optional)(Et([mt(\"button\"),mt(\"submit\")])),variant:(0,c.optional)(Et([mt(\"primary\"),mt(\"destructive\")])),disabled:(0,c.optional)((0,c.boolean)())}),$e=Me(\"Input\",{name:(0,c.string)(),type:(0,c.optional)(Et([mt(\"text\"),mt(\"password\"),mt(\"number\")])),value:(0,c.optional)((0,c.string)()),placeholder:(0,c.optional)((0,c.string)())}),Ke=Me(\"Option\",{value:(0,c.string)(),children:(0,c.string)()}),Ve=Me(\"Dropdown\",{name:(0,c.string)(),value:(0,c.optional)((0,c.string)()),children:je(Ke)}),Ge=Me(\"Field\",{label:(0,c.optional)((0,c.string)()),error:(0,c.optional)((0,c.string)()),children:Et([(0,c.tuple)([$e,De]),$e,Ve])}),qe=Me(\"Form\",{children:je(Et([Ge,De])),name:(0,c.string)()}),We=Me(\"Bold\",{children:je((0,c.nullable)(Et([(0,c.string)(),(0,c.lazy)((()=>Xe))])))}),Xe=Me(\"Italic\",{children:je((0,c.nullable)(Et([(0,c.string)(),(0,c.lazy)((()=>We))])))}),ze=Et([We,Xe]),Je=Me(\"Address\",{address:ot}),Ye=Me(\"Box\",{children:je((0,c.nullable)((0,c.lazy)((()=>ar)))),direction:(0,c.optional)(Et([mt(\"horizontal\"),mt(\"vertical\")])),alignment:(0,c.optional)(Et([mt(\"start\"),mt(\"center\"),mt(\"end\"),mt(\"space-between\"),mt(\"space-around\")]))}),Ze=Me(\"Copyable\",{value:(0,c.string)(),sensitive:(0,c.optional)((0,c.boolean)())}),Qe=Me(\"Divider\"),tr=Me(\"Value\",{value:(0,c.string)(),extra:(0,c.string)()}),er=Me(\"Heading\",{children:Ue}),rr=Me(\"Image\",{src:(0,c.string)(),alt:(0,c.optional)((0,c.string)())}),nr=Me(\"Link\",{href:(0,c.string)(),children:je((0,c.nullable)(Et([ze,(0,c.string)()])))}),ir=Me(\"Text\",{children:je((0,c.nullable)(Et([(0,c.string)(),We,Xe,nr])))}),or=Me(\"Row\",{label:(0,c.string)(),children:Et([Je,rr,ir,tr]),variant:(0,c.optional)(Et([mt(\"default\"),mt(\"warning\"),mt(\"error\")]))}),sr=Me(\"Spinner\"),ar=Et([De,$e,qe,We,Xe,Je,Ye,Ze,Qe,er,rr,nr,or,sr,ir,Ve]),cr=ar,ur=(Et([De,$e,Ge,qe,We,Xe,Je,Ye,Ze,Qe,er,rr,nr,or,sr,ir,Ve,Ke,tr]),(0,c.record)((0,c.string)(),(0,c.nullable)((0,c.string)())));(0,c.record)((0,c.string)(),(0,c.union)([ur,(0,c.nullable)((0,c.string)())])),(0,c.union)([we,cr]),(0,c.record)((0,c.string)(),w);!function(t){t.Mainnet=\"bip122:000000000019d6689c085ae165831e93\",t.Testnet=\"bip122:000000000933ea01ad0ee984209779ba\"}(He||(He={})),function(t){t.Btc=\"bip122:000000000019d6689c085ae165831e93/slip44:0\",t.TBtc=\"bip122:000000000933ea01ad0ee984209779ba/slip44:0\"}(Fe||(Fe={}));const fr={onChainService:{dataClient:{options:{apiKey:\"A___agdRpkDchYPuxqWhXfFidteuWj4m\"}}},wallet:{defaultAccountIndex:0,defaultAccountType:\"bip122:p2wpkh\"},avaliableNetworks:Object.values(He),avaliableAssets:Object.values(Fe),unit:\"BTC\",explorer:{[He.Mainnet]:\"https://blockstream.info/address/${address}\",[He.Testnet]:\"https://blockstream.info/testnet/address/${address}\"},logLevel:\"6\"},hr={randomUUID:\"undefined\"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let lr;const pr=new Uint8Array(16);function dr(){if(!lr&&(lr=\"undefined\"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!lr))throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");return lr(pr)}const yr=[];for(let t=0;t<256;++t)yr.push((t+256).toString(16).slice(1));function gr(t,e=0){return yr[t[e+0]]+yr[t[e+1]]+yr[t[e+2]]+yr[t[e+3]]+\"-\"+yr[t[e+4]]+yr[t[e+5]]+\"-\"+yr[t[e+6]]+yr[t[e+7]]+\"-\"+yr[t[e+8]]+yr[t[e+9]]+\"-\"+yr[t[e+10]]+yr[t[e+11]]+yr[t[e+12]]+yr[t[e+13]]+yr[t[e+14]]+yr[t[e+15]]}const br=function(t,e,r){if(hr.randomUUID&&!e&&!t)return hr.randomUUID();const n=(t=t||{}).random||(t.rng||dr)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(let t=0;t<16;++t)e[r+t]=n[t];return e}return gr(n)};class wr extends Error{name;constructor(t){super(t),Object.defineProperty(this,\"name\",{value:new.target.name,enumerable:!1,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace(this,this.constructor)}}function mr(t,e){return t instanceof e?t:new e(t.message)}function vr(t){return[dt,Ot,Mt,kt,Ot,Pt,Rt,Bt,Ct,Nt,Lt,Ut,jt,St,At,It,Tt,xt].some((e=>t instanceof e))}var Er=r(1048);function _r(t,e=!0){try{return Er.Buffer.from(e?function(t){return t.startsWith(\"0x\")?t.substring(2):t}(t):t,\"hex\")}catch(t){throw new Error(\"Unable to convert hex string to buffer\")}}function Sr(t,e){try{return t.toString(e)}catch(t){throw new Error(\"Unable to convert buffer to string\")}}const Ar=(0,c.enums)(fr.avaliableAssets),Ir=(0,c.enums)(fr.avaliableNetworks),Tr=(0,c.pattern)((0,c.string)(),/^(?!0\\d)(\\d+(\\.\\d+)?)$/u),xr=(new Error(\"timeout while waiting for mutex to become available\"),new Error(\"mutex already locked\"),new Error(\"request for lock canceled\"));var Or=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};class kr{constructor(t,e=xr){if(this._maxConcurrency=t,this._cancelError=e,this._queue=[],this._waiters=[],t<=0)throw new Error(\"semaphore must be initialized to a positive value\");this._value=t}acquire(){const t=this.isLocked(),e=new Promise(((t,e)=>this._queue.push({resolve:t,reject:e})));return t||this._dispatch(),e}runExclusive(t){return Or(this,void 0,void 0,(function*(){const[e,r]=yield this.acquire();try{return yield t(e)}finally{r()}}))}waitForUnlock(){return Or(this,void 0,void 0,(function*(){if(!this.isLocked())return Promise.resolve();return new Promise((t=>this._waiters.push({resolve:t})))}))}isLocked(){return this._value<=0}release(){if(this._maxConcurrency>1)throw new Error(\"this method is unavailable on semaphores with concurrency > 1; use the scoped release returned by acquire instead\");if(this._currentReleaser){const t=this._currentReleaser;this._currentReleaser=void 0,t()}}cancel(){this._queue.forEach((t=>t.reject(this._cancelError))),this._queue=[]}_dispatch(){const t=this._queue.shift();if(!t)return;let e=!1;this._currentReleaser=()=>{e||(e=!0,this._value++,this._resolveWaiters(),this._dispatch())},t.resolve([this._value--,this._currentReleaser])}_resolveWaiters(){this._waiters.forEach((t=>t.resolve())),this._waiters=[]}}var Pr=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};class Rr{constructor(t){this._semaphore=new kr(1,t)}acquire(){return Pr(this,void 0,void 0,(function*(){const[,t]=yield this._semaphore.acquire();return t}))}runExclusive(t){return this._semaphore.runExclusive((()=>t()))}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Br=new Rr;var Cr;!function(t){t[t.ERROR=1]=\"ERROR\",t[t.WARN=2]=\"WARN\",t[t.INFO=3]=\"INFO\",t[t.DEBUG=4]=\"DEBUG\",t[t.TRACE=5]=\"TRACE\",t[t.ALL=6]=\"ALL\",t[t.OFF=0]=\"OFF\"}(Cr||(Cr={}));const Nr=(t,...e)=>{};const Lr=new class{log;warn;error;debug;info;trace;#t=Cr.OFF;set logLevel(t){this.#t=t,this.init()}get logLevel(){return this.#t}init(){this.error=console.error.bind(console),this.warn=console.warn.bind(console),this.info=console.info.bind(console),this.debug=console.debug.bind(console),this.trace=console.trace.bind(console),this.log=console.log.bind(console),this.#t{const e=await this.get();await t(e),await this.set(e)}))}async withTransaction(t){await this.mtx.runExclusive((async()=>{if(await this.#n(),!this.#e.current||!this.#e.orgState||!this.#e.id)throw new Error(\"Failed to begin transaction\");Lr.info(`SnapStateManager.withTransaction [${this.#r}]: begin transaction`);try{await t(this.#e.current),await this.set(this.#e.current)}catch(t){throw Lr.info(`SnapStateManager.withTransaction [${this.#r}]: error : ${JSON.stringify(t.message)}`),await this.#i(),t}finally{this.#o()}}))}async commit(){if(!this.#e.current||!this.#e.orgState)throw new Error(\"Failed to commit transaction\");this.#e.hasCommited=!0,await this.set(this.#e.current)}async#n(){this.#e={id:br(),orgState:await this.get(),current:await this.get(),isRollingBack:!1,hasCommited:!1}}async#i(){try{this.#e.hasCommited&&!this.#e.isRollingBack&&this.#e.orgState&&(Lr.info(`SnapStateManager.rollback [${this.#r}]: attemp to rollback state`),this.#e.isRollingBack=!0,await this.set(this.#e.orgState))}catch(t){throw Lr.info(`SnapStateManager.rollback [${this.#r}]: error : ${JSON.stringify(t)}`),new Error(\"Failed to rollback state\")}}#o(){this.#e.orgState=void 0,this.#e.current=void 0,this.#e.id=void 0,this.#e.isRollingBack=!1,this.#e.hasCommited=!1}get#r(){return this.#e.id??\"\"}}function jr(t,e){try{(0,c.assert)(t,e)}catch(t){throw new It(t.message)}}function Mr(t,e){try{(0,c.assert)(t,e)}catch(t){throw new dt(\"Invalid Response\")}}var Hr=1e6,Fr=1e6,Dr=\"[big.js] \",$r=Dr+\"Invalid \",Kr=$r+\"decimal places\",Vr=$r+\"rounding mode\",Gr=Dr+\"Division by zero\",qr={},Wr=void 0,Xr=/^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i;function zr(t,e,r,n){var i=t.c;if(r===Wr&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(Vr);if(e<1)n=3===r&&(n||!!i[0])||0===e&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(n||i[1]!==Wr))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e=5||2===r&&(i[e]>5||5===i[e]&&(n||i[e+1]!==Wr||1&i[e-1]))||3===r&&(n||!!i[0]),i.length=e,n)for(;++i[--e]>9;)if(i[e]=0,0===e){++t.e,i.unshift(1);break}for(e=i.length;!i[--e];)i.pop()}return t}function Jr(t,e,r){var n=t.e,i=t.c.join(\"\"),o=i.length;if(e)i=i.charAt(0)+(o>1?\".\"+i.slice(1):\"\")+(n<0?\"e\":\"e+\")+n;else if(n<0){for(;++n;)i=\"0\"+i;i=\"0.\"+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+=\"0\";else n1&&(i=i.charAt(0)+\".\"+i.slice(1));return t.s<0&&r?\"-\"+i:i}qr.abs=function(){var t=new this.constructor(this);return t.s=1,t},qr.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,s=t.s,a=r.e,c=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(e=o<0,a!=c)return a>c^e?1:-1;for(s=(a=n.length)<(c=i.length)?a:c,o=-1;++oi[o]^e?1:-1;return a==c?0:a>c^e?1:-1},qr.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,o=e.s==t.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>Hr)throw Error(Kr);if(!i[0])throw Error(Gr);if(!n[0])return t.s=o,t.c=[t.e=0],t;var a,c,u,f,h,l=i.slice(),p=a=i.length,d=n.length,y=n.slice(0,a),g=y.length,b=t,w=b.c=[],m=0,v=s+(b.e=e.e-t.e)+1;for(b.s=o,o=v<0?0:v,l.unshift(0);g++g?1:-1;else for(h=-1,f=0;++hy[h]?1:-1;break}if(!(f<0))break;for(c=g==a?i:l;g;){if(y[--g]v&&zr(b,v,r.RM,y[0]!==Wr),b},qr.eq=function(t){return 0===this.cmp(t)},qr.gt=function(t){return this.cmp(t)>0},qr.gte=function(t){return this.cmp(t)>-1},qr.lt=function(t){return this.cmp(t)<0},qr.lte=function(t){return this.cmp(t)<1},qr.minus=qr.sub=function(t){var e,r,n,i,o=this,s=o.constructor,a=o.s,c=(t=new s(t)).s;if(a!=c)return t.s=-c,o.plus(t);var u=o.c.slice(),f=o.e,h=t.c,l=t.e;if(!u[0]||!h[0])return h[0]?t.s=-c:u[0]?t=new s(o):t.s=1,t;if(a=f-l){for((i=a<0)?(a=-a,n=u):(l=f,n=h),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(r=((i=u.length0)for(;c--;)u[e++]=0;for(c=e;r>a;){if(u[--r]0?(c=s,n=u):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-u.length<0&&(n=u,u=a,a=n),e=u.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+u[e]+r)/10|0;for(r&&(a.unshift(r),++c),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=c,t},qr.pow=function(t){var e=this,r=new e.constructor(\"1\"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>Fr)throw Error($r+\"exponent\");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},qr.prec=function(t,e){if(t!==~~t||t<1||t>Hr)throw Error($r+\"precision\");return zr(new this.constructor(this),t,e)},qr.round=function(t,e){if(t===Wr)t=0;else if(t!==~~t||t<-Hr||t>Hr)throw Error(Kr);return zr(new this.constructor(this),t+this.e+1,e)},qr.sqrt=function(){var t,e,r,n=this,i=n.constructor,o=n.s,s=n.e,a=new i(\"0.5\");if(!n.c[0])return new i(n);if(o<0)throw Error(Dr+\"No square root\");0===(o=Math.sqrt(n+\"\"))||o===1/0?((e=n.c.join(\"\")).length+s&1||(e+=\"0\"),s=((s+1)/2|0)-(s<0||1&s),t=new i(((o=Math.sqrt(e))==1/0?\"5e\":(o=o.toExponential()).slice(0,o.indexOf(\"e\")+1))+s)):t=new i(o+\"\"),s=t.e+(i.DP+=4);do{r=t,t=a.times(r.plus(n.div(r)))}while(r.c.slice(0,s).join(\"\")!==t.c.slice(0,s).join(\"\"));return zr(t,(i.DP-=4)+t.e+1,i.RM)},qr.times=qr.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,s=i.length,a=o.length,c=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=c+u,sc;)a=e[u]+o[c]*i[u-c-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},qr.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==Wr){if(t!==~~t||t<0||t>Hr)throw Error(Kr);for(r=zr(new r.constructor(r),++t,e);r.c.lengthHr)throw Error(Kr);for(t=t+(r=zr(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length=e.PE,!!t.c[0])},qr.toNumber=function(){var t=Number(Jr(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(Dr+\"Imprecise conversion\");return t},qr.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==Wr){if(t!==~~t||t<1||t>Hr)throw Error($r+\"precision\");for(r=zr(new n(r),t,e);r.c.length=n.PE,!!i)},qr.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(Dr+\"valueOf disallowed\");return Jr(t,t.e<=e.NE||t.e>=e.PE,!0)};var Yr=function t(){function e(r){var n=this;if(!(n instanceof e))return r===Wr?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if(\"string\"!=typeof r){if(!0===e.strict&&\"bigint\"!=typeof r)throw TypeError($r+\"value\");r=0===r&&1/r<0?\"-0\":String(r)}!function(t,e){var r,n,i;if(!Xr.test(e))throw Error($r+\"number\");t.s=\"-\"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf(\".\"))>-1&&(e=e.replace(\".\",\"\"));(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length);for(i=e.length,n=0;n0&&\"0\"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=qr,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();const Zr=Yr,Qr=21e14;function tn(t,e=!1){if(\"number\"==typeof t&&!Number.isInteger(t))throw new Error(\"satsToBtc must be called on an integer number\");const r=new Zr(t).div(1e8).toFixed(8);return e?`${r} ${fr.unit}`:r}function en(t){const e=t.split(\".\");if(e.length>1&&e[1].length>8)throw new Error(\"BTC amount is out of range\");const r=new Zr(t).times(1e8);if(r.lt(0)||r.gt(Qr))throw new Error(\"BTC amount is out of range\");return BigInt(r.toFixed(0))}class rn extends wr{}class nn extends wr{}var on,sn,an,cn=r(7612);class un{_dataClient;_options;constructor(t,e){this._dataClient=t,this._options=e}get network(){return this._options.network}async getBalances(t,e){try{if(e.length>1)throw new nn(\"Only one asset is supported\");if(!new Set(Object.values(Fe)).has(e[0])||this.network===cn.o8.testnet&&e[0]!==Fe.TBtc||this.network===cn.o8.bitcoin&&e[0]!==Fe.Btc)throw new nn(\"Invalid asset\");const r=await this._dataClient.getBalances(t);return t.reduce(((t,n)=>(t.balances[n]={[e[0]]:{amount:BigInt(r[n])}},t)),{balances:{}})}catch(t){throw mr(t,nn)}}async getFeeRates(){try{const t=await this._dataClient.getFeeRates();return{fees:Object.entries(t).map((([t,e])=>({type:t,rate:BigInt(e)})))}}catch(t){throw mr(t,nn)}}async getTransactionStatus(t){try{return await this._dataClient.getTransactionStatus(t)}catch(t){throw new nn(t)}}async getDataForTransaction(t){try{return{data:{utxos:await this._dataClient.getUtxos(t)}}}catch(t){throw mr(t,nn)}}async broadcastTransaction(t){try{return{transactionId:await this._dataClient.sendTransaction(t)}}catch(t){throw mr(t,nn)}}listTransactions(){throw new Error(\"Method not implemented.\")}}!function(t){t.Fast=\"fast\",t.Medium=\"medium\",t.Slow=\"slow\"}(on||(on={})),function(t){t.Confirmed=\"confirmed\",t.Pending=\"pending\",t.Failed=\"failed\"}(sn||(sn={}));class fn{_options;constructor(t){this._options=t}get baseUrl(){switch(this._options.network){case cn.o8.bitcoin:return\"https://api.blockchair.com/bitcoin\";case cn.o8.testnet:return\"https://api.blockchair.com/bitcoin/testnet\";default:throw new Error(\"Invalid network\")}}getApiUrl(t){const e=new URL(`${this.baseUrl}${t}`);return this._options.apiKey&&e.searchParams.append(\"key\",this._options.apiKey),e.toString()}async get(t){const e=await fetch(this.getApiUrl(t),{method:\"GET\"});if(!e.ok)throw new Error(`Failed to fetch data from blockchair: ${e.statusText}`);return e.json()}async post(t,e){const r=await fetch(this.getApiUrl(t),{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(e)});if(400==r.status){const t=await r.json();throw new Error(`Failed to post data from blockchair: ${t.context.error}`)}if(!r.ok)throw new Error(`Failed to post data from blockchair: ${r.statusText}`);return r.json()}async getTxDashboardData(t){try{Lr.info(\"[BlockChairClient.getTxDashboardData] start:\");const e=await this.get(`/dashboards/transaction/${t}`);return Lr.info(`[BlockChairClient.getTxDashboardData] response: ${JSON.stringify(e)}`),e}catch(t){throw Lr.info(`[BlockChairClient.getTxDashboardData] error: ${t.message}`),mr(t,rn)}}async getBalances(t){try{Lr.info(`[BlockChairClient.getBalance] start: { addresses : ${JSON.stringify(t)} }`);const e=await this.get(`/addresses/balances?addresses=${t.join(\",\")}`);return Lr.info(`[BlockChairClient.getBalance] response: ${JSON.stringify(e)}`),t.reduce(((t,r)=>(t[r]=e.data[r]??0,t)),{})}catch(t){throw Lr.info(`[BlockChairClient.getBalance] error: ${t.message}`),mr(t,rn)}}async getUtxos(t,e){try{let r=!0,n=0;const i=1e3,o=[];for(;r;){let s=`/dashboards/address/${t}?limit=0,${i}&offset=0,${n}`;e||(s+=\"&state=latest\");const a=await this.get(s);if(Lr.info(`[BlockChairClient.getUtxos] response: ${JSON.stringify(a)}`),!Object.prototype.hasOwnProperty.call(a.data,t))throw new Error(\"Data not avaiable\");a.data[t].utxo.forEach((t=>{o.push({block:t.block_id,txHash:t.transaction_hash,index:t.index,value:t.value})})),n+=1,a.data[t].utxo.lengththis.validateInputs(t,e,r))))throw new dn(\"Invalid signature to sign the PSBT's inputs\")}catch(t){throw mr(t,dn)}}finalize(){try{this._psbt.finalizeAllInputs();const t=this._psbt.extractTransaction().toHex();if(this._psbt.extractTransaction().weight()>4e5)throw new dn(\"Transaction is too large\");return t}catch(t){throw mr(t,dn)}}validateInputs(t,e,r){return xn.fromPublicKey(t).verify(e,r)}}class kn{publicKey;fingerprint;_node;constructor(t,e){this._node=t,this.publicKey=this._node.publicKey,this.fingerprint=e??this._node.fingerprint}derivePath(t){try{let e=t.split(\"/\");\"m\"===e[0]&&(e=e.slice(1));const r=e.reduce(((t,e)=>{let r;return e.endsWith(\"'\")?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this._node);return new kn(r,this.fingerprint)}catch(t){throw new Error(\"Unable to derive path\")}}async sign(t){return this._node.sign(t)}verify(t,e){return this._node.verify(t,e)}}class Pn{sender;_change;_recipients;_outputTotal;_txFee;_feeRate;constructor(t,e){this.feeRate=e,this.txFee=0,this.sender=t,this._recipients=[],this._outputTotal=BigInt(0)}addRecipients(t){for(const e of t)this.addRecipient(e)}addRecipient(t){this._outputTotal+=t.bigIntValue,this._recipients.push({address:t.address,value:t.bigIntValue})}addChange(t){this._change={address:t.address,value:t.bigIntValue}}set txFee(t){this._txFee=\"number\"==typeof t?BigInt(t):t}get txFee(){return this._txFee}set feeRate(t){this._feeRate=\"number\"==typeof t?BigInt(t):t}get feeRate(){return this._feeRate}get total(){return this._outputTotal+(this.change?BigInt(this.change.value):BigInt(0))+this.txFee}get recipients(){return this._recipients}get change(){return this._change}}class Rn{_value;script;txHash;index;block;constructor(t,e){this.script=e,this._value=BigInt(t.value),this.index=t.index,this.txHash=t.txHash,this.block=t.block}get value(){return Number(this._value)}get bigIntValue(){return this._value}}class Bn{_value;script;address;constructor(t,e,r){this.value=t,this.address=e,this.script=r}get value(){return Number(this._value)}set value(t){this._value=\"number\"==typeof t?BigInt(t):t}get bigIntValue(){return this._value}}class Cn{_deriver;_network;constructor(t,e){this._deriver=t,this._network=e}async unlock(t,e){try{const r=this.getAccountCtor(e??an.P2wpkh),n=await this._deriver.getRoot(r.path),i=await this._deriver.getChild(n,t),o=[\"m\",\"0'\",\"0\",`${t}`].join(\"/\");return new r(Sr(n.fingerprint,\"hex\"),t,o,Sr(i.publicKey,\"hex\"),this._network,r.scriptType,`bip122:${r.scriptType.toLowerCase()}`,this.getHdSigner(n))}catch(t){throw mr(t,ln)}}async createTransaction(t,e,r){const n=t.script,{scriptType:i}=t,o=r.utxos.map((t=>new Rn(t,n))),s=e.map((t=>{if(bn(t.value,i))throw new pn(\"Transaction amount too small\");const e=function(t,e){try{return cn.hl.toOutputScript(t,e)}catch(t){throw new Error(\"Destination address has no matching Script\")}}(t.address,this._network);return new Bn(t.value,t.address,e)})),a=Math.max(1,r.fee),c=new Tn(a),u=new Bn(0,t.address,n),f=c.selectCoins(o,s,u),h=new On(this._network);h.addInputs(f.inputs,r.replaceable,t.hdPath,_r(t.pubkey,!1),_r(t.mfp,!1));const l=new Pn(t.address,a);for(const t of f.outputs)h.addOutput(t),l.addRecipient(t);f.change&&(bn(u.value,i)?Lr.warn(\"[BtcWallet.createTransaction] Change is too small, adding to fees\"):(h.addOutput(f.change),l.addChange(f.change)));const p=await h.signDummy(t.signer);return l.txFee=p.getFee(),{tx:h.toBase64(),txInfo:l}}async signTransaction(t,e){const r=On.fromBase64(this._network,e);return await r.signNVerify(t),r.finalize()}getHdSigner(t){return new kn(t,t.fingerprint)}getAccountCtor(t){let e=t;switch(t.includes(\"bip122:\")&&(e=t.split(\":\")[1]),e.toLowerCase()){case an.P2wpkh.toLowerCase():return mn;case an.P2shP2wkh.toLowerCase():return vn;default:throw new ln(\"Invalid script type\")}}}class Nn{static createOnChainServiceProvider(t){var e,r;const n=gn(t),i=new fn({network:n,apiKey:null===(r=fr.onChainService.dataClient.options)||void 0===r||null===(e=r.apiKey)||void 0===e?void 0:e.toString()});return new un(i,{network:n})}static createWallet(t){const e=gn(t);return new Cn(new Sn(e),e)}}class Ln extends Ur{async get(){return super.get().then((t=>(t||(t={walletIds:[],wallets:{}}),t.walletIds||(t.walletIds=[]),t.wallets||(t.wallets={}),t)))}async listAccounts(){try{const t=await this.get();return t.walletIds.map((e=>t.wallets[e].account))}catch(t){throw mr(t,Error)}}async addWallet(t){try{await this.update((async e=>{const{id:r,address:n}=t.account;if(this.isAccountExist(e,r)||this.getAccountByAddress(e,n))throw new Error(`Account address ${n} already exists`);e.wallets[r]=t,e.walletIds.push(r)}))}catch(t){throw mr(t,Error)}}async updateAccount(t){try{await this.update((async e=>{if(!this.isAccountExist(e,t.id))throw new Error(`Account id ${t.id} does not exist`);const r=e.wallets[t.id].account;if(r.address.toLowerCase()!==t.address.toLowerCase()||r.type!==t.type)throw new Error(\"Account address or type is immutable\");e.wallets[t.id].account=t}))}catch(t){throw mr(t,Error)}}async removeAccounts(t){try{await this.update((async e=>{const r=new Set;for(const n of t){if(!this.isAccountExist(e,n))throw new Error(`Account id ${n} does not exist`);r.add(n)}r.forEach((t=>delete e.wallets[t])),e.walletIds=e.walletIds.filter((t=>!r.has(t)))}))}catch(t){throw mr(t,Error)}}async getAccount(t){try{var e;return(null===(e=(await this.get()).wallets[t])||void 0===e?void 0:e.account)??null}catch(t){throw mr(t,Error)}}async getWallet(t){try{return(await this.get()).wallets[t]??null}catch(t){throw mr(t,Error)}}getAccountByAddress(t,e){var r;return(null===(r=Object.values(t.wallets).find((t=>t.account.address.toString()===e.toLowerCase())))||void 0===r?void 0:r.account)??null}isAccountExist(t,e){return Object.prototype.hasOwnProperty.call(t.wallets,e)}}(0,c.object)({scope:Ir});const Un=(0,c.object)({assets:(0,c.array)(Ar),scope:Ir});(0,c.object)({assets:(0,c.record)(Ar,(0,c.object)({amount:Tr,unit:(0,c.enums)([fr.unit])}))});const jn=(0,c.object)({transactionId:(0,c.string)(),scope:Ir}),Mn=(0,c.object)({status:(0,c.enums)(Object.values(sn))});const Hn=(0,c.refine)((0,c.record)(t.BtcP2wpkhAddressStruct,(0,c.string)()),\"TransactionAmountStuct\",(t=>{if(0===Object.entries(t).length)return\"Transaction must have at least one recipient\";for(const e of Object.values(t)){const t=parseFloat(e);if(Number.isNaN(t)||t<=0||!Number.isFinite(t))return\"Invalid amount for send\";try{en(e)}catch(t){return\"Invalid amount for send\"}}return!0})),Fn=(0,c.object)({amounts:Hn,comment:(0,c.string)(),subtractFeeFrom:(0,c.array)(t.BtcP2wpkhAddressStruct),replaceable:(0,c.boolean)(),dryrun:(0,c.optional)((0,c.boolean)()),scope:Ir}),Dn=(0,c.object)({txId:(0,c.nonempty)((0,c.string)()),txHash:(0,c.optional)((0,c.string)())});async function $n(t,e){try{jr(e,Fn);const{dryrun:r,scope:n}=e,i=Nn.createOnChainServiceProvider(n),o=Nn.createWallet(n),s=await i.getFeeRates();if(0===s.fees.length)throw new Error(\"No fee rates available\");const a=Math.max(Number(s.fees[s.fees.length-1].rate),1),c=Object.entries(e.amounts).map((([t,e])=>({address:t,value:en(e)}))),u=await i.getDataForTransaction(t.address),{tx:f,txInfo:h}=await o.createTransaction(t,c,{utxos:u.data.utxos,fee:a,subtractFeeFrom:e.subtractFeeFrom,replaceable:e.replaceable});if(!await async function(t,e,r){const n=\"Send Request\",i=\"Review the request before proceeding. Once the transaction is made, it's irreversible.\",o=\"Recipient\",s=\"Amount\",a=\"Comment\",c=\"Network fee\",u=\"Total\",f=\"Requested by\",h=[be([zt(n),ue(i),pe(f,ue(\"[portfolio.metamask.io](https://portfolio.metamask.io/)\"))]),Wt()],l=t.recipients.length+(t.change?1:0)>1;let p=0;const d=t=>{const e=[];e.push(pe(l?`${o} ${p+1}`:o,ue(`[${function(t){return function(t,e,r,n=\"...\"){return t?`${t.substring(0,e)}${n}${t.substring(t.length-r)}`:t}(t,5,3)}(t.address)}](${function(t,e){switch(e){case He.Mainnet:return fr.explorer[He.Mainnet].replace(\"${address}\",t);case He.Testnet:return fr.explorer[He.Testnet].replace(\"${address}\",t);default:throw new Error(\"Invalid Chain ID\")}}(t.address,r)})`))),e.push(pe(s,ue(tn(t.value,!0),!1))),p+=1,h.push(be(e)),h.push(Wt())};t.recipients.forEach(d),t.change&&[t.change].forEach(d);const y=[];e.trim().length>0&&y.push(pe(a,ue(e.trim(),!1)));return y.push(pe(c,ue(`${tn(t.txFee,!0)}`,!1))),y.push(pe(u,ue(`${tn(t.total,!0)}`,!1))),h.push(be(y)),await async function(t){return snap.request({method:\"snap_dialog\",params:{type:\"confirmation\",content:be(t)}})}(h)}(h,e.comment,n))throw new Mt;const l=await o.signTransaction(t.signer,f);if(r)return{txId:\"\",txHash:l};const p={txId:(await i.broadcastTransaction(l)).transactionId};return Mr(p,Dn),p}catch(t){if(Lr.error(\"Failed to send the transaction\",t),vr(t))throw t;if(t instanceof pn)throw t;throw new Error(\"Failed to send the transaction\")}}const Kn=(0,c.object)({scope:Ir});class Vn{_stateMgr;_options;_methods=[\"btc_sendmany\"];constructor(t,e){this._stateMgr=t,this._options=e}async listAccounts(){try{return await this._stateMgr.listAccounts()}catch(t){throw new Error(t)}}async getAccount(t){try{return await this._stateMgr.getAccount(t)??void 0}catch(t){throw new Error(t)}}async createAccount(e){try{(0,c.assert)(e,Kn);const r=this.getBtcWallet(e.scope),n=this._options.defaultIndex,i=fr.wallet.defaultAccountType,o=await this.discoverAccount(r,n,i);Lr.info(`[BtcKeyring.createAccount] Account unlocked: ${o.address}`);const s=this.newKeyringAccount(o,{scope:e.scope,index:n});return Lr.info(`[BtcKeyring.createAccount] Keyring account data: ${JSON.stringify(s)}`),await this._stateMgr.withTransaction((async()=>{await this._stateMgr.addWallet({account:s,hdPath:o.hdPath,index:o.index,scope:e.scope}),await this.#c(t.KeyringEvent.AccountCreated,{account:s})})),s}catch(t){if(Lr.info(`[BtcKeyring.createAccount] Error: ${t.message}`),t instanceof c.StructError)throw new Error(\"Invalid params to create an account\");throw new Error(t)}}async filterAccountChains(t,e){throw new Error(\"Method not implemented.\")}async updateAccount(e){try{await this._stateMgr.withTransaction((async()=>{await this._stateMgr.updateAccount(e),await this.#c(t.KeyringEvent.AccountUpdated,{account:e})}))}catch(t){throw Lr.info(`[BtcKeyring.updateAccount] Error: ${t.message}`),new Error(t)}}async deleteAccount(e){try{await this._stateMgr.withTransaction((async()=>{await this._stateMgr.removeAccounts([e]),await this.#c(t.KeyringEvent.AccountDeleted,{id:e})}))}catch(t){throw Lr.info(`[BtcKeyring.deleteAccount] Error: ${t.message}`),new Error(t)}}async submitRequest(t){return{pending:!1,result:await this.handleSubmitRequest(t)}}async handleSubmitRequest(t){const{scope:e,account:r}=t,{method:n,params:i}=t.request,o=await this.getWalletData(r);if(o.scope!==e)throw new Error(\"Account's scope does not match with the request's scope\");const s=this.getBtcWallet(o.scope),a=await this.discoverAccount(s,o.index,o.account.type);if(this.verifyIfAccountValid(a,o.account),\"btc_sendmany\"===n)return await $n(a,{...i,scope:o.scope});throw new Ot(n)}async#c(e,r){this._options.emitEvents&&await(0,t.emitSnapKeyringEvent)(snap,e,r)}async getAccountBalances(t,e){try{const r=await this.getWalletData(t),n=this.getBtcWallet(r.scope),i=await this.discoverAccount(n,r.index,r.account.type);return this.verifyIfAccountValid(i,r.account),await async function(t,e){try{jr(e,Un),(0,c.assert)(e,Un);const{assets:r,scope:n}=e,i=Nn.createOnChainServiceProvider(n),o=[t.address],s=new Set(o),a=new Set(r),u=await i.getBalances(o,r),f=Object.entries(u.balances),h=new Map;for(const[t,e]of f)if(s.has(t))for(const t in e){if(!a.has(t))continue;const{amount:r}=e[t];let n=h.get(t);n&&(n+=r),h.set(t,n??r)}const l=Object.fromEntries([...h.entries()].map((([t,e])=>[t,{amount:tn(e),unit:fr.unit}])));return Mr(e,Un),l}catch(t){if(Lr.error(\"Failed to get balances\",t),vr(t))throw t;throw new Error(\"Fail to get the balances\")}}(i,{assets:e,scope:r.scope})}catch(t){throw Lr.info(`[BtcKeyring.getAccountBalances] Error: ${t.message}`),new Error(t)}}async getWalletData(t){const e=await this._stateMgr.getWallet(t);if(!e)throw new Error(\"Account not found\");return e}getBtcWallet(t){return Nn.createWallet(t)}async discoverAccount(t,e,r){return await t.unlock(e,r)}verifyIfAccountValid(t,e){if(!t||t.address!==e.address)throw new Error(\"Account not found\")}newKeyringAccount(t,e){return{type:t.type,id:br(),address:t.address,options:{...e},methods:this._methods}}}var Gn;!function(t){t.GetTransactionStatus=\"chain_getTransactionStatus\",t.CreateAccount=\"chain_createAccount\"}(Gn||(Gn={}));const qn=new Set([t.KeyringRpcMethod.ListAccounts,t.KeyringRpcMethod.GetAccount,t.KeyringRpcMethod.CreateAccount,t.KeyringRpcMethod.FilterAccountChains,t.KeyringRpcMethod.ListRequests,t.KeyringRpcMethod.GetRequest,t.KeyringRpcMethod.ApproveRequest,t.KeyringRpcMethod.RejectRequest,t.KeyringRpcMethod.SubmitRequest,t.KeyringRpcMethod.GetAccountBalances,Gn.GetTransactionStatus]),Wn=new Set([t.KeyringRpcMethod.ListAccounts,t.KeyringRpcMethod.GetAccount,t.KeyringRpcMethod.CreateAccount,t.KeyringRpcMethod.FilterAccountChains,t.KeyringRpcMethod.UpdateAccount,t.KeyringRpcMethod.DeleteAccount,t.KeyringRpcMethod.ListRequests,t.KeyringRpcMethod.GetRequest,t.KeyringRpcMethod.ApproveRequest,t.KeyringRpcMethod.RejectRequest,t.KeyringRpcMethod.SubmitRequest,t.KeyringRpcMethod.GetAccountBalances,Gn.GetTransactionStatus]),Xn=[\"https://portfolio.metamask.io\",\"https://portfolio-builds.metafi-dev.codefi.network\",\"https://dev.portfolio.metamask.io\",\"https://ramps-dev.portfolio.metamask.io\"],zn=new Map([]);for(const t of Xn)zn.set(t,qn);zn.set(\"metamask\",Wn),zn.set(\"http://localhost:3000\",new Set([...qn,Gn.CreateAccount]));const Jn=(t,e)=>{var r;if(!t)throw new Ut(\"Origin not found\");if(!(null===(r=zn.get(t))||void 0===r?void 0:r.has(e)))throw new Ut(\"Permission denied\")},Yn=async({origin:t,request:e})=>{Lr.logLevel=parseInt(fr.logLevel,10);try{const{method:r}=e;switch(Jn(t,r),r){case Gn.CreateAccount:return await async function(t){const e=new Vn(new Ln,{defaultIndex:fr.wallet.defaultAccountIndex,emitEvents:!1});return await e.createAccount({scope:t.scope})}(e.params);case Gn.GetTransactionStatus:return await async function(t){try{jr(t,jn);const{scope:e,transactionId:r}=t,n=Nn.createOnChainServiceProvider(e),i={status:(await n.getTransactionStatus(r)).status};return Mr(i,Mn),i}catch(t){if(Lr.error(\"Failed to get transaction status\",t),vr(t))throw t;throw new Error(\"Fail to get the transaction status\")}}(e.params);default:throw new Ot(r)}}catch(t){let e=t;throw vr(t)||(e=new dt(t)),Lr.error(`onRpcRequest error: ${JSON.stringify(e.toJSON(),null,2)}`),e}},Zn=async({origin:e,request:r})=>{Lr.logLevel=parseInt(fr.logLevel,10);try{Jn(e,r.method);const n=new Vn(new Ln,{defaultIndex:fr.wallet.defaultAccountIndex,emitEvents:!0});return await(0,t.handleKeyringRequest)(n,r)}catch(t){let e=t;throw vr(t)||(e=new dt(t)),Lr.error(`onKeyringRequest error: ${JSON.stringify(e.toJSON(),null,2)}`),e}}})();var i=exports;for(var o in n)i[o]=n[o];n.__esModule&&Object.defineProperty(i,\"__esModule\",{value:!0})})();"}],"removable":false} \ No newline at end of file diff --git a/app/scripts/snaps/preinstalled-snaps.ts b/app/scripts/snaps/preinstalled-snaps.ts index bc3bbab76880..4d94e8a86354 100644 --- a/app/scripts/snaps/preinstalled-snaps.ts +++ b/app/scripts/snaps/preinstalled-snaps.ts @@ -1,7 +1,7 @@ import type { PreinstalledSnap } from '@metamask/snaps-controllers'; import MessageSigningSnap from '@metamask/message-signing-snap/dist/preinstalled-snap.json'; ///: BEGIN:ONLY_INCLUDE_IF(build-flask) -import BitcoinManagerSnap from './bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json'; +import BitcoinManagerSnap from '@consensys/bitcoin-manager-snap/dist/preinstalled-snap.json'; ///: END:ONLY_INCLUDE_IF const PREINSTALLED_SNAPS: readonly PreinstalledSnap[] = Object.freeze([ diff --git a/package.json b/package.json index d57e25eaeaff..80004d72de66 100644 --- a/package.json +++ b/package.json @@ -260,6 +260,7 @@ "dependencies": { "@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", "@blockaid/ppom_release": "^1.4.8", + "@consensys/bitcoin-manager-snap": "0.1.4-rc4", "@contentful/rich-text-html-renderer": "^16.3.5", "@ensdomains/content-hash": "^2.5.7", "@ethereumjs/tx": "^4.1.1", diff --git a/yarn.lock b/yarn.lock index 035e63c8c6a6..1c02f865d9df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1710,6 +1710,16 @@ __metadata: languageName: node linkType: hard +"@bitcoinerlab/secp256k1@npm:^1.1.1": + version: 1.1.1 + resolution: "@bitcoinerlab/secp256k1@npm:1.1.1" + dependencies: + "@noble/hashes": "npm:^1.1.5" + "@noble/secp256k1": "npm:^1.7.1" + checksum: 10/708fad4b2bff19411ee13b18821085a86ec70d9dae79965768f1e2c2de4fe887fb47522dbfe7ca5f2ff25a900aa909420c648bfadda1217795053bbcf248ec49 + languageName: node + linkType: hard + "@blockaid/ppom_release@npm:^1.4.8": version: 1.4.8 resolution: "@blockaid/ppom_release@npm:1.4.8" @@ -1758,6 +1768,27 @@ __metadata: languageName: node linkType: hard +"@consensys/bitcoin-manager-snap@npm:0.1.4-rc4": + version: 0.1.4-rc4 + resolution: "@consensys/bitcoin-manager-snap@npm:0.1.4-rc4" + dependencies: + "@bitcoinerlab/secp256k1": "npm:^1.1.1" + "@metamask/key-tree": "npm:^9.0.0" + "@metamask/keyring-api": "npm:^8.0.0" + "@metamask/snaps-sdk": "npm:^4.0.0" + async-mutex: "npm:^0.3.2" + big.js: "npm:^6.2.1" + bip32: "npm:^4.0.0" + bitcoinjs-lib: "npm:^6.1.5" + buffer: "npm:^6.0.3" + coinselect: "npm:^3.1.13" + ecpair: "npm:^2.1.0" + superstruct: "npm:^1.0.3" + uuid: "npm:^9.0.1" + checksum: 10/dc66b27f71e330195547ecad6de39a2886b34347ec536567423c9b12a483ef9e409d4ad8372e9362d8a37dfcb72267f09da5f2705dc8c75735b7dd8eaec7b400 + languageName: node + linkType: hard + "@contentful/rich-text-html-renderer@npm:^16.3.5": version: 16.3.5 resolution: "@contentful/rich-text-html-renderer@npm:16.3.5" @@ -5596,7 +5627,7 @@ __metadata: languageName: node linkType: hard -"@metamask/key-tree@npm:^9.1.1": +"@metamask/key-tree@npm:^9.0.0, @metamask/key-tree@npm:^9.1.1": version: 9.1.1 resolution: "@metamask/key-tree@npm:9.1.1" dependencies: @@ -6646,7 +6677,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.1.2, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0": +"@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.1.2, @noble/hashes@npm:^1.1.5, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0": version: 1.4.0 resolution: "@noble/hashes@npm:1.4.0" checksum: 10/e156e65794c473794c52fa9d06baf1eb20903d0d96719530f523cc4450f6c721a957c544796e6efd0197b2296e7cd70efeb312f861465e17940a3e3c7e0febc6 @@ -6667,7 +6698,7 @@ __metadata: languageName: node linkType: hard -"@noble/secp256k1@npm:^1.7.0": +"@noble/secp256k1@npm:^1.7.0, @noble/secp256k1@npm:^1.7.1": version: 1.7.1 resolution: "@noble/secp256k1@npm:1.7.1" checksum: 10/214d4756c20ed20809d948d0cc161e95664198cb127266faf747fd7deffe5444901f05fe9f833787738f2c6e60b09e544c2f737f42f73b3699e3999ba15b1b63 @@ -12510,7 +12541,7 @@ __metadata: languageName: node linkType: hard -"async-mutex@npm:^0.3.1": +"async-mutex@npm:^0.3.1, async-mutex@npm:^0.3.2": version: 0.3.2 resolution: "async-mutex@npm:0.3.2" dependencies: @@ -13039,6 +13070,13 @@ __metadata: languageName: node linkType: hard +"big.js@npm:^6.2.1": + version: 6.2.1 + resolution: "big.js@npm:6.2.1" + checksum: 10/1d4b621451de712cab20464a26f22b2eee5e7daf0ee88c49dfbfa76061ec37cff2257751e8c3fc183c231bcffac2f006e33af930d8f49b03c758890080b76ada + languageName: node + linkType: hard + "bigint-buffer@npm:^1.1.5": version: 1.1.5 resolution: "bigint-buffer@npm:1.1.5" @@ -13091,6 +13129,25 @@ __metadata: languageName: node linkType: hard +"bip174@npm:^2.1.1": + version: 2.1.1 + resolution: "bip174@npm:2.1.1" + checksum: 10/b90da3f9fe5b076a3d7b125a9dd39345a8cd8ece2dcc328a19c92948a60d7242886235bc94712935c71a9c5bc445b98a3570dca8881d19d421fc88a30b150b46 + languageName: node + linkType: hard + +"bip32@npm:^4.0.0": + version: 4.0.0 + resolution: "bip32@npm:4.0.0" + dependencies: + "@noble/hashes": "npm:^1.2.0" + "@scure/base": "npm:^1.1.1" + typeforce: "npm:^1.11.5" + wif: "npm:^2.0.6" + checksum: 10/f2da719618b26e2fdec3d0bc4945cf7dc435ff93eaeebc0b6b70b8911e7a33128cf77c4c0bce45be679c5f2a96aa5128dbed329193a9f88d755ff9c90185b6a0 + languageName: node + linkType: hard + "bip66@npm:^1.1.5": version: 1.1.5 resolution: "bip66@npm:1.1.5" @@ -13107,6 +13164,20 @@ __metadata: languageName: node linkType: hard +"bitcoinjs-lib@npm:^6.1.5": + version: 6.1.6 + resolution: "bitcoinjs-lib@npm:6.1.6" + dependencies: + "@noble/hashes": "npm:^1.2.0" + bech32: "npm:^2.0.0" + bip174: "npm:^2.1.1" + bs58check: "npm:^3.0.1" + typeforce: "npm:^1.11.3" + varuint-bitcoin: "npm:^1.1.2" + checksum: 10/18057362e92756aacb3fdbb996beddb134406a998515fdab86d221a96fb203a9345e4c25e8151a788df169eae0cbb271c467d5669f40f2bc9fce487721061928 + languageName: node + linkType: hard + "bitwise@npm:^2.0.4": version: 2.1.0 resolution: "bitwise@npm:2.1.0" @@ -13604,7 +13675,7 @@ __metadata: languageName: node linkType: hard -"bs58check@npm:2.1.2, bs58check@npm:^2.1.2": +"bs58check@npm:2.1.2, bs58check@npm:<3.0.0, bs58check@npm:^2.1.2": version: 2.1.2 resolution: "bs58check@npm:2.1.2" dependencies: @@ -14532,6 +14603,13 @@ __metadata: languageName: node linkType: hard +"coinselect@npm:^3.1.13": + version: 3.1.13 + resolution: "coinselect@npm:3.1.13" + checksum: 10/84450a8d0c2472152ebfe0dbef6d3cfb641d015f0865058f5ac646b03461da5f118cf0709f2385845d8005ea3d617ede8001af777724e4756837299a0e0be6a6 + languageName: node + linkType: hard + "collapse-white-space@npm:^1.0.2": version: 1.0.5 resolution: "collapse-white-space@npm:1.0.5" @@ -16666,6 +16744,17 @@ __metadata: languageName: node linkType: hard +"ecpair@npm:^2.1.0": + version: 2.1.0 + resolution: "ecpair@npm:2.1.0" + dependencies: + randombytes: "npm:^2.1.0" + typeforce: "npm:^1.18.0" + wif: "npm:^2.0.6" + checksum: 10/06a9dfe50ac4528e6f61ce709218baf3261b28ce2ae05273c590a1e9646481699e36df97ca1dbe5c0ffc91753da543b8778f4341db24dc6c74e9046fcb975b3e + languageName: node + linkType: hard + "ee-first@npm:1.1.1": version: 1.1.1 resolution: "ee-first@npm:1.1.1" @@ -25150,6 +25239,7 @@ __metadata: "@babel/register": "npm:^7.22.15" "@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch" "@blockaid/ppom_release": "npm:^1.4.8" + "@consensys/bitcoin-manager-snap": "npm:0.1.4-rc4" "@contentful/rich-text-html-renderer": "npm:^16.3.5" "@ensdomains/content-hash": "npm:^2.5.7" "@ethereumjs/tx": "npm:^4.1.1" @@ -34150,7 +34240,7 @@ __metadata: languageName: node linkType: hard -"typeforce@npm:^1.18.0": +"typeforce@npm:^1.11.3, typeforce@npm:^1.11.5, typeforce@npm:^1.18.0": version: 1.18.0 resolution: "typeforce@npm:1.18.0" checksum: 10/dbf98c75b1d57e56e33c1e1271d5505e67981f4e6a2e2e6e8e31160b58777fea1726160810b6c606517db16476805b7dce315926ba2d4859b9a56cab05b7a41f @@ -35793,6 +35883,15 @@ __metadata: languageName: node linkType: hard +"wif@npm:^2.0.6": + version: 2.0.6 + resolution: "wif@npm:2.0.6" + dependencies: + bs58check: "npm:<3.0.0" + checksum: 10/c8d7581664532d9ab6d163ee5194a9bec71b089a6e50d54d6ec57a9bd714fcf84bc8d9f22f4cfc7c297fc6ad10b973b8e83eca5c41240163fc61f44b5154b7da + languageName: node + linkType: hard + "wif@npm:^4.0.0": version: 4.0.0 resolution: "wif@npm:4.0.0" From 28c94743635413e48c68ade1450392cdee2f4757 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Tue, 2 Jul 2024 21:53:55 +0200 Subject: [PATCH 15/75] Revert "chore(btc): use bitcoin-manager-snap as a dependency" This reverts commit 34a1e1572e9a53a2cd12182a1160d280eceb961c. --- ...ager-snap-0.1.4-rc4-preinstalled-snap.json | 1 + app/scripts/snaps/preinstalled-snaps.ts | 2 +- package.json | 1 - yarn.lock | 111 +----------------- 4 files changed, 8 insertions(+), 107 deletions(-) create mode 100644 app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json diff --git a/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json b/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json new file mode 100644 index 000000000000..238392b18ab7 --- /dev/null +++ b/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json @@ -0,0 +1 @@ +{"snapId":"npm:@consensys/bitcoin-manager-snap","manifest":{"version":"0.1.4-rc4","description":"A MetaMask snap to manage Bitcoin","proposedName":"Bitcoin Manager","repository":{"type":"git","url":"https://github.com/MetaMask/bitcoin.git"},"source":{"shasum":"QOQ8JIPH6mEZUppVP94GxVdmReCCNGTwwl2wAnLLQaI=","location":{"npm":{"filePath":"dist/bundle.js","iconPath":"images/icon.svg","packageName":"@consensys/bitcoin-manager-snap","registry":"https://registry.npmjs.org/"}}},"initialConnections":{"http://localhost:3000":{},"https://ramps-dev.portfolio.metamask.io":{},"https://portfolio.metamask.io":{},"https://portfolio-builds.metafi-dev.codefi.network":{},"https://dev.portfolio.metamask.io":{}},"initialPermissions":{"endowment:rpc":{"dapps":true,"snaps":false},"endowment:keyring":{"allowedOrigins":["http://localhost:3000","https://ramps-dev.portfolio.metamask.io","https://portfolio.metamask.io","https://portfolio-builds.metafi-dev.codefi.network","https://dev.portfolio.metamask.io"]},"snap_getBip32Entropy":[{"path":["m","84'","0'"],"curve":"secp256k1"},{"path":["m","84'","1'"],"curve":"secp256k1"}],"endowment:network-access":{},"snap_manageAccounts":{},"snap_manageState":{},"snap_dialog":{}},"manifestVersion":"0.1"},"files":[{"path":"images/icon.svg","value":"\n\n\n\n\n\n\n\n\n\n"},{"path":"dist/bundle.js","value":"(()=>{var t={242:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer,i=r(4261),o=r(4347),s=r(7651);var a,c,u=(a=i,c=Object.create(null),a&&Object.keys(a).forEach((function(t){if(\"default\"!==t){var e=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(c,t,e.get?e:{enumerable:!0,get:function(){return a[t]}})}})),c.default=a,Object.freeze(c));const f=\"Expected Private\",h=\"Expected Point\",l=\"Expected Tweak\",p=\"Expected Signature\",d=\"Expected Extra Data (32 bytes)\",y=\"Expected Scalar\";u.utils.hmacSha256Sync=(t,...e)=>o.hmac(s.sha256,t,u.utils.concatBytes(...e)),u.utils.sha256Sync=(...t)=>s.sha256(u.utils.concatBytes(...t));const g=u.utils._normalizePrivateKey,b=32,w=32,m=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),v=32,E=new Uint8Array(32),_=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function S(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]=0)}function T(t){return t instanceof Uint8Array&&64===t.length&&S(t.subarray(0,32),m)<0&&S(t.subarray(32,64),m)<0}function x(t){return t instanceof Uint8Array&&64===t.length&&S(t.subarray(0,32),_)<0}function O(t){return t instanceof Uint8Array&&t.length===b}function k(t){return void 0===t||t instanceof Uint8Array&&t.length===v}function P(t){if(\"string\"!=typeof t)throw new TypeError(\"hexToNumber: expected string, got \"+typeof t);return BigInt(`0x${t}`)}function R(t){let e;if(\"bigint\"==typeof t)e=t;else if(\"number\"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if(\"string\"==typeof t){if(64!==t.length)throw new Error(\"Expected 32 bytes of private scalar\");e=P(t)}else{if(!(t instanceof Uint8Array))throw new TypeError(\"Expected valid private scalar\");if(32!==t.length)throw new Error(\"Expected 32 bytes of private scalar\");r=t,e=P(u.utils.bytesToHex(r))}var r;if(e<0)throw new Error(\"Expected private scalar >= 0\");return e}const B=(t,e,r)=>{const n=u.Point.fromHex(t),i=R(e),o=u.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error(\"Tweaked point at infinity\");return o.toRawBytes(r)};function C(t,e){return void 0===t?void 0===e||j(e):!!t}function N(t){try{return t()}catch(t){return null}}function L(t,e){if(32===t.length!==e)return!1;try{return!!u.Point.fromHex(t)}catch(t){return!1}}function U(t){return L(t,!1)}function j(t){return L(t,!1)&&33===t.length}function M(t){return u.utils.isValidPrivateKey(t)}function H(t){return L(t,!0)}function F(t){if(!U(t))throw new Error(h);return t.slice(1,33)}function D(t,e){if(!M(t))throw new Error(f);return N((()=>u.getPublicKey(t,C(e))))}e.isPoint=U,e.isPointCompressed=j,e.isPrivate=M,e.isXOnlyPoint=H,e.pointAdd=function(t,e,r){if(!U(t)||!U(e))throw new Error(h);return N((()=>{const n=u.Point.fromHex(t),i=u.Point.fromHex(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(C(r,t))}))},e.pointAddScalar=function(t,e,r){if(!U(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>B(t,e,C(r,t))))},e.pointCompress=function(t,e){if(!U(t))throw new Error(h);return u.Point.fromHex(t).toRawBytes(C(e,t))},e.pointFromScalar=D,e.pointMultiply=function(t,e,r){if(!U(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>((t,e,r)=>{const n=u.Point.fromHex(t),i=\"string\"==typeof e?e:u.utils.bytesToHex(e),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)})(t,e,C(r,t))))},e.privateAdd=function(t,e){if(!1===M(t))throw new Error(f);if(!1===I(e))throw new Error(l);return N((()=>((t,e)=>{const r=g(t),n=R(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r+n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.privateNegate=function(t){if(!1===M(t))throw new Error(f);return(t=>{const e=g(t),r=u.utils._bigintTo32Bytes(u.CURVE.n-e);return u.utils.isValidPrivateKey(r)?r:null})(t)},e.privateSub=function(t,e){if(!1===M(t))throw new Error(f);if(!1===I(e))throw new Error(l);return N((()=>((t,e)=>{const r=g(t),n=R(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r-n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.recover=function(t,e,r,n){if(!O(t))throw new Error(\"Expected Hash\");if(!T(e)||!function(t){return!(A(t.subarray(0,32))||A(t.subarray(32,64)))}(e))throw new Error(p);if(2&r&&!x(e))throw new Error(\"Bad Recovery Id\");if(!H(e.subarray(0,32)))throw new Error(p);return u.recoverPublicKey(t,e,r,C(n))},e.sign=function(t,e,r){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);return u.signSync(t,e,{der:!1,extraEntropy:r})},e.signRecoverable=function(t,e,r){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);const[n,i]=u.signSync(t,e,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}},e.signSchnorr=function(t,e,r=n.alloc(32,0)){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);return u.schnorr.signSync(t,e,r)},e.verify=function(t,e,r,n){if(!U(e))throw new Error(h);if(!T(r))throw new Error(p);if(!O(t))throw new Error(y);return u.verify(r,t,e,{strict:n})},e.verifySchnorr=function(t,e,r){if(!H(e))throw new Error(h);if(!T(r))throw new Error(p);if(!O(t))throw new Error(y);return u.schnorr.verifySync(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!H(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>{const r=B(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=F,e.xOnlyPointFromScalar=function(t){if(!M(t))throw new Error(f);return F(D(t))}},4857:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(4857),i=r(9019);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},4347:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(4857),i=r(9019);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),\"function\"!=typeof this.iHash.update)throw new Error(\"Expected instance of class which extends utils.Hash\");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;tnew o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},7651:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(8822),i=r(9019),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},9019:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(4605),i=r(4857);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},8460:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function i(t,...e){if(!((r=t)instanceof Uint8Array||null!=r&&\"object\"==typeof r&&\"Uint8Array\"===r.constructor.name))throw new Error(\"Expected Uint8Array\");var r;if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function o(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function a(t,e){i(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.add=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=e.split=e.fromBig=void 0;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;oBigInt(t>>>0)<>>0);e.toBig=s;const a=(t,e,r)=>t>>>r;e.shrSH=a;const c=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=c;const u=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=u;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const h=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=h;const l=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=l;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<>>32-r;e.rotlSH=y;const g=(t,e,r)=>e<>>32-r;e.rotlSL=g;const b=(t,e,r)=>e<>>64-r;e.rotlBH=b;const w=(t,e,r)=>t<>>64-r;function m(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w,e.add=m;const v=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=v;const E=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=E;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const A=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=A;const I=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=I;const T={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:h,rotrBL:l,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:g,rotlBH:b,rotlBL:w,add:m,add3L:v,add3H:E,add4L:_,add4H:S,add5H:I,add5L:A};e.default=T},6910:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},448:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.shake256=e.shake128=e.keccak_512=e.keccak_384=e.keccak_256=e.keccak_224=e.sha3_512=e.sha3_384=e.sha3_256=e.sha3_224=e.Keccak=e.keccakP=void 0;const n=r(8460),i=r(8081),o=r(9074),[s,a,c]=[[],[],[]],u=BigInt(0),f=BigInt(1),h=BigInt(2),l=BigInt(7),p=BigInt(256),d=BigInt(113);for(let t=0,e=f,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],s.push(2*(5*n+r)),a.push((t+1)*(t+2)/2%64);let i=u;for(let t=0;t<7;t++)e=(e<>l)*d)%p,e&h&&(i^=f<<(f<r>32?(0,i.rotlBH)(t,e,r):(0,i.rotlSH)(t,e,r),w=(t,e,r)=>r>32?(0,i.rotlBL)(t,e,r):(0,i.rotlSL)(t,e,r);function m(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,i=(e+2)%10,o=r[i],s=r[i+1],a=b(o,s,1)^r[n],c=w(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=c}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=a[r],o=b(e,i,n),c=w(e,i,n),u=s[r];e=t[u],i=t[u+1],t[u]=o,t[u+1]=c}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=y[n],t[1]^=g[n]}r.fill(0)}e.keccakP=m;class v extends o.Hash{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,n.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error(\"Sha3 supports only keccak-f1600 function\");this.state=new Uint8Array(200),this.state32=(0,o.u32)(this.state)}keccak(){m(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){(0,n.exists)(this);const{blockLen:e,state:r}=this,i=(t=(0,o.toBytes)(t)).length;for(let n=0;n=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error(\"XOF is not possible for this instance\");return this.writeInto(t)}xof(t){return(0,n.number)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,n.output)(t,this),this.finished)throw new Error(\"digest() was already called\");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return t||(t=new v(e,r,n,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=o,t.destroyed=this.destroyed,t}}e.Keccak=v;const E=(t,e,r)=>(0,o.wrapConstructor)((()=>new v(e,t,r)));e.sha3_224=E(6,144,28),e.sha3_256=E(6,136,32),e.sha3_384=E(6,104,48),e.sha3_512=E(6,72,64),e.keccak_224=E(1,144,28),e.keccak_256=E(1,136,32),e.keccak_384=E(1,104,48),e.keccak_512=E(1,72,64);const _=(t,e,r)=>(0,o.wrapXOFConstructorWithOpts)(((n={})=>new v(e,t,void 0===n.dkLen?r:n.dkLen,!0)));e.shake128=_(31,168,16),e.shake256=_(31,136,32)},9074:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const n=r(6910);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error(\"Non little-endian hardware is not supported\");const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){if(!i(t))throw new Error(\"Uint8Array expected\");let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},4261:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const n=r(2028),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),c=BigInt(8),u=Object.freeze({a:i,b:BigInt(7),P:BigInt(\"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\"),n:BigInt(\"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"),h:o,Gx:BigInt(\"55066263022277343669578718895168534326250603453777594175500187360389116729240\"),Gy:BigInt(\"32670510020758816978083085130507043184471273380659243275938904335757337482424\"),beta:BigInt(\"0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee\")});e.CURVE=u;const f=(t,e)=>(t+e/s)/e,h={beta:BigInt(\"0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee\"),splitScalar(t){const{n:e}=u,r=BigInt(\"0x3086d221a7d46bcde86c90e49284eb15\"),n=-o*BigInt(\"0xe4437ed6010e88286f547fa90abfe4c3\"),i=BigInt(\"0x114ca50f7a8e2f3f657c1108d9d44cfd8\"),s=r,a=BigInt(\"0x100000000000000000000000000000000\"),c=f(s*t,e),h=f(-n*t,e);let l=H(t-c*r-h*i,e),p=H(-c*n-h*s,e);const d=l>a,y=p>a;if(d&&(l=e-l),y&&(p=e-p),l>a||p>a)throw new Error(\"splitScalarEndo: Endomorphism failed, k=\"+t);return{k1neg:d,k1:l,k2neg:y,k2:p}}},l=32,p=32,d=l+1,y=2*l+1;function g(t){const{a:e,b:r}=u,n=H(t*t),i=H(n*t);return H(i+e*t+r)}const b=u.a===i;class w extends Error{constructor(t){super(t)}}function m(t){if(!(t instanceof v))throw new TypeError(\"JacobianPoint expected\")}class v{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof S))throw new TypeError(\"JacobianPoint#fromAffine: expected Point\");return t.equals(S.ZERO)?v.ZERO:new v(t.x,t.y,o)}static toAffineBatch(t){const e=function(t,e=u.P){const r=new Array(t.length),n=t.reduce(((t,n,o)=>n===i?t:(r[o]=t,H(t*n,e))),o),s=D(n,e);return t.reduceRight(((t,n,o)=>n===i?t:(r[o]=H(t*r[o],e),H(t*n,e))),s),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return v.toAffineBatch(t).map(v.fromAffine)}equals(t){m(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:s}=t,a=H(n*n),c=H(s*s),u=H(e*c),f=H(i*a),h=H(H(r*s)*c),l=H(H(o*n)*a);return u===f&&h===l}negate(){return new v(this.x,H(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=H(t*t),i=H(e*e),o=H(i*i),u=t+i,f=H(s*(H(u*u)-n-o)),h=H(a*n),l=H(h*h),p=H(l-s*f),d=H(h*(f-p)-c*o),y=H(s*e*r);return new v(p,d,y)}add(t){m(t);const{x:e,y:r,z:n}=this,{x:o,y:a,z:c}=t;if(o===i||a===i)return this;if(e===i||r===i)return t;const u=H(n*n),f=H(c*c),h=H(e*f),l=H(o*u),p=H(H(r*c)*f),d=H(H(a*n)*u),y=H(l-h),g=H(d-p);if(y===i)return g===i?this.double():v.ZERO;const b=H(y*y),w=H(y*b),E=H(h*b),_=H(g*g-w-s*E),S=H(g*(E-_)-p*w),A=H(n*c*y);return new v(_,S,A)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=v.ZERO;if(\"bigint\"==typeof t&&t===i)return e;let r=M(t);if(r===o)return this;if(!b){let t=e,n=this;for(;r>i;)r&o&&(t=t.add(n)),n=n.double(),r>>=o;return t}let{k1neg:n,k1:s,k2neg:a,k2:c}=h.splitScalar(r),u=e,f=e,l=this;for(;s>i||c>i;)s&o&&(u=u.add(l)),c&o&&(f=f.add(l)),l=l.double(),s>>=o,c>>=o;return n&&(u=u.negate()),a&&(f=f.negate()),f=new v(H(f.x*h.beta),f.y,f.z),u.add(f)}precomputeWindow(t){const e=b?128/t+1:256/t+1,r=[];let n=this,i=n;for(let o=0;o>=h,a>c&&(a-=f,t+=o);const l=r,p=r+Math.abs(a)-1,d=e%2!=0,y=a<0;0===a?s=s.add(E(d,n[l])):i=i.add(E(y,n[p]))}return{p:i,f:s}}multiply(t,e){let r,n,i=M(t);if(b){const{k1neg:t,k1:o,k2neg:s,k2:a}=h.splitScalar(i);let{p:c,f:u}=this.wNAF(o,e),{p:f,f:l}=this.wNAF(a,e);c=E(t,c),f=E(s,f),f=new v(H(f.x*h.beta),f.y,f.z),r=c.add(f),n=u.add(l)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return v.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(v.ZERO);null==t&&(t=i?c:D(n));const s=t,a=H(s*s),u=H(a*s),f=H(e*a),h=H(r*u),l=H(n*s);if(i)return S.ZERO;if(l!==o)throw new Error(\"invZ was invalid\");return new S(f,h)}}function E(t,e){const r=e.negate();return t?r:e}v.BASE=new v(u.Gx,u.Gy,o),v.ZERO=new v(i,o,i);const _=new WeakMap;class S{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,_.delete(this)}hasEvenY(){return this.y%s===i}static fromCompressedHex(t){const e=32===t.length,r=U(e?t:t.subarray(1));if(!W(r))throw new Error(\"Point is not on curve\");let n=function(t){const{P:e}=u,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),c=BigInt(44),f=BigInt(88),h=t*t*t%e,l=h*h*t%e,p=F(l,a)*l%e,d=F(p,a)*l%e,y=F(d,s)*h%e,g=F(y,n)*y%e,b=F(g,i)*g%e,w=F(b,c)*b%e,m=F(w,f)*w%e,v=F(m,c)*b%e,E=F(v,a)*l%e,_=F(E,o)*g%e,S=F(_,r)*h%e,A=F(S,s);if(A*A%e!==t)throw new Error(\"Cannot find square root\");return A}(g(r));const i=(n&o)===o;if(e)i&&(n=H(-n));else{1==(1&t[0])!==i&&(n=H(-n))}const c=new S(r,n);return c.assertValidity(),c}static fromUncompressedHex(t){const e=U(t.subarray(1,l+1)),r=U(t.subarray(l+1,2*l+1)),n=new S(e,r);return n.assertValidity(),n}static fromHex(t){const e=j(t),r=e.length,n=e[0];if(r===l)return this.fromCompressedHex(e);if(r===d&&(2===n||3===n))return this.fromCompressedHex(e);if(r===y&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-${d} compressed bytes or ${y} uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return S.BASE.multiply(z(t))}static fromSignature(t,e,r){const{r:n,s:i}=Y(e);if(![0,1,2,3].includes(r))throw new Error(\"Cannot recover: invalid recovery bit\");const o=$(j(t)),{n:s}=u,a=2===r||3===r?n+s:n,c=D(a,s),f=H(-o*c,s),h=H(i*c,s),l=1&r?\"03\":\"02\",p=S.fromHex(l+R(a)),d=S.BASE.multiplyAndAddUnsafe(p,f,h);if(!d)throw new Error(\"Cannot recover signature: point at infinify\");return d.assertValidity(),d}toRawBytes(t=!1){return L(this.toHex(t))}toHex(t=!1){const e=R(this.x);if(t){return`${this.hasEvenY()?\"02\":\"03\"}${e}`}return`04${e}${R(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t=\"Point is not on elliptic curve\",{x:e,y:r}=this;if(!W(e)||!W(r))throw new Error(t);const n=H(r*r);if(H(n-g(e))!==i)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new S(this.x,H(-this.y))}double(){return v.fromAffine(this).double().toAffine()}add(t){return v.fromAffine(this).add(v.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return v.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=v.fromAffine(this),s=e===i||e===o||this!==S.BASE?n.multiplyUnsafe(e):n.multiply(e),a=v.fromAffine(t).multiplyUnsafe(r),c=s.add(a);return c.equals(v.ZERO)?void 0:c.toAffine()}}function A(t){return Number.parseInt(t[0],16)>=8?\"00\"+t:t}function I(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${k(t)}`);const e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error(\"Invalid signature integer: wrong length\");if(0===r[0]&&r[1]<=127)throw new Error(\"Invalid signature integer: trailing length\");return{data:U(r),left:t.subarray(e+2)}}e.Point=S,S.BASE=new S(u.Gx,u.Gy),S.ZERO=new S(i,i);class T{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,r=\"Signature.fromCompact\";if(\"string\"!=typeof t&&!e)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=e?k(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new T(N(n.slice(0,64)),N(n.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if(\"string\"!=typeof t&&!e)throw new TypeError(\"Signature.fromDER: Expected string or Uint8Array\");const{r,s:n}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${k(t)}`);if(t[1]!==t.length-2)throw new Error(\"Invalid signature: incorrect length\");const{data:e,left:r}=I(t.subarray(2)),{data:n,left:i}=I(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${k(i)}`);return{r:e,s:n}}(e?t:L(t));return new T(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!q(t))throw new Error(\"Invalid Signature: r must be 0 < r < n\");if(!q(e))throw new Error(\"Invalid Signature: s must be 0 < s < n\")}hasHighS(){const t=u.n>>o;return this.s>t}normalizeS(){return this.hasHighS()?new T(this.r,H(-this.s,u.n)):this}toDERRawBytes(){return L(this.toDERHex())}toDERHex(){const t=A(C(this.s)),e=A(C(this.r)),r=t.length/2,n=e.length/2,i=C(r),o=C(n);return`30${C(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return L(this.toCompactHex())}toCompactHex(){return R(this.r)+R(this.s)}}function x(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error(\"Uint8Array list expected\");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;ee.toString(16).padStart(2,\"0\")));function k(t){if(!(t instanceof Uint8Array))throw new Error(\"Expected Uint8Array\");let e=\"\";for(let r=0;r0)return BigInt(t);if(\"bigint\"==typeof t&&q(t))return t;throw new TypeError(\"Expected valid private scalar: 0 < scalar < curve.n\")}function H(t,e=u.P){const r=t%e;return r>=i?r:e+r}function F(t,e){const{P:r}=u;let n=t;for(;e-- >i;)n*=n,n%=r;return n}function D(t,e=u.P){if(t===i||e<=i)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=H(t,e),n=e,s=i,a=o,c=o,f=i;for(;r!==i;){const t=n/r,e=n%r,i=s-c*t,o=a-f*t;n=r,r=e,s=c,a=f,c=i,f=o}if(n!==o)throw new Error(\"invert: does not exist\");return H(s,e)}function $(t,e=!1){const r=function(t){const e=8*t.length-8*p,r=U(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=u;return r>=n?r-n:r}let K,V;class G{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,\"number\"!=typeof t||t<2)throw new Error(\"hashLen must be a number\");if(\"number\"!=typeof e||e<2)throw new Error(\"qByteLen must be a number\");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return e.utils.hmacSha256(this.k,...t)}hmacSync(...t){return V(this.k,...t)}checkSync(){if(\"function\"!=typeof V)throw new w(\"hmacSha256Sync needs to be set\")}incr(){if(this.counter>=1e3)throw new Error(\"Tried 1,000 k values for sign(), all were invalid\");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),0!==t.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),0!==t.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t0)e=BigInt(t);else if(\"string\"==typeof t){if(t.length!==2*p)throw new Error(\"Expected 32 bytes of private key\");e=N(t)}else{if(!(t instanceof Uint8Array))throw new TypeError(\"Expected valid private key\");if(t.length!==p)throw new Error(\"Expected 32 bytes of private key\");e=U(t)}if(!q(e))throw new Error(\"Expected private key: 0 < key < n\");return e}function J(t){return t instanceof S?(t.assertValidity(),t):S.fromHex(t)}function Y(t){if(t instanceof T)return t.assertValidity(),t;try{return T.fromDER(t)}catch(e){return T.fromCompact(t)}}function Z(t){const e=t instanceof Uint8Array,r=\"string\"==typeof t,n=(e||r)&&t.length;return e?n===d||n===y:r?n===2*d||n===2*y:t instanceof S}function Q(t){return U(t.length>l?t.slice(0,l):t)}function tt(t){const e=Q(t),r=H(e,u.n);return et(r{t=j(t);const e=p+8;if(t.length1024)throw new Error(\"Expected valid bytes of private key as per FIPS 186\");return B(H(U(t),u.n-o)+o)},randomBytes:(t=32)=>{if(lt.web)return lt.web.getRandomValues(new Uint8Array(t));if(lt.node){const{randomBytes:e}=lt.node;return Uint8Array.from(e(t))}throw new Error(\"The environment doesn't have randomBytes function\")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(p+8)),precompute(t=8,e=S.BASE){const r=e===S.BASE?e:new S(e.x,e.y);return r._setWindowSize(t),r.multiply(a),r},sha256:async(...t)=>{if(lt.web){const e=await lt.web.subtle.digest(\"SHA-256\",x(...t));return new Uint8Array(e)}if(lt.node){const{createHash:e}=lt.node,r=e(\"sha256\");return t.forEach((t=>r.update(t))),Uint8Array.from(r.digest())}throw new Error(\"The environment doesn't have sha256 function\")},hmacSha256:async(t,...e)=>{if(lt.web){const r=await lt.web.subtle.importKey(\"raw\",t,{name:\"HMAC\",hash:{name:\"SHA-256\"}},!1,[\"sign\"]),n=x(...e),i=await lt.web.subtle.sign(\"HMAC\",r,n);return new Uint8Array(i)}if(lt.node){const{createHmac:r}=lt.node,n=r(\"sha256\",t);return e.forEach((t=>n.update(t))),Uint8Array.from(n.digest())}throw new Error(\"The environment doesn't have hmac-sha256 function\")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...r)=>{let n=dt[t];if(void 0===n){const r=await e.utils.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=x(r,r),dt[t]=n}return e.utils.sha256(n,...r)},taggedHashSync:(t,...e)=>{if(\"function\"!=typeof K)throw new w(\"sha256Sync is undefined, you need to set it\");let r=dt[t];if(void 0===r){const e=K(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=x(e,e),dt[t]=r}return K(r,...e)},_JacobianPoint:v},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get:()=>K,set(t){K||(K=t)}},hmacSha256Sync:{configurable:!1,get:()=>V,set(t){V||(V=t)}}})},6710:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function n(...t){const e=(t,e)=>r=>t(e(r)),r=Array.from(t).reverse().reduce(((t,r)=>t?e(t,r.encode):r.encode),void 0),n=t.reduce(((t,r)=>t?e(t,r.decode):r.decode),void 0);return{encode:r,decode:n}}function i(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&\"number\"!=typeof e[0])throw new Error(\"alphabet.encode input should be an array of numbers\");return e.map((e=>{if(r(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&\"string\"!=typeof e[0])throw new Error(\"alphabet.decode input should be array of strings\");return e.map((e=>{if(\"string\"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: \"${e}\". Allowed: ${t}`);return r}))}}}function o(t=\"\"){if(\"string\"!=typeof t)throw new Error(\"join separator should be string\");return{encode:e=>{if(!Array.isArray(e)||e.length&&\"string\"!=typeof e[0])throw new Error(\"join.encode input should be array of strings\");for(let t of e)if(\"string\"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if(\"string\"!=typeof e)throw new Error(\"join.decode input should be string\");return e.split(t)}}}function s(t,e=\"=\"){if(r(t),\"string\"!=typeof e)throw new Error(\"padding chr should be string\");return{encode(r){if(!Array.isArray(r)||r.length&&\"string\"!=typeof r[0])throw new Error(\"padding.encode input should be array of strings\");for(let t of r)if(\"string\"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&\"string\"!=typeof r[0])throw new Error(\"padding.encode input should be array of strings\");for(let t of r)if(\"string\"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let n=r.length;if(n*t%8)throw new Error(\"Invalid padding: string should have whole number of bytes\");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error(\"Invalid padding: string has too much padding\");return r.slice(0,n)}}}function a(t){if(\"function\"!=typeof t)throw new Error(\"normalize fn should be function\");return{encode:t=>t,decode:e=>t(e)}}function c(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error(\"convertRadix: data should be array\");if(!t.length)return[];let i=0;const o=[],s=Array.from(t);for(s.forEach((t=>{if(r(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)}));;){let t=0,r=!0;for(let o=i;oe?u(e,t%e):t,f=(t,e)=>t+(e-u(t,e));function h(t,e,n,i){if(!Array.isArray(t))throw new Error(\"convertRadix2: data should be array\");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(f(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${f(e,n)}`);let o=0,s=0;const a=2**n-1,c=[];for(const i of t){if(r(i),i>=2**e)throw new Error(`convertRadix2: invalid data word=${i} from=${e}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)c.push((o>>s-n&a)>>>0);o&=2**s-1}if(o=o<=e)throw new Error(\"Excess padding\");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&c.push(o>>>0),c}function l(t){return r(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error(\"radix.encode input should be Uint8Array\");return c(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&\"number\"!=typeof e[0])throw new Error(\"radix.decode input should be array of strings\");return Uint8Array.from(c(e,t,256))}}}function p(t,e=!1){if(r(t),t<=0||t>32)throw new Error(\"radix2: bits should be in (0..32]\");if(f(8,t)>32||f(t,8)>32)throw new Error(\"radix2: carry overflow\");return{encode:r=>{if(!(r instanceof Uint8Array))throw new Error(\"radix2.encode input should be Uint8Array\");return h(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&\"number\"!=typeof r[0])throw new Error(\"radix2.decode input should be array of strings\");return Uint8Array.from(h(r,t,8,e))}}}function d(t){if(\"function\"!=typeof t)throw new Error(\"unsafeWrapper fn should be function\");return function(...e){try{return t.apply(null,e)}catch(t){}}}function y(t,e){if(r(t),\"function\"!=typeof e)throw new Error(\"checksum fn should be function\");return{encode(r){if(!(r instanceof Uint8Array))throw new Error(\"checksum.encode: input should be Uint8Array\");const n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!(r instanceof Uint8Array))throw new Error(\"checksum.decode: input should be Uint8Array\");const n=r.slice(0,-t),i=e(n).slice(0,t),o=r.slice(-t);for(let e=0;et.toUpperCase().replace(/O/g,\"0\").replace(/[IL]/g,\"1\")))),e.base64=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"),s(6),o(\"\")),e.base64url=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\"),s(6),o(\"\")),e.base64urlnopad=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\"),o(\"\"));const g=t=>n(l(58),i(t),o(\"\"));e.base58=g(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\"),e.base58flickr=g(\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"),e.base58xrp=g(\"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz\");const b=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let r=\"\";for(let n=0;nn(y(4,(e=>t(t(e)))),e.base58);const w=n(i(\"qpzry9x8gf2tvdw0s3jn54khce6mua7l\"),o(\"\")),m=[996825010,642813549,513874426,1027748829,705979059];function v(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t>t&1)&&(r^=m[t]);return r}function E(t,e,r=1){const n=t.length;let i=1;for(let e=0;e126)throw new Error(`Invalid prefix (${t})`);i=v(i)^r>>5}i=v(i);for(let e=0;er)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${r})`);const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())throw new Error(\"String must be lowercase or uppercase\");const i=(t=n).lastIndexOf(\"1\");if(0===i||-1===i)throw new Error('Letter \"1\" must be present between prefix and data only');const o=t.slice(0,i),s=t.slice(i+1);if(s.length<6)throw new Error(\"Data must be at least 6 characters long\");const a=w.decode(s).slice(0,-6),c=E(o,a,e);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected \"${c}\"`);return{prefix:o,words:a}}return{encode:function(t,r,n=90){if(\"string\"!=typeof t)throw new Error(\"bech32.encode prefix should be string, not \"+typeof t);if(!Array.isArray(r)||r.length&&\"number\"!=typeof r[0])throw new Error(\"bech32.encode words should be array of numbers, not \"+typeof r);const i=t.length+7+r.length;if(!1!==n&&i>n)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=t.toLowerCase(),s=E(o,r,e);return`${o}1${w.encode(r)}${s}`},decode:s,decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:d(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}e.bech32=_(\"bech32\"),e.bech32m=_(\"bech32m\"),e.utf8={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},e.hex=n(p(4),i(\"0123456789abcdef\"),o(\"\"),a((t=>{if(\"string\"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));const S={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},A=\"Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr\";e.bytesToString=(t,e)=>{if(\"string\"!=typeof t||!S.hasOwnProperty(t))throw new TypeError(A);if(!(e instanceof Uint8Array))throw new TypeError(\"bytesToString() expects Uint8Array\");return S[t].encode(e)},e.str=e.bytesToString;e.stringToBytes=(t,e)=>{if(!S.hasOwnProperty(t))throw new TypeError(A);if(\"string\"!=typeof e)throw new TypeError(\"stringToBytes() expects string\");return S[t].decode(e)},e.bytes=e.stringToBytes},9784:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError(\"Alphabet too long\");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,p=s-1;(0!==h||l>>0,f[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error(\"Non-zero carry\");o=l,r++}for(var d=s-o;d!==s&&0===f[d];)d++;var y=n.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var g=i;d!==s;)y[g++]=f[d++];return y}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError(\"Expected Buffer\");if(0===e.length)return\"\";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var l=e[o],p=0,d=u-1;(0!==l||p>>0,h[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error(\"Non-zero carry\");i=p,o++}for(var y=u-i;y!==u&&0===h[y];)y++;for(var g=c.repeat(r);y{\"use strict\";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],c=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,c)),f=0,h=c>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===c&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===c&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,u=n-i;au?u:a+s));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+\"==\")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\"));return o.join(\"\")};for(var r=[],n=[],i=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,o=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var r=t.indexOf(\"=\");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,n){for(var i,o,s=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join(\"\")}n[\"-\".charCodeAt(0)]=62,n[\"_\".charCodeAt(0)]=63},6586:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.bech32m=e.bech32=void 0;const r=\"qpzry9x8gf2tvdw0s3jn54khce6mua7l\",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r126)return\"Invalid prefix (\"+t+\")\";e=i(e)^n>>5}e=i(e);for(let r=0;r=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)return\"Excess padding\";if(i<r)return\"Exceeds length limit\";const s=t.toLowerCase(),a=t.toUpperCase();if(t!==s&&t!==a)return\"Mixed-case string \"+t;const c=(t=s).lastIndexOf(\"1\");if(-1===c)return\"No separator character for \"+t;if(0===c)return\"Missing prefix for \"+t;const u=t.slice(0,c),f=t.slice(c+1);if(f.length<6)return\"Data too short\";let h=o(u);if(\"string\"==typeof h)return h;const l=[];for(let t=0;t=f.length||l.push(r)}return h!==e?\"Invalid checksum for \"+t:{prefix:u,words:l}}return e=\"bech32\"===t?1:734539939,{decodeUnsafe:function(t,e){const r=s(t,e);if(\"object\"==typeof r)return r},decode:function(t,e){const r=s(t,e);if(\"object\"==typeof r)return r;throw new Error(r)},encode:function(t,n,s){if(s=s||90,t.length+7+n.length>s)throw new TypeError(\"Exceeds length limit\");let a=o(t=t.toLowerCase());if(\"string\"==typeof a)throw new Error(a);let c=t+\"1\";for(let t=0;t>5!=0)throw new Error(\"Non 5-bit word\");a=i(a)^e,c+=r.charAt(e)}for(let t=0;t<6;++t)a=i(a);a^=e;for(let t=0;t<6;++t){c+=r.charAt(a>>5*(5-t)&31)}return c},toWords:a,fromWordsUnsafe:c,fromWords:u}}e.bech32=f(\"bech32\"),e.bech32m=f(\"bech32m\")},3162:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});const n=r(6808);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter((t=>t.key.toString(\"hex\")===n))[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function s(t){const e=new Set;return t.forEach((t=>{const r=t.key.toString(\"hex\");if(e.has(r))throw new Error(\"Combine: KeyValue Map keys should be unique\");e.add(r)})),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),a=t.slice(1);if(0===a.length)throw new Error(\"Combine: Nothing to combine\");const c=o(e);if(void 0===c)throw new Error(\"Combine: Self missing transaction\");const u=s(r.globalKeyVals),f=r.inputKeyVals.map(s),h=r.outputKeyVals.map(s);for(const t of a){const e=o(t);if(void 0===e||!e.toBuffer().equals(c.toBuffer()))throw new Error(\"Combine: One of the Psbts does not have the same transaction.\");const a=n.psbtToKeyVals(t);s(a.globalKeyVals).forEach(i(u,r.globalKeyVals,a.globalKeyVals));a.inputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(f[e],r.inputKeyVals[e],a.inputKeyVals[e]))));a.outputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(h[e],r.outputKeyVals[e],a.outputKeyVals[e]))))}return n.psbtFromKeyVals(c,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},9977:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error(\"Decode Error: could not decode globalXpub with key 0x\"+t.key.toString(\"hex\"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error(\"Decode Error: globalXpub has invalid extended pubkey in key 0x\"+t.key.toString(\"hex\"));if(t.value.length/4%1!=0)throw new Error(\"Decode Error: Global GLOBAL_XPUB value length should be multiple of 4\");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:\"m\"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+=\"/\"+o.toString(10)+(i?\"'\":\"\")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split(\"/\"),s=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e=\"'\"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:r,value:s}},e.expected=\"{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }\",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&\"string\"==typeof i&&!!i.match(/^m(\\/\\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.extendedPubkey.equals(e.extendedPubkey))).length)}},3398:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},6317:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});const n=r(9889),i=r(9977),o=r(3398),s=r(7312),a=r(1661),c=r(8730),u=r(5098),f=r(4474),h=r(9175),l=r(7279),p=r(7544),d=r(241),y=r(3155),g=r(4709),b=r(9574),w=r(6896),m=r(437),v=r(5400),E=r(2751),_=r(9632),S=r(9079),A={unsignedTx:o,globalXpub:i,checkPubkey:m.makeChecker([])};e.globals=A;const I={nonWitnessUtxo:c,partialSig:u,sighashType:h,finalScriptSig:s,finalScriptWitness:a,porCommitment:f,witnessUtxo:g,bip32Derivation:w.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:l,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:E.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:_.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=I;const T={bip32Derivation:w.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:E.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:b,tapInternalKey:_.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},7312:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error(\"Decode Error: could not decode finalScriptSig with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},1661:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error(\"Decode Error: could not decode finalScriptWitness with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},8730:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error(\"Decode Error: could not decode nonWitnessUtxo with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},5098:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error(\"Decode Error: could not decode partialSig with key 0x\"+t.key.toString(\"hex\"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error(\"Decode Error: partialSig has invalid pubkey in key 0x\"+t.key.toString(\"hex\"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected=\"{ pubkey: Buffer; signature: Buffer; }\",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}},4474:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error(\"Decode Error: could not decode porCommitment with key 0x\"+t.key.toString(\"hex\"));return t.value.toString(\"utf8\")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,\"utf8\")}},e.expected=\"string\",e.check=function(t){return\"string\"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}},9175:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error(\"Decode Error: could not decode sighashType with key 0x\"+t.key.toString(\"hex\"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected=\"number\",e.check=function(t){return\"number\"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},7279:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapKeySig with key 0x\"+t.key.toString(\"hex\"));if(!o(t.value))throw new Error(\"Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature\");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected=\"Buffer\",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},7544:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error(\"Decode Error: could not decode tapLeafScript with key 0x\"+t.key.toString(\"hex\"));if((t.key.length-2)%32!=0)throw new Error(\"Decode Error: tapLeafScript has invalid control block in key 0x\"+t.key.toString(\"hex\"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error(\"Decode Error: tapLeafScript bad leaf version in key 0x\"+t.key.toString(\"hex\"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected=\"{ controlBlock: Buffer; leafVersion: number, script: Buffer; }\",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.controlBlock.equals(e.controlBlock))).length)}},241:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapMerkleRoot with key 0x\"+t.key.toString(\"hex\"));if(!o(t.value))throw new Error(\"Decode Error: tapMerkleRoot not a 32-byte hash\");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected=\"Buffer\",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},3155:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error(\"Decode Error: could not decode tapScriptSig with key 0x\"+t.key.toString(\"hex\"));if(65!==t.key.length)throw new Error(\"Decode Error: tapScriptSig has invalid key 0x\"+t.key.toString(\"hex\"));if(64!==t.value.length&&65!==t.value.length)throw new Error(\"Decode Error: tapScriptSig has invalid signature in key 0x\"+t.key.toString(\"hex\"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected=\"{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }\",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString(\"hex\")+e.leafHash.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash))).length)}},4709:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889),o=r(5962),s=r(2715);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error(\"Decode Error: could not decode witnessUtxo with key 0x\"+t.key.toString(\"hex\"));const e=o.readUInt64LE(t.value,0);let r=8;const n=s.decode(t.value,r);r+=s.encodingLength(n);const a=t.value.slice(r);if(a.length!==n)throw new Error(\"Decode Error: WITNESS_UTXO script is not proper length\");return{script:a,value:e}},e.encode=function(t){const{script:e,value:r}=t,a=s.encodingLength(e.length),c=n.allocUnsafe(8+a+e.length);return o.writeUInt64LE(c,r,0),s.encode(e.length,c,8),e.copy(c,8+a),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:c}},e.expected=\"{ script: Buffer; value: number; }\",e.check=function(t){return n.isBuffer(t.script)&&\"number\"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},9574:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889),o=r(2715);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapTree with key 0x\"+t.key.toString(\"hex\"));let e=0;const r=[];for(;e[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script])));return{key:e,value:n.concat(r)}},e.expected=\"{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }\",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every((t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script)))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},6896:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=t=>33===t.length&&[2,3].includes(t[0])||65===t.length&&4===t[0];e.makeConverter=function(t,e=i){return{decode:function(r){if(r.key[0]!==t)throw new Error(\"Decode Error: could not decode bip32Derivation with key 0x\"+r.key.toString(\"hex\"));const n=r.key.slice(1);if(!e(n))throw new Error(\"Decode Error: bip32Derivation has invalid pubkey in key 0x\"+r.key.toString(\"hex\"));if(r.value.length/4%1!=0)throw new Error(\"Decode Error: Input BIP32_DERIVATION value length should be multiple of 4\");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:\"m\"};for(const t of(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+=\"/\"+o.toString(10)+(n?\"'\":\"\")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split(\"/\"),s=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e=\"'\"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:i,value:s}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&\"string\"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:\"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }\",canAddToArray:function(t,e,r){const n=e.pubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}}}},437:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error(\"Format Error: invalid pubkey in key 0x\"+e.key.toString(\"hex\"));return r}}},5400:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error(\"Decode Error: could not decode redeemScript with key 0x\"+e.key.toString(\"hex\"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.redeemScript}}}},2751:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(2715),o=r(6896),s=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,s);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),s=new Array(r);for(let e=0,i=n;en.isBuffer(t)&&32===t.length))&&e.check(t)},expected:\"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }\",canAddToArray:e.canAddToArray}}},9632:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t||1!==e.key.length)throw new Error(\"Decode Error: could not decode tapInternalKey with key 0x\"+e.key.toString(\"hex\"));if(32!==e.value.length)throw new Error(\"Decode Error: tapInternalKey not a 32-byte x-only pubkey\");return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)&&32===t.length},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.tapInternalKey}}}},9079:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error(\"Decode Error: could not decode witnessScript with key 0x\"+e.key.toString(\"hex\"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.witnessScript}}}},5962:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(2715);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),s=i.encodingLength(r),a=n.allocUnsafe(o+e+s+r);return i.encode(e,a,0),t.key.copy(a,o),i.encode(r,a,o+e),t.value.copy(a,o+e+s),a}function s(t,e){if(\"number\"!=typeof t)throw new Error(\"cannot write a non-number as a number\");if(t<0)throw new Error(\"specified a negative value for writing an unsigned value\");if(t>e)throw new Error(\"RangeError: value out of range\");if(Math.floor(t)!==t)throw new Error(\"value has a fractional component\")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError(\"value out of range\")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.encode=function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError(\"buffer must be a Buffer instance\");return i||(i=0),e<253?(r.writeUInt8(e,i),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError(\"buffer must be a Buffer instance\");r||(r=0);const i=e.readUInt8(r);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===i)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),i=4294967296*e.readUInt32LE(r+5)+n;return o(i),i}},e.encodingLength=s},4112:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317),o=r(5962),s=r(2715),a=r(9889);function c(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString(\"hex\")}`)}function u(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const s={unsignedTx:t};let u=0;for(const t of e)switch(t.key[0]){case a.GlobalTypes.UNSIGNED_TX:if(c(\"global\",t.key,a.GlobalTypes.UNSIGNED_TX),u>0)throw new Error(\"Format Error: GlobalMap has multiple UNSIGNED_TX\");u++;break;case a.GlobalTypes.GLOBAL_XPUB:void 0===s.globalXpub&&(s.globalXpub=[]),s.globalXpub.push(i.globals.globalXpub.decode(t));break;default:s.unknownKeyVals||(s.unknownKeyVals=[]),s.unknownKeyVals.push(t)}const f=r.length,h=n.length,l=[],p=[];for(const t of o.range(f)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case a.InputTypes.NON_WITNESS_UTXO:if(c(\"input\",n.key,a.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error(\"Format Error: Input has multiple NON_WITNESS_UTXO\");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case a.InputTypes.WITNESS_UTXO:if(c(\"input\",n.key,a.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error(\"Format Error: Input has multiple WITNESS_UTXO\");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case a.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case a.InputTypes.SIGHASH_TYPE:if(c(\"input\",n.key,a.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error(\"Format Error: Input has multiple SIGHASH_TYPE\");e.sighashType=i.inputs.sighashType.decode(n);break;case a.InputTypes.REDEEM_SCRIPT:if(c(\"input\",n.key,a.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error(\"Format Error: Input has multiple REDEEM_SCRIPT\");e.redeemScript=i.inputs.redeemScript.decode(n);break;case a.InputTypes.WITNESS_SCRIPT:if(c(\"input\",n.key,a.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error(\"Format Error: Input has multiple WITNESS_SCRIPT\");e.witnessScript=i.inputs.witnessScript.decode(n);break;case a.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case a.InputTypes.FINAL_SCRIPTSIG:c(\"input\",n.key,a.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case a.InputTypes.FINAL_SCRIPTWITNESS:c(\"input\",n.key,a.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case a.InputTypes.POR_COMMITMENT:c(\"input\",n.key,a.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case a.InputTypes.TAP_KEY_SIG:c(\"input\",n.key,a.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case a.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case a.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case a.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case a.InputTypes.TAP_INTERNAL_KEY:c(\"input\",n.key,a.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case a.InputTypes.TAP_MERKLE_ROOT:c(\"input\",n.key,a.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}l.push(e)}for(const t of o.range(h)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case a.OutputTypes.REDEEM_SCRIPT:if(c(\"output\",r.key,a.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error(\"Format Error: Output has multiple REDEEM_SCRIPT\");e.redeemScript=i.outputs.redeemScript.decode(r);break;case a.OutputTypes.WITNESS_SCRIPT:if(c(\"output\",r.key,a.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error(\"Format Error: Output has multiple WITNESS_SCRIPT\");e.witnessScript=i.outputs.witnessScript.decode(r);break;case a.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case a.OutputTypes.TAP_INTERNAL_KEY:c(\"output\",r.key,a.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case a.OutputTypes.TAP_TREE:c(\"output\",r.key,a.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case a.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:s,inputs:l,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=s.decode(t,r);r+=s.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function c(){if(r>=t.length)throw new Error(\"Format Error: Unexpected End of PSBT\");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error(\"Format Error: Invalid Magic Number\");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error(\"Format Error: Magic Number must be followed by 0xff separator\");const f=[],h={};for(;!c();){const t=i(),e=t.key.toString(\"hex\");if(h[e])throw new Error(\"Format Error: Keys must be unique for global keymap: key \"+e);h[e]=1,f.push(t)}const l=f.filter((t=>t.key[0]===a.GlobalTypes.UNSIGNED_TX));if(1!==l.length)throw new Error(\"Format Error: Only one UNSIGNED_TX allowed\");const p=e(l[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),g=[],b=[];for(const t of o.range(d)){const e={},r=[];for(;!c();){const n=i(),o=n.key.toString(\"hex\");if(e[o])throw new Error(\"Format Error: Keys must be unique for each input: input index \"+t+\" key \"+o);e[o]=1,r.push(n)}g.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!c();){const n=i(),o=n.key.toString(\"hex\");if(e[o])throw new Error(\"Format Error: Keys must be unique for each output: output index \"+t+\" key \"+o);e[o]=1,r.push(n)}b.push(r)}return u(p,{globalMapKeyVals:f,inputKeyVals:g,outputKeyVals:b})},e.checkKeyBuffer=c,e.psbtFromKeyVals=u},6808:(t,e,r)=>{\"use strict\";function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,\"__esModule\",{value:!0}),n(r(4112)),n(r(2673))},2673:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317),o=r(5962);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:s,outputKeyVals:a}=c({globalMap:t,inputs:e,outputs:r}),u=o.keyValsToBuffer(i),f=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),h=f(s),l=f(a),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,u].concat(h,l))};const s=(t,e)=>t.key.compare(e.key);function a(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if(\"unknownKeyVals\"===n)return t;const o=e[n];if(void 0===o)return t;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((t=>t.key.toString(\"hex\"))).forEach((t=>{if(r.has(t))throw new Error(\"Serialize Error: Duplicate key: \"+t);r.add(t)})),t.concat(s)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString(\"hex\")))):[];return n.concat(i).sort(s)}function c({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:a(t,i.globals),inputKeyVals:e.map((t=>a(t,i.inputs))),outputKeyVals:r.map((t=>a(t,i.outputs)))}}e.psbtToKeyVals=c},7003:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(3162),o=r(6808),s=r(9889),a=r(2431);e.Psbt=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,\"base64\");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,\"hex\");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString(\"base64\")}toHex(){return this.toBuffer().toString(\"hex\")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return a.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=a.checkForInput(this.inputs,t);return a.updateInput(e,r),this}updateOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return a.checkHasKey(t,this.globalMap.unknownKeyVals,a.getEnumLength(s.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=a.checkForInput(this.inputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error(\"unknownKeyVals must be an Array\");return e.forEach((t=>this.addUnknownKeyValToInput(r,t))),a.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error(\"unknownKeyVals must be an Array\");return e.forEach((t=>this.addUnknownKeyValToOutput(r,t))),a.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=a.checkForInput(this.inputs,t);a.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))[\"witnessUtxo\",\"nonWitnessUtxo\",\"finalScriptSig\",\"finalScriptWitness\",\"unknownKeyVals\"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},9889:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),function(t){t[t.UNSIGNED_TX=0]=\"UNSIGNED_TX\",t[t.GLOBAL_XPUB=1]=\"GLOBAL_XPUB\"}(e.GlobalTypes||(e.GlobalTypes={})),e.GLOBAL_TYPE_NAMES=[\"unsignedTx\",\"globalXpub\"],function(t){t[t.NON_WITNESS_UTXO=0]=\"NON_WITNESS_UTXO\",t[t.WITNESS_UTXO=1]=\"WITNESS_UTXO\",t[t.PARTIAL_SIG=2]=\"PARTIAL_SIG\",t[t.SIGHASH_TYPE=3]=\"SIGHASH_TYPE\",t[t.REDEEM_SCRIPT=4]=\"REDEEM_SCRIPT\",t[t.WITNESS_SCRIPT=5]=\"WITNESS_SCRIPT\",t[t.BIP32_DERIVATION=6]=\"BIP32_DERIVATION\",t[t.FINAL_SCRIPTSIG=7]=\"FINAL_SCRIPTSIG\",t[t.FINAL_SCRIPTWITNESS=8]=\"FINAL_SCRIPTWITNESS\",t[t.POR_COMMITMENT=9]=\"POR_COMMITMENT\",t[t.TAP_KEY_SIG=19]=\"TAP_KEY_SIG\",t[t.TAP_SCRIPT_SIG=20]=\"TAP_SCRIPT_SIG\",t[t.TAP_LEAF_SCRIPT=21]=\"TAP_LEAF_SCRIPT\",t[t.TAP_BIP32_DERIVATION=22]=\"TAP_BIP32_DERIVATION\",t[t.TAP_INTERNAL_KEY=23]=\"TAP_INTERNAL_KEY\",t[t.TAP_MERKLE_ROOT=24]=\"TAP_MERKLE_ROOT\"}(e.InputTypes||(e.InputTypes={})),e.INPUT_TYPE_NAMES=[\"nonWitnessUtxo\",\"witnessUtxo\",\"partialSig\",\"sighashType\",\"redeemScript\",\"witnessScript\",\"bip32Derivation\",\"finalScriptSig\",\"finalScriptWitness\",\"porCommitment\",\"tapKeySig\",\"tapScriptSig\",\"tapLeafScript\",\"tapBip32Derivation\",\"tapInternalKey\",\"tapMerkleRoot\"],function(t){t[t.REDEEM_SCRIPT=0]=\"REDEEM_SCRIPT\",t[t.WITNESS_SCRIPT=1]=\"WITNESS_SCRIPT\",t[t.BIP32_DERIVATION=2]=\"BIP32_DERIVATION\",t[t.TAP_INTERNAL_KEY=5]=\"TAP_INTERNAL_KEY\",t[t.TAP_TREE=6]=\"TAP_TREE\",t[t.TAP_BIP32_DERIVATION=7]=\"TAP_BIP32_DERIVATION\"}(e.OutputTypes||(e.OutputTypes={})),e.OUTPUT_TYPE_NAMES=[\"redeemScript\",\"witnessScript\",\"bip32Derivation\",\"tapInternalKey\",\"tapTree\",\"tapBip32Derivation\"]},2431:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function s(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function a(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function c(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:s,canAddToArray:c,check:u,expected:f}=i[t+\"s\"][n]||{};if(u)if(!!c){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(u)||a(t,n,f,o);const e=r[n]||[],i=new Set;if(!o.every((t=>c(e,t,i))))throw new Error(\"Can not add duplicate data to array\");r[n]=e.concat(o)}else{if(u(o)||a(t,n,f,o),!s(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=s,e.checkHasKey=function(t,e,r){if(t.key[0]e.key.equals(t.key))).length)throw new Error(`Duplicate Key: ${t.key.toString(\"hex\")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach((t=>{Number(isNaN(Number(t)))&&e++})),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,s=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=c(\"global\"),e.updateInput=c(\"input\"),e.updateOutput=c(\"output\"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=s(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error(\"Set Version: Invalid Transaction\");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error(\"Set Locktime: Invalid Transaction\");return e.writeUInt32LE(t,e.length-4),e}},3678:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(3678),i=r(1752);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.add=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=e.split=e.fromBig=void 0;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;oBigInt(t>>>0)<>>0);e.toBig=s;const a=(t,e,r)=>t>>>r;e.shrSH=a;const c=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=c;const u=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=u;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const h=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=h;const l=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=l;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<>>32-r;e.rotlSH=y;const g=(t,e,r)=>e<>>32-r;e.rotlSL=g;const b=(t,e,r)=>e<>>64-r;e.rotlBH=b;const w=(t,e,r)=>t<>>64-r;function m(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w,e.add=m;const v=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=v;const E=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=E;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const A=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=A;const I=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=I;const T={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:h,rotrBL:l,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:g,rotlBH:b,rotlBL:w,add:m,add3L:v,add3H:E,add4L:_,add4H:S,add5H:I,add5L:A};e.default=T},8280:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},4966:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(3678),i=r(1752);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),\"function\"!=typeof this.iHash.update)throw new Error(\"Expected instance of class which extends utils.Hash\");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;tnew o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},2985:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(7653),i=r(1752),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),a=s.map((t=>(9*t+5)%16));let c=[s],u=[a];for(let t=0;t<4;t++)for(let e of[c,u])e.push(e[t].map((t=>o[t])));const f=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),l=u.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const g=new Uint32Array(16);class b extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)g[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,a=0|this.h2,f=a,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=p[t],_=d[t],S=c[t],A=u[t],I=h[t],T=l[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,a,b)+g[S[e]]+E,I[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(a,10),a=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,s,f,w)+g[A[t]]+_,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(f,10),f=s,s=r}}this.set(this.h1+a+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+f|0)}roundClean(){g.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=b,e.ripemd160=(0,i.wrapConstructor)((()=>new b))},4458:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(7653),i=r(1752),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},4787:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha384=e.sha512_256=e.sha512_224=e.sha512=e.SHA512=void 0;const n=r(7653),i=r(6079),o=r(1752),[s,a]=i.default.split([\"0x428a2f98d728ae22\",\"0x7137449123ef65cd\",\"0xb5c0fbcfec4d3b2f\",\"0xe9b5dba58189dbbc\",\"0x3956c25bf348b538\",\"0x59f111f1b605d019\",\"0x923f82a4af194f9b\",\"0xab1c5ed5da6d8118\",\"0xd807aa98a3030242\",\"0x12835b0145706fbe\",\"0x243185be4ee4b28c\",\"0x550c7dc3d5ffb4e2\",\"0x72be5d74f27b896f\",\"0x80deb1fe3b1696b1\",\"0x9bdc06a725c71235\",\"0xc19bf174cf692694\",\"0xe49b69c19ef14ad2\",\"0xefbe4786384f25e3\",\"0x0fc19dc68b8cd5b5\",\"0x240ca1cc77ac9c65\",\"0x2de92c6f592b0275\",\"0x4a7484aa6ea6e483\",\"0x5cb0a9dcbd41fbd4\",\"0x76f988da831153b5\",\"0x983e5152ee66dfab\",\"0xa831c66d2db43210\",\"0xb00327c898fb213f\",\"0xbf597fc7beef0ee4\",\"0xc6e00bf33da88fc2\",\"0xd5a79147930aa725\",\"0x06ca6351e003826f\",\"0x142929670a0e6e70\",\"0x27b70a8546d22ffc\",\"0x2e1b21385c26c926\",\"0x4d2c6dfc5ac42aed\",\"0x53380d139d95b3df\",\"0x650a73548baf63de\",\"0x766a0abb3c77b2a8\",\"0x81c2c92e47edaee6\",\"0x92722c851482353b\",\"0xa2bfe8a14cf10364\",\"0xa81a664bbc423001\",\"0xc24b8b70d0f89791\",\"0xc76c51a30654be30\",\"0xd192e819d6ef5218\",\"0xd69906245565a910\",\"0xf40e35855771202a\",\"0x106aa07032bbd1b8\",\"0x19a4c116b8d2d0c8\",\"0x1e376c085141ab53\",\"0x2748774cdf8eeb99\",\"0x34b0bcb5e19b48a8\",\"0x391c0cb3c5c95a63\",\"0x4ed8aa4ae3418acb\",\"0x5b9cca4f7763e373\",\"0x682e6ff3d6b2b8a3\",\"0x748f82ee5defb2fc\",\"0x78a5636f43172f60\",\"0x84c87814a1f0ab72\",\"0x8cc702081a6439ec\",\"0x90befffa23631e28\",\"0xa4506cebde82bde9\",\"0xbef9a3f7b2c67915\",\"0xc67178f2e372532b\",\"0xca273eceea26619c\",\"0xd186b8c721c0c207\",\"0xeada7dd6cde0eb1e\",\"0xf57d4f7fee6ed178\",\"0x06f067aa72176fba\",\"0x0a637dc5a2c898a6\",\"0x113f9804bef90dae\",\"0x1b710b35131c471b\",\"0x28db77f523047d84\",\"0x32caab7b40c72493\",\"0x3c9ebe0a15c9bebc\",\"0x431d67c49c100d4c\",\"0x4cc5d4becb3e42b6\",\"0x597f299cfc657e2a\",\"0x5fcb6fab3ad6faec\",\"0x6c44198c4a475817\"].map((t=>BigInt(t)))),c=new Uint32Array(80),u=new Uint32Array(80);class f extends n.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:f,Fl:h,Gh:l,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,s,a,c,u,f,h,l,p,d,y]}set(t,e,r,n,i,o,s,a,c,u,f,h,l,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|f,this.Fl=0|h,this.Gh=0|l,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)c[r]=t.getUint32(e),u[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|c[t-15],r=0|u[t-15],n=i.default.rotrSH(e,r,1)^i.default.rotrSH(e,r,8)^i.default.shrSH(e,r,7),o=i.default.rotrSL(e,r,1)^i.default.rotrSL(e,r,8)^i.default.shrSL(e,r,7),s=0|c[t-2],a=0|u[t-2],f=i.default.rotrSH(s,a,19)^i.default.rotrBH(s,a,61)^i.default.shrSH(s,a,6),h=i.default.rotrSL(s,a,19)^i.default.rotrBL(s,a,61)^i.default.shrSL(s,a,6),l=i.default.add4L(o,h,u[t-7],u[t-16]),p=i.default.add4H(l,n,f,c[t-7],c[t-16]);c[t]=0|p,u[t]=0|l}let{Ah:r,Al:n,Bh:o,Bl:f,Ch:h,Cl:l,Dh:p,Dl:d,Eh:y,El:g,Fh:b,Fl:w,Gh:m,Gl:v,Hh:E,Hl:_}=this;for(let t=0;t<80;t++){const e=i.default.rotrSH(y,g,14)^i.default.rotrSH(y,g,18)^i.default.rotrBH(y,g,41),S=i.default.rotrSL(y,g,14)^i.default.rotrSL(y,g,18)^i.default.rotrBL(y,g,41),A=y&b^~y&m,I=g&w^~g&v,T=i.default.add5L(_,S,I,a[t],u[t]),x=i.default.add5H(T,E,e,A,s[t],c[t]),O=0|T,k=i.default.rotrSH(r,n,28)^i.default.rotrBH(r,n,34)^i.default.rotrBH(r,n,39),P=i.default.rotrSL(r,n,28)^i.default.rotrBL(r,n,34)^i.default.rotrBL(r,n,39),R=r&o^r&h^o&h,B=n&f^n&l^f&l;E=0|m,_=0|v,m=0|b,v=0|w,b=0|y,w=0|g,({h:y,l:g}=i.default.add(0|p,0|d,0|x,0|O)),p=0|h,d=0|l,h=0|o,l=0|f,o=0|r,f=0|n;const C=i.default.add3L(O,P,B);r=i.default.add3H(C,x,k,R),n=0|C}({h:r,l:n}=i.default.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:f}=i.default.add(0|this.Bh,0|this.Bl,0|o,0|f)),({h,l}=i.default.add(0|this.Ch,0|this.Cl,0|h,0|l)),({h:p,l:d}=i.default.add(0|this.Dh,0|this.Dl,0|p,0|d)),({h:y,l:g}=i.default.add(0|this.Eh,0|this.El,0|y,0|g)),({h:b,l:w}=i.default.add(0|this.Fh,0|this.Fl,0|b,0|w)),({h:m,l:v}=i.default.add(0|this.Gh,0|this.Gl,0|m,0|v)),({h:E,l:_}=i.default.add(0|this.Hh,0|this.Hl,0|E,0|_)),this.set(r,n,o,f,h,l,p,d,y,g,b,w,m,v,E,_)}roundClean(){c.fill(0),u.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}e.SHA512=f;class h extends f{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class l extends f{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class p extends f{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}e.sha512=(0,o.wrapConstructor)((()=>new f)),e.sha512_224=(0,o.wrapConstructor)((()=>new h)),e.sha512_256=(0,o.wrapConstructor)((()=>new l)),e.sha384=(0,o.wrapConstructor)((()=>new p))},1752:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(8280),i=r(3678);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},3803:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.BIP32Factory=void 0;const i=r(1772),o=r(8899),s=r(6710),a=r(4458),c=r(973),u=r(6952),f=(0,s.base58check)(a.sha256),h=t=>f.encode(Uint8Array.from(t)),l=t=>n.from(f.decode(t));e.BIP32Factory=function(t){(0,o.testEcc)(t);const e=c.BufferN(32),r=c.compile({wif:c.UInt8,bip32:{public:c.UInt32,private:c.UInt32}}),s={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},a=2147483648,f=Math.pow(2,31)-1;function p(t){return c.String(t)&&null!==t.match(/^(m\\/)?(\\d+'?\\/)*\\d+'?$/)}function d(t){return c.UInt32(t)&&t<=f}class y{constructor(t,e){this.__D=t,this.__Q=e,this.lowR=!1}get publicKey(){return void 0===this.__Q&&(this.__Q=n.from(t.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error(\"Missing private key\");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.privateKey));{let r=n.from(t.sign(e,this.privateKey));const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=n.from(t.sign(e,this.privateKey,i));return r}}signSchnorr(e){if(!this.privateKey)throw new Error(\"Missing private key\");if(!t.signSchnorr)throw new Error(\"signSchnorr not supported by ecc library\");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error(\"verifySchnorr not supported by ecc library\");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}}class g extends y{constructor(t,e,n,i,o=0,s=0,a=0){super(t,e),this.chainCode=n,this.network=i,this.__DEPTH=o,this.__INDEX=s,this.__PARENT_FINGERPRINT=a,c(r,i)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return i.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return m(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=n.allocUnsafe(78);return r.writeUInt32BE(e,0),r.writeUInt8(this.depth,4),r.writeUInt32BE(this.parentFingerprint,5),r.writeUInt32BE(this.index,9),this.chainCode.copy(r,13),this.isNeutered()?this.publicKey.copy(r,45):(r.writeUInt8(0,45),this.privateKey.copy(r,46)),h(r)}toWIF(){if(!this.privateKey)throw new TypeError(\"Missing private key\");return u.encode(this.network.wif,this.privateKey,!0)}derive(e){c(c.UInt32,e);const r=e>=a,o=n.allocUnsafe(37);if(r){if(this.isNeutered())throw new TypeError(\"Missing private key for hardened child key\");o[0]=0,this.privateKey.copy(o,1),o.writeUInt32BE(e,33)}else this.publicKey.copy(o,0),o.writeUInt32BE(e,33);const s=i.hmacSHA512(this.chainCode,o),u=s.slice(0,32),f=s.slice(32);if(!t.isPrivate(u))return this.derive(e+1);let h;if(this.isNeutered()){const r=n.from(t.pointAddScalar(this.publicKey,u,!0));if(null===r)return this.derive(e+1);h=m(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}else{const r=n.from(t.privateAdd(this.privateKey,u));if(null==r)return this.derive(e+1);h=w(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}return h}deriveHardened(t){return c(d,t),this.derive(t+a)}derivePath(t){c(p,t);let e=t.split(\"/\");if(\"m\"===e[0]){if(this.parentFingerprint)throw new TypeError(\"Expected master, got child\");e=e.slice(1)}return e.reduce(((t,e)=>{let r;return\"'\"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error(\"xOnlyPointAddTweak not supported by ecc library\");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error(\"Cannot tweak public key!\");const s=n.from([0===o.parity?2:3]),a=n.concat([s,o.xOnlyPubkey]);return new y(void 0,a)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&1==(1&this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error(\"privateNegate not supported by ecc library\")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error(\"Invalid tweaked private key!\");return new y(n.from(o),void 0)}}function b(t,e,r){return w(t,e,r)}function w(r,n,i,o,a,u){if(c({privateKey:e,chainCode:e},{privateKey:r,chainCode:n}),i=i||s,!t.isPrivate(r))throw new TypeError(\"Private key not in range [1, n)\");return new g(r,void 0,n,i,o,a,u)}function m(r,n,i,o,a,u){if(c({publicKey:c.BufferN(33),chainCode:e},{publicKey:r,chainCode:n}),i=i||s,!t.isPoint(r))throw new TypeError(\"Point is not on the curve\");return new g(void 0,r,n,i,o,a,u)}return{fromSeed:function(t,e){if(c(c.Buffer,t),t.length<16)throw new TypeError(\"Seed should be at least 128 bits\");if(t.length>64)throw new TypeError(\"Seed should be at most 512 bits\");e=e||s;const r=i.hmacSHA512(n.from(\"Bitcoin seed\",\"utf8\"),t);return b(r.slice(0,32),r.slice(32),e)},fromBase58:function(t,e){const r=l(t);if(78!==r.length)throw new TypeError(\"Invalid buffer length\");e=e||s;const n=r.readUInt32BE(0);if(n!==e.bip32.private&&n!==e.bip32.public)throw new TypeError(\"Invalid network version\");const i=r[4],o=r.readUInt32BE(5);if(0===i&&0!==o)throw new TypeError(\"Invalid parent fingerprint\");const a=r.readUInt32BE(9);if(0===i&&0!==a)throw new TypeError(\"Invalid index\");const c=r.slice(13,45);let u;if(n===e.bip32.private){if(0!==r.readUInt8(45))throw new TypeError(\"Invalid private key\");u=w(r.slice(46,78),c,e,i,a,o)}else{u=m(r.slice(45,78),c,e,i,a,o)}return u},fromPublicKey:function(t,e,r){return m(t,e,r)},fromPrivateKey:b}}},1772:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmacSHA512=e.hash160=void 0;const i=r(4966),o=r(2985),s=r(4458),a=r(4787);e.hash160=function(t){const e=(0,s.sha256)(Uint8Array.from(t));return n.from((0,o.ripemd160)(e))},e.hmacSHA512=function(t,e){return n.from((0,i.hmac)(a.sha512,t,e))}},3553:(t,e,r)=>{\"use strict\";e.Pr=void 0;var n=r(3803);Object.defineProperty(e,\"Pr\",{enumerable:!0,get:function(){return n.BIP32Factory}})},8899:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,\"hex\");function o(t){if(!t)throw new Error(\"ecc library invalid\")}e.testEcc=function(t){if(o(t.isPoint(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(!t.isPoint(i(\"030000000000000000000000000000000000000000000000000000000000000005\"))),o(t.isPrivate(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(!t.isPrivate(i(\"0000000000000000000000000000000000000000000000000000000000000000\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142\"))),o(n.from(t.pointFromScalar(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99\"))),t.xOnlyPointAddTweak){o(null===t.xOnlyPointAddTweak(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\")));let e=t.xOnlyPointAddTweak(i(\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\"),i(\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\"));o(n.from(e.xOnlyPubkey).equals(i(\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"))&&1===e.parity),e=t.xOnlyPointAddTweak(i(\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\"),i(\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\"))}o(n.from(t.pointAddScalar(i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"0000000000000000000000000000000000000000000000000000000000000003\"))).equals(i(\"02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\"))),o(n.from(t.privateAdd(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"),i(\"0000000000000000000000000000000000000000000000000000000000000002\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),t.privateNegate&&(o(n.from(t.privateNegate(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(n.from(t.privateNegate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateNegate(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792\")))),o(n.from(t.sign(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))).equals(i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),o(t.verify(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),t.signSchnorr&&o(n.from(t.signSchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9\"),i(\"c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906\"))).equals(i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\"))),t.verifySchnorr&&o(t.verifySchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8\"),i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\")))}},3877:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(3877),i=r(775);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},742:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(1810),i=r(775),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),a=s.map((t=>(9*t+5)%16));let c=[s],u=[a];for(let t=0;t<4;t++)for(let e of[c,u])e.push(e[t].map((t=>o[t])));const f=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),l=u.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const g=new Uint32Array(16);class b extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)g[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,a=0|this.h2,f=a,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=p[t],_=d[t],S=c[t],A=u[t],I=h[t],T=l[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,a,b)+g[S[e]]+E,I[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(a,10),a=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,s,f,w)+g[A[t]]+_,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(f,10),f=s,s=r}}this.set(this.h1+a+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+f|0)}roundClean(){g.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=b,e.ripemd160=(0,i.wrapConstructor)((()=>new b))},3293:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha1=void 0;const n=r(1810),i=r(775),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),s=new Uint32Array(80);class a extends n.HashMD{constructor(){super(64,20,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4]}get(){const{A:t,B:e,C:r,D:n,E:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)s[t]=(0,i.rotl)(s[t-3]^s[t-8]^s[t-14]^s[t-16],1);let{A:r,B:o,C:a,D:c,E:u}=this;for(let t=0;t<80;t++){let e,f;t<20?(e=(0,n.Chi)(o,a,c),f=1518500249):t<40?(e=o^a^c,f=1859775393):t<60?(e=(0,n.Maj)(o,a,c),f=2400959708):(e=o^a^c,f=3395469782);const h=(0,i.rotl)(r,5)+e+u+f+s[t]|0;u=c,c=a,a=(0,i.rotl)(o,30),o=r,r=h}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,c=c+this.D|0,u=u+this.E|0,this.set(r,o,a,c,u)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.sha1=(0,i.wrapConstructor)((()=>new a))},5743:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(1810),i=r(775),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},775:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(8713),i=r(3877);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},7748:t=>{\"use strict\";t.exports=function(t){if(t.length>=255)throw new TypeError(\"Alphabet too long\");for(var e=new Uint8Array(256),r=0;r>>0,u=new Uint8Array(o);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,l=o-1;(0!==f||h>>0,u[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error(\"Non-zero carry\");i=h,r++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var d=new Uint8Array(n+(o-p)),y=n;p!==o;)d[y++]=u[p++];return d}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError(\"Expected Uint8Array\");if(0===e.length)return\"\";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var c=(o-i)*u+1>>>0,f=new Uint8Array(c);i!==o;){for(var h=e[i],l=0,p=c-1;(0!==h||l>>0,f[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error(\"Non-zero carry\");n=l,i++}for(var d=c-n;d!==c&&0===f[d];)d++;for(var y=a.repeat(r);d{const n=r(7748);t.exports=n(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\")},5940:(t,e,r)=>{\"use strict\";var n=r(8155);t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),i=t(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error(\"Invalid checksum\");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},7329:(t,e,r)=>{\"use strict\";var{sha256:n}=r(5743),i=r(5940);t.exports=i((function(t){return n(n(t))}))},3348:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.toOutputScript=e.fromOutputScript=e.toBech32=e.toBase58Check=e.fromBech32=e.fromBase58Check=void 0;const i=r(2529),o=r(8614),s=r(4009),a=r(5593),c=r(6586),u=r(7329),f=40,h=2,l=16,p=2,d=80,y=\"WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.\";function g(t){const e=n.from(u.decode(t));if(e.length<21)throw new TypeError(t+\" is too short\");if(e.length>21)throw new TypeError(t+\" is too long\");return{version:e.readUInt8(0),hash:e.slice(1)}}function b(t){let e,r;try{e=c.bech32.decode(t)}catch(t){}if(e){if(r=e.words[0],0!==r)throw new TypeError(t+\" uses wrong encoding\")}else if(e=c.bech32m.decode(t),r=e.words[0],0===r)throw new TypeError(t+\" uses wrong encoding\");const i=c.bech32.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:n.from(i)}}function w(t,e,r){const n=c.bech32.toWords(t);return n.unshift(e),0===e?c.bech32.encode(r,n):c.bech32m.encode(r,n)}e.fromBase58Check=g,e.fromBech32=b,e.toBase58Check=function(t,e){(0,a.typeforce)((0,a.tuple)(a.Hash160bit,a.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),u.encode(r)},e.toBech32=w,e.fromOutputScript=function(t,e){e=e||i.bitcoin;try{return o.p2pkh({output:t,network:e}).address}catch(t){}try{return o.p2sh({output:t,network:e}).address}catch(t){}try{return o.p2wpkh({output:t,network:e}).address}catch(t){}try{return o.p2wsh({output:t,network:e}).address}catch(t){}try{return o.p2tr({output:t,network:e}).address}catch(t){}try{return function(t,e){const r=t.slice(2);if(r.lengthf)throw new TypeError(\"Invalid program length for segwit address\");const n=t[0]-d;if(nl)throw new TypeError(\"Invalid version for segwit address\");if(t[1]!==r.length)throw new TypeError(\"Invalid script for segwit address\");return console.warn(y),w(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(s.toASM(t)+\" has no matching Address\")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=g(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===e.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=b(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+\" has an invalid prefix\");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=p&&n.version<=l&&n.data.length>=h&&n.data.length<=f)return console.warn(y),s.compile([n.version+d,n.data])}}throw new Error(t+\" has no matching Script\")}},195:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=e.check=void 0,e.check=function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;const e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;const r=t[5+e];return 0!==r&&(6+e+r===t.length&&(!(128&t[4])&&(!(e>1&&0===t[4]&&!(128&t[5]))&&(!(128&t[e+6])&&!(r>1&&0===t[e+6]&&!(128&t[e+7]))))))},e.decode=function(t){if(t.length<8)throw new Error(\"DER sequence length is too short\");if(t.length>72)throw new Error(\"DER sequence length is too long\");if(48!==t[0])throw new Error(\"Expected DER sequence\");if(t[1]!==t.length-2)throw new Error(\"DER sequence length is invalid\");if(2!==t[2])throw new Error(\"Expected DER integer\");const e=t[3];if(0===e)throw new Error(\"R length is zero\");if(5+e>=t.length)throw new Error(\"R length is too long\");if(2!==t[4+e])throw new Error(\"Expected DER integer (2)\");const r=t[5+e];if(0===r)throw new Error(\"S length is zero\");if(6+e+r!==t.length)throw new Error(\"S length is invalid\");if(128&t[4])throw new Error(\"R value is negative\");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error(\"R value excessively padded\");if(128&t[e+6])throw new Error(\"S value is negative\");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error(\"S value excessively padded\");return{r:t.slice(4,4+e),s:t.slice(6+e)}},e.encode=function(t,e){const r=t.length,i=e.length;if(0===r)throw new Error(\"R length is zero\");if(0===i)throw new Error(\"S length is zero\");if(r>33)throw new Error(\"R length is too long\");if(i>33)throw new Error(\"S length is too long\");if(128&t[0])throw new Error(\"R value is negative\");if(128&e[0])throw new Error(\"S value is negative\");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error(\"R value excessively padded\");if(i>1&&0===e[0]&&!(128&e[1]))throw new Error(\"S value excessively padded\");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=t.length,t.copy(o,4),o[4+r]=2,o[5+r]=e.length,e.copy(o,6+r),o}},1169:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Block=void 0;const i=r(3831),o=r(6891),s=r(7992),a=r(3063),c=r(5593),{typeforce:u}=c,f=new TypeError(\"Cannot compute merkle root for zero transactions\"),h=new TypeError(\"Cannot compute witness commit for non-segwit block\");class l{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(t){if(t.length<80)throw new Error(\"Buffer too small (< 80 bytes)\");const e=new i.BufferReader(t),r=new l;if(r.version=e.readInt32(),r.prevHash=e.readSlice(32),r.merkleRoot=e.readSlice(32),r.timestamp=e.readUInt32(),r.bits=e.readUInt32(),r.nonce=e.readUInt32(),80===t.length)return r;const n=()=>{const t=a.Transaction.fromBuffer(e.buffer.slice(e.offset),!0);return e.offset+=t.byteLength(),t},o=e.readVarInt();r.transactions=[];for(let t=0;t>24)-3,r=8388607&t,i=n.alloc(32,0);return i.writeUIntBE(r,29-e,3),i}static calculateMerkleRoot(t,e){if(u([{getHash:c.Function}],t),0===t.length)throw f;if(e&&!p(t))throw h;const r=t.map((t=>t.getHash(e))),i=(0,s.fastMerkleRoot)(r,o.hash256);return e?o.hash256(n.concat([i,t[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!p(this.transactions))return null;const t=this.transactions[0].outs.filter((t=>t.script.slice(0,6).equals(n.from(\"6a24aa21a9ed\",\"hex\")))).map((t=>t.script.slice(6,38)));if(0===t.length)return null;const e=t[t.length-1];return e instanceof n&&32===e.length?e:null}hasWitnessCommit(){return this.witnessCommit instanceof n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(t=this.transactions)instanceof Array&&t.some((t=>\"object\"==typeof t&&t.ins instanceof Array&&t.ins.some((t=>\"object\"==typeof t&&t.witness instanceof Array&&t.witness.length>0))));var t}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(t,e=!0){return t||!this.transactions?80:80+i.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((t,r)=>t+r.byteLength(e)),0)}getHash(){return o.hash256(this.toBuffer(!0))}getId(){return(0,i.reverseBuffer)(this.getHash()).toString(\"hex\")}getUTCDate(){const t=new Date(0);return t.setUTCSeconds(this.timestamp),t}toBuffer(t){const e=n.allocUnsafe(this.byteLength(t)),r=new i.BufferWriter(e);return r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),t||!this.transactions||(i.varuint.encode(this.transactions.length,e,r.offset),r.offset+=i.varuint.encode.bytes,this.transactions.forEach((t=>{const n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}toHex(t){return this.toBuffer(t).toString(\"hex\")}checkTxRoots(){const t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&(this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit()))}checkProofOfWork(){const t=(0,i.reverseBuffer)(this.getHash()),e=l.calculateTarget(this.bits);return t.compare(e)<=0}__checkMerkleRoot(){if(!this.transactions)throw f;const t=l.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw f;if(!this.hasWitnessCommit())throw h;const t=l.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}function p(t){return t instanceof Array&&t[0]&&t[0].ins&&t[0].ins instanceof Array&&t[0].ins[0]&&t[0].ins[0].witness&&t[0].ins[0].witness instanceof Array&&t[0].ins[0].witness.length>0}e.Block=l},3831:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.BufferReader=e.BufferWriter=e.cloneBuffer=e.reverseBuffer=e.writeUInt64LE=e.readUInt64LE=e.varuint=void 0;const i=r(5593),{typeforce:o}=i,s=r(7820);function a(t,e){if(\"number\"!=typeof t)throw new Error(\"cannot write a non-number as a number\");if(t<0)throw new Error(\"specified a negative value for writing an unsigned value\");if(t>e)throw new Error(\"RangeError: value out of range\");if(Math.floor(t)!==t)throw new Error(\"value has a fractional component\")}function c(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r}function u(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}e.varuint=s,e.readUInt64LE=c,e.writeUInt64LE=u,e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;nthis.writeVarSlice(t)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}e.BufferWriter=f;e.BufferReader=class{constructor(t,e=0){this.buffer=t,this.offset=e,o(i.tuple(i.Buffer,i.UInt32),[t,e])}readUInt8(){const t=this.buffer.readUInt8(this.offset);return this.offset++,t}readInt32(){const t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}readUInt32(){const t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}readUInt64(){const t=c(this.buffer,this.offset);return this.offset+=8,t}readVarInt(){const t=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,t}readSlice(t){if(this.buffer.length{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const i=r(742),o=r(3293),s=r(5743);function a(t){return n.from((0,s.sha256)(Uint8Array.from(t)))}e.ripemd160=function(t){return n.from((0,i.ripemd160)(Uint8Array.from(t)))},e.sha1=function(t){return n.from((0,o.sha1)(Uint8Array.from(t)))},e.sha256=a,e.hash160=function(t){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(t))))},e.TAGS=[\"BIP0340/challenge\",\"BIP0340/aux\",\"BIP0340/nonce\",\"TapLeaf\",\"TapBranch\",\"TapSighash\",\"TapTweak\",\"KeyAgg list\",\"KeyAgg coefficient\"],e.TAGGED_HASH_PREFIXES={\"BIP0340/challenge\":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),\"BIP0340/aux\":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),\"BIP0340/nonce\":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),\"KeyAgg list\":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),\"KeyAgg coefficient\":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},e.taggedHash=function(t,r){return a(n.concat([e.TAGGED_HASH_PREFIXES[t],r]))}},6313:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.getEccLib=e.initEccLib=void 0;const i={};e.initEccLib=function(t){var e;t?t!==i.eccLib&&(s(\"function\"==typeof(e=t).isXOnlyPoint),s(e.isXOnlyPoint(o(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),s(e.isXOnlyPoint(o(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e\"))),s(e.isXOnlyPoint(o(\"f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9\"))),s(e.isXOnlyPoint(o(\"0000000000000000000000000000000000000000000000000000000000000001\"))),s(!e.isXOnlyPoint(o(\"0000000000000000000000000000000000000000000000000000000000000000\"))),s(!e.isXOnlyPoint(o(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\"))),s(\"function\"==typeof e.xOnlyPointAddTweak),a.forEach((t=>{const r=e.xOnlyPointAddTweak(o(t.pubkey),o(t.tweak));null===t.result?s(null===r):(s(null!==r),s(r.parity===t.parity),s(n.from(r.xOnlyPubkey).equals(o(t.result))))})),i.eccLib=t):i.eccLib=t},e.getEccLib=function(){if(!i.eccLib)throw new Error(\"No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance\");return i.eccLib};const o=t=>n.from(t,\"hex\");function s(t){if(!t)throw new Error(\"ecc library invalid\")}const a=[{pubkey:\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\",tweak:\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\",parity:-1,result:null},{pubkey:\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\",tweak:\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\",parity:1,result:\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"},{pubkey:\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\",tweak:\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\",parity:0,result:\"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c\"}]},7612:(t,e,r)=>{\"use strict\";e.ZX=e.iL=e.KT=e.o8=e.hl=void 0;const n=r(3348);e.hl=n;r(6891);const i=r(2529);e.o8=i;const o=r(8614);e.KT=o;r(4009);var s=r(1169);var a=r(6689);Object.defineProperty(e,\"iL\",{enumerable:!0,get:function(){return a.Psbt}});var c=r(8156);var u=r(3063);Object.defineProperty(e,\"ZX\",{enumerable:!0,get:function(){return u.Transaction}});var f=r(6313)},7992:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.fastMerkleRoot=void 0,e.fastMerkleRoot=function(t,e){if(!Array.isArray(t))throw TypeError(\"Expected values Array\");if(\"function\"!=typeof e)throw TypeError(\"Expected digest Function\");let r=t.length;const i=t.concat();for(;r>1;){let t=0;for(let o=0;o{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.testnet=e.regtest=e.bitcoin=void 0,e.bitcoin={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.regtest={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bcrt\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},e.testnet={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"tb\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},8156:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.REVERSE_OPS=e.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};e.OPS=r;const n={};e.REVERSE_OPS=n;for(const t of Object.keys(r)){n[r[t]]=t}},5247:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(1048),i=r(6313),o=r(6891),s=r(3831),a=r(5593);e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128;function c(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return o.taggedHash(\"TapLeaf\",n.Buffer.concat([n.Buffer.from([r]),h(t.output)]))}function u(t,e){return o.taggedHash(\"TapTweak\",n.Buffer.concat(e?[t,e]:[t]))}function f(t,e){return o.taggedHash(\"TapBranch\",n.Buffer.concat([t,e]))}function h(t){const e=s.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return s.varuint.encode(t.length,r),n.Buffer.concat([r,t])}e.rootHashFromPath=function(t,e){if(t.length<33)throw new TypeError(`The control-block length is too small. Got ${t.length}, expected min 33.`);const r=(t.length-33)/32;let n=e;for(let e=0;et.hash.compare(e.hash)));const[n,i]=r;return{hash:f(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function t(e,r){if(\"left\"in(n=e)&&\"right\"in n){const n=t(e.left,r);if(void 0!==n)return[...n,e.right.hash];const i=t(e.right,r);if(void 0!==i)return[...i,e.left.hash]}else if(e.hash.equals(r))return[];var n},e.tapleafHash=c,e.tapTweakHash=u,e.tweakKey=function(t,e){if(!n.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;const r=u(t,e),o=(0,i.getEccLib)().xOnlyPointAddTweak(t,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},271:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2data=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;e.p2data=function(t,e){if(!t.data&&!t.output)throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},t);const r={name:\"embed\",network:t.network||n.bitcoin};if(s.prop(r,\"output\",(()=>{if(t.data)return i.compile([a.OP_RETURN].concat(t.data))})),s.prop(r,\"data\",(()=>{if(t.output)return i.decompile(t.output).slice(1)})),e.validate&&t.output){const e=i.decompile(t.output);if(e[0]!==a.OP_RETURN)throw new TypeError(\"Output is invalid\");if(!e.slice(1).every(o.typeforce.Buffer))throw new TypeError(\"Output is invalid\");if(t.data&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.data,r.data))throw new TypeError(\"Data mismatch\")}return Object.assign(r,t)}},8614:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const n=r(271);Object.defineProperty(e,\"embed\",{enumerable:!0,get:function(){return n.p2data}});const i=r(2810);Object.defineProperty(e,\"p2ms\",{enumerable:!0,get:function(){return i.p2ms}});const o=r(5643);Object.defineProperty(e,\"p2pk\",{enumerable:!0,get:function(){return o.p2pk}});const s=r(9379);Object.defineProperty(e,\"p2pkh\",{enumerable:!0,get:function(){return s.p2pkh}});const a=r(2129);Object.defineProperty(e,\"p2sh\",{enumerable:!0,get:function(){return a.p2sh}});const c=r(7090);Object.defineProperty(e,\"p2wpkh\",{enumerable:!0,get:function(){return c.p2wpkh}});const u=r(2366);Object.defineProperty(e,\"p2wsh\",{enumerable:!0,get:function(){return u.p2wsh}});const f=r(1992);Object.defineProperty(e,\"p2tr\",{enumerable:!0,get:function(){return f.p2tr}})},9158:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.value=e.prop=void 0,e.prop=function(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){const t=r.call(this);return this[e]=t,t},set(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})},e.value=function(t){let e;return()=>(void 0!==e||(e=t()),e)}},2810:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2ms=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS,c=a.OP_RESERVED;function u(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}e.p2ms=function(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError(\"Not enough data\");function r(t){return i.isCanonicalScriptSignature(t)||void 0!==(e.allowIncomplete&&t===a.OP_0)}e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const f={network:t.network||n.bitcoin};let h=[],l=!1;function p(t){l||(l=!0,h=i.decompile(t),f.m=h[0]-c,f.n=h[h.length-2]-c,f.pubkeys=h.slice(1,-2))}if(s.prop(f,\"output\",(()=>{if(t.m&&f.n&&t.pubkeys)return i.compile([].concat(c+t.m,t.pubkeys,c+f.n,a.OP_CHECKMULTISIG))})),s.prop(f,\"m\",(()=>{if(f.output)return p(f.output),f.m})),s.prop(f,\"n\",(()=>{if(f.pubkeys)return f.pubkeys.length})),s.prop(f,\"pubkeys\",(()=>{if(t.output)return p(t.output),f.pubkeys})),s.prop(f,\"signatures\",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),s.prop(f,\"input\",(()=>{if(t.signatures)return i.compile([a.OP_0].concat(t.signatures))})),s.prop(f,\"witness\",(()=>{if(f.input)return[]})),s.prop(f,\"name\",(()=>{if(f.m&&f.n)return`p2ms(${f.m} of ${f.n})`})),e.validate){if(t.output){if(p(t.output),!o.typeforce.Number(h[0]))throw new TypeError(\"Output is invalid\");if(!o.typeforce.Number(h[h.length-2]))throw new TypeError(\"Output is invalid\");if(h[h.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError(\"Output is invalid\");if(f.m<=0||f.n>16||f.m>f.n||f.n!==h.length-3)throw new TypeError(\"Output is invalid\");if(!f.pubkeys.every((t=>(0,o.isPoint)(t))))throw new TypeError(\"Output is invalid\");if(void 0!==t.m&&t.m!==f.m)throw new TypeError(\"m mismatch\");if(void 0!==t.n&&t.n!==f.n)throw new TypeError(\"n mismatch\");if(t.pubkeys&&!u(t.pubkeys,f.pubkeys))throw new TypeError(\"Pubkeys mismatch\")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError(\"Pubkey count mismatch\");if(f.n=t.pubkeys.length,f.nf.m)throw new TypeError(\"Too many signatures provided\")}if(t.input){if(t.input[0]!==a.OP_0)throw new TypeError(\"Input is invalid\");if(0===f.signatures.length||!f.signatures.every(r))throw new TypeError(\"Input has invalid signature(s)\");if(t.signatures&&!u(t.signatures,f.signatures))throw new TypeError(\"Signature mismatch\");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError(\"Signature count mismatch\")}}return Object.assign(f,t)}},5643:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2pk=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;e.p2pk=function(t,e){if(!(t.input||t.output||t.pubkey||t.input||t.signature))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const r=s.value((()=>i.decompile(t.input))),c={name:\"p2pk\",network:t.network||n.bitcoin};if(s.prop(c,\"output\",(()=>{if(t.pubkey)return i.compile([t.pubkey,a.OP_CHECKSIG])})),s.prop(c,\"pubkey\",(()=>{if(t.output)return t.output.slice(1,-1)})),s.prop(c,\"signature\",(()=>{if(t.input)return r()[0]})),s.prop(c,\"input\",(()=>{if(t.signature)return i.compile([t.signature])})),s.prop(c,\"witness\",(()=>{if(c.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==a.OP_CHECKSIG)throw new TypeError(\"Output is invalid\");if(!(0,o.isPoint)(c.pubkey))throw new TypeError(\"Output pubkey is invalid\");if(t.pubkey&&!t.pubkey.equals(c.pubkey))throw new TypeError(\"Pubkey mismatch\")}if(t.signature&&t.input&&!t.input.equals(c.input))throw new TypeError(\"Signature mismatch\");if(t.input){if(1!==r().length)throw new TypeError(\"Input is invalid\");if(!i.isCanonicalScriptSignature(c.signature))throw new TypeError(\"Input has invalid signature\")}}return Object.assign(c,t)}},9379:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2pkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(7329),f=s.OPS;e.p2pkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(25)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),input:a.typeforce.maybe(a.typeforce.Buffer)},t);const r=c.value((()=>{const e=n.from(u.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),h=c.value((()=>s.decompile(t.input))),l=t.network||o.bitcoin,p={name:\"p2pkh\",network:l};if(c.prop(p,\"address\",(()=>{if(!p.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(l.pubKeyHash,0),p.hash.copy(t,1),u.encode(t)})),c.prop(p,\"hash\",(()=>t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),c.prop(p,\"output\",(()=>{if(p.hash)return s.compile([f.OP_DUP,f.OP_HASH160,p.hash,f.OP_EQUALVERIFY,f.OP_CHECKSIG])})),c.prop(p,\"pubkey\",(()=>{if(t.input)return h()[1]})),c.prop(p,\"signature\",(()=>{if(t.input)return h()[0]})),c.prop(p,\"input\",(()=>{if(t.pubkey&&t.signature)return s.compile([t.signature,t.pubkey])})),c.prop(p,\"witness\",(()=>{if(p.input)return[]})),e.validate){let e=n.from([]);if(t.address){if(r().version!==l.pubKeyHash)throw new TypeError(\"Invalid version or Network mismatch\");if(20!==r().hash.length)throw new TypeError(\"Invalid address\");e=r().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==f.OP_DUP||t.output[1]!==f.OP_HASH160||20!==t.output[2]||t.output[23]!==f.OP_EQUALVERIFY||t.output[24]!==f.OP_CHECKSIG)throw new TypeError(\"Output is invalid\");const r=t.output.slice(3,23);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.input){const r=h();if(2!==r.length)throw new TypeError(\"Input is invalid\");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError(\"Input has invalid signature\");if(!(0,a.isPoint)(r[1]))throw new TypeError(\"Input has invalid pubkey\");if(t.signature&&!t.signature.equals(r[0]))throw new TypeError(\"Signature mismatch\");if(t.pubkey&&!t.pubkey.equals(r[1]))throw new TypeError(\"Pubkey mismatch\");const n=i.hash160(r[1]);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\")}}return Object.assign(p,t)}},2129:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2sh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(7329),f=s.OPS;e.p2sh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(23)),redeem:a.typeforce.maybe({network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||o.bitcoin);const h={network:r},l=c.value((()=>{const e=n.from(u.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),p=c.value((()=>s.decompile(t.input))),d=c.value((()=>{const e=p(),i=e[e.length-1];return{network:r,output:i===f.OP_FALSE?n.from([]):i,input:s.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(c.prop(h,\"address\",(()=>{if(!h.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(h.network.scriptHash,0),h.hash.copy(t,1),u.encode(t)})),c.prop(h,\"hash\",(()=>t.output?t.output.slice(2,22):t.address?l().hash:h.redeem&&h.redeem.output?i.hash160(h.redeem.output):void 0)),c.prop(h,\"output\",(()=>{if(h.hash)return s.compile([f.OP_HASH160,h.hash,f.OP_EQUAL])})),c.prop(h,\"redeem\",(()=>{if(t.input)return d()})),c.prop(h,\"input\",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return s.compile([].concat(s.decompile(t.redeem.input),t.redeem.output))})),c.prop(h,\"witness\",(()=>h.redeem&&h.redeem.witness?h.redeem.witness:h.input?[]:void 0)),c.prop(h,\"name\",(()=>{const t=[\"p2sh\"];return void 0!==h.redeem&&void 0!==h.redeem.name&&t.push(h.redeem.name),t.join(\"-\")})),e.validate){let e=n.from([]);if(t.address){if(l().version!==r.scriptHash)throw new TypeError(\"Invalid version or Network mismatch\");if(20!==l().hash.length)throw new TypeError(\"Invalid address\");e=l().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==f.OP_HASH160||20!==t.output[1]||t.output[22]!==f.OP_EQUAL)throw new TypeError(\"Output is invalid\");const r=t.output.slice(2,22);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}const o=t=>{if(t.output){const r=s.decompile(t.output);if(!r||r.length<1)throw new TypeError(\"Redeem.output too short\");if(t.output.byteLength>520)throw new TypeError(\"Redeem.output unspendable if larger than 520 bytes\");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError(\"Redeem.output unspendable with more than 201 non-push ops\");const n=i.hash160(t.output);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\");e=n}if(t.input){const e=t.input.length>0,r=t.witness&&t.witness.length>0;if(!e&&!r)throw new TypeError(\"Empty input\");if(e&&r)throw new TypeError(\"Input and witness provided\");if(e){const e=s.decompile(t.input);if(!s.isPushOnly(e))throw new TypeError(\"Non push-only scriptSig\")}}};if(t.input){const t=p();if(!t||t.length<1)throw new TypeError(\"Input too short\");if(!n.isBuffer(d().output))throw new TypeError(\"Input is invalid\");o(d())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError(\"Network mismatch\");if(t.input){const e=d();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError(\"Redeem.output mismatch\");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError(\"Redeem.input mismatch\")}o(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,t.witness))throw new TypeError(\"Witness and redeem.witness mismatch\")}return Object.assign(h,t)}},1992:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2tr=void 0;const n=r(1048),i=r(2529),o=r(4009),s=r(5593),a=r(6313),c=r(5247),u=r(9158),f=r(6586),h=o.OPS;e.p2tr=function(t,e){if(!(t.address||t.output||t.pubkey||t.internalPubkey||t.witness&&t.witness.length>1))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},t);const r=u.value((()=>{const e=f.bech32m.decode(t.address),r=e.words.shift(),i=f.bech32m.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.Buffer.from(i)}})),l=u.value((()=>{if(t.witness&&t.witness.length)return t.witness.length>=2&&80===t.witness[t.witness.length-1][0]?t.witness.slice(0,-1):t.witness.slice()})),p=u.value((()=>t.scriptTree?(0,c.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),d=t.network||i.bitcoin,y={name:\"p2tr\",network:d};if(u.prop(y,\"address\",(()=>{if(!y.pubkey)return;const t=f.bech32m.toWords(y.pubkey);return t.unshift(1),f.bech32m.encode(d.bech32,t)})),u.prop(y,\"hash\",(()=>{const t=p();if(t)return t.hash;const e=l();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&s.TAPLEAF_VERSION_MASK,n=e[e.length-2],i=(0,c.tapleafHash)({output:n,version:r});return(0,c.rootHashFromPath)(t,i)}return null})),u.prop(y,\"output\",(()=>{if(y.pubkey)return o.compile([h.OP_1,y.pubkey])})),u.prop(y,\"redeemVersion\",(()=>t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:c.LEAF_VERSION_TAPSCRIPT)),u.prop(y,\"redeem\",(()=>{const t=l();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&s.TAPLEAF_VERSION_MASK}})),u.prop(y,\"pubkey\",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(y.internalPubkey){const t=(0,c.tweakKey)(y.internalPubkey,y.hash);if(t)return t.x}})),u.prop(y,\"internalPubkey\",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=l();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),u.prop(y,\"signature\",(()=>{if(t.signature)return t.signature;const e=l();return e&&1===e.length?e[0]:void 0})),u.prop(y,\"witness\",(()=>{if(t.witness)return t.witness;const e=p();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,c.tapleafHash)({output:t.redeem.output,version:y.redeemVersion}),i=(0,c.findScriptPath)(e,r);if(!i)return;const o=(0,c.tweakKey)(t.internalPubkey,e.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([y.redeemVersion|o.parity]),t.internalPubkey].concat(i));return[t.redeem.output,s]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(d&&d.bech32!==r().prefix)throw new TypeError(\"Invalid prefix or Network mismatch\");if(1!==r().version)throw new TypeError(\"Invalid address version\");if(32!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.pubkey){if(e.length>0&&!e.equals(t.pubkey))throw new TypeError(\"Pubkey mismatch\");e=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==h.OP_1||32!==t.output[1])throw new TypeError(\"Output is invalid\");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError(\"Pubkey mismatch\");e=t.output.slice(2)}if(t.internalPubkey){const r=(0,c.tweakKey)(t.internalPubkey,y.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError(\"Pubkey mismatch\");e=r.x}if(e&&e.length&&!(0,a.getEccLib)().isXOnlyPoint(e))throw new TypeError(\"Invalid pubkey for p2tr\");const i=p();if(t.hash&&i&&!t.hash.equals(i.hash))throw new TypeError(\"Hash mismatch\");if(t.redeem&&t.redeem.output&&i){const e=(0,c.tapleafHash)({output:t.redeem.output,version:y.redeemVersion});if(!(0,c.findScriptPath)(i,e))throw new TypeError(\"Redeem script not in tree\")}const u=l();if(t.redeem&&y.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==y.redeem.redeemVersion)throw new TypeError(\"Redeem.redeemVersion and witness mismatch\");if(t.redeem.output){if(0===o.decompile(t.redeem.output).length)throw new TypeError(\"Redeem.output is invalid\");if(y.redeem.output&&!t.redeem.output.equals(y.redeem.output))throw new TypeError(\"Redeem.output and witness mismatch\")}if(t.redeem.witness&&y.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,y.redeem.witness))throw new TypeError(\"Redeem.witness and witness mismatch\")}if(u&&u.length)if(1===u.length){if(t.signature&&!t.signature.equals(u[0]))throw new TypeError(\"Signature mismatch\")}else{const r=u[u.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(i))throw new TypeError(\"Internal pubkey mismatch\");if(!(0,a.getEccLib)().isXOnlyPoint(i))throw new TypeError(\"Invalid internalPubkey for p2tr witness\");const o=r[0]&s.TAPLEAF_VERSION_MASK,f=u[u.length-2],h=(0,c.tapleafHash)({output:f,version:o}),l=(0,c.rootHashFromPath)(r,h),p=(0,c.tweakKey)(i,l);if(!p)throw new TypeError(\"Invalid outputKey for p2tr witness\");if(e.length&&!e.equals(p.x))throw new TypeError(\"Pubkey mismatch for p2tr witness\");if(p.parity!==(1&r[0]))throw new Error(\"Incorrect parity\")}}return Object.assign(y,t)}},7090:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2wpkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(6586),f=s.OPS,h=n.alloc(0);e.p2wpkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(22)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=c.value((()=>{const e=u.bech32.decode(t.address),r=e.words.shift(),i=u.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),l=t.network||o.bitcoin,p={name:\"p2wpkh\",network:l};if(c.prop(p,\"address\",(()=>{if(!p.hash)return;const t=u.bech32.toWords(p.hash);return t.unshift(0),u.bech32.encode(l.bech32,t)})),c.prop(p,\"hash\",(()=>t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),c.prop(p,\"output\",(()=>{if(p.hash)return s.compile([f.OP_0,p.hash])})),c.prop(p,\"pubkey\",(()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0)),c.prop(p,\"signature\",(()=>{if(t.witness)return t.witness[0]})),c.prop(p,\"input\",(()=>{if(p.witness)return h})),c.prop(p,\"witness\",(()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){let e=n.from([]);if(t.address){if(l&&l.bech32!==r().prefix)throw new TypeError(\"Invalid prefix or Network mismatch\");if(0!==r().version)throw new TypeError(\"Invalid address version\");if(20!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==f.OP_0||20!==t.output[1])throw new TypeError(\"Output is invalid\");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError(\"Hash mismatch\");e=t.output.slice(2)}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");if(e=r,!(0,a.isPoint)(t.pubkey)||33!==t.pubkey.length)throw new TypeError(\"Invalid pubkey for p2wpkh\")}if(t.witness){if(2!==t.witness.length)throw new TypeError(\"Witness is invalid\");if(!s.isCanonicalScriptSignature(t.witness[0]))throw new TypeError(\"Witness has invalid signature\");if(!(0,a.isPoint)(t.witness[1])||33!==t.witness[1].length)throw new TypeError(\"Witness has invalid pubkey\");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError(\"Signature mismatch\");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError(\"Pubkey mismatch\");const r=i.hash160(t.witness[1]);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\")}}return Object.assign(p,t)}},2366:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2wsh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(6586),f=s.OPS,h=n.alloc(0);function l(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,a.isPoint)(t))}e.p2wsh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),output:a.typeforce.maybe(a.typeforce.BufferN(34)),redeem:a.typeforce.maybe({input:a.typeforce.maybe(a.typeforce.Buffer),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.BufferN(0)),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=c.value((()=>{const e=u.bech32.decode(t.address),r=e.words.shift(),i=u.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),p=c.value((()=>s.decompile(t.redeem.input)));let d=t.network;d||(d=t.redeem&&t.redeem.network||o.bitcoin);const y={network:d};if(c.prop(y,\"address\",(()=>{if(!y.hash)return;const t=u.bech32.toWords(y.hash);return t.unshift(0),u.bech32.encode(d.bech32,t)})),c.prop(y,\"hash\",(()=>t.output?t.output.slice(2):t.address?r().data:y.redeem&&y.redeem.output?i.sha256(y.redeem.output):void 0)),c.prop(y,\"output\",(()=>{if(y.hash)return s.compile([f.OP_0,y.hash])})),c.prop(y,\"redeem\",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:h,witness:t.witness.slice(0,-1)}})),c.prop(y,\"input\",(()=>{if(y.witness)return h})),c.prop(y,\"witness\",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=s.toStack(p());return y.redeem=Object.assign({witness:e},t.redeem),y.redeem.input=h,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),c.prop(y,\"name\",(()=>{const t=[\"p2wsh\"];return void 0!==y.redeem&&void 0!==y.redeem.name&&t.push(y.redeem.name),t.join(\"-\")})),e.validate){let e=n.from([]);if(t.address){if(r().prefix!==d.bech32)throw new TypeError(\"Invalid prefix or Network mismatch\");if(0!==r().version)throw new TypeError(\"Invalid address version\");if(32!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==f.OP_0||32!==t.output[1])throw new TypeError(\"Output is invalid\");const r=t.output.slice(2);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.redeem){if(t.redeem.network&&t.redeem.network!==d)throw new TypeError(\"Network mismatch\");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError(\"Ambiguous witness source\");if(t.redeem.output){const r=s.decompile(t.redeem.output);if(!r||r.length<1)throw new TypeError(\"Redeem.output is invalid\");if(t.redeem.output.byteLength>3600)throw new TypeError(\"Redeem.output unspendable if larger than 3600 bytes\");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError(\"Redeem.output unspendable with more than 201 non-push ops\");const n=i.sha256(t.redeem.output);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\");e=n}if(t.redeem.input&&!s.isPushOnly(p()))throw new TypeError(\"Non push-only scriptSig\");if(t.witness&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.witness,t.redeem.witness))throw new TypeError(\"Witness and redeem.witness mismatch\");if(t.redeem.input&&p().some(l)||t.redeem.output&&(s.decompile(t.redeem.output)||[]).some(l))throw new TypeError(\"redeem.input or redeem.output contains uncompressed pubkey\")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError(\"Witness and redeem.output mismatch\");if(t.witness.some(l)||(s.decompile(e)||[]).some(l))throw new TypeError(\"Witness contains uncompressed pubkey\")}}return Object.assign(y,t)}},6689:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Psbt=void 0;const i=r(7003),o=r(2715),s=r(2431),a=r(3348),c=r(3831),u=r(2529),f=r(8614),h=r(5247),l=r(4009),p=r(3063),d=r(6412),y=r(8990),g={network:u.bitcoin,maximumFeeRate:5e3};class b{static fromBase64(t,e={}){const r=n.from(t,\"base64\");return this.fromBuffer(r,e)}static fromHex(t,e={}){const r=n.from(t,\"hex\");return this.fromBuffer(r,e)}static fromBuffer(t,e={}){const r=i.Psbt.fromBuffer(t,w),n=new b(e,r);var o,s;return o=n.__CACHE.__TX,s=n.__CACHE,o.ins.forEach((t=>{x(s,t)})),n}constructor(t={},e=new i.Psbt(new m)){this.data=e,this.opts=Object.assign({},g,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(t,e,r,n)=>Object.defineProperty(t,e,{enumerable:r,writable:n});r(this,\"__CACHE\",!1,!0),r(this,\"opts\",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map((t=>({hash:(0,c.cloneBuffer)(t.hash),index:t.index,sequence:t.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((t=>{let e;try{e=(0,a.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,c.cloneBuffer)(t.script),value:t.value,address:e}}))}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){const t=b.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){A(t),this.opts.maximumFeeRate=t}setVersion(t){A(t),I(this.data.inputs,\"setVersion\");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){A(t),I(this.data.inputs,\"setLocktime\");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){A(e),I(this.data.inputs,\"setInputSequence\");const r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error(\"Input index too high\");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach((t=>this.addInput(t))),this}addInput(t){if(arguments.length>1||!t||void 0===t.hash||void 0===t.index)throw new Error(\"Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]\");(0,d.checkTaprootInputFields)(t,t,\"addInput\"),I(this.data.inputs,\"addInput\"),t.witnessScript&&X(t.witnessScript);const e=this.__CACHE;this.data.addInput(t);x(e,e.__TX.ins[e.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&D(this.__CACHE,n,r),e.__FEE=void 0,e.__FEE_RATE=void 0,e.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach((t=>this.addOutput(t))),this}addOutput(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error(\"Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]\");I(this.data.inputs,\"addOutput\");const{address:e}=t;if(\"string\"==typeof e){const{network:r}=this.opts,n=(0,a.toOutputScript)(e,r);t=Object.assign(t,{script:n})}(0,d.checkTaprootOutputFields)(t,t,\"addOutput\");const r=this.__CACHE;return this.data.addOutput(t),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(_))throw new Error(\"Not finalized\");const e=this.__CACHE;if(t||function(t,e,r){const n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,e,this.opts),e.__EXTRACTED_TX)return e.__EXTRACTED_TX;const r=e.__TX.clone();return $(this.data.inputs,r,e,!0),r}getFeeRate(){return R(\"__FEE_RATE\",\"fee rate\",this.data.inputs,this.__CACHE)}getFee(){return R(\"__FEE\",\"fee\",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,s.checkForInput)(this.data.inputs,0),J(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(r)?this._finalizeTaprootInput(t,r,void 0,e):this._finalizeInput(t,r,e)}finalizeTaprootInput(t,e,r=d.tapScriptFinalizer){const n=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,e,r=B){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(t,e,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){const o=K(r,e,t),s=n.ins[t].index;i.script=o.outs[s].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);(e.witnessScript||(0,y.isP2WPKH)(i.script))&&(i.isSegwit=!0);return i}(t,e,this.__CACHE);if(!n)throw new Error(`No script found for input #${t}`);!function(t){if(!t.sighashType||!t.partialSig)return;const{partialSig:e,sighashType:r}=t;e.forEach((t=>{const{hashType:e}=l.signature.decode(t.signature);if(r!==e)throw new Error(\"Signature sighash does not match input sighash type\")}))}(e);const{finalScriptSig:a,finalScriptWitness:c}=r(t,e,n,s,i,o);if(a&&this.data.updateInput(t,{finalScriptSig:a}),c&&this.data.updateInput(t,{finalScriptWitness:c}),!a&&!c)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,e,r,n=d.tapScriptFinalizer){if(!e.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(e.tapKeySig){const r=f.p2tr({output:e.witnessUtxo.script,signature:e.tapKeySig}),n=(0,y.witnessStackToScriptWitness)(r.witness);this.data.updateInput(t,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(t,e,r);this.data.updateInput(t,{finalScriptWitness:i})}return this.data.clearFinalizedInput(t),this}getInputType(t){const e=(0,s.checkForInput)(this.data.inputs,t),r=W(V(t,e,this.__CACHE),t,\"input\",e.redeemScript||function(t){if(!t)return;const e=l.decompile(t);if(!e)return;const r=e[e.length-1];if(!n.isBuffer(r)||q(r)||(i=r,l.isCanonicalScriptSignature(i)))return;var i;if(!l.decompile(r))return;return r}(e.finalScriptSig),e.witnessScript||function(t){if(!t)return;const e=F(t),r=e[e.length-1];if(q(r))return;if(!l.decompile(r))return;return r}(e.finalScriptWitness));return(\"raw\"===r.type?\"\":r.type+\"-\")+z(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=V(r,e,n),{meaningfulScript:o}=W(i,r,\"input\",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,s.checkForInput)(this.data.inputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(t,e){return function(t,e,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=W(i,r,\"output\",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,s.checkForOutput)(this.data.outputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){(0,s.checkForInput)(this.data.inputs,0);return J(this.data.inputs.length).map((e=>this.validateSignaturesOfInput(e,t))).reduce(((t,e)=>!0===e&&t),!0)}validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t];return(0,d.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}_validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error(\"No signatures to validate\");if(\"function\"!=typeof e)throw new Error(\"Need validator function to validate signatures\");const o=r?i.filter((t=>t.pubkey.equals(r))):i;if(o.length<1)throw new Error(\"No signatures for this pubkey\");const s=[];let a,c,u;for(const r of o){const i=l.signature.decode(r.signature),{hash:o,script:f}=u!==i.hashType?N(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:c};u=i.hashType,a=o,c=f,T(r.pubkey,f,\"verify\"),s.push(e(r.pubkey,o,i.signature))}return s.every((t=>!0===t))}validateSignaturesOfTaprootInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error(\"No signatures to validate\");if(\"function\"!=typeof e)throw new Error(\"Need validator function to validate signatures\");const s=(r=r&&(0,d.toXOnly)(r))?j(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=L(t,e,n);r&&i.push(r)}if(e.tapScriptSig){const t=e.tapScriptSig.map((t=>t.pubkey));i.push(...t)}const o=i.map((i=>j(t,e,r,i,n)));return o.flat()}(t,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error(\"No signatures for this pubkey\");const a=s.find((t=>!t.leafHash));let c=0;if(i&&a){if(!e(a.pubkey,a.hash,U(i)))return!1;c++}if(o)for(const t of o){const r=s.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,U(t.signature)))return!1;c++}}return c>0}signAllInputsHD(t,e=[p.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error(\"Need HDSigner to sign input\");const r=[];for(const n of J(this.data.inputs.length))try{this.signInputHD(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error(\"No inputs were signed\");return this}signAllInputsHDAsync(t,e=[p.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!t||!t.publicKey||!t.fingerprint)return n(new Error(\"Need HDSigner to sign input\"));const i=[],o=[];for(const r of J(this.data.inputs.length))o.push(this.signInputHDAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error(\"No inputs were signed\"));r()}))}))}signInputHD(t,e,r=[p.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error(\"Need HDSigner to sign input\");return H(t,this.data.inputs,e).forEach((e=>this.signInput(t,e,r))),this}signInputHDAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!e||!e.publicKey||!e.fingerprint)return i(new Error(\"Need HDSigner to sign input\"));const o=H(t,this.data.inputs,e).map((e=>this.signInputAsync(t,e,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(t,e){if(!t||!t.publicKey)throw new Error(\"Need Signer to sign input\");const r=[];for(const n of J(this.data.inputs.length))try{this.signInput(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error(\"No inputs were signed\");return this}signAllInputsAsync(t,e){return new Promise(((r,n)=>{if(!t||!t.publicKey)return n(new Error(\"Need Signer to sign input\"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error(\"No inputs were signed\"));r()}))}))}signInput(t,e,r){if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}signTaprootInput(t,e,r,n){if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInput(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=C(this.data.inputs,t,e.publicKey,this.__CACHE,r),o=[{pubkey:e.publicKey,signature:l.signature.encode(e.sign(n),i)}];return this.data.updateInput(t,{partialSig:o}),this}_signTaprootInput(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=o.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],a=o.filter((t=>!!t.leafHash)).map((t=>({pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash})));return s&&this.data.updateInput(t,{tapKeySig:s}),a.length&&this.data.updateInput(t,{tapScriptSig:a}),this}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInputAsync(t,n,e,void 0,r):this._signInputAsync(t,e,r)}))}signTaprootInputAsync(t,e,r,n){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInputAsync(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}))}_signInputAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=C(this.data.inputs,t,e.publicKey,this.__CACHE,r);return Promise.resolve(e.sign(n)).then((r=>{const n=[{pubkey:e.publicKey,signature:l.signature.encode(r,i)}];this.data.updateInput(t,{partialSig:n})}))}async _signTaprootInputAsync(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=[],a=o.filter((t=>!t.leafHash))[0];if(a){const t=Promise.resolve(r.signSchnorr(a.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));s.push(t)}const c=o.filter((t=>!!t.leafHash));if(c.length){const t=c.map((t=>Promise.resolve(r.signSchnorr(t.hash)).then((n=>({tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]})))));s.push(...t)}return Promise.all(s).then((e=>{e.forEach((e=>this.data.updateInput(t,e)))}))}checkTaprootHashesForSig(t,e,r,n,i){if(\"function\"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const o=j(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${t} with the key ${r.publicKey.toString(\"hex\")}`);return o}toBuffer(){return v(this.__CACHE),this.data.toBuffer()}toHex(){return v(this.__CACHE),this.data.toHex()}toBase64(){return v(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&X(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,\"updateInput\"),this.data.updateInput(t,e),e.nonWitnessUtxo&&D(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,e){const r=this.data.outputs[t];return(0,d.checkTaprootOutputFields)(r,e,\"updateOutput\"),this.data.updateOutput(t,e),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,e){return this.data.addUnknownKeyValToInput(t,e),this}addUnknownKeyValToOutput(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}e.Psbt=b;const w=t=>new m(t);class m{constructor(t=n.from([2,0,0,0,0,0,0,0,0,0])){this.tx=p.Transaction.fromBuffer(t),function(t){if(!t.ins.every((t=>t.script&&0===t.script.length&&t.witness&&0===t.witness.length)))throw new Error(\"Format Error: Transaction ScriptSigs are not empty\")}(this.tx),Object.defineProperty(this,\"tx\",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!n.isBuffer(t.hash)&&\"string\"!=typeof t.hash||\"number\"!=typeof t.index)throw new Error(\"Error adding input.\");const e=\"string\"==typeof t.hash?(0,c.reverseBuffer)(n.from(t.hash,\"hex\")):t.hash;this.tx.addInput(e,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!n.isBuffer(t.script)||\"number\"!=typeof t.value)throw new Error(\"Error adding output.\");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function v(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error(\"Not BIP174 compliant, can not export\")}function E(t,e,r){if(!e)return!1;let n;if(n=r?r.map((t=>{const r=function(t){if(65===t.length){const e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((t=>t.pubkey.equals(r)))})).filter((t=>!!t)):e,n.length>t)throw new Error(\"Too many signatures\");return n.length===t}function _(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function S(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function A(t){if(\"number\"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error(\"Invalid 32 bit integer\")}function I(t,e){t.forEach((t=>{if((0,d.isTaprootInput)(t)?(0,d.checkTaprootInputForSigs)(t,e):(0,y.checkInputForSig)(t,e))throw new Error(\"Can not modify transaction, signatures exist.\")}))}function T(t,e,r){if(!(0,y.pubkeyInScript)(t,e))throw new Error(`Can not ${r} for this input with the key ${t.toString(\"hex\")}`)}function x(t,e){const r=(0,c.reverseBuffer)(n.from(e.hash)).toString(\"hex\")+\":\"+e.index;if(t.__TX_IN_CACHE[r])throw new Error(\"Duplicate input detected.\");t.__TX_IN_CACHE[r]=1}function O(t,e){return(r,n,i,o)=>{const s=t({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${e} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const k=O(f.p2sh,\"Redeem script\"),P=O(f.p2wsh,\"Witness script\");function R(t,e,r,n){if(!r.every(_))throw new Error(`PSBT must be finalized to calculate ${e}`);if(\"__FEE_RATE\"===t&&n.__FEE_RATE)return n.__FEE_RATE;if(\"__FEE\"===t&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),$(r,i,n,o),\"__FEE_RATE\"===t?n.__FEE_RATE:\"__FEE\"===t?n.__FEE:void 0}function B(t,e,r,n,i,o){const s=z(r);if(!function(t,e,r){switch(r){case\"pubkey\":case\"pubkeyhash\":case\"witnesspubkeyhash\":return E(1,t.partialSig);case\"multisig\":const r=f.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,s))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,o){let s,a;const c=function(t,e,r){let n;switch(e){case\"multisig\":const e=function(t,e){const r=f.p2ms({output:t});return r.pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=f.p2ms({output:t,signatures:e});break;case\"pubkey\":n=f.p2pk({output:t,signature:r[0].signature});break;case\"pubkeyhash\":n=f.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case\"witnesspubkeyhash\":n=f.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),u=o?f.p2wsh({redeem:c}):null,h=i?f.p2sh({redeem:u||c}):null;n?(a=u?(0,y.witnessStackToScriptWitness)(u.witness):(0,y.witnessStackToScriptWitness)(c.witness),h&&(s=h.input)):s=h?h.input:c.input;return{finalScriptSig:s,finalScriptWitness:a}}(r,s,e.partialSig,n,i,o)}function C(t,e,r,n,i){const o=(0,s.checkForInput)(t,e),{hash:a,sighashType:c,script:u}=N(e,o,n,!1,i);return T(r,u,\"sign\"),{hash:a,sighashType:c}}function N(t,e,r,n,i){const o=r.__TX,s=e.sighashType||p.Transaction.SIGHASH_ALL;let a,c;if(M(s,i),e.nonWitnessUtxo){const n=K(r,e,t),i=o.ins[t].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const a=o.ins[t].index;c=n.outs[a]}else{if(!e.witnessUtxo)throw new Error(\"Need a Utxo input item for signing\");c=e.witnessUtxo}const{meaningfulScript:u,type:h}=W(c.script,t,\"input\",e.redeemScript,e.witnessScript);if([\"p2sh-p2wsh\",\"p2wsh\"].indexOf(h)>=0)a=o.hashForWitnessV0(t,u,c.value,s);else if((0,y.isP2WPKH)(u)){const e=f.p2pkh({hash:u.slice(2)}).output;a=o.hashForWitnessV0(t,e,c.value,s)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${t} has witnessUtxo but non-segwit script: ${u.toString(\"hex\")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn(\"Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecesor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\\n*********************\\nPROCEED WITH CAUTION!\\n*********************\"),a=o.hashForSignature(t,u,s)}return{script:u,sighashType:s,hash:a}}function L(t,e,r){const{script:n}=G(t,e,r);return(0,y.isP2TR)(n)?n.subarray(2,34):null}function U(t){return 64===t.length?t:t.subarray(0,64)}function j(t,e,r,i,o,s,a){const c=o.__TX,u=e.sighashType||p.Transaction.SIGHASH_DEFAULT;M(u,a);const f=r.map(((t,e)=>G(e,t,o))),l=f.map((t=>t.script)),g=f.map((t=>t.value)),b=[];if(e.tapInternalKey&&!s){const r=L(t,e,o)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=c.hashForWitnessV1(t,l,g,u);b.push({pubkey:i,hash:e})}}const w=(e.tapLeafScript||[]).filter((t=>(0,y.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,h.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!s||s.equals(t.hash))).map((e=>{const r=c.hashForWitnessV1(t,l,g,p.Transaction.SIGHASH_DEFAULT,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return b.concat(w)}function M(t,e){if(e&&e.indexOf(t)<0){const e=function(t){let e=t&p.Transaction.SIGHASH_ANYONECANPAY?\"SIGHASH_ANYONECANPAY | \":\"\";switch(31&t){case p.Transaction.SIGHASH_ALL:e+=\"SIGHASH_ALL\";break;case p.Transaction.SIGHASH_SINGLE:e+=\"SIGHASH_SINGLE\";break;case p.Transaction.SIGHASH_NONE:e+=\"SIGHASH_NONE\"}return e}(t);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${e}`)}}function H(t,e,r){const n=(0,s.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error(\"Need bip32Derivation to sign with HD\");const i=n.bip32Derivation.map((t=>t.masterFingerprint.equals(r.fingerprint)?t:void 0)).filter((t=>!!t));if(0===i.length)throw new Error(\"Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint\");return i.map((t=>{const e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error(\"pubkey did not match bip32Derivation\");return e}))}function F(t){let e=0;function r(){const r=o.decode(t,e);return e+=o.decode.bytes,r}function n(){return n=r(),e+=n,t.slice(e-n,e);var n}return function(){const t=r(),e=[];for(let r=0;r{if(n&&t.finalScriptSig&&(e.ins[o].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[o].witness=F(t.finalScriptWitness)),t.witnessUtxo)i+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=K(r,t,o),s=e.ins[o].index,a=n.outs[s];i+=a.value}}));const o=e.outs.reduce(((t,e)=>t+e.value),0),s=i-o;if(s<0)throw new Error(\"Outputs are spending more than Inputs\");const a=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/a)}function K(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||D(t,e,r),n[r]}function V(t,e,r){const{script:n}=G(t,e,r);return n}function G(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=K(r,e,t).outs[r.__TX.ins[t].index];return{script:n.script,value:n.value}}throw new Error(\"Can't find pubkey in input without Utxo data\")}function q(t){return 33===t.length&&l.isCanonicalPubKey(t)}function W(t,e,r,n,i){const o=(0,y.isP2SHScript)(t),s=o&&n&&(0,y.isP2WSHScript)(n),a=(0,y.isP2WSHScript)(t);if(o&&void 0===n)throw new Error(\"scriptPubkey is P2SH but redeemScript missing\");if((a||s)&&void 0===i)throw new Error(\"scriptPubkey or redeemScript is P2WSH but witnessScript missing\");let c;return s?(c=i,k(e,t,n,r),P(e,n,i,r),X(c)):a?(c=i,P(e,t,i,r),X(c)):o?(c=n,k(e,t,n,r)):c=t,{meaningfulScript:c,type:s?\"p2sh-p2wsh\":o?\"p2sh\":a?\"p2wsh\":\"raw\"}}function X(t){if((0,y.isP2WPKH)(t)||(0,y.isP2SHScript)(t))throw new Error(\"P2WPKH or P2SH can not be contained within P2WSH\")}function z(t){return(0,y.isP2WPKH)(t)?\"witnesspubkeyhash\":(0,y.isP2PKH)(t)?\"pubkeyhash\":(0,y.isP2MS)(t)?\"multisig\":(0,y.isP2PK)(t)?\"pubkey\":\"nonstandard\"}function J(t){return[...Array(t).keys()]}},6412:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.checkTaprootInputForSigs=e.tapTreeFromList=e.tapTreeToList=e.tweakInternalPubKey=e.checkTaprootOutputFields=e.checkTaprootInputFields=e.isTaprootOutput=e.isTaprootInput=e.serializeTaprootSignature=e.tapScriptFinalizer=e.toXOnly=void 0;const i=r(5593),o=r(3063),s=r(8990),a=r(5247),c=r(8614),u=r(8990);function f(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,s.isP2TR)(t.witnessUtxo.script))}function h(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,s.isP2TR)(e))}function l(t=[]){return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){let e;for(const r of t)if(e=y(r,e),!e)throw new Error(\"No room left to insert tapleaf in tree\");return e}(t)}function p(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function d(t,e=[],r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error(\"Max taptree depth exceeded.\");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||a.LEAF_VERSION_TAPSCRIPT,script:t.output}),e):(t[0]&&d(t[0],e,r+1),t[1]&&d(t[1],e,r+1),e):[]}function y(t,e,r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error(\"Max taptree depth exceeded.\");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if((0,i.isTapleaf)(e))return;const n=y(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];const o=y(t,e&&e[1],r+1);return o?[e&&e[0],o]:void 0}function g(t,e){if(!e)return!0;const r=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(0,a.rootHashFromPath)(t.controlBlock,r).equals(e)}function b(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}e.toXOnly=t=>32===t.length?t:t.slice(1,33),e.tapScriptFinalizer=function(t,e,r){const n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${e}. No tapleaf script signature provided.`);const n=(t.tapLeafScript||[]).sort(((t,e)=>t.controlBlock.length-e.controlBlock.length)).find((e=>function(t,e,r){const n=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((t=>t.leafHash.equals(n)))}(e,t.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`);return n}(e,t,r);try{const t=function(t,e){const r=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((t=>t.leafHash.equals(r))).map((t=>function(t,e){return Object.assign({positionInScript:(0,s.pubkeyPositionInScript)(e.pubkey,t)},e)}(e.script,t))).sort(((t,e)=>e.positionInScript-t.positionInScript)).map((t=>t.signature))}(e,n),r=t.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,s.witnessStackToScriptWitness)(r)}}catch(e){throw new Error(`Can not finalize taproot input #${t}: ${e}`)}},e.serializeTaprootSignature=function(t,e){const r=e?n.from([e]):n.from([]);return n.concat([t,r])},e.isTaprootInput=f,e.isTaprootOutput=h,e.checkTaprootInputFields=function(t,e,r){!function(t,e,r){const n=f(t)&&b(e),i=b(t)&&f(e),o=t===e&&f(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot){if(!(e.tapLeafScript||[]).every((e=>g(e,t.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}}(t,e,r)},e.checkTaprootOutputFields=function(t,e,r){!function(t,e,r){const n=h(t)&&b(e),i=b(t)&&h(e),o=t===e&&h(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e){if(!e.tapTree&&!e.tapInternalKey)return;const r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){const{script:e}=t,i=function(t,e){const r=e&&l(e.leaves),{output:n}=(0,c.p2tr)({internalPubkey:t,scriptTree:r});return n}(r,n);if(e&&!e.equals(i))throw new Error(\"Error adding output. Script or address missmatch.\")}}(t,e)},e.tweakInternalPubKey=function(t,e){const r=e.tapInternalKey,n=r&&(0,a.tweakKey)(r,e.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${t}. Public key: ${r&&r.toString(\"hex\")}`);return n.x},e.tapTreeToList=function(t){if(!(0,i.isTaptree)(t))throw new Error(\"Cannot convert taptree to tapleaf list. Expecting a tapree structure.\");return d(t)},e.tapTreeFromList=l,e.checkTaprootInputForSigs=function(t,e){return function(t){const e=[];t.tapKeySig&&e.push(t.tapKeySig);t.tapScriptSig&&e.push(...t.tapScriptSig.map((t=>t.signature)));if(!e.length){const r=function(t){if(!t)return;const e=t.slice(2);if(64===e.length||65===e.length)return e}(t.finalScriptWitness);r&&e.push(r)}return e}(t).some((t=>(0,u.signatureBlocksAction)(t,p,e)))}},8990:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.signatureBlocksAction=e.checkInputForSig=e.pubkeyInScript=e.pubkeyPositionInScript=e.witnessStackToScriptWitness=e.isP2TR=e.isP2SHScript=e.isP2WSHScript=e.isP2WPKH=e.isP2PKH=e.isP2PK=e.isP2MS=void 0;const i=r(2715),o=r(4009),s=r(3063),a=r(6891),c=r(8614);function u(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function f(t,e){const r=(0,a.hash160)(t),n=t.slice(1,33),i=o.decompile(e);if(null===i)throw new Error(\"Unknown script error\");return i.findIndex((e=>\"number\"!=typeof e&&(e.equals(t)||e.equals(r)||e.equals(n))))}function h(t,e,r){const{hashType:n}=e(t),i=[];n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push(\"addInput\");switch(31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push(\"addOutput\"),i.push(\"setInputSequence\")}return-1===i.indexOf(r)}e.isP2MS=u(c.p2ms),e.isP2PK=u(c.p2pk),e.isP2PKH=u(c.p2pkh),e.isP2WPKH=u(c.p2wpkh),e.isP2WSHScript=u(c.p2wsh),e.isP2SHScript=u(c.p2sh),e.isP2TR=u(c.p2tr),e.witnessStackToScriptWitness=function(t){let e=n.allocUnsafe(0);function r(t){const r=e.length,o=i.encodingLength(t);e=n.concat([e,n.allocUnsafe(o)]),i.encode(t,e,r)}function o(t){r(t.length),function(t){e=n.concat([e,n.from(t)])}(t)}var s;return r((s=t).length),s.forEach(o),e},e.pubkeyPositionInScript=f,e.pubkeyInScript=function(t,e){return-1!==f(t,e)},e.checkInputForSig=function(t,e){return function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){const e=t.finalScriptSig&&o.decompile(t.finalScriptSig)||[],r=t.finalScriptWitness&&o.decompile(t.finalScriptWitness)||[];return e.concat(r).filter((t=>n.isBuffer(t)&&o.isCanonicalScriptSignature(t))).map((t=>({signature:t})))}(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t).some((t=>h(t,o.signature.decode,e)))},e.signatureBlocksAction=h},1213:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.decode=e.encode=e.encodingLength=void 0;const n=r(8156);function i(t){return tt.length)return null;i=t.readUInt8(e+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(e+3>t.length)return null;i=t.readUInt16LE(e+1),o=3}else{if(e+5>t.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error(\"Unexpected opcode\");i=t.readUInt32LE(e+1),o=5}return{opcode:r,number:i,size:o}}},4009:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const i=r(195),o=r(8156);Object.defineProperty(e,\"OPS\",{enumerable:!0,get:function(){return o.OPS}});const s=r(1213),a=r(5333),c=r(1108),u=r(5593),{typeforce:f}=u,h=o.OPS.OP_RESERVED;function l(t){return u.Buffer(t)||function(t){return u.Number(t)&&(t===o.OPS.OP_0||t>=o.OPS.OP_1&&t<=o.OPS.OP_16||t===o.OPS.OP_1NEGATE)}(t)}function p(t){return u.Array(t)&&t.every(l)}function d(t){return 0===t.length?o.OPS.OP_0:1===t.length?t[0]>=1&&t[0]<=16?h+t[0]:129===t[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(t){return n.isBuffer(t)}function g(t){return n.isBuffer(t)}function b(t){if(y(t))return t;f(u.Array,t);const e=t.reduce(((t,e)=>g(e)?1===e.length&&void 0!==d(e)?t+1:t+s.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(g(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=s.encode(r,t.length,i),t.copy(r,i),i+=t.length}else r.writeUInt8(t,i),i+=1})),i!==r.length)throw new Error(\"Could not decode chunks\");return r}function w(t){if(e=t,u.Array(e))return t;var e;f(u.Buffer,t);const r=[];let n=0;for(;no.OPS.OP_0&&e<=o.OPS.OP_PUSHDATA4){const e=s.decode(t,n);if(null===e)return null;if(n+=e.size,n+e.number>t.length)return null;const i=t.slice(n,n+e.number);n+=e.number;const o=d(i);void 0!==o?r.push(o):r.push(i)}else r.push(e),n+=1}return r}function m(t){const e=-129&t;return e>0&&e<4}e.isPushOnly=p,e.countNonPushOnlyOPs=function(t){return t.length-t.filter(l).length},e.compile=b,e.decompile=w,e.toASM=function(t){return y(t)&&(t=w(t)),t.map((t=>{if(g(t)){const e=d(t);if(void 0===e)return t.toString(\"hex\");t=e}return o.REVERSE_OPS[t]})).join(\" \")},e.fromASM=function(t){return f(u.String,t),b(t.split(\" \").map((t=>void 0!==o.OPS[t]?o.OPS[t]:(f(u.Hex,t),n.from(t,\"hex\")))))},e.toStack=function(t){return t=w(t),f(p,t),t.map((t=>g(t)?t:t===o.OPS.OP_0?n.allocUnsafe(0):a.encode(t-h)))},e.isCanonicalPubKey=function(t){return u.isPoint(t)},e.isDefinedHashType=m,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&(!!m(t[t.length-1])&&i.check(t.slice(0,-1)))},e.number=a,e.signature=c},5333:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=void 0,e.decode=function(t,e,r){e=e||4,r=void 0===r||r;const n=t.length;if(0===n)return 0;if(n>e)throw new TypeError(\"Script number overflow\");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error(\"Non-minimally encoded script number\");if(5===n){const e=t.readUInt32LE(0),r=t.readUInt8(4);return 128&r?-(4294967296*(-129&r)+e):4294967296*r+e}let i=0;for(let e=0;e2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),i=n.allocUnsafe(r),o=t<0;for(let t=0;t>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i}},1108:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=void 0;const i=r(195),o=r(5593),{typeforce:s}=o,a=n.alloc(1,0);function c(t){let e=0;for(;0===t[e];)++e;return e===t.length?a:128&(t=t.slice(e))[0]?n.concat([a,t],1+t.length):t}function u(t){0===t[0]&&(t=t.slice(1));const e=n.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}e.decode=function(t){const e=t.readUInt8(t.length-1),r=-129&e;if(r<=0||r>=4)throw new Error(\"Invalid hashType \"+e);const o=i.decode(t.slice(0,-1)),s=u(o.r),a=u(o.s);return{signature:n.concat([s,a],64),hashType:e}},e.encode=function(t,e){s({signature:o.BufferN(64),hashType:o.UInt8},{signature:t,hashType:e});const r=-129&e;if(r<=0||r>=4)throw new Error(\"Invalid hashType \"+e);const a=n.allocUnsafe(1);a.writeUInt8(e,0);const u=c(t.slice(0,32)),f=c(t.slice(32,64));return n.concat([i.encode(u,f),a])}},3063:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Transaction=void 0;const i=r(3831),o=r(6891),s=r(4009),a=r(4009),c=r(5593),{typeforce:u}=c;function f(t){const e=t.length;return i.varuint.encodingLength(e)+e}const h=n.allocUnsafe(0),l=[],p=n.from(\"0000000000000000000000000000000000000000000000000000000000000000\",\"hex\"),d=n.from(\"0000000000000000000000000000000000000000000000000000000000000001\",\"hex\"),y=n.from(\"ffffffffffffffff\",\"hex\"),g={script:h,valueBuffer:y};class b{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,e){const r=new i.BufferReader(t),n=new b;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let a=!1;o===b.ADVANCED_TRANSACTION_MARKER&&s===b.ADVANCED_TRANSACTION_FLAG?a=!0:r.offset-=2;const c=r.readVarInt();for(let t=0;t0!==t.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const e=t&&this.hasWitnesses();return(e?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce(((t,e)=>t+40+f(e.script)),0)+this.outs.reduce(((t,e)=>t+8+f(e.script)),0)+(e?this.ins.reduce(((t,e)=>t+function(t){const e=t.length;return i.varuint.encodingLength(e)+t.reduce(((t,e)=>t+f(e)),0)}(e.witness)),0):0)}clone(){const t=new b;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((t=>({hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}))),t.outs=this.outs.map((t=>({script:t.script,value:t.value}))),t}hashForSignature(t,e,r){if(u(c.tuple(c.UInt32,c.Buffer,c.Number),arguments),t>=this.ins.length)return d;const i=s.compile(s.decompile(e).filter((t=>t!==a.OPS.OP_CODESEPARATOR))),f=this.clone();if((31&r)===b.SIGHASH_NONE)f.outs=[],f.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===b.SIGHASH_SINGLE){if(t>=this.outs.length)return d;f.outs.length=t+1;for(let e=0;e{r!==t&&(e.sequence=0)}))}r&b.SIGHASH_ANYONECANPAY?(f.ins=[f.ins[t]],f.ins[0].script=i):(f.ins.forEach((t=>{t.script=h})),f.ins[t].script=i);const l=n.allocUnsafe(f.byteLength(!1)+4);return l.writeInt32LE(r,l.length-4),f.__toBuffer(l,0,!1),o.hash256(l)}hashForWitnessV1(t,e,r,s,a,l){if(u(c.tuple(c.UInt32,u.arrayOf(c.Buffer),u.arrayOf(c.Satoshi),c.UInt32),arguments),r.length!==this.ins.length||e.length!==this.ins.length)throw new Error(\"Must supply prevout script and value for all inputs\");const p=s===b.SIGHASH_DEFAULT?b.SIGHASH_ALL:s&b.SIGHASH_OUTPUT_MASK,d=(s&b.SIGHASH_INPUT_MASK)===b.SIGHASH_ANYONECANPAY,y=p===b.SIGHASH_NONE,g=p===b.SIGHASH_SINGLE;let w=h,m=h,v=h,E=h,_=h;if(!d){let t=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((e=>{t.writeSlice(e.hash),t.writeUInt32(e.index)})),w=o.sha256(t.end()),t=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach((e=>t.writeUInt64(e))),m=o.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(f).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),v=o.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),E=o.sha256(t.end())}if(y||g){if(g&&t8+f(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),_=o.sha256(e.end())}const S=(a?2:0)+(l?1:0),A=174-(d?49:0)-(y?32:0)+(l?32:0)+(a?37:0),I=i.BufferWriter.withCapacity(A);if(I.writeUInt8(s),I.writeInt32(this.version),I.writeUInt32(this.locktime),I.writeSlice(w),I.writeSlice(m),I.writeSlice(v),I.writeSlice(E),y||g||I.writeSlice(_),I.writeUInt8(S),d){const n=this.ins[t];I.writeSlice(n.hash),I.writeUInt32(n.index),I.writeUInt64(r[t]),I.writeVarSlice(e[t]),I.writeUInt32(n.sequence)}else I.writeUInt32(t);if(l){const t=i.BufferWriter.withCapacity(f(l));t.writeVarSlice(l),I.writeSlice(o.sha256(t.end()))}return g&&I.writeSlice(_),a&&(I.writeSlice(a),I.writeUInt8(0),I.writeUInt32(4294967295)),o.taggedHash(\"TapSighash\",n.concat([n.from([0]),I.end()]))}hashForWitnessV0(t,e,r,s){u(c.tuple(c.UInt32,c.Buffer,c.Satoshi,c.UInt32),arguments);let a,h=n.from([]),l=p,d=p,y=p;if(s&b.SIGHASH_ANYONECANPAY||(h=n.allocUnsafe(36*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeSlice(t.hash),a.writeUInt32(t.index)})),d=o.hash256(h)),s&b.SIGHASH_ANYONECANPAY||(31&s)===b.SIGHASH_SINGLE||(31&s)===b.SIGHASH_NONE||(h=n.allocUnsafe(4*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeUInt32(t.sequence)})),y=o.hash256(h)),(31&s)!==b.SIGHASH_SINGLE&&(31&s)!==b.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+f(e.script)),0);h=n.allocUnsafe(t),a=new i.BufferWriter(h,0),this.outs.forEach((t=>{a.writeUInt64(t.value),a.writeVarSlice(t.script)})),l=o.hash256(h)}else if((31&s)===b.SIGHASH_SINGLE&&t{o.writeSlice(t.hash),o.writeUInt32(t.index),o.writeVarSlice(t.script),o.writeUInt32(t.sequence)})),o.writeVarInt(this.outs.length),this.outs.forEach((t=>{void 0!==t.value?o.writeUInt64(t.value):o.writeSlice(t.valueBuffer),o.writeVarSlice(t.script)})),s&&this.ins.forEach((t=>{o.writeVector(t.witness)})),o.writeUInt32(this.locktime),void 0!==e?t.slice(e,o.offset):t}}e.Transaction=b,b.DEFAULT_SEQUENCE=4294967295,b.SIGHASH_DEFAULT=0,b.SIGHASH_ALL=1,b.SIGHASH_NONE=2,b.SIGHASH_SINGLE=3,b.SIGHASH_ANYONECANPAY=128,b.SIGHASH_OUTPUT_MASK=3,b.SIGHASH_INPUT_MASK=128,b.ADVANCED_TRANSACTION_MARKER=0,b.ADVANCED_TRANSACTION_FLAG=1},5593:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const n=r(1048);e.typeforce=r(973);const i=n.Buffer.alloc(32,0),o=n.Buffer.from(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\",\"hex\");e.isPoint=function(t){if(!n.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;const e=t[0],r=t.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;const s=t.slice(33);return 0!==s.compare(i)&&(!(s.compare(o)>=0)&&(4===e&&65===t.length))};const s=Math.pow(2,31)-1;function a(t){return e.typeforce.String(t)&&!!t.match(/^(m\\/)?(\\d+'?\\/)*\\d+'?$/)}e.UInt31=function(t){return e.typeforce.UInt32(t)&&t<=s},e.BIP32Path=a,a.toJSON=()=>\"BIP32 derivation path\",e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||\"function\"==typeof t.getPublicKey)&&\"function\"==typeof t.sign};function c(t){return!(!t||!(\"output\"in t))&&(!!n.Buffer.isBuffer(t.output)&&(void 0===t.version||(t.version&e.TAPLEAF_VERSION_MASK)===t.version))}e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.ECPoint=e.typeforce.quacksLike(\"Point\"),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=c,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):c(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf},9216:(t,e,r)=>{var n=r(9784);t.exports=n(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\")},7639:(t,e,r)=>{\"use strict\";var n=r(9216),i=r(5636).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error(\"Invalid checksum\");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},9848:(t,e,r)=>{\"use strict\";var n=r(3257),i=r(7639);t.exports=i((function(t){var e=n(\"sha256\").update(t).digest();return n(\"sha256\").update(e).digest()}))},1048:(t,e,r)=>{\"use strict\";const n=r(7991),i=r(9318),o=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null;e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if(\"number\"==typeof t){if(\"string\"==typeof e)throw new TypeError('The \"string\" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,e,r){if(\"string\"==typeof t)return function(t,e){\"string\"==typeof e&&\"\"!==e||(e=\"utf8\");if(!c.isEncoding(e))throw new TypeError(\"Unknown encoding: \"+e);const r=0|y(t,e);let n=a(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(z(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof t);if(z(t,ArrayBuffer)||t&&z(t.buffer,ArrayBuffer))return p(t,e,r);if(\"undefined\"!=typeof SharedArrayBuffer&&(z(t,SharedArrayBuffer)||t&&z(t.buffer,SharedArrayBuffer)))return p(t,e,r);if(\"number\"==typeof t)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return c.from(n,e,r);const i=function(t){if(c.isBuffer(t)){const e=0|d(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return\"number\"!=typeof t.length||J(t.length)?a(0):l(t);if(\"Buffer\"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(i)return i;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive](\"string\"),e,r);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof t)}function f(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be of type number');if(t<0)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"')}function h(t){return f(t),a(t<0?0:0|d(t))}function l(t){const e=t.length<0?0:0|d(t.length),r=a(e);for(let n=0;n=s)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+s.toString(16)+\" bytes\");return 0|t}function y(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||z(t,ArrayBuffer))return t.byteLength;if(\"string\"!=typeof t)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case\"ascii\":case\"latin1\":case\"binary\":return r;case\"utf8\":case\"utf-8\":return q(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*r;case\"hex\":return r>>>1;case\"base64\":return W(t).length;default:if(i)return n?-1:q(t).length;e=(\"\"+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return\"\";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return\"\";if((r>>>=0)<=(e>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return P(this,e,r);case\"utf8\":case\"utf-8\":return T(this,e,r);case\"ascii\":return O(this,e,r);case\"latin1\":case\"binary\":return k(this,e,r);case\"base64\":return I(this,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return R(this,e,r);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if(\"string\"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if(\"string\"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if(\"number\"==typeof e)return e&=255,\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function m(t,e,r,n,i){let o,s=1,a=t.length,c=e.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;ni&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function I(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(o=c));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r=\"\",n=0;for(;nn.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!c.isBuffer(e))throw new TypeError('\"list\" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},c.byteLength=y,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let e=0;er&&(t+=\" ... \"),\"\"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(t,e,r,n,i){if(z(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),u=this.slice(n,i),f=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n=\"utf8\")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let o=!1;for(;;)switch(n){case\"hex\":return v(this,t,e,r);case\"utf8\":case\"utf-8\":return E(this,t,e,r);case\"ascii\":case\"latin1\":case\"binary\":return _(this,t,e,r);case\"base64\":return S(this,t,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return A(this,t,e,r);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function O(t,e,r){let n=\"\";r=Math.min(t.length,r);for(let i=e;in)&&(r=n);let i=\"\";for(let n=e;nr)throw new RangeError(\"Trying to access beyond buffer length\")}function C(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError(\"Index out of range\")}function N(t,e,r,n,i){$(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function L(t,e,r,n,i){$(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError(\"Index out of range\");if(r<0)throw new RangeError(\"Index out of range\")}function j(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=Z((function(t){K(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o=i&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=Z((function(t){K(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){C(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,!n){C(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=Z((function(t,e=0){return N(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeBigUInt64BE=Z((function(t,e=0){return L(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=Z((function(t,e=0){return N(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeBigInt64BE=Z((function(t,e=0){return L(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError(\"argument should be a Buffer\");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),\"number\"==typeof t)for(i=e;i=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function $(t,e,r,n,i,o){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new H.ERR_OUT_OF_RANGE(\"value\",i,t)}!function(t,e,r){K(e,\"offset\"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(n,i,o)}function K(t,e){if(\"number\"!=typeof t)throw new H.ERR_INVALID_ARG_TYPE(e,\"number\",t)}function V(t,e,r){if(Math.floor(t)!==t)throw K(t,r),new H.ERR_OUT_OF_RANGE(r||\"offset\",\"an integer\",t);if(e<0)throw new H.ERR_BUFFER_OUT_OF_BOUNDS;throw new H.ERR_OUT_OF_RANGE(r||\"offset\",`>= ${r?1:0} and <= ${e}`,t)}F(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(t){return t?`${t} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),F(\"ERR_INVALID_ARG_TYPE\",(function(t,e){return`The \"${t}\" argument must be of type number. Received type ${typeof e}`}),TypeError),F(\"ERR_OUT_OF_RANGE\",(function(t,e,r){let n=`The value of \"${t}\" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):\"bigint\"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+=\"n\"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error(\"Invalid code point\");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function W(t){return n.toByteArray(function(t){if((t=(t=t.split(\"=\")[0]).trim().replace(G,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}(t))}function X(t,e,r,n){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Y=function(){const t=\"0123456789abcdef\",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Z(t){return\"undefined\"==typeof BigInt?Q:t}function Q(){throw new Error(\"BigInt not supported\")}},7589:(t,e,r)=>{var n=r(5636).Buffer,i=r(1983).Transform,o=r(8888).I;function s(t){i.call(this),this.hashMode=\"string\"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(5615)(s,i),s.prototype.update=function(t,e,r){\"string\"==typeof t&&(t=n.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error(\"trying to get auth tag in unsupported state\")},s.prototype.setAuthTag=function(){throw new Error(\"trying to set auth tag in unsupported state\")},s.prototype.setAAD=function(){throw new Error(\"trying to set aad in unsupported state\")},s.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error(\"can't switch encodings\");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=s},7232:(t,e,r)=>{var n=r(366);t.exports=function(t,e,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],e),o=0,s=[],a=n.sumOrNaN(e),c=0;cu.value){if(c===t.length-1)return{fee:r*(i+f)}}else if(i+=f,o+=l,s.push(u),!(o{var n=r(366);t.exports=function(t,e,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],e),o=0,s=[],a=n.sumOrNaN(e),c=n.dustThreshold({},r),u=0;ua+l+c)&&(i+=h,o+=p,s.push(f),!(o{var n=r(7232),i=r(2379),o=r(366);function s(t,e){return t.value-e*o.inputBytes(t)}t.exports=function(t,e,r){t=t.concat().sort((function(t,e){return s(e,r)-s(t,r)}));var o=i(t,e,r);return o.inputs?o:n(t,e,r)}},366:t=>{var e=10,r=41,n=107,i=9,o=25;function s(t){return r+(t.script?t.script.length:n)}function a(t){return i+(t.script?t.script.length:o)}function c(t,e){return s({})*e}function u(t,r){return e+t.reduce((function(t,e){return t+s(e)}),0)+r.reduce((function(t,e){return t+a(e)}),0)}function f(t){return\"number\"!=typeof t?NaN:isFinite(t)?Math.floor(t)!==t||t<0?NaN:t:NaN}function h(t){return t.reduce((function(t,e){return t+f(e.value)}),0)}var l=a({});t.exports={dustThreshold:c,finalize:function(t,e,r){var n=u(t,e),i=r*(n+l),o=h(t)-(h(e)+i);o>c(0,r)&&(e=e.concat({value:o}));var s=h(t)-h(e);return isFinite(s)?{inputs:t,outputs:e,fee:s}:{fee:r*n}},inputBytes:s,outputBytes:a,sumOrNaN:h,sumForgiving:function(t){return t.reduce((function(t,e){return t+(isFinite(e.value)?e.value:0)}),0)},transactionBytes:u,uintOrNaN:f}},3257:(t,e,r)=>{\"use strict\";var n=r(5615),i=r(3275),o=r(5586),s=r(3229),a=r(7589);function c(t){a.call(this,\"digest\"),this._hash=t}n(c,a),c.prototype._update=function(t){this._hash.update(t)},c.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return\"md5\"===(t=t.toLowerCase())?new i:\"rmd160\"===t||\"ripemd160\"===t?new o:new c(s(t))}},8437:t=>{var e=1e3,r=60*e,n=60*r,i=24*n,o=7*i,s=365.25*i;function a(t,e,r,n){var i=e>=1.5*r;return Math.round(t/r)+\" \"+n+(i?\"s\":\"\")}t.exports=function(t,c){c=c||{};var u=typeof t;if(\"string\"===u&&t.length>0)return function(t){if((t=String(t)).length>100)return;var a=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return c*s;case\"weeks\":case\"week\":case\"w\":return c*o;case\"days\":case\"day\":case\"d\":return c*i;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return c*n;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return c*r;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return c*e;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return c;default:return}}(t);if(\"number\"===u&&isFinite(t))return c.long?function(t){var o=Math.abs(t);if(o>=i)return a(t,o,i,\"day\");if(o>=n)return a(t,o,n,\"hour\");if(o>=r)return a(t,o,r,\"minute\");if(o>=e)return a(t,o,e,\"second\");return t+\" ms\"}(t):function(t){var o=Math.abs(t);if(o>=i)return Math.round(t/i)+\"d\";if(o>=n)return Math.round(t/n)+\"h\";if(o>=r)return Math.round(t/r)+\"m\";if(o>=e)return Math.round(t/e)+\"s\";return t+\"ms\"}(t);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(t))}},124:(t,e,r)=>{e.formatArgs=function(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+t.exports.humanize(this.diff),!this.useColors)return;const r=\"color: \"+this.color;e.splice(1,0,r,\"color: inherit\");let n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(t=>{\"%%\"!==t&&(n++,\"%c\"===t&&(i=n))})),e.splice(i,0,r)},e.save=function(t){try{t?e.storage.setItem(\"debug\",t):e.storage.removeItem(\"debug\")}catch(t){}},e.load=function(){let t;try{t=e.storage.getItem(\"debug\")}catch(t){}!t&&\"undefined\"!=typeof process&&\"env\"in process&&(t=\"false\");return t},e.useColors=function(){if(\"undefined\"!=typeof window&&window.process&&(\"renderer\"===window.process.type||window.process.__nwjs))return!0;if(\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))return!1;return\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),e.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],e.log=console.debug||console.log||(()=>{}),t.exports=r(7891)(e);const{formatters:n}=t.exports;n.j=function(t){try{return JSON.stringify(t)}catch(t){return\"[UnexpectedJSONParseError]: \"+t.message}}},7891:(t,e,r)=>{t.exports=function(t){function e(t){let r,i,o,s=null;function a(...t){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,t[0]=e.coerce(t[0]),\"string\"!=typeof t[0]&&t.unshift(\"%O\");let s=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if(\"%%\"===r)return\"%\";s++;const o=e.formatters[i];if(\"function\"==typeof o){const e=t[s];r=o.call(n,e),t.splice(s,1),s--}return r})),e.formatArgs.call(n,t);(n.log||e.log).apply(n,t)}return a.namespace=t,a.useColors=e.useColors(),a.color=e.selectColor(t),a.extend=n,a.destroy=e.destroy,Object.defineProperty(a,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==e.namespaces&&(i=e.namespaces,o=e.enabled(t)),o),set:t=>{s=t}}),\"function\"==typeof e.init&&e.init(a),a}function n(t,r){const n=e(this.namespace+(void 0===r?\":\":r)+t);return n.log=this.log,n}function i(t){return t.toString().substring(2,t.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return e.debug=e,e.default=e,e.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},e.disable=function(){const t=[...e.names.map(i),...e.skips.map(i).map((t=>\"-\"+t))].join(\",\");return e.enable(\"\"),t},e.enable=function(t){let r;e.save(t),e.namespaces=t,e.names=[],e.skips=[];const n=(\"string\"==typeof t?t:\"\").split(/[\\s,]+/),i=n.length;for(r=0;r{e[r]=t[r]})),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let r=0;for(let e=0;e{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(3540);e.networks=i;const o=r(146),s=r(2644),a=r(6952),c=r(5581),u=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError(\"Private key not in range [1, n)\");return o.typeforce(u,r),new f(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(u,r),new f(void 0,e,r)}(0,c.testEcc)(t);class f{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error(\"Missing private key\");return a.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error(\"Missing private key\");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error(\"Missing private key\");if(!t.signSchnorr)throw new Error(\"signSchnorr not supported by ecc library\");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error(\"verifySchnorr not supported by ecc library\");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const s=t.xOnlyPointAddTweak(i,e);if(!s||null===s.xOnlyPubkey)throw new Error(\"Cannot tweak public key!\");const a=n.from([0===s.parity?2:3]);return r(n.concat([a,s.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3===this.publicKey[0]||4===this.publicKey[0]&&1==(1&this.publicKey[64])?t.privateNegate(this.privateKey):this.privateKey,o=t.privateAdd(i,r);if(!o)throw new Error(\"Invalid tweaked private key!\");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=a.decode(t),s=n.version;if(o.Array(r)){if(!(r=r.filter((t=>s===t.wif)).pop()))throw new Error(\"Unknown network version\")}else if(r=r||i.bitcoin,s!==r.wif)throw new Error(\"Invalid network version\");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(u,r),void 0===r&&(r={});const n=r.rng||s;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},1075:(t,e,r)=>{\"use strict\";e.Ay=void 0;var n=r(2239);Object.defineProperty(e,\"Ay\",{enumerable:!0,get:function(){return n.ECPairFactory}})},3540:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"tb\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},5581:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,\"hex\");function o(t){if(!t)throw new Error(\"ecc library invalid\")}e.testEcc=function(t){o(t.isPoint(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(!t.isPoint(i(\"030000000000000000000000000000000000000000000000000000000000000005\"))),o(t.isPrivate(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(!t.isPrivate(i(\"0000000000000000000000000000000000000000000000000000000000000000\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142\"))),o(n.from(t.privateAdd(i(\"0000000000000000000000000000000000000000000000000000000000000001\"),i(\"0000000000000000000000000000000000000000000000000000000000000000\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))),o(null===t.privateAdd(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"),i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateAdd(i(\"e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500\"),i(\"b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665\"))).equals(i(\"9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24\"))),o(n.from(t.privateNegate(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(n.from(t.privateNegate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateNegate(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792\"))),o(n.from(t.pointCompress(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"),!0)).equals(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(n.from(t.pointCompress(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"),!1)).equals(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"))),o(n.from(t.pointCompress(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),!0)).equals(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(n.from(t.pointCompress(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),!1)).equals(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"))),o(n.from(t.pointFromScalar(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99\"))),o(null===t.xOnlyPointAddTweak(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\")));let e=t.xOnlyPointAddTweak(i(\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\"),i(\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\"));o(n.from(e.xOnlyPubkey).equals(i(\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"))&&1===e.parity),e=t.xOnlyPointAddTweak(i(\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\"),i(\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\")),o(n.from(e.xOnlyPubkey).equals(i(\"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c\"))&&0===e.parity),o(n.from(t.sign(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))).equals(i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),o(t.verify(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),t.signSchnorr&&o(n.from(t.signSchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9\"),i(\"c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906\"))).equals(i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\"))),t.verifySchnorr&&o(t.verifySchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8\"),i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\")))}},146:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(973),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},46:t=>{\"use strict\";var e,r=\"object\"==typeof Reflect?Reflect:null,n=r&&\"function\"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&\"function\"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){\"function\"==typeof t.removeListener&&t.removeListener(\"error\",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),\"error\"!==e&&function(t,e,r){\"function\"==typeof t.on&&y(t,\"error\",e,r)}(t,i,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if(\"function\"!=typeof t)throw new TypeError('The \"listener\" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var i,o,s,u;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit(\"newListener\",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if(\"function\"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(t))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error(\"Possible EventEmitter memory leak detected. \"+s.length+\" \"+String(e)+\" listeners added. Use emitter.setMaxListeners() to increase limit\");f.name=\"MaxListenersExceededWarning\",f.emitter=t,f.type=e,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function l(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:\"function\"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(s=e[0]),s instanceof Error)throw s;var a=new Error(\"Unhandled error.\"+(s?\" (\"+s.message+\")\":\"\"));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if(\"function\"==typeof c)n(c,this,e);else{var u=c.length,f=d(c,u);for(r=0;r=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return l(this,t,!0)},o.prototype.rawListeners=function(t){return l(this,t,!1)},o.listenerCount=function(t,e){return\"function\"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},282:t=>{t.exports=s,s.default=s,s.stable=f,s.stableStringify=f;var e=\"[...]\",r=\"[Circular]\",n=[],i=[];function o(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function s(t,e,r,s){var a;void 0===s&&(s=o()),c(t,\"\",0,[],void 0,0,s);try{a=0===i.length?JSON.stringify(t,e,r):JSON.stringify(t,l(e),r)}catch(t){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function a(t,e,r,o){var s=Object.getOwnPropertyDescriptor(o,r);void 0!==s.get?s.configurable?(Object.defineProperty(o,r,{value:t}),n.push([o,r,e,s])):i.push([e,r,t]):(o[r]=t,n.push([o,r,e]))}function c(t,n,i,o,s,u,f){var h;if(u+=1,\"object\"==typeof t&&null!==t){for(h=0;hf.depthLimit)return void a(e,t,n,s);if(void 0!==f.edgesLimit&&i+1>f.edgesLimit)return void a(e,t,n,s);if(o.push(t),Array.isArray(t))for(h=0;he?1:0}function f(t,e,r,s){void 0===s&&(s=o());var a,c=h(t,\"\",0,[],void 0,0,s)||t;try{a=0===i.length?JSON.stringify(c,e,r):JSON.stringify(c,l(e),r)}catch(t){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function h(t,i,o,s,c,f,l){var p;if(f+=1,\"object\"==typeof t&&null!==t){for(p=0;pl.depthLimit)return void a(e,t,i,c);if(void 0!==l.edgesLimit&&o+1>l.edgesLimit)return void a(e,t,i,c);if(s.push(t),Array.isArray(t))for(p=0;p0)for(var n=0;n{\"use strict\";const n=r(919),i=r(6226),o=r(5181);t.exports={XMLParser:i,XMLValidator:n,XMLBuilder:o}},1209:(t,e)=>{\"use strict\";const r=\":A-Za-z_\\\\u00C0-\\\\u00D6\\\\u00D8-\\\\u00F6\\\\u00F8-\\\\u02FF\\\\u0370-\\\\u037D\\\\u037F-\\\\u1FFF\\\\u200C-\\\\u200D\\\\u2070-\\\\u218F\\\\u2C00-\\\\u2FEF\\\\u3001-\\\\uD7FF\\\\uF900-\\\\uFDCF\\\\uFDF0-\\\\uFFFD\",n=\"[\"+r+\"][\"+(r+\"\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040\")+\"]*\",i=new RegExp(\"^\"+n+\"$\");e.isExist=function(t){return void 0!==t},e.isEmptyObject=function(t){return 0===Object.keys(t).length},e.merge=function(t,e,r){if(e){const n=Object.keys(e),i=n.length;for(let o=0;o{\"use strict\";const n=r(1209),i={allowBooleanAttributes:!1,unpairedTags:[]};function o(t){return\" \"===t||\"\\t\"===t||\"\\n\"===t||\"\\r\"===t}function s(t,e){const r=e;for(;e5&&\"xml\"===n)return d(\"InvalidXml\",\"XML declaration allowed only at the start of the document.\",g(t,e));if(\"?\"==t[e]&&\">\"==t[e+1]){e++;break}}return e}function a(t,e){if(t.length>e+5&&\"-\"===t[e+1]&&\"-\"===t[e+2]){for(e+=3;e\"===t[e+2]){e+=2;break}}else if(t.length>e+8&&\"D\"===t[e+1]&&\"O\"===t[e+2]&&\"C\"===t[e+3]&&\"T\"===t[e+4]&&\"Y\"===t[e+5]&&\"P\"===t[e+6]&&\"E\"===t[e+7]){let r=1;for(e+=8;e\"===t[e]&&(r--,0===r))break}else if(t.length>e+9&&\"[\"===t[e+1]&&\"C\"===t[e+2]&&\"D\"===t[e+3]&&\"A\"===t[e+4]&&\"T\"===t[e+5]&&\"A\"===t[e+6]&&\"[\"===t[e+7])for(e+=8;e\"===t[e+2]){e+=2;break}return e}e.validate=function(t,e){e=Object.assign({},i,e);const r=[];let c=!1,u=!1;\"\\ufeff\"===t[0]&&(t=t.substr(1));for(let i=0;i\"!==t[i]&&\" \"!==t[i]&&\"\\t\"!==t[i]&&\"\\n\"!==t[i]&&\"\\r\"!==t[i];i++)w+=t[i];if(w=w.trim(),\"/\"===w[w.length-1]&&(w=w.substring(0,w.length-1),i--),h=w,!n.isName(h)){let e;return e=0===w.trim().length?\"Invalid space after '<'.\":\"Tag '\"+w+\"' is an invalid name.\",d(\"InvalidTag\",e,g(t,i))}const m=f(t,i);if(!1===m)return d(\"InvalidAttr\",\"Attributes for '\"+w+\"' have open quote.\",g(t,i));let v=m.value;if(i=m.index,\"/\"===v[v.length-1]){const r=i-v.length;v=v.substring(0,v.length-1);const n=l(v,e);if(!0!==n)return d(n.err.code,n.err.msg,g(t,r+n.err.line));c=!0}else if(b){if(!m.tagClosed)return d(\"InvalidTag\",\"Closing tag '\"+w+\"' doesn't have proper closing.\",g(t,i));if(v.trim().length>0)return d(\"InvalidTag\",\"Closing tag '\"+w+\"' can't have attributes or invalid starting.\",g(t,y));{const e=r.pop();if(w!==e.tagName){let r=g(t,e.tagStartPos);return d(\"InvalidTag\",\"Expected closing tag '\"+e.tagName+\"' (opened in line \"+r.line+\", col \"+r.col+\") instead of closing tag '\"+w+\"'.\",g(t,y))}0==r.length&&(u=!0)}}else{const n=l(v,e);if(!0!==n)return d(n.err.code,n.err.msg,g(t,i-v.length+n.err.line));if(!0===u)return d(\"InvalidXml\",\"Multiple possible root nodes found.\",g(t,i));-1!==e.unpairedTags.indexOf(w)||r.push({tagName:w,tagStartPos:y}),c=!0}for(i++;i0)||d(\"InvalidXml\",\"Invalid '\"+JSON.stringify(r.map((t=>t.tagName)),null,4).replace(/\\r?\\n/g,\"\")+\"' found.\",{line:1,col:1}):d(\"InvalidXml\",\"Start tag expected.\",1)};const c='\"',u=\"'\";function f(t,e){let r=\"\",n=\"\",i=!1;for(;e\"===t[e]&&\"\"===n){i=!0;break}r+=t[e]}return\"\"===n&&{value:r,index:e,tagClosed:i}}const h=new RegExp(\"(\\\\s*)([^\\\\s=]+)(\\\\s*=)?(\\\\s*(['\\\"])(([\\\\s\\\\S])*?)\\\\5)?\",\"g\");function l(t,e){const r=n.getAllMatches(t,h),i={};for(let t=0;t{\"use strict\";const n=r(4655),i={attributeNamePrefix:\"@_\",attributesGroupName:!1,textNodeName:\"#text\",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:\" \",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp(\"&\",\"g\"),val:\"&\"},{regex:new RegExp(\">\",\"g\"),val:\">\"},{regex:new RegExp(\"<\",\"g\"),val:\"<\"},{regex:new RegExp(\"'\",\"g\"),val:\"'\"},{regex:new RegExp('\"',\"g\"),val:\""\"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function o(t){this.options=Object.assign({},i,t),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=c),this.processTextOrObjNode=s,this.options.format?(this.indentate=a,this.tagEndChar=\">\\n\",this.newLine=\"\\n\"):(this.indentate=function(){return\"\"},this.tagEndChar=\">\",this.newLine=\"\")}function s(t,e,r){const n=this.j2x(t,r+1);return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,r):this.buildObjectNode(n.val,e,n.attrStr,r)}function a(t){return this.options.indentBy.repeat(t)}function c(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}o.prototype.build=function(t){return this.options.preserveOrder?n(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0).val)},o.prototype.j2x=function(t,e){let r=\"\",n=\"\";for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i))if(void 0===t[i])this.isAttribute(i)&&(n+=\"\");else if(null===t[i])this.isAttribute(i)?n+=\"\":\"?\"===i[0]?n+=this.indentate(e)+\"<\"+i+\"?\"+this.tagEndChar:n+=this.indentate(e)+\"<\"+i+\"/\"+this.tagEndChar;else if(t[i]instanceof Date)n+=this.buildTextValNode(t[i],i,\"\",e);else if(\"object\"!=typeof t[i]){const o=this.isAttribute(i);if(o)r+=this.buildAttrPairStr(o,\"\"+t[i]);else if(i===this.options.textNodeName){let e=this.options.tagValueProcessor(i,\"\"+t[i]);n+=this.replaceEntitiesValue(e)}else n+=this.buildTextValNode(t[i],i,\"\",e)}else if(Array.isArray(t[i])){const r=t[i].length;let o=\"\";for(let s=0;s\"+t+i}},o.prototype.closeTag=function(t){let e=\"\";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e=\"/\"):e=this.options.suppressEmptyNode?\"/\":`>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(n)+`\\x3c!--${t}--\\x3e`+this.newLine;if(\"?\"===e[0])return this.indentate(n)+\"<\"+e+r+\"?\"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),\"\"===i?this.indentate(n)+\"<\"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(n)+\"<\"+e+r+\">\"+i+\"0&&this.options.processEntities)for(let e=0;e{function e(t,s,a,c){let u=\"\",f=!1;for(let h=0;h`,f=!1;continue}if(p===s.commentPropName){u+=c+`\\x3c!--${l[p][0][s.textNodeName]}--\\x3e`,f=!0;continue}if(\"?\"===p[0]){const t=n(l[\":@\"],s),e=\"?xml\"===p?\"\":c;let r=l[p][0][s.textNodeName];r=0!==r.length?\" \"+r:\"\",u+=e+`<${p}${r}${t}?>`,f=!0;continue}let y=c;\"\"!==y&&(y+=s.indentBy);const g=c+`<${p}${n(l[\":@\"],s)}`,b=e(l[p],s,d,y);-1!==s.unpairedTags.indexOf(p)?s.suppressUnpairedNode?u+=g+\">\":u+=g+\"/>\":b&&0!==b.length||!s.suppressEmptyNode?b&&b.endsWith(\">\")?u+=g+`>${b}${c}`:(u+=g+\">\",b&&\"\"!==c&&(b.includes(\"/>\")||b.includes(\"`):u+=g+\"/>\",f=!0}return u}function r(t){const e=Object.keys(t);for(let r=0;r0&&e.processEntities)for(let r=0;r0&&(n=\"\\n\"),e(t,r,\"\",n)}},3233:(t,e,r)=>{const n=r(1209);function i(t,e){let r=\"\";for(;e\"===t[e]){if(l?\"-\"===t[e-1]&&\"-\"===t[e-2]&&(l=!1,n--):n--,0===n)break}else\"[\"===t[e]?h=!0:p+=t[e];else{if(h&&s(t,e))e+=7,[entityName,val,e]=i(t,e+1),-1===val.indexOf(\"&\")&&(r[f(entityName)]={regx:RegExp(`&${entityName};`,\"g\"),val});else if(h&&a(t,e))e+=8;else if(h&&c(t,e))e+=8;else if(h&&u(t,e))e+=9;else{if(!o)throw new Error(\"Invalid DOCTYPE\");l=!0}n++,p=\"\"}if(0!==n)throw new Error(\"Unclosed DOCTYPE\")}return{entities:r,i:e}}},7063:(t,e)=>{const r={preserveOrder:!1,attributeNamePrefix:\"@_\",attributesGroupName:!1,textNodeName:\"#text\",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t}};e.buildOptions=function(t){return Object.assign({},r,t)},e.defaultOptions=r},5139:(t,e,r)=>{\"use strict\";const n=r(1209),i=r(5381),o=r(3233),s=r(8262);function a(t){const e=Object.keys(t);for(let r=0;r0)){s||(t=this.replaceEntitiesValue(t));const n=this.options.tagValueProcessor(e,t,r,i,o);if(null==n)return t;if(typeof n!=typeof t||n!==t)return n;if(this.options.trimValues)return v(t,this.options.parseTagValue,this.options.numberParseOptions);return t.trim()===t?v(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function u(t){if(this.options.removeNSPrefix){const e=t.split(\":\"),r=\"/\"===t.charAt(0)?\"/\":\"\";if(\"xmlns\"===e[0])return\"\";2===e.length&&(t=r+e[1])}return t}const f=new RegExp(\"([^\\\\s=]+)\\\\s*(=\\\\s*(['\\\"])([\\\\s\\\\S]*?)\\\\3)?\",\"gm\");function h(t,e,r){if(!this.options.ignoreAttributes&&\"string\"==typeof t){const r=n.getAllMatches(t,f),i=r.length,o={};for(let t=0;t\",a,\"Closing Tag is not closed.\");let i=t.substring(a+2,e).trim();if(this.options.removeNSPrefix){const t=i.indexOf(\":\");-1!==t&&(i=i.substr(t+1))}this.options.transformTagName&&(i=this.options.transformTagName(i)),r&&(n=this.saveTextToParentTag(n,r,s));const o=s.substring(s.lastIndexOf(\".\")+1);if(i&&-1!==this.options.unpairedTags.indexOf(i))throw new Error(`Unpaired tag can not be used as closing tag: `);let c=0;o&&-1!==this.options.unpairedTags.indexOf(o)?(c=s.lastIndexOf(\".\",s.lastIndexOf(\".\")-1),this.tagsNodeStack.pop()):c=s.lastIndexOf(\".\"),s=s.substring(0,c),r=this.tagsNodeStack.pop(),n=\"\",a=e}else if(\"?\"===t[a+1]){let e=w(t,a,!1,\"?>\");if(!e)throw new Error(\"Pi Tag is not closed.\");if(n=this.saveTextToParentTag(n,r,s),this.options.ignoreDeclaration&&\"?xml\"===e.tagName||this.options.ignorePiTags);else{const t=new i(e.tagName);t.add(this.options.textNodeName,\"\"),e.tagName!==e.tagExp&&e.attrExpPresent&&(t[\":@\"]=this.buildAttributesMap(e.tagExp,s,e.tagName)),this.addChild(r,t,s)}a=e.closeIndex+1}else if(\"!--\"===t.substr(a+1,3)){const e=b(t,\"--\\x3e\",a+4,\"Comment is not closed.\");if(this.options.commentPropName){const i=t.substring(a+4,e-2);n=this.saveTextToParentTag(n,r,s),r.add(this.options.commentPropName,[{[this.options.textNodeName]:i}])}a=e}else if(\"!D\"===t.substr(a+1,2)){const e=o(t,a);this.docTypeEntities=e.entities,a=e.i}else if(\"![\"===t.substr(a+1,2)){const e=b(t,\"]]>\",a,\"CDATA is not closed.\")-2,i=t.substring(a+9,e);n=this.saveTextToParentTag(n,r,s);let o=this.parseTextData(i,r.tagname,s,!0,!1,!0,!0);null==o&&(o=\"\"),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:i}]):r.add(this.options.textNodeName,o),a=e+2}else{let o=w(t,a,this.options.removeNSPrefix),c=o.tagName;const u=o.rawTagName;let f=o.tagExp,h=o.attrExpPresent,l=o.closeIndex;this.options.transformTagName&&(c=this.options.transformTagName(c)),r&&n&&\"!xml\"!==r.tagname&&(n=this.saveTextToParentTag(n,r,s,!1));const p=r;if(p&&-1!==this.options.unpairedTags.indexOf(p.tagname)&&(r=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf(\".\"))),c!==e.tagname&&(s+=s?\".\"+c:c),this.isItStopNode(this.options.stopNodes,s,c)){let e=\"\";if(f.length>0&&f.lastIndexOf(\"/\")===f.length-1)a=o.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(c))a=o.closeIndex;else{const r=this.readStopNodeData(t,u,l+1);if(!r)throw new Error(`Unexpected end of ${u}`);a=r.i,e=r.tagContent}const n=new i(c);c!==f&&h&&(n[\":@\"]=this.buildAttributesMap(f,s,c)),e&&(e=this.parseTextData(e,c,s,!0,h,!0,!0)),s=s.substr(0,s.lastIndexOf(\".\")),n.add(this.options.textNodeName,e),this.addChild(r,n,s)}else{if(f.length>0&&f.lastIndexOf(\"/\")===f.length-1){\"/\"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),f=c):f=f.substr(0,f.length-1),this.options.transformTagName&&(c=this.options.transformTagName(c));const t=new i(c);c!==f&&h&&(t[\":@\"]=this.buildAttributesMap(f,s,c)),this.addChild(r,t,s),s=s.substr(0,s.lastIndexOf(\".\"))}else{const t=new i(c);this.tagsNodeStack.push(r),c!==f&&h&&(t[\":@\"]=this.buildAttributesMap(f,s,c)),this.addChild(r,t,s),r=t}n=\"\",a=l}}else n+=t[a]}return e.child};function p(t,e,r){const n=this.options.updateTag(e.tagname,r,e[\":@\"]);!1===n||(\"string\"==typeof n?(e.tagname=n,t.addChild(e)):t.addChild(e))}const d=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const r=this.docTypeEntities[e];t=t.replace(r.regx,r.val)}for(let e in this.lastEntities){const r=this.lastEntities[e];t=t.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const r=this.htmlEntities[e];t=t.replace(r.regex,r.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function y(t,e,r,n){return t&&(void 0===n&&(n=0===Object.keys(e.child).length),void 0!==(t=this.parseTextData(t,e.tagname,r,!1,!!e[\":@\"]&&0!==Object.keys(e[\":@\"]).length,n))&&\"\"!==t&&e.add(this.options.textNodeName,t),t=\"\"),t}function g(t,e,r){const n=\"*.\"+r;for(const r in t){const i=t[r];if(n===i||e===i)return!0}return!1}function b(t,e,r,n){const i=t.indexOf(e,r);if(-1===i)throw new Error(n);return i+e.length-1}function w(t,e,r,n=\">\"){const i=function(t,e,r=\">\"){let n,i=\"\";for(let o=e;o\",r,`${e} is not closed`);if(t.substring(r+2,o).trim()===e&&(i--,0===i))return{tagContent:t.substring(n,r),i:o};r=o}else if(\"?\"===t[r+1]){r=b(t,\"?>\",r+1,\"StopNode is not closed.\")}else if(\"!--\"===t.substr(r+1,3)){r=b(t,\"--\\x3e\",r+3,\"StopNode is not closed.\")}else if(\"![\"===t.substr(r+1,2)){r=b(t,\"]]>\",r,\"StopNode is not closed.\")-2}else{const n=w(t,r,\">\");if(n){(n&&n.tagName)===e&&\"/\"!==n.tagExp[n.tagExp.length-1]&&i++,r=n.closeIndex}}}function v(t,e,r){if(e&&\"string\"==typeof t){const e=t.trim();return\"true\"===e||\"false\"!==e&&s(t,r)}return n.isExist(t)?t:\"\"}t.exports=class{constructor(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:\"'\"},gt:{regex:/&(gt|#62|#x3E);/g,val:\">\"},lt:{regex:/&(lt|#60|#x3C);/g,val:\"<\"},quot:{regex:/&(quot|#34|#x22);/g,val:'\"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:\"&\"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:\" \"},cent:{regex:/&(cent|#162);/g,val:\"¢\"},pound:{regex:/&(pound|#163);/g,val:\"£\"},yen:{regex:/&(yen|#165);/g,val:\"¥\"},euro:{regex:/&(euro|#8364);/g,val:\"€\"},copyright:{regex:/&(copy|#169);/g,val:\"©\"},reg:{regex:/&(reg|#174);/g,val:\"®\"},inr:{regex:/&(inr|#8377);/g,val:\"₹\"}},this.addExternalEntities=a,this.parseXml=l,this.parseTextData=c,this.resolveNameSpace=u,this.buildAttributesMap=h,this.isItStopNode=g,this.replaceEntitiesValue=d,this.readStopNodeData=m,this.saveTextToParentTag=y,this.addChild=p}}},6226:(t,e,r)=>{const{buildOptions:n}=r(7063),i=r(5139),{prettify:o}=r(896),s=r(919);t.exports=class{constructor(t){this.externalEntities={},this.options=n(t)}parse(t,e){if(\"string\"==typeof t);else{if(!t.toString)throw new Error(\"XML data is accepted in String or Bytes[] form.\");t=t.toString()}if(e){!0===e&&(e={});const r=s.validate(t,e);if(!0!==r)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const r=new i(this.options);r.addExternalEntities(this.externalEntities);const n=r.parseXml(t);return this.options.preserveOrder||void 0===n?n:o(n,this.options)}addEntity(t,e){if(-1!==e.indexOf(\"&\"))throw new Error(\"Entity value can't have '&'\");if(-1!==t.indexOf(\"&\")||-1!==t.indexOf(\";\"))throw new Error(\"An entity must be set without '&' and ';'. Eg. use '#xD' for ' '\");if(\"&\"===e)throw new Error(\"An entity with value '&' is not permitted\");this.externalEntities[t]=e}}},896:(t,e)=>{\"use strict\";function r(t,e,s){let a;const c={};for(let u=0;u0&&(c[e.textNodeName]=a):void 0!==a&&(c[e.textNodeName]=a),c}function n(t){const e=Object.keys(t);for(let t=0;t{\"use strict\";t.exports=class{constructor(t){this.tagname=t,this.child=[],this[\":@\"]={}}add(t,e){\"__proto__\"===t&&(t=\"#__proto__\"),this.child.push({[t]:e})}addChild(t){\"__proto__\"===t.tagname&&(t.tagname=\"#__proto__\"),t[\":@\"]&&Object.keys(t[\":@\"]).length>0?this.child.push({[t.tagname]:t.child,\":@\":t[\":@\"]}):this.child.push({[t.tagname]:t.child})}}},9467:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=r(4156).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(5615)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t,e){if(!n.isBuffer(t)&&\"string\"!=typeof t)throw new TypeError(e+\" must be a string or a buffer\")}(t,\"Data\"),this._finalized)throw new Error(\"Digest already called\");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error(\"_update is not implemented\")},o.prototype.digest=function(t){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error(\"_digest is not implemented\")},t.exports=o},9318:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,c=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=u}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,u-=8);t[r+p-d]|=128*y}},5615:t=>{\"function\"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},3624:(t,e,r)=>{\"use strict\";const n=r(222),i=Symbol(\"max\"),o=Symbol(\"length\"),s=Symbol(\"lengthCalculator\"),a=Symbol(\"allowStale\"),c=Symbol(\"maxAge\"),u=Symbol(\"dispose\"),f=Symbol(\"noDisposeOnSet\"),h=Symbol(\"lruList\"),l=Symbol(\"cache\"),p=Symbol(\"updateAgeOnGet\"),d=()=>1;const y=(t,e,r)=>{const n=t[l].get(e);if(n){const e=n.value;if(g(t,e)){if(w(t,n),!t[a])return}else r&&(t[p]&&(n.value.now=Date.now()),t[h].unshiftNode(n));return e.value}},g=(t,e)=>{if(!e||!e.maxAge&&!t[c])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[c]&&r>t[c]},b=t=>{if(t[o]>t[i])for(let e=t[h].tail;t[o]>t[i]&&null!==e;){const r=e.prev;w(t,e),e=r}},w=(t,e)=>{if(e){const r=e.value;t[u]&&t[u](r.key,r.value),t[o]-=r.length,t[l].delete(r.key),t[h].removeNode(e)}};class m{constructor(t,e,r,n,i){this.key=t,this.value=e,this.length=r,this.now=n,this.maxAge=i||0}}const v=(t,e,r,n)=>{let i=r.value;g(t,i)&&(w(t,r),t[a]||(i=void 0)),i&&e.call(n,i.value,i.key,t)};t.exports=class{constructor(t){if(\"number\"==typeof t&&(t={max:t}),t||(t={}),t.max&&(\"number\"!=typeof t.max||t.max<0))throw new TypeError(\"max must be a non-negative number\");this[i]=t.max||1/0;const e=t.length||d;if(this[s]=\"function\"!=typeof e?d:e,this[a]=t.stale||!1,t.maxAge&&\"number\"!=typeof t.maxAge)throw new TypeError(\"maxAge must be a number\");this[c]=t.maxAge||0,this[u]=t.dispose,this[f]=t.noDisposeOnSet||!1,this[p]=t.updateAgeOnGet||!1,this.reset()}set max(t){if(\"number\"!=typeof t||t<0)throw new TypeError(\"max must be a non-negative number\");this[i]=t||1/0,b(this)}get max(){return this[i]}set allowStale(t){this[a]=!!t}get allowStale(){return this[a]}set maxAge(t){if(\"number\"!=typeof t)throw new TypeError(\"maxAge must be a non-negative number\");this[c]=t,b(this)}get maxAge(){return this[c]}set lengthCalculator(t){\"function\"!=typeof t&&(t=d),t!==this[s]&&(this[s]=t,this[o]=0,this[h].forEach((t=>{t.length=this[s](t.value,t.key),this[o]+=t.length}))),b(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[h].length}rforEach(t,e){e=e||this;for(let r=this[h].tail;null!==r;){const n=r.prev;v(this,t,r,e),r=n}}forEach(t,e){e=e||this;for(let r=this[h].head;null!==r;){const n=r.next;v(this,t,r,e),r=n}}keys(){return this[h].toArray().map((t=>t.key))}values(){return this[h].toArray().map((t=>t.value))}reset(){this[u]&&this[h]&&this[h].length&&this[h].forEach((t=>this[u](t.key,t.value))),this[l]=new Map,this[h]=new n,this[o]=0}dump(){return this[h].map((t=>!g(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[h]}set(t,e,r){if((r=r||this[c])&&\"number\"!=typeof r)throw new TypeError(\"maxAge must be a number\");const n=r?Date.now():0,a=this[s](e,t);if(this[l].has(t)){if(a>this[i])return w(this,this[l].get(t)),!1;const s=this[l].get(t).value;return this[u]&&(this[f]||this[u](t,s.value)),s.now=n,s.maxAge=r,s.value=e,this[o]+=a-s.length,s.length=a,this.get(t),b(this),!0}const p=new m(t,e,a,n,r);return p.length>this[i]?(this[u]&&this[u](t,e),!1):(this[o]+=p.length,this[h].unshift(p),this[l].set(t,this[h].head),b(this),!0)}has(t){if(!this[l].has(t))return!1;const e=this[l].get(t).value;return!g(this,e)}get(t){return y(this,t,!0)}peek(t){return y(this,t,!1)}pop(){const t=this[h].tail;return t?(w(this,t),t.value):null}del(t){w(this,this[l].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const n=t[r],i=n.e||0;if(0===i)this.set(n.k,n.v);else{const t=i-e;t>0&&this.set(n.k,n.v,t)}}}prune(){this[l].forEach(((t,e)=>y(this,e,!1)))}}},3275:(t,e,r)=>{\"use strict\";var n=r(5615),i=r(9467),o=r(5636).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return c(t+(e&r|~e&n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return c(t+(e&n|r&~n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return c(t+(e^r^n)+i+o|0,s)+e|0}function l(t,e,r,n,i,o,s){return c(t+(r^(e|~n))+i+o|0,s)+e|0}n(a,i),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,o=this._d;r=u(r,n,i,o,t[0],3614090360,7),o=u(o,r,n,i,t[1],3905402710,12),i=u(i,o,r,n,t[2],606105819,17),n=u(n,i,o,r,t[3],3250441966,22),r=u(r,n,i,o,t[4],4118548399,7),o=u(o,r,n,i,t[5],1200080426,12),i=u(i,o,r,n,t[6],2821735955,17),n=u(n,i,o,r,t[7],4249261313,22),r=u(r,n,i,o,t[8],1770035416,7),o=u(o,r,n,i,t[9],2336552879,12),i=u(i,o,r,n,t[10],4294925233,17),n=u(n,i,o,r,t[11],2304563134,22),r=u(r,n,i,o,t[12],1804603682,7),o=u(o,r,n,i,t[13],4254626195,12),i=u(i,o,r,n,t[14],2792965006,17),r=f(r,n=u(n,i,o,r,t[15],1236535329,22),i,o,t[1],4129170786,5),o=f(o,r,n,i,t[6],3225465664,9),i=f(i,o,r,n,t[11],643717713,14),n=f(n,i,o,r,t[0],3921069994,20),r=f(r,n,i,o,t[5],3593408605,5),o=f(o,r,n,i,t[10],38016083,9),i=f(i,o,r,n,t[15],3634488961,14),n=f(n,i,o,r,t[4],3889429448,20),r=f(r,n,i,o,t[9],568446438,5),o=f(o,r,n,i,t[14],3275163606,9),i=f(i,o,r,n,t[3],4107603335,14),n=f(n,i,o,r,t[8],1163531501,20),r=f(r,n,i,o,t[13],2850285829,5),o=f(o,r,n,i,t[2],4243563512,9),i=f(i,o,r,n,t[7],1735328473,14),r=h(r,n=f(n,i,o,r,t[12],2368359562,20),i,o,t[5],4294588738,4),o=h(o,r,n,i,t[8],2272392833,11),i=h(i,o,r,n,t[11],1839030562,16),n=h(n,i,o,r,t[14],4259657740,23),r=h(r,n,i,o,t[1],2763975236,4),o=h(o,r,n,i,t[4],1272893353,11),i=h(i,o,r,n,t[7],4139469664,16),n=h(n,i,o,r,t[10],3200236656,23),r=h(r,n,i,o,t[13],681279174,4),o=h(o,r,n,i,t[0],3936430074,11),i=h(i,o,r,n,t[3],3572445317,16),n=h(n,i,o,r,t[6],76029189,23),r=h(r,n,i,o,t[9],3654602809,4),o=h(o,r,n,i,t[12],3873151461,11),i=h(i,o,r,n,t[15],530742520,16),r=l(r,n=h(n,i,o,r,t[2],3299628645,23),i,o,t[0],4096336452,6),o=l(o,r,n,i,t[7],1126891415,10),i=l(i,o,r,n,t[14],2878612391,15),n=l(n,i,o,r,t[5],4237533241,21),r=l(r,n,i,o,t[12],1700485571,6),o=l(o,r,n,i,t[3],2399980690,10),i=l(i,o,r,n,t[10],4293915773,15),n=l(n,i,o,r,t[1],2240044497,21),r=l(r,n,i,o,t[8],1873313359,6),o=l(o,r,n,i,t[15],4264355552,10),i=l(i,o,r,n,t[6],2734768916,15),n=l(n,i,o,r,t[13],1309151649,21),r=l(r,n,i,o,t[4],4149444226,6),o=l(o,r,n,i,t[11],3174756917,10),i=l(i,o,r,n,t[2],718787259,15),n=l(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=o.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},9756:(t,e,r)=>{\"use strict\";const{ErrorWithCause:n}=r(4525),{findCauseByReference:i,getErrorCause:o,messageWithCauses:s,stackWithCauses:a}=r(2197);t.exports={ErrorWithCause:n,findCauseByReference:i,getErrorCause:o,stackWithCauses:a,messageWithCauses:s}},4525:t=>{\"use strict\";class e extends Error{constructor(t,{cause:r}={}){super(t),this.name=e.name,r&&(this.cause=r),this.message=t}}t.exports={ErrorWithCause:e}},2197:t=>{\"use strict\";const e=t=>{if(t&&\"object\"==typeof t&&\"cause\"in t){if(\"function\"==typeof t.cause){const e=t.cause();return e instanceof Error?e:void 0}return t.cause instanceof Error?t.cause:void 0}},r=(t,n)=>{if(!(t instanceof Error))return\"\";const i=t.stack||\"\";if(n.has(t))return i+\"\\ncauses have become circular...\";const o=e(t);return o?(n.add(t),i+\"\\ncaused by: \"+r(o,n)):i},n=(t,r,i)=>{if(!(t instanceof Error))return\"\";const o=i?\"\":t.message||\"\";if(r.has(t))return o+\": ...\";const s=e(t);if(s){r.add(t);const e=\"cause\"in t&&\"function\"==typeof t.cause;return o+(e?\"\":\": \")+n(s,r,e)}return o};t.exports={findCauseByReference:(t,r)=>{if(!t||!r)return;if(!(t instanceof Error))return;if(!(r.prototype instanceof Error)&&r!==Error)return;const n=new Set;let i=t;for(;i&&!n.has(i);){if(n.add(i),i instanceof r)return i;i=e(i)}},getErrorCause:e,stackWithCauses:t=>r(t,new Set),messageWithCauses:t=>n(t,new Set)}},2644:(t,e,r)=>{\"use strict\";var n=65536,i=4294967295;var o=r(5636).Buffer,s=r.g.crypto||r.g.msCrypto;s&&s.getRandomValues?t.exports=function(t,e){if(t>i)throw new RangeError(\"requested too many random bytes\");var r=o.allocUnsafe(t);if(t>0)if(t>n)for(var a=0;a{\"use strict\";var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return\"string\"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?\"one of \".concat(e,\" \").concat(t.slice(0,r-1).join(\", \"),\", or \")+t[r-1]:2===r?\"one of \".concat(e,\" \").concat(t[0],\" or \").concat(t[1]):\"of \".concat(e,\" \").concat(t[0])}return\"of \".concat(e,\" \").concat(String(t))}r(\"ERR_INVALID_OPT_VALUE\",(function(t,e){return'The value \"'+e+'\" is invalid for option \"'+t+'\"'}),TypeError),r(\"ERR_INVALID_ARG_TYPE\",(function(t,e,r){var i,o,s,a;if(\"string\"==typeof e&&(o=\"not \",e.substr(!s||s<0?0:+s,o.length)===o)?(i=\"must not be\",e=e.replace(/^not /,\"\")):i=\"must be\",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t,\" argument\"))a=\"The \".concat(t,\" \").concat(i,\" \").concat(n(e,\"type\"));else{var c=function(t,e,r){return\"number\"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,\".\")?\"property\":\"argument\";a='The \"'.concat(t,'\" ').concat(c,\" \").concat(i,\" \").concat(n(e,\"type\"))}return a+=\". Received type \".concat(typeof r)}),TypeError),r(\"ERR_STREAM_PUSH_AFTER_EOF\",\"stream.push() after EOF\"),r(\"ERR_METHOD_NOT_IMPLEMENTED\",(function(t){return\"The \"+t+\" method is not implemented\"})),r(\"ERR_STREAM_PREMATURE_CLOSE\",\"Premature close\"),r(\"ERR_STREAM_DESTROYED\",(function(t){return\"Cannot call \"+t+\" after a stream was destroyed\"})),r(\"ERR_MULTIPLE_CALLBACK\",\"Callback called multiple times\"),r(\"ERR_STREAM_CANNOT_PIPE\",\"Cannot pipe, not readable\"),r(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\"),r(\"ERR_STREAM_NULL_VALUES\",\"May not write null values to stream\",TypeError),r(\"ERR_UNKNOWN_ENCODING\",(function(t){return\"Unknown encoding: \"+t}),TypeError),r(\"ERR_STREAM_UNSHIFT_AFTER_END_EVENT\",\"stream.unshift() after end event\"),t.exports.F=e},1265:(t,e,r)=>{\"use strict\";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=u;var i=r(8199),o=r(5291);r(5615)(u,i);for(var s=n(o.prototype),a=0;a{\"use strict\";t.exports=i;var n=r(9415);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(5615)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},8199:(t,e,r)=>{\"use strict\";var n;t.exports=A,A.ReadableState=S;r(46).EventEmitter;var i=function(t,e){return t.listeners(e).length},o=r(4856),s=r(1048).Buffer,a=(void 0!==r.g?r.g:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var c,u=r(3951);c=u&&u.debuglog?u.debuglog(\"stream\"):function(){};var f,h,l,p=r(82),d=r(6527),y=r(9952).getHighWaterMark,g=r(5699).F,b=g.ERR_INVALID_ARG_TYPE,w=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,v=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(5615)(A,o);var E=d.errorOrDestroy,_=[\"error\",\"close\",\"destroy\",\"pause\",\"resume\"];function S(t,e,i){n=n||r(1265),t=t||{},\"boolean\"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,\"readableHighWaterMark\",i),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(8888).I),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function A(t){if(n=n||r(1265),!(this instanceof A))return new A(t);var e=this instanceof n;this._readableState=new S(t,this,e),this.readable=!0,t&&(\"function\"==typeof t.read&&(this._read=t.read),\"function\"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function I(t,e,r,n,i){c(\"readableAddChunk\",e);var o,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(c(\"onEofChunk\"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?k(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,P(t)))}(t,u);else if(i||(o=function(t,e){var r;n=e,s.isBuffer(n)||n instanceof a||\"string\"==typeof e||void 0===e||t.objectMode||(r=new b(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],e));var n;return r}(u,e)),o)E(t,o);else if(u.objectMode||e&&e.length>0)if(\"string\"==typeof e||u.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),n)u.endEmitted?E(t,new v):T(t,u,e,!0);else if(u.ended)E(t,new w);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!r?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):R(t,u)):T(t,u,e,!1)}else n||(u.reading=!1,R(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function k(t){var e=t._readableState;c(\"emitReadable\",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c(\"emitReadable\",e.flowing),e.emittedReadable=!0,process.nextTick(P,t))}function P(t){var e=t._readableState;c(\"emitReadable_\",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit(\"readable\"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,U(t)}function R(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(B,t,e))}function B(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount(\"data\")>0&&t.resume()}function N(t){c(\"readable nexttick read 0\"),t.read(0)}function L(t,e){c(\"resume\",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit(\"resume\"),U(t),e.flowing&&!e.reading&&t.read(0)}function U(t){var e=t._readableState;for(c(\"flow\",e.flowing);e.flowing&&null!==t.read(););}function j(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(\"\"):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function M(t){var e=t._readableState;c(\"endReadable\",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(H,e,t))}function H(t,e){if(c(\"endReadableNT\",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit(\"end\"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function F(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return c(\"read: emitReadable\",e.length,e.ended),0===e.length&&e.ended?M(this):k(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,i=e.needReadable;return c(\"need readable\",i),(0===e.length||e.length-t0?j(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit(\"data\",n),n},A.prototype._read=function(t){E(this,new m(\"_read()\"))},A.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,c(\"pipe count=%d opts=%j\",n.pipesCount,e);var o=(!e||!1!==e.end)&&t!==process.stdout&&t!==process.stderr?a:y;function s(e,i){c(\"onunpipe\"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,c(\"cleanup\"),t.removeListener(\"close\",p),t.removeListener(\"finish\",d),t.removeListener(\"drain\",u),t.removeListener(\"error\",l),t.removeListener(\"unpipe\",s),r.removeListener(\"end\",a),r.removeListener(\"end\",y),r.removeListener(\"data\",h),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}function a(){c(\"onend\"),t.end()}n.endEmitted?process.nextTick(o):r.once(\"end\",o),t.on(\"unpipe\",s);var u=function(t){return function(){var e=t._readableState;c(\"pipeOnDrain\",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,\"data\")&&(e.flowing=!0,U(t))}}(r);t.on(\"drain\",u);var f=!1;function h(e){c(\"ondata\");var i=t.write(e);c(\"dest.write\",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==F(n.pipes,t))&&!f&&(c(\"false write response, pause\",n.awaitDrain),n.awaitDrain++),r.pause())}function l(e){c(\"onerror\",e),y(),t.removeListener(\"error\",l),0===i(t,\"error\")&&E(t,e)}function p(){t.removeListener(\"finish\",d),y()}function d(){c(\"onfinish\"),t.removeListener(\"close\",p),y()}function y(){c(\"unpipe\"),r.unpipe(t)}return r.on(\"data\",h),function(t,e,r){if(\"function\"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,\"error\",l),t.once(\"close\",p),t.once(\"finish\",d),t.emit(\"pipe\",r),n.flowing||(c(\"pipe resume\"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit(\"unpipe\",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==n.flowing&&this.resume()):\"readable\"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,c(\"on readable\",n.length,n.reading),n.length?k(this):n.reading||process.nextTick(N,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,e){var r=o.prototype.removeListener.call(this,t,e);return\"readable\"===t&&process.nextTick(C,this),r},A.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return\"readable\"!==t&&void 0!==t||process.nextTick(C,this),e},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(c(\"resume\"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(L,t,e))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return c(\"call pause flowing=%j\",this._readableState.flowing),!1!==this._readableState.flowing&&(c(\"pause\"),this._readableState.flowing=!1,this.emit(\"pause\")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on(\"end\",(function(){if(c(\"wrapped end\"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on(\"data\",(function(i){(c(\"wrapped data\"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&\"function\"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o<_.length;o++)t.on(_[o],this.emit.bind(this,_[o]));return this._read=function(e){c(\"wrapped _read\",e),n&&(n=!1,t.resume())},this},\"function\"==typeof Symbol&&(A.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(534)),h(this)}),Object.defineProperty(A.prototype,\"readableHighWaterMark\",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(A.prototype,\"readableBuffer\",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(A.prototype,\"readableFlowing\",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),A._fromList=j,Object.defineProperty(A.prototype,\"readableLength\",{enumerable:!1,get:function(){return this._readableState.length}}),\"function\"==typeof Symbol&&(A.from=function(t,e){return void 0===l&&(l=r(1260)),l(A,t,e)})},9415:(t,e,r)=>{\"use strict\";t.exports=f;var n=r(5699).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,c=r(1265);function u(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit(\"error\",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{\"use strict\";function n(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;t.entry=null;for(;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}var i;t.exports=A,A.WritableState=S;var o={deprecate:r(6732)},s=r(4856),a=r(1048).Buffer,c=(void 0!==r.g?r.g:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var u,f=r(6527),h=r(9952).getHighWaterMark,l=r(5699).F,p=l.ERR_INVALID_ARG_TYPE,d=l.ERR_METHOD_NOT_IMPLEMENTED,y=l.ERR_MULTIPLE_CALLBACK,g=l.ERR_STREAM_CANNOT_PIPE,b=l.ERR_STREAM_DESTROYED,w=l.ERR_STREAM_NULL_VALUES,m=l.ERR_STREAM_WRITE_AFTER_END,v=l.ERR_UNKNOWN_ENCODING,E=f.errorOrDestroy;function _(){}function S(t,e,o){i=i||r(1265),t=t||{},\"boolean\"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,\"writableHighWaterMark\",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(\"function\"!=typeof i)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(P,t,e),t._writableState.errorEmitted=!0,E(t,n)):(i(n),t._writableState.errorEmitted=!0,E(t,n),P(t,e))}(t,r,n,e,i);else{var o=O(r)||t.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||x(t,r),n?process.nextTick(T,t,r,o,i):T(t,r,o,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function A(t){var e=this instanceof(i=i||r(1265));if(!e&&!u.call(A,this))return new A(t);this._writableState=new S(t,this,e),this.writable=!0,t&&(\"function\"==typeof t.write&&(this._write=t.write),\"function\"==typeof t.writev&&(this._writev=t.writev),\"function\"==typeof t.destroy&&(this._destroy=t.destroy),\"function\"==typeof t.final&&(this._final=t.final)),s.call(this)}function I(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b(\"write\")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function T(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit(\"drain\"))}(t,e),e.pendingcb--,n(),P(t,e)}function x(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,o=new Array(i),s=e.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)o[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;o.allBuffers=c,I(t,e,!0,e.length,o,\"\",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new n(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(I(t,e,!1,e.objectMode?1:u.length,u,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function O(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function k(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit(\"prefinish\"),P(t,e)}))}function P(t,e){var r=O(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||(\"function\"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit(\"prefinish\")):(e.pendingcb++,e.finalCalled=!0,process.nextTick(k,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit(\"finish\"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(5615)(A,s),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,\"buffer\",{get:o.deprecate((function(){return this.getBuffer()}),\"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.\",\"DEP0003\")})}catch(t){}}(),\"function\"==typeof Symbol&&Symbol.hasInstance&&\"function\"==typeof Function.prototype[Symbol.hasInstance]?(u=Function.prototype[Symbol.hasInstance],Object.defineProperty(A,Symbol.hasInstance,{value:function(t){return!!u.call(this,t)||this===A&&(t&&t._writableState instanceof S)}})):u=function(t){return t instanceof this},A.prototype.pipe=function(){E(this,new g)},A.prototype.write=function(t,e,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=t,a.isBuffer(n)||n instanceof c);return s&&!a.isBuffer(t)&&(t=function(t){return a.from(t)}(t)),\"function\"==typeof e&&(r=e,e=null),s?e=\"buffer\":e||(e=i.defaultEncoding),\"function\"!=typeof r&&(r=_),i.ending?function(t,e){var r=new m;E(t,r),process.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var i;return null===r?i=new w:\"string\"==typeof r||e.objectMode||(i=new p(\"chunk\",[\"string\",\"Buffer\"],r)),!i||(E(t,i),process.nextTick(n,i),!1)}(this,i,t,r))&&(i.pendingcb++,o=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||\"string\"!=typeof e||(e=a.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i=\"buffer\",n=s)}var c=e.objectMode?1:n.length;e.length+=c;var u=e.length-1))throw new v(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(A.prototype,\"writableBuffer\",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(t,e,r){r(new d(\"_write()\"))},A.prototype._writev=null,A.prototype.end=function(t,e,r){var n=this._writableState;return\"function\"==typeof t?(r=t,t=null,e=null):\"function\"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,P(t,e),r&&(e.finished?process.nextTick(r):t.once(\"finish\",r));e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(A.prototype,\"writableLength\",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,\"destroyed\",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),A.prototype.destroy=f.destroy,A.prototype._undestroy=f.undestroy,A.prototype._destroy=function(t,e){e(t)}},534:(t,e,r)=>{\"use strict\";var n;function i(t,e,r){return(e=function(t){var e=function(t,e){if(\"object\"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||\"default\");if(\"object\"!=typeof n)return n;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===e?String:Number)(t)}(t,\"string\");return\"symbol\"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=r(4869),s=Symbol(\"lastResolve\"),a=Symbol(\"lastReject\"),c=Symbol(\"error\"),u=Symbol(\"ended\"),f=Symbol(\"lastPromise\"),h=Symbol(\"handlePromise\"),l=Symbol(\"stream\");function p(t,e){return{value:t,done:e}}function d(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(p(r,!1)))}}function y(t){process.nextTick(d,t)}var g=Object.getPrototypeOf((function(){})),b=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(p(void 0,!0));if(this[l].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[c]?r(t[c]):e(p(void 0,!0))}))}));var r,n=this[f];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[u]?r(p(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var i=this[l].read();if(null!==i)return Promise.resolve(p(i,!1));r=new Promise(this[h])}return this[f]=r,r}},Symbol.asyncIterator,(function(){return this})),i(n,\"return\",(function(){var t=this;return new Promise((function(e,r){t[l].destroy(null,(function(t){t?r(t):e(p(void 0,!0))}))}))})),n),g);t.exports=function(t){var e,r=Object.create(b,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,c,{value:null,writable:!0}),i(e,u,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var n=r[l].read();n?(r[f]=null,r[s]=null,r[a]=null,t(p(n,!1))):(r[s]=t,r[a]=e)},writable:!0}),e));return r[f]=null,o(t,(function(t){if(t&&\"ERR_STREAM_PREMATURE_CLOSE\"!==t.code){var e=r[a];return null!==e&&(r[f]=null,r[s]=null,r[a]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[f]=null,r[s]=null,r[a]=null,n(p(void 0,!0))),r[u]=!0})),t.on(\"readable\",y.bind(null,r)),r}},82:(t,e,r)=>{\"use strict\";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:\"unshift\",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:\"shift\",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:\"clear\",value:function(){this.head=this.tail=null,this.length=0}},{key:\"join\",value:function(t){if(0===this.length)return\"\";for(var e=this.head,r=\"\"+e.data;e=e.next;)r+=t+e.data;return r}},{key:\"concat\",value:function(t){if(0===this.length)return c.alloc(0);for(var e,r,n,i=c.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,c.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:\"consume\",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:\"_getBuffer\",value:function(t){var e=c.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return u(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&s(e.prototype,r),n&&s(e,n),Object.defineProperty(e,\"prototype\",{writable:!1}),t}()},6527:t=>{\"use strict\";function e(t,e){n(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit(\"close\")}function n(t,e){t.emit(\"error\",e)}t.exports={destroy:function(t,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?o._writableState?o._writableState.errorEmitted?process.nextTick(r,o):(o._writableState.errorEmitted=!0,process.nextTick(e,o,t)):process.nextTick(e,o,t):i?(process.nextTick(r,o),i(t)):process.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit(\"error\",e)}}},4869:(t,e,r)=>{\"use strict\";var n=r(5699).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if(\"function\"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i{t.exports=function(){throw new Error(\"Readable.from is not available in the browser\")}},6815:(t,e,r)=>{\"use strict\";var n;var i=r(5699).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function c(t){t()}function u(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){f||(f=t),t&&l.forEach(c),o||(l.forEach(c),h(f))}))}));return e.reduce(u)}},9952:(t,e,r)=>{\"use strict\";var n=r(5699).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:\"highWaterMark\",o);return Math.floor(o)}return t.objectMode?16:16384}}},4856:(t,e,r)=>{t.exports=r(46).EventEmitter},4156:(t,e,r)=>{(e=t.exports=r(8199)).Stream=e,e.Readable=e,e.Writable=r(5291),e.Duplex=r(1265),e.Transform=r(9415),e.PassThrough=r(4421),e.finished=r(4869),e.pipeline=r(6815)},5586:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer,i=r(5615),o=r(9467),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],c=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],l=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function y(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function w(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}i(p,o),p.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,v=0|this._a,E=0|this._b,_=0|this._c,S=0|this._d,A=0|this._e,I=0;I<80;I+=1){var T,x;I<16?(T=y(r,n,i,o,p,t[a[I]],h[0],u[I]),x=m(v,E,_,S,A,t[c[I]],l[0],f[I])):I<32?(T=g(r,n,i,o,p,t[a[I]],h[1],u[I]),x=w(v,E,_,S,A,t[c[I]],l[1],f[I])):I<48?(T=b(r,n,i,o,p,t[a[I]],h[2],u[I]),x=b(v,E,_,S,A,t[c[I]],l[2],f[I])):I<64?(T=w(r,n,i,o,p,t[a[I]],h[3],u[I]),x=g(v,E,_,S,A,t[c[I]],l[3],f[I])):(T=m(r,n,i,o,p,t[a[I]],h[4],u[I]),x=y(v,E,_,S,A,t[c[I]],l[4],f[I])),r=p,p=o,o=d(i,10),i=n,n=T,v=A,A=S,S=d(_,10),_=E,E=x}var O=this._b+i+S|0;this._b=this._c+o+A|0,this._c=this._d+p+v|0,this._d=this._e+r+E|0,this._e=this._a+n+_|0,this._a=O},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},5636:(t,e,r)=>{var n=r(1048),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if(\"number\"==typeof t)throw new TypeError(\"Argument must not be a number\");return i(t,e,r)},s.alloc=function(t,e,r){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");var n=i(t);return void 0!==e?\"string\"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return i(t)},s.allocUnsafeSlow=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return n.SlowBuffer(t)}},1565:(t,e,r)=>{const n=Symbol(\"SemVer ANY\");class i{static get ANY(){return n}constructor(t,e){if(e=o(e),t instanceof i){if(t.loose===!!e.loose)return t;t=t.value}t=t.trim().split(/\\s+/).join(\" \"),u(\"comparator\",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===n?this.value=\"\":this.value=this.operator+this.semver.version,u(\"comp\",this)}parse(t){const e=this.options.loose?s[a.COMPARATORLOOSE]:s[a.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==r[1]?r[1]:\"\",\"=\"===this.operator&&(this.operator=\"\"),r[2]?this.semver=new f(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(t){if(u(\"Comparator.test\",t,this.options.loose),this.semver===n||t===n)return!0;if(\"string\"==typeof t)try{t=new f(t,this.options)}catch(t){return!1}return c(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof i))throw new TypeError(\"a Comparator is required\");return\"\"===this.operator?\"\"===this.value||new h(t.value,e).test(this.value):\"\"===t.operator?\"\"===t.value||new h(this.value,e).test(t.semver):(!(e=o(e)).includePrerelease||\"<0.0.0-0\"!==this.value&&\"<0.0.0-0\"!==t.value)&&(!(!e.includePrerelease&&(this.value.startsWith(\"<0.0.0\")||t.value.startsWith(\"<0.0.0\")))&&(!(!this.operator.startsWith(\">\")||!t.operator.startsWith(\">\"))||(!(!this.operator.startsWith(\"<\")||!t.operator.startsWith(\"<\"))||(!(this.semver.version!==t.semver.version||!this.operator.includes(\"=\")||!t.operator.includes(\"=\"))||(!!(c(this.semver,\"<\",t.semver,e)&&this.operator.startsWith(\">\")&&t.operator.startsWith(\"<\"))||!!(c(this.semver,\">\",t.semver,e)&&this.operator.startsWith(\"<\")&&t.operator.startsWith(\">\")))))))}}t.exports=i;const o=r(3990),{safeRe:s,t:a}=r(2841),c=r(4004),u=r(1361),f=r(4517),h=r(7476)},7476:(t,e,r)=>{class n{constructor(t,e){if(e=o(e),t instanceof n)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new n(t.raw,e);if(t instanceof s)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t.trim().split(/\\s+/).join(\" \"),this.set=this.raw.split(\"||\").map((t=>this.parseRange(t.trim()))).filter((t=>t.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const t=this.set[0];if(this.set=this.set.filter((t=>!g(t[0]))),0===this.set.length)this.set=[t];else if(this.set.length>1)for(const t of this.set)if(1===t.length&&b(t[0])){this.set=[t];break}}this.format()}format(){return this.range=this.set.map((t=>t.join(\" \").trim())).join(\"||\").trim(),this.range}toString(){return this.range}parseRange(t){const e=((this.options.includePrerelease&&d)|(this.options.loose&&y))+\":\"+t,r=i.get(e);if(r)return r;const n=this.options.loose,o=n?u[f.HYPHENRANGELOOSE]:u[f.HYPHENRANGE];t=t.replace(o,k(this.options.includePrerelease)),a(\"hyphen replace\",t),t=t.replace(u[f.COMPARATORTRIM],h),a(\"comparator trim\",t),t=t.replace(u[f.TILDETRIM],l),a(\"tilde trim\",t),t=t.replace(u[f.CARETTRIM],p),a(\"caret trim\",t);let c=t.split(\" \").map((t=>m(t,this.options))).join(\" \").split(/\\s+/).map((t=>O(t,this.options)));n&&(c=c.filter((t=>(a(\"loose invalid filter\",t,this.options),!!t.match(u[f.COMPARATORLOOSE]))))),a(\"range list\",c);const b=new Map,w=c.map((t=>new s(t,this.options)));for(const t of w){if(g(t))return[t];b.set(t.value,t)}b.size>1&&b.has(\"\")&&b.delete(\"\");const v=[...b.values()];return i.set(e,v),v}intersects(t,e){if(!(t instanceof n))throw new TypeError(\"a Range is required\");return this.set.some((r=>w(r,e)&&t.set.some((t=>w(t,e)&&r.every((r=>t.every((t=>r.intersects(t,e)))))))))}test(t){if(!t)return!1;if(\"string\"==typeof t)try{t=new c(t,this.options)}catch(t){return!1}for(let e=0;e\"<0.0.0-0\"===t.value,b=t=>\"\"===t.value,w=(t,e)=>{let r=!0;const n=t.slice();let i=n.pop();for(;r&&n.length;)r=n.every((t=>i.intersects(t,e))),i=n.pop();return r},m=(t,e)=>(a(\"comp\",t,e),t=S(t,e),a(\"caret\",t),t=E(t,e),a(\"tildes\",t),t=I(t,e),a(\"xrange\",t),t=x(t,e),a(\"stars\",t),t),v=t=>!t||\"x\"===t.toLowerCase()||\"*\"===t,E=(t,e)=>t.trim().split(/\\s+/).map((t=>_(t,e))).join(\" \"),_=(t,e)=>{const r=e.loose?u[f.TILDELOOSE]:u[f.TILDE];return t.replace(r,((e,r,n,i,o)=>{let s;return a(\"tilde\",t,e,r,n,i,o),v(r)?s=\"\":v(n)?s=`>=${r}.0.0 <${+r+1}.0.0-0`:v(i)?s=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:o?(a(\"replaceTilde pr\",o),s=`>=${r}.${n}.${i}-${o} <${r}.${+n+1}.0-0`):s=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,a(\"tilde return\",s),s}))},S=(t,e)=>t.trim().split(/\\s+/).map((t=>A(t,e))).join(\" \"),A=(t,e)=>{a(\"caret\",t,e);const r=e.loose?u[f.CARETLOOSE]:u[f.CARET],n=e.includePrerelease?\"-0\":\"\";return t.replace(r,((e,r,i,o,s)=>{let c;return a(\"caret\",t,e,r,i,o,s),v(r)?c=\"\":v(i)?c=`>=${r}.0.0${n} <${+r+1}.0.0-0`:v(o)?c=\"0\"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:s?(a(\"replaceCaret pr\",s),c=\"0\"===r?\"0\"===i?`>=${r}.${i}.${o}-${s} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}-${s} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o}-${s} <${+r+1}.0.0-0`):(a(\"no pr\"),c=\"0\"===r?\"0\"===i?`>=${r}.${i}.${o}${n} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o} <${+r+1}.0.0-0`),a(\"caret return\",c),c}))},I=(t,e)=>(a(\"replaceXRanges\",t,e),t.split(/\\s+/).map((t=>T(t,e))).join(\" \")),T=(t,e)=>{t=t.trim();const r=e.loose?u[f.XRANGELOOSE]:u[f.XRANGE];return t.replace(r,((r,n,i,o,s,c)=>{a(\"xRange\",t,r,n,i,o,s,c);const u=v(i),f=u||v(o),h=f||v(s),l=h;return\"=\"===n&&l&&(n=\"\"),c=e.includePrerelease?\"-0\":\"\",u?r=\">\"===n||\"<\"===n?\"<0.0.0-0\":\"*\":n&&l?(f&&(o=0),s=0,\">\"===n?(n=\">=\",f?(i=+i+1,o=0,s=0):(o=+o+1,s=0)):\"<=\"===n&&(n=\"<\",f?i=+i+1:o=+o+1),\"<\"===n&&(c=\"-0\"),r=`${n+i}.${o}.${s}${c}`):f?r=`>=${i}.0.0${c} <${+i+1}.0.0-0`:h&&(r=`>=${i}.${o}.0${c} <${i}.${+o+1}.0-0`),a(\"xRange return\",r),r}))},x=(t,e)=>(a(\"replaceStars\",t,e),t.trim().replace(u[f.STAR],\"\")),O=(t,e)=>(a(\"replaceGTE0\",t,e),t.trim().replace(u[e.includePrerelease?f.GTE0PRE:f.GTE0],\"\")),k=t=>(e,r,n,i,o,s,a,c,u,f,h,l,p)=>`${r=v(n)?\"\":v(i)?`>=${n}.0.0${t?\"-0\":\"\"}`:v(o)?`>=${n}.${i}.0${t?\"-0\":\"\"}`:s?`>=${r}`:`>=${r}${t?\"-0\":\"\"}`} ${c=v(u)?\"\":v(f)?`<${+u+1}.0.0-0`:v(h)?`<${u}.${+f+1}.0-0`:l?`<=${u}.${f}.${h}-${l}`:t?`<${u}.${f}.${+h+1}-0`:`<=${c}`}`.trim(),P=(t,e,r)=>{for(let r=0;r0){const n=t[r].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}},4517:(t,e,r)=>{const n=r(1361),{MAX_LENGTH:i,MAX_SAFE_INTEGER:o}=r(9543),{safeRe:s,t:a}=r(2841),c=r(3990),{compareIdentifiers:u}=r(3806);class f{constructor(t,e){if(e=c(e),t instanceof f){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(\"string\"!=typeof t)throw new TypeError(`Invalid version. Must be a string. Got type \"${typeof t}\".`);if(t.length>i)throw new TypeError(`version is longer than ${i} characters`);n(\"SemVer\",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;const r=t.trim().match(e.loose?s[a.LOOSE]:s[a.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>o||this.major<0)throw new TypeError(\"Invalid major version\");if(this.minor>o||this.minor<0)throw new TypeError(\"Invalid minor version\");if(this.patch>o||this.patch<0)throw new TypeError(\"Invalid patch version\");r[4]?this.prerelease=r[4].split(\".\").map((t=>{if(/^[0-9]+$/.test(t)){const e=+t;if(e>=0&&e=0;)\"number\"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(e===this.prerelease.join(\".\")&&!1===r)throw new Error(\"invalid increment argument: identifier already exists\");this.prerelease.push(t)}}if(e){let n=[e,t];!1===r&&(n=[e]),0===u(this.prerelease[0],e)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(\".\")}`),this}}t.exports=f},2281:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t.trim().replace(/^[=v]+/,\"\"),e);return r?r.version:null}},4004:(t,e,r)=>{const n=r(8848),i=r(8220),o=r(9761),s=r(2386),a=r(1262),c=r(9639);t.exports=(t,e,r,u)=>{switch(e){case\"===\":return\"object\"==typeof t&&(t=t.version),\"object\"==typeof r&&(r=r.version),t===r;case\"!==\":return\"object\"==typeof t&&(t=t.version),\"object\"==typeof r&&(r=r.version),t!==r;case\"\":case\"=\":case\"==\":return n(t,r,u);case\"!=\":return i(t,r,u);case\">\":return o(t,r,u);case\">=\":return s(t,r,u);case\"<\":return a(t,r,u);case\"<=\":return c(t,r,u);default:throw new TypeError(`Invalid operator: ${e}`)}}},6783:(t,e,r)=>{const n=r(4517),i=r(3955),{safeRe:o,t:s}=r(2841);t.exports=(t,e)=>{if(t instanceof n)return t;if(\"number\"==typeof t&&(t=String(t)),\"string\"!=typeof t)return null;let r=null;if((e=e||{}).rtl){const n=e.includePrerelease?o[s.COERCERTLFULL]:o[s.COERCERTL];let i;for(;(i=n.exec(t))&&(!r||r.index+r[0].length!==t.length);)r&&i.index+i[0].length===r.index+r[0].length||(r=i),n.lastIndex=i.index+i[1].length+i[2].length;n.lastIndex=-1}else r=t.match(e.includePrerelease?o[s.COERCEFULL]:o[s.COERCE]);if(null===r)return null;const a=r[2],c=r[3]||\"0\",u=r[4]||\"0\",f=e.includePrerelease&&r[5]?`-${r[5]}`:\"\",h=e.includePrerelease&&r[6]?`+${r[6]}`:\"\";return i(`${a}.${c}.${u}${f}${h}`,e)}},6106:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r)=>{const i=new n(t,r),o=new n(e,r);return i.compare(o)||i.compareBuild(o)}},2132:(t,e,r)=>{const n=r(7851);t.exports=(t,e)=>n(t,e,!0)},7851:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r)=>new n(t,r).compare(new n(e,r))},3269:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,null,!0),i=n(e,null,!0),o=r.compare(i);if(0===o)return null;const s=o>0,a=s?r:i,c=s?i:r,u=!!a.prerelease.length;if(!!c.prerelease.length&&!u)return c.patch||c.minor?a.patch?\"patch\":a.minor?\"minor\":\"major\":\"major\";const f=u?\"pre\":\"\";return r.major!==i.major?f+\"major\":r.minor!==i.minor?f+\"minor\":r.patch!==i.patch?f+\"patch\":\"prerelease\"}},8848:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>0===n(t,e,r)},9761:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)>0},2386:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)>=0},8868:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r,i,o)=>{\"string\"==typeof r&&(o=i,i=r,r=void 0);try{return new n(t instanceof n?t.version:t,r).inc(e,i,o).version}catch(t){return null}}},1262:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)<0},9639:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)<=0},6381:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).major},1353:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).minor},8220:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>0!==n(t,e,r)},3955:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r=!1)=>{if(t instanceof n)return t;try{return new n(t,e)}catch(t){if(!r)return null;throw t}}},6082:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).patch},9428:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,e);return r&&r.prerelease.length?r.prerelease:null}},7555:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(e,t,r)},3810:(t,e,r)=>{const n=r(6106);t.exports=(t,e)=>t.sort(((t,r)=>n(r,t,e)))},7229:(t,e,r)=>{const n=r(7476);t.exports=(t,e,r)=>{try{e=new n(e,r)}catch(t){return!1}return e.test(t)}},4042:(t,e,r)=>{const n=r(6106);t.exports=(t,e)=>t.sort(((t,r)=>n(t,r,e)))},8474:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,e);return r?r.version:null}},2722:(t,e,r)=>{const n=r(2841),i=r(9543),o=r(4517),s=r(3806),a=r(3955),c=r(8474),u=r(2281),f=r(8868),h=r(3269),l=r(6381),p=r(1353),d=r(6082),y=r(9428),g=r(7851),b=r(7555),w=r(2132),m=r(6106),v=r(4042),E=r(3810),_=r(9761),S=r(1262),A=r(8848),I=r(8220),T=r(2386),x=r(9639),O=r(4004),k=r(6783),P=r(1565),R=r(7476),B=r(7229),C=r(6364),N=r(5039),L=r(5357),U=r(1280),j=r(7403),M=r(8854),H=r(7226),F=r(7183),D=r(8623),$=r(6486),K=r(583);t.exports={parse:a,valid:c,clean:u,inc:f,diff:h,major:l,minor:p,patch:d,prerelease:y,compare:g,rcompare:b,compareLoose:w,compareBuild:m,sort:v,rsort:E,gt:_,lt:S,eq:A,neq:I,gte:T,lte:x,cmp:O,coerce:k,Comparator:P,Range:R,satisfies:B,toComparators:C,maxSatisfying:N,minSatisfying:L,minVersion:U,validRange:j,outside:M,gtr:H,ltr:F,intersects:D,simplifyRange:$,subset:K,SemVer:o,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers}},9543:t=>{const e=Number.MAX_SAFE_INTEGER||9007199254740991;t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:[\"major\",\"premajor\",\"minor\",\"preminor\",\"patch\",\"prepatch\",\"prerelease\"],SEMVER_SPEC_VERSION:\"2.0.0\",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},1361:t=>{const e=\"object\"==typeof process&&process.env&&/\\bsemver\\b/i.test(\"false\")?(...t)=>console.error(\"SEMVER\",...t):()=>{};t.exports=e},3806:t=>{const e=/^[0-9]+$/,r=(t,r)=>{const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:tr(e,t)}},3990:t=>{const e=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=t=>t?\"object\"!=typeof t?e:t:r},2841:(t,e,r)=>{const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:o}=r(9543),s=r(1361),a=(e=t.exports={}).re=[],c=e.safeRe=[],u=e.src=[],f=e.t={};let h=0;const l=\"[a-zA-Z0-9-]\",p=[[\"\\\\s\",1],[\"\\\\d\",o],[l,i]],d=(t,e,r)=>{const n=(t=>{for(const[e,r]of p)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t})(e),i=h++;s(t,i,e),f[t]=i,u[i]=e,a[i]=new RegExp(e,r?\"g\":void 0),c[i]=new RegExp(n,r?\"g\":void 0)};d(\"NUMERICIDENTIFIER\",\"0|[1-9]\\\\d*\"),d(\"NUMERICIDENTIFIERLOOSE\",\"\\\\d+\"),d(\"NONNUMERICIDENTIFIER\",`\\\\d*[a-zA-Z-]${l}*`),d(\"MAINVERSION\",`(${u[f.NUMERICIDENTIFIER]})\\\\.(${u[f.NUMERICIDENTIFIER]})\\\\.(${u[f.NUMERICIDENTIFIER]})`),d(\"MAINVERSIONLOOSE\",`(${u[f.NUMERICIDENTIFIERLOOSE]})\\\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),d(\"PRERELEASEIDENTIFIER\",`(?:${u[f.NUMERICIDENTIFIER]}|${u[f.NONNUMERICIDENTIFIER]})`),d(\"PRERELEASEIDENTIFIERLOOSE\",`(?:${u[f.NUMERICIDENTIFIERLOOSE]}|${u[f.NONNUMERICIDENTIFIER]})`),d(\"PRERELEASE\",`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\\\.${u[f.PRERELEASEIDENTIFIER]})*))`),d(\"PRERELEASELOOSE\",`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),d(\"BUILDIDENTIFIER\",`${l}+`),d(\"BUILD\",`(?:\\\\+(${u[f.BUILDIDENTIFIER]}(?:\\\\.${u[f.BUILDIDENTIFIER]})*))`),d(\"FULLPLAIN\",`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),d(\"FULL\",`^${u[f.FULLPLAIN]}$`),d(\"LOOSEPLAIN\",`[v=\\\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),d(\"LOOSE\",`^${u[f.LOOSEPLAIN]}$`),d(\"GTLT\",\"((?:<|>)?=?)\"),d(\"XRANGEIDENTIFIERLOOSE\",`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\\\*`),d(\"XRANGEIDENTIFIER\",`${u[f.NUMERICIDENTIFIER]}|x|X|\\\\*`),d(\"XRANGEPLAIN\",`[v=\\\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\\\.(${u[f.XRANGEIDENTIFIER]})(?:\\\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),d(\"XRANGEPLAINLOOSE\",`[v=\\\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),d(\"XRANGE\",`^${u[f.GTLT]}\\\\s*${u[f.XRANGEPLAIN]}$`),d(\"XRANGELOOSE\",`^${u[f.GTLT]}\\\\s*${u[f.XRANGEPLAINLOOSE]}$`),d(\"COERCEPLAIN\",`(^|[^\\\\d])(\\\\d{1,${n}})(?:\\\\.(\\\\d{1,${n}}))?(?:\\\\.(\\\\d{1,${n}}))?`),d(\"COERCE\",`${u[f.COERCEPLAIN]}(?:$|[^\\\\d])`),d(\"COERCEFULL\",u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?`+`(?:${u[f.BUILD]})?(?:$|[^\\\\d])`),d(\"COERCERTL\",u[f.COERCE],!0),d(\"COERCERTLFULL\",u[f.COERCEFULL],!0),d(\"LONETILDE\",\"(?:~>?)\"),d(\"TILDETRIM\",`(\\\\s*)${u[f.LONETILDE]}\\\\s+`,!0),e.tildeTrimReplace=\"$1~\",d(\"TILDE\",`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),d(\"TILDELOOSE\",`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),d(\"LONECARET\",\"(?:\\\\^)\"),d(\"CARETTRIM\",`(\\\\s*)${u[f.LONECARET]}\\\\s+`,!0),e.caretTrimReplace=\"$1^\",d(\"CARET\",`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),d(\"CARETLOOSE\",`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),d(\"COMPARATORLOOSE\",`^${u[f.GTLT]}\\\\s*(${u[f.LOOSEPLAIN]})$|^$`),d(\"COMPARATOR\",`^${u[f.GTLT]}\\\\s*(${u[f.FULLPLAIN]})$|^$`),d(\"COMPARATORTRIM\",`(\\\\s*)${u[f.GTLT]}\\\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=\"$1$2$3\",d(\"HYPHENRANGE\",`^\\\\s*(${u[f.XRANGEPLAIN]})\\\\s+-\\\\s+(${u[f.XRANGEPLAIN]})\\\\s*$`),d(\"HYPHENRANGELOOSE\",`^\\\\s*(${u[f.XRANGEPLAINLOOSE]})\\\\s+-\\\\s+(${u[f.XRANGEPLAINLOOSE]})\\\\s*$`),d(\"STAR\",\"(<|>)?=?\\\\s*\\\\*\"),d(\"GTE0\",\"^\\\\s*>=\\\\s*0\\\\.0\\\\.0\\\\s*$\"),d(\"GTE0PRE\",\"^\\\\s*>=\\\\s*0\\\\.0\\\\.0-0\\\\s*$\")},7226:(t,e,r)=>{const n=r(8854);t.exports=(t,e,r)=>n(t,e,\">\",r)},8623:(t,e,r)=>{const n=r(7476);t.exports=(t,e,r)=>(t=new n(t,r),e=new n(e,r),t.intersects(e,r))},7183:(t,e,r)=>{const n=r(8854);t.exports=(t,e,r)=>n(t,e,\"<\",r)},5039:(t,e,r)=>{const n=r(4517),i=r(7476);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new i(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&-1!==s.compare(t)||(o=t,s=new n(o,r)))})),o}},5357:(t,e,r)=>{const n=r(4517),i=r(7476);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new i(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&1!==s.compare(t)||(o=t,s=new n(o,r)))})),o}},1280:(t,e,r)=>{const n=r(4517),i=r(7476),o=r(9761);t.exports=(t,e)=>{t=new i(t,e);let r=new n(\"0.0.0\");if(t.test(r))return r;if(r=new n(\"0.0.0-0\"),t.test(r))return r;r=null;for(let e=0;e{const e=new n(t.semver.version);switch(t.operator){case\">\":0===e.prerelease.length?e.patch++:e.prerelease.push(0),e.raw=e.format();case\"\":case\">=\":s&&!o(e,s)||(s=e);break;case\"<\":case\"<=\":break;default:throw new Error(`Unexpected operation: ${t.operator}`)}})),!s||r&&!o(r,s)||(r=s)}return r&&t.test(r)?r:null}},8854:(t,e,r)=>{const n=r(4517),i=r(1565),{ANY:o}=i,s=r(7476),a=r(7229),c=r(9761),u=r(1262),f=r(9639),h=r(2386);t.exports=(t,e,r,l)=>{let p,d,y,g,b;switch(t=new n(t,l),e=new s(e,l),r){case\">\":p=c,d=f,y=u,g=\">\",b=\">=\";break;case\"<\":p=u,d=h,y=c,g=\"<\",b=\"<=\";break;default:throw new TypeError('Must provide a hilo val of \"<\" or \">\"')}if(a(t,e,l))return!1;for(let r=0;r{t.semver===o&&(t=new i(\">=0.0.0\")),s=s||t,a=a||t,p(t.semver,s.semver,l)?s=t:y(t.semver,a.semver,l)&&(a=t)})),s.operator===g||s.operator===b)return!1;if((!a.operator||a.operator===g)&&d(t,a.semver))return!1;if(a.operator===b&&y(t,a.semver))return!1}return!0}},6486:(t,e,r)=>{const n=r(7229),i=r(7851);t.exports=(t,e,r)=>{const o=[];let s=null,a=null;const c=t.sort(((t,e)=>i(t,e,r)));for(const t of c){n(t,e,r)?(a=t,s||(s=t)):(a&&o.push([s,a]),a=null,s=null)}s&&o.push([s,null]);const u=[];for(const[t,e]of o)t===e?u.push(t):e||t!==c[0]?e?t===c[0]?u.push(`<=${e}`):u.push(`${t} - ${e}`):u.push(`>=${t}`):u.push(\"*\");const f=u.join(\" || \"),h=\"string\"==typeof e.raw?e.raw:String(e);return f.length{const n=r(7476),i=r(1565),{ANY:o}=i,s=r(7229),a=r(7851),c=[new i(\">=0.0.0-0\")],u=[new i(\">=0.0.0\")],f=(t,e,r)=>{if(t===e)return!0;if(1===t.length&&t[0].semver===o){if(1===e.length&&e[0].semver===o)return!0;t=r.includePrerelease?c:u}if(1===e.length&&e[0].semver===o){if(r.includePrerelease)return!0;e=u}const n=new Set;let i,f,p,d,y,g,b;for(const e of t)\">\"===e.operator||\">=\"===e.operator?i=h(i,e,r):\"<\"===e.operator||\"<=\"===e.operator?f=l(f,e,r):n.add(e.semver);if(n.size>1)return null;if(i&&f){if(p=a(i.semver,f.semver,r),p>0)return null;if(0===p&&(\">=\"!==i.operator||\"<=\"!==f.operator))return null}for(const t of n){if(i&&!s(t,String(i),r))return null;if(f&&!s(t,String(f),r))return null;for(const n of e)if(!s(t,String(n),r))return!1;return!0}let w=!(!f||r.includePrerelease||!f.semver.prerelease.length)&&f.semver,m=!(!i||r.includePrerelease||!i.semver.prerelease.length)&&i.semver;w&&1===w.prerelease.length&&\"<\"===f.operator&&0===w.prerelease[0]&&(w=!1);for(const t of e){if(b=b||\">\"===t.operator||\">=\"===t.operator,g=g||\"<\"===t.operator||\"<=\"===t.operator,i)if(m&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===m.major&&t.semver.minor===m.minor&&t.semver.patch===m.patch&&(m=!1),\">\"===t.operator||\">=\"===t.operator){if(d=h(i,t,r),d===t&&d!==i)return!1}else if(\">=\"===i.operator&&!s(i.semver,String(t),r))return!1;if(f)if(w&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===w.major&&t.semver.minor===w.minor&&t.semver.patch===w.patch&&(w=!1),\"<\"===t.operator||\"<=\"===t.operator){if(y=l(f,t,r),y===t&&y!==f)return!1}else if(\"<=\"===f.operator&&!s(f.semver,String(t),r))return!1;if(!t.operator&&(f||i)&&0!==p)return!1}return!(i&&g&&!f&&0!==p)&&(!(f&&b&&!i&&0!==p)&&(!m&&!w))},h=(t,e,r)=>{if(!t)return e;const n=a(t.semver,e.semver,r);return n>0?t:n<0||\">\"===e.operator&&\">=\"===t.operator?e:t},l=(t,e,r)=>{if(!t)return e;const n=a(t.semver,e.semver,r);return n<0?t:n>0||\"<\"===e.operator&&\"<=\"===t.operator?e:t};t.exports=(t,e,r={})=>{if(t===e)return!0;t=new n(t,r),e=new n(e,r);let i=!1;t:for(const n of t.set){for(const t of e.set){const e=f(n,t,r);if(i=i||null!==e,e)continue t}if(i)return!1}return!0}},6364:(t,e,r)=>{const n=r(7476);t.exports=(t,e)=>new n(t,e).set.map((t=>t.map((t=>t.value)).join(\" \").trim().split(\" \")))},7403:(t,e,r)=>{const n=r(7476);t.exports=(t,e)=>{try{return new n(t,e).range||\"*\"}catch(t){return null}}},1229:(t,e,r)=>{var n=r(5636).Buffer;function i(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){\"string\"==typeof t&&(e=e||\"utf8\",t=n.from(t,e));for(var r=this._block,i=this._blockSize,o=t.length,s=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error(\"_update must be implemented by subclass\")},t.exports=i},3229:(t,e,r)=>{var n=t.exports=function(t){t=t.toLowerCase();var e=n[t];if(!e)throw new Error(t+\" is not supported (we accept pull requests)\");return new e};n.sha=r(3675),n.sha1=r(8980),n.sha224=r(947),n.sha256=r(2826),n.sha384=r(9922),n.sha512=r(6080)},3675:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var p=~~(l/20),d=0|((e=n)<<5|e>>>27)+f(p,i,o,a)+c+r[l]+s[p];c=a,a=o,o=u(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=c},8980:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function f(t){return t<<30|t>>>2}function h(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var p=0;p<80;++p){var d=~~(p/20),y=u(n)+h(d,i,o,a)+c+r[p]+s[d]|0;c=a,a=o,o=f(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=c},947:(t,e,r)=>{var n=r(5615),i=r(2826),o=r(1229),s=r(5636).Buffer,a=new Array(64);function c(){this.init(),this._w=a,o.call(this,64,56)}n(c,i),c.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},c.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=c},2826:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=new Array(64);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function h(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function l(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(c,i),c.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,d=0|this._f,y=0|this._g,g=0|this._h,b=0;b<16;++b)r[b]=t.readInt32BE(4*b);for(;b<64;++b)r[b]=0|(((e=r[b-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[b-7]+p(r[b-15])+r[b-16];for(var w=0;w<64;++w){var m=g+l(c)+u(c,d,y)+s[w]+r[w]|0,v=h(n)+f(n,i,o)|0;g=y,y=d,d=c,c=a+m|0,a=o,o=i,i=n,n=m+v|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0,this._f=d+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},c.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=c},9922:(t,e,r)=>{var n=r(5615),i=r(6080),o=r(1229),s=r(5636).Buffer,a=new Array(160);function c(){this.init(),this._w=a,o.call(this,128,112)}n(c,i),c.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},c.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=c},6080:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function c(){this.init(),this._w=a,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function h(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function l(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0>>0?1:0}n(c,i),c.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},c.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,c=0|this._fh,w=0|this._gh,m=0|this._hh,v=0|this._al,E=0|this._bl,_=0|this._cl,S=0|this._dl,A=0|this._el,I=0|this._fl,T=0|this._gl,x=0|this._hl,O=0;O<32;O+=2)e[O]=t.readInt32BE(4*O),e[O+1]=t.readInt32BE(4*O+4);for(;O<160;O+=2){var k=e[O-30],P=e[O-30+1],R=p(k,P),B=d(P,k),C=y(k=e[O-4],P=e[O-4+1]),N=g(P,k),L=e[O-14],U=e[O-14+1],j=e[O-32],M=e[O-32+1],H=B+U|0,F=R+L+b(H,B)|0;F=(F=F+C+b(H=H+N|0,N)|0)+j+b(H=H+M|0,M)|0,e[O]=F,e[O+1]=H}for(var D=0;D<160;D+=2){F=e[D],H=e[D+1];var $=f(r,n,i),K=f(v,E,_),V=h(r,v),G=h(v,r),q=l(a,A),W=l(A,a),X=s[D],z=s[D+1],J=u(a,c,w),Y=u(A,I,T),Z=x+W|0,Q=m+q+b(Z,x)|0;Q=(Q=(Q=Q+J+b(Z=Z+Y|0,Y)|0)+X+b(Z=Z+z|0,z)|0)+F+b(Z=Z+H|0,H)|0;var tt=G+K|0,et=V+$+b(tt,G)|0;m=w,x=T,w=c,T=I,c=a,I=A,a=o+Q+b(A=S+Z|0,S)|0,o=i,S=_,i=n,_=E,n=r,E=v,r=Q+et+b(v=Z+tt|0,Z)|0}this._al=this._al+v|0,this._bl=this._bl+E|0,this._cl=this._cl+_|0,this._dl=this._dl+S|0,this._el=this._el+A|0,this._fl=this._fl+I|0,this._gl=this._gl+T|0,this._hl=this._hl+x|0,this._ah=this._ah+r+b(this._al,v)|0,this._bh=this._bh+n+b(this._bl,E)|0,this._ch=this._ch+i+b(this._cl,_)|0,this._dh=this._dh+o+b(this._dl,S)|0,this._eh=this._eh+a+b(this._el,A)|0,this._fh=this._fh+c+b(this._fl,I)|0,this._gh=this._gh+w+b(this._gl,T)|0,this._hh=this._hh+m+b(this._hl,x)|0},c.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=c},1983:(t,e,r)=>{t.exports=i;var n=r(46).EventEmitter;function i(){n.call(this)}r(5615)(i,n),i.Readable=r(8199),i.Writable=r(5291),i.Duplex=r(1265),i.Transform=r(9415),i.PassThrough=r(4421),i.finished=r(4869),i.pipeline=r(6815),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on(\"data\",i),t.on(\"drain\",o),t._isStdio||e&&!1===e.end||(r.on(\"end\",a),r.on(\"close\",c));var s=!1;function a(){s||(s=!0,t.end())}function c(){s||(s=!0,\"function\"==typeof t.destroy&&t.destroy())}function u(t){if(f(),0===n.listenerCount(this,\"error\"))throw t}function f(){r.removeListener(\"data\",i),t.removeListener(\"drain\",o),r.removeListener(\"end\",a),r.removeListener(\"close\",c),r.removeListener(\"error\",u),t.removeListener(\"error\",u),r.removeListener(\"end\",f),r.removeListener(\"close\",f),t.removeListener(\"close\",f)}return r.on(\"error\",u),t.on(\"error\",u),r.on(\"end\",f),r.on(\"close\",f),t.on(\"close\",f),t.emit(\"pipe\",r),t}},8888:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=n.isEncoding||function(t){switch((t=\"\"+t)&&t.toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":case\"raw\":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return\"utf8\";for(var e;;)switch(t){case\"utf8\":case\"utf-8\":return\"utf8\";case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return\"utf16le\";case\"latin1\":case\"binary\":return\"latin1\";case\"base64\":case\"ascii\":case\"hex\":return t;default:if(e)return;t=(\"\"+t).toLowerCase(),e=!0}}(t);if(\"string\"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error(\"Unknown encoding: \"+t);return e||t}(t),this.encoding){case\"utf16le\":this.text=c,this.end=u,e=4;break;case\"utf8\":this.fillLast=a,e=4;break;case\"base64\":this.text=f,this.end=h,e=3;break;default:return this.write=l,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,\"�\";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,\"�\";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,\"�\"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function c(t,e){if((t.length-e)%2==0){var r=t.toString(\"utf16le\",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString(\"utf16le\",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):\"\";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString(\"utf16le\",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString(\"base64\",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString(\"base64\",e,t.length-r))}function h(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+this.lastChar.toString(\"base64\",0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):\"\"}e.I=o,o.prototype.write=function(t){if(0===t.length)return\"\";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return\"\";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString(\"utf8\",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString(\"utf8\",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},8262:t=>{const e=/^[-+]?0x[a-fA-F0-9]+$/,r=/^([\\-\\+])?(0*)(\\.[0-9]+([eE]\\-?[0-9]+)?|[0-9]+(\\.[0-9]+([eE]\\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const n={hex:!0,leadingZeros:!0,decimalPoint:\".\",eNotation:!0};t.exports=function(t,i={}){if(i=Object.assign({},n,i),!t||\"string\"!=typeof t)return t;let o=t.trim();if(void 0!==i.skipLike&&i.skipLike.test(o))return t;if(i.hex&&e.test(o))return Number.parseInt(o,16);{const e=r.exec(o);if(e){const r=e[1],n=e[2];let s=function(t){if(t&&-1!==t.indexOf(\".\"))return\".\"===(t=t.replace(/0+$/,\"\"))?t=\"0\":\".\"===t[0]?t=\"0\"+t:\".\"===t[t.length-1]&&(t=t.substr(0,t.length-1)),t;return t}(e[3]);const a=e[4]||e[6];if(!i.leadingZeros&&n.length>0&&r&&\".\"!==o[2])return t;if(!i.leadingZeros&&n.length>0&&!r&&\".\"!==o[1])return t;{const e=Number(o),c=\"\"+e;return-1!==c.search(/[eE]/)||a?i.eNotation?e:t:-1!==o.indexOf(\".\")?\"0\"===c&&\"\"===s||c===s||r&&c===\"-\"+s?e:t:n?s===c||r+s===c?e:t:o===c||o===r+c?e:t}}return t}}},4322:(t,e,r)=>{var n=r(2890);function i(t){return t.name||t.toString().match(/function (.*?)\\s*\\(/)[1]}function o(t){return n.Nil(t)?\"\":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?\"Array\":t&&n.Object(t)?\"Object\":void 0!==t?t:\"\"}function c(t,e,r){var i=function(t){return n.Function(t)?\"\":n.String(t)?JSON.stringify(t):t&&n.Object(t)?\"\":t}(e);return\"Expected \"+a(t)+\", got\"+(\"\"!==r?\" \"+r:\"\")+(\"\"!==i?\" \"+i:\"\")}function u(t,e,r){r=r||o(e),this.message=c(t,e,r),s(this,u),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='\" of type ';return\"key\"===e&&(o='\" with key type '),c('property \"'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property \"'+e+'\"',s(this,u),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,f.prototype=Object.create(Error.prototype),f.prototype.constructor=u,t.exports={TfTypeError:u,TfPropertyTypeError:f,tfCustomError:function(t,e){return new u(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+\".\"+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof u&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},315:(t,e,r)=>{var n=r(1048).Buffer,i=r(2890),o=r(4322);function s(t){return n.isBuffer(t)}function a(t){return\"string\"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function c(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+\"(Length: \"+e+\")\",r+\"(Length: \"+n.length+\")\")}return n.toJSON=function(){return r},n}var u=c.bind(null,i.Array),f=c.bind(null,s),h=c.bind(null,a),l=c.bind(null,i.String);var p=Math.pow(2,53)-1;var d={ArrayN:u,Buffer:s,BufferN:f,Finite:function(t){return\"number\"==typeof t&&isFinite(t)},Hex:a,HexN:h,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return\"number\"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n>>0===t},UInt53:function(t){return\"number\"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},973:(t,e,r)=>{var n=r(4322),i=r(2890),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,u=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return l(t,e,n)}catch(t){throw c(t,r)}}))))))}return t=h(t),e=e||{},r.toJSON=function(){var r=\"[\"+o(t)+\"]\";return void 0!==e.length?r+=\"{\"+e.length+\"}\":void 0===e.minLength&&void 0===e.maxLength||(r+=\"{\"+(void 0===e.minLength?0:e.minLength)+\",\"+(void 0===e.maxLength?1/0:e.maxLength)+\"}\"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return\"?\"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw c(t,o,\"key\")}try{var s=r[o];l(t,s,n)}catch(t){throw c(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return\"{\"+o(e)+\": \"+o(t)+\"}\"}:function(){return\"{\"+o(t)+\"}\"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw c(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some((function(t){try{return l(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(\"|\")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every((function(t){try{return l(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(\" & \")},e},quacksLike:function(t){function e(e){return t===u(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every((function(t,n){try{return l(t,e[n],r)}catch(t){throw c(t,n)}}))))}return e.toJSON=function(){return\"(\"+t.map(o).join(\", \")+\")\"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return\"?\"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError(\"Expected compile() parameter of type Array of length 1\");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var p in f.oneOf=f.anyOf,i)l[p]=i[p];for(p in f)l[p]=f[p];var d=r(315);for(p in d)l[p]=d[p];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,t.exports=l},2890:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return\"boolean\"==typeof t},Function:function(t){return\"function\"==typeof t},Nil:function(t){return null==t},Number:function(t){return\"number\"==typeof t},Object:function(t){return\"object\"==typeof t},String:function(t){return\"string\"==typeof t},\"\":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},6732:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&\"true\"===String(e).toLowerCase()}t.exports=function(t,e){if(n(\"noDeprecation\"))return t;var r=!1;return function(){if(!r){if(n(\"throwDeprecation\"))throw new Error(e);n(\"traceDeprecation\")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},4596:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),Object.defineProperty(e,\"NIL\",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(e,\"parse\",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(e,\"stringify\",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(e,\"v1\",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,\"v3\",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,\"v4\",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,\"v5\",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,\"validate\",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,\"version\",{enumerable:!0,get:function(){return c.default}});var n=l(r(4603)),i=l(r(9917)),o=l(r(2712)),s=l(r(3423)),a=l(r(5911)),c=l(r(4072)),u=l(r(4564)),f=l(r(6585)),h=l(r(9975));function l(t){return t&&t.__esModule?t:{default:t}}},2668:(t,e)=>{\"use strict\";function r(t){return 14+(t+64>>>9<<4)+1}function n(t,e){const r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function i(t,e,r,i,o,s){return n((a=n(n(e,t),n(i,s)))<<(c=o)|a>>>32-c,r);var a,c}function o(t,e,r,n,o,s,a){return i(e&r|~e&n,t,e,o,s,a)}function s(t,e,r,n,o,s,a){return i(e&n|r&~n,t,e,o,s,a)}function a(t,e,r,n,o,s,a){return i(e^r^n,t,e,o,s,a)}function c(t,e,r,n,o,s,a){return i(r^(e|~n),t,e,o,s,a)}Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var u=function(t){if(\"string\"==typeof t){const e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(let r=0;r>5]>>>i%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(15&r),16);e.push(o)}return e}(function(t,e){t[e>>5]|=128<>5]|=(255&t[r/8])<{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var r={randomUUID:\"undefined\"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};e.default=r},5911:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;e.default=\"00000000-0000-0000-0000-000000000000\"},9975:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};var o=function(t){if(!(0,i.default)(t))throw TypeError(\"Invalid UUID\");let e;const r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=255&e,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=255&e,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=255&e,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=255&e,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=255&e,r};e.default=o},6635:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;e.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},4089:(t,e)=>{\"use strict\";let r;Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=function(){if(!r&&(r=\"undefined\"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!r))throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");return r(n)};const n=new Uint8Array(16)},4271:(t,e)=>{\"use strict\";function r(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function n(t,e){return t<>>32-e}Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var i=function(t){const e=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520];if(\"string\"==typeof t){const e=unescape(encodeURIComponent(t));t=[];for(let r=0;r>>0;h=f,f=u,u=n(c,30)>>>0,c=s,s=a}i[0]=i[0]+s>>>0,i[1]=i[1]+c>>>0,i[2]=i[2]+u>>>0,i[3]=i[3]+f>>>0,i[4]=i[4]+h>>>0}return[i[0]>>24&255,i[0]>>16&255,i[0]>>8&255,255&i[0],i[1]>>24&255,i[1]>>16&255,i[1]>>8&255,255&i[1],i[2]>>24&255,i[2]>>16&255,i[2]>>8&255,255&i[2],i[3]>>24&255,i[3]>>16&255,i[3]>>8&255,255&i[3],i[4]>>24&255,i[4]>>16&255,i[4]>>8&255,255&i[4]]};e.default=i},6585:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0,e.unsafeStringify=s;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};const o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));function s(t,e=0){return o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+\"-\"+o[t[e+4]]+o[t[e+5]]+\"-\"+o[t[e+6]]+o[t[e+7]]+\"-\"+o[t[e+8]]+o[t[e+9]]+\"-\"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]}var a=function(t,e=0){const r=s(t,e);if(!(0,i.default)(r))throw TypeError(\"Stringified UUID is invalid\");return r};e.default=a},4603:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4089))&&n.__esModule?n:{default:n},o=r(6585);let s,a,c=0,u=0;var f=function(t,e,r){let n=e&&r||0;const f=e||new Array(16);let h=(t=t||{}).node||s,l=void 0!==t.clockseq?t.clockseq:a;if(null==h||null==l){const e=t.random||(t.rng||i.default)();null==h&&(h=s=[1|e[0],e[1],e[2],e[3],e[4],e[5]]),null==l&&(l=a=16383&(e[6]<<8|e[7]))}let p=void 0!==t.msecs?t.msecs:Date.now(),d=void 0!==t.nsecs?t.nsecs:u+1;const y=p-c+(d-u)/1e4;if(y<0&&void 0===t.clockseq&&(l=l+1&16383),(y<0||p>c)&&void 0===t.nsecs&&(d=0),d>=1e4)throw new Error(\"uuid.v1(): Can't create more than 10M uuids/sec\");c=p,u=d,a=l,p+=122192928e5;const g=(1e4*(268435455&p)+d)%4294967296;f[n++]=g>>>24&255,f[n++]=g>>>16&255,f[n++]=g>>>8&255,f[n++]=255&g;const b=p/4294967296*1e4&268435455;f[n++]=b>>>8&255,f[n++]=255&b,f[n++]=b>>>24&15|16,f[n++]=b>>>16&255,f[n++]=l>>>8|128,f[n++]=255&l;for(let t=0;t<6;++t)f[n+t]=h[t];return e||(0,o.unsafeStringify)(f)};e.default=f},9917:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=o(r(4782)),i=o(r(2668));function o(t){return t&&t.__esModule?t:{default:t}}var s=(0,n.default)(\"v3\",48,i.default);e.default=s},4782:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.URL=e.DNS=void 0,e.default=function(t,e,r){function n(t,n,s,a){var c;if(\"string\"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));const e=[];for(let r=0;r{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=s(r(193)),i=s(r(4089)),o=r(6585);function s(t){return t&&t.__esModule?t:{default:t}}var a=function(t,e,r){if(n.default.randomUUID&&!e&&!t)return n.default.randomUUID();const s=(t=t||{}).random||(t.rng||i.default)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e){r=r||0;for(let t=0;t<16;++t)e[r+t]=s[t];return e}return(0,o.unsafeStringify)(s)};e.default=a},3423:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=o(r(4782)),i=o(r(4271));function o(t){return t&&t.__esModule?t:{default:t}}var s=(0,n.default)(\"v5\",80,i.default);e.default=s},4564:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(6635))&&n.__esModule?n:{default:n};var o=function(t){return\"string\"==typeof t&&i.default.test(t)};e.default=o},4072:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};var o=function(t){if(!(0,i.default)(t))throw TypeError(\"Invalid UUID\");return parseInt(t.slice(14,15),16)};e.default=o},7820:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError(\"value out of range\")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError(\"buffer must be a Buffer instance\");return i||(i=0),e<253?(r.writeUInt8(e,i),t.bytes=1):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),t.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),t.bytes=9),r},decode:function t(e,r){if(!n.isBuffer(e))throw new TypeError(\"buffer must be a Buffer instance\");r||(r=0);var i=e.readUInt8(r);if(i<253)return t.bytes=1,i;if(253===i)return t.bytes=3,e.readUInt16LE(r+1);if(254===i)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var s=e.readUInt32LE(r+1),a=4294967296*e.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},6952:(t,e,r)=>{var n=r(1048).Buffer,i=r(9848);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error(\"Invalid network version\");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error(\"Invalid WIF length\");if(1!==t[33])throw new Error(\"Invalid compression flag\");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function s(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return\"number\"==typeof t?i.encode(s(t,e,r)):i.encode(s(t.version,t.privateKey,t.compressed))},encodeRaw:s}},7047:t=>{\"use strict\";t.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},222:(t,e,r)=>{\"use strict\";function n(t){var e=this;if(e instanceof n||(e=new n),e.tail=null,e.head=null,e.length=0,t&&\"function\"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,i=arguments.length;r1)r=e;else{if(!this.head)throw new TypeError(\"Reduce of empty list with no initial value\");n=this.head.next,r=this.head.value}for(var i=0;null!==n;i++)r=t(r,n.value,i),n=n.next;return r},n.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError(\"Reduce of empty list with no initial value\");n=this.tail.prev,r=this.tail.value}for(var i=this.length-1;null!==n;i--)r=t(r,n.value,i),n=n.prev;return r},n.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},n.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},n.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new n;if(ethis.length&&(e=this.length);for(var i=0,o=this.head;null!==o&&ithis.length&&(e=this.length);for(var i=this.length,o=this.tail;null!==o&&i>e;i--)o=o.prev;for(;null!==o&&i>t;i--,o=o.prev)r.push(o.value);return r},n.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var n=0,o=this.head;null!==o&&n{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.JsonRpcRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(4520);e.JsonRpcRequestStruct=(0,o.object)({jsonrpc:(0,i.literal)(\"2.0\"),id:(0,i.union)([(0,i.string)(),(0,i.number)(),(0,i.literal)(null)]),method:(0,i.string)(),params:(0,o.exactOptional)((0,i.union)([(0,i.array)(n.JsonStruct),(0,i.record)((0,i.string)(),n.JsonStruct)]))})},1236:function(t,e,r){\"use strict\";var n,i,o,s=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if(\"m\"===n)throw new TypeError(\"Private method is not writable\");if(\"a\"===n&&!i)throw new TypeError(\"Private accessor was defined without a setter\");if(\"function\"==typeof e?t!==e||!i:!e.has(t))throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");return\"a\"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},a=this&&this.__classPrivateFieldGet||function(t,e,r,n){if(\"a\"===r&&!n)throw new TypeError(\"Private accessor was defined without a getter\");if(\"function\"==typeof e?t!==e||!n:!e.has(t))throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");return\"m\"===r?n:\"a\"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringClient=void 0;const c=r(7251),u=r(4596),f=r(2582),h=r(1925),l=r(4520);e.KeyringClient=class{constructor(t){n.add(this),i.set(this,void 0),s(this,i,t,\"f\")}async listAccounts(){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ListAccounts}),f.ListAccountsResponseStruct)}async getAccount(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetAccount,params:{id:t}}),f.GetAccountResponseStruct)}async getAccountBalances(t,e){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetAccountBalances,params:{id:t,assets:e}}),f.GetAccountBalancesResponseStruct)}async createAccount(t={}){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.CreateAccount,params:{options:t}}),f.CreateAccountResponseStruct)}async filterAccountChains(t,e){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.FilterAccountChains,params:{id:t,chains:e}}),f.FilterAccountChainsResponseStruct)}async updateAccount(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.UpdateAccount,params:{account:t}}),f.UpdateAccountResponseStruct)}async deleteAccount(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.DeleteAccount,params:{id:t}}),f.DeleteAccountResponseStruct)}async exportAccount(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ExportAccount,params:{id:t}}),f.ExportAccountResponseStruct)}async listRequests(){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ListRequests}),f.ListRequestsResponseStruct)}async getRequest(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetRequest,params:{id:t}}),f.GetRequestResponseStruct)}async submitRequest(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.SubmitRequest,params:t}),f.SubmitRequestResponseStruct)}async approveRequest(t,e={}){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ApproveRequest,params:{id:t,data:e}}),f.ApproveRequestResponseStruct)}async rejectRequest(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.RejectRequest,params:{id:t}}),f.RejectRequestResponseStruct)}},i=new WeakMap,n=new WeakSet,o=async function(t){return a(this,i,\"f\").send({jsonrpc:\"2.0\",id:(0,u.v4)(),...t})}},4071:function(t,e,r){\"use strict\";var n,i,o=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if(\"m\"===n)throw new TypeError(\"Private method is not writable\");if(\"a\"===n&&!i)throw new TypeError(\"Private accessor was defined without a setter\");if(\"function\"==typeof e?t!==e||!i:!e.has(t))throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");return\"a\"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},s=this&&this.__classPrivateFieldGet||function(t,e,r,n){if(\"a\"===r&&!n)throw new TypeError(\"Private accessor was defined without a getter\");if(\"function\"==typeof e?t!==e||!n:!e.has(t))throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");return\"m\"===r?n:\"a\"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringSnapRpcClient=e.SnapRpcSender=void 0;const a=r(1236);class c{constructor(t,e){n.set(this,void 0),i.set(this,void 0),o(this,n,t,\"f\"),o(this,i,e,\"f\")}async send(t){return s(this,i,\"f\").request({method:\"wallet_invokeKeyring\",params:{snapId:s(this,n,\"f\"),request:t}})}}e.SnapRpcSender=c,n=new WeakMap,i=new WeakMap;class u extends a.KeyringClient{constructor(t,e){super(new c(t,e))}}e.KeyringSnapRpcClient=u},1950:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringAccountStruct=e.BtcAccountType=e.EthAccountType=void 0;const n=r(2049),i=r(7251),o=r(4520),s=r(6580);var a,c;!function(t){t.Eoa=\"eip155:eoa\",t.Erc4337=\"eip155:erc4337\"}(a=e.EthAccountType||(e.EthAccountType={})),function(t){t.P2wpkh=\"bip122:p2wpkh\"}(c=e.BtcAccountType||(e.BtcAccountType={})),e.KeyringAccountStruct=(0,o.object)({id:s.UuidStruct,type:(0,i.enums)([`${a.Eoa}`,`${a.Erc4337}`,`${c.P2wpkh}`]),address:(0,i.string)(),options:(0,i.record)((0,i.string)(),n.JsonStruct),methods:(0,i.array)((0,i.string)())})},3433:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.BalanceStruct=void 0;const n=r(7251),i=r(4520),o=r(6580);e.BalanceStruct=(0,i.object)({amount:o.StringNumberStruct,unit:(0,n.string)()})},8588:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.isCaipAssetId=e.isCaipAssetType=e.CaipAssetIdStruct=e.CaipAssetTypeStruct=void 0;const n=r(7251),i=r(4520);e.CaipAssetTypeStruct=(0,i.definePattern)(\"CaipAssetType\",/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})$/u),e.CaipAssetIdStruct=(0,i.definePattern)(\"CaipAssetId\",/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})\\/(?[-.%a-zA-Z0-9]{1,78})$/u),e.isCaipAssetType=function(t){return(0,n.is)(t,e.CaipAssetTypeStruct)},e.isCaipAssetId=function(t){return(0,n.is)(t,e.CaipAssetIdStruct)}},4015:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringAccountDataStruct=void 0;const n=r(2049),i=r(7251);e.KeyringAccountDataStruct=(0,i.record)((0,i.string)(),n.JsonStruct)},5417:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(1950),e),i(r(3433),e),i(r(8588),e),i(r(4015),e),i(r(5444),e),i(r(7884),e),i(r(6142),e)},5444:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},7884:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(4520),s=r(6580);e.KeyringRequestStruct=(0,o.object)({id:s.UuidStruct,scope:(0,i.string)(),account:s.UuidStruct,request:(0,o.object)({method:(0,i.string)(),params:(0,o.exactOptional)((0,i.union)([(0,i.array)(n.JsonStruct),(0,i.record)((0,i.string)(),n.JsonStruct)]))})})},6142:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringResponseStruct=void 0;const n=r(2049),i=r(7251),o=r(4520);e.KeyringResponseStruct=(0,i.union)([(0,o.object)({pending:(0,i.literal)(!0),redirect:(0,o.exactOptional)((0,o.object)({message:(0,o.exactOptional)((0,i.string)()),url:(0,o.exactOptional)((0,i.string)())}))}),(0,o.object)({pending:(0,i.literal)(!1),result:n.JsonStruct})])},5238:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(5787),e)},5787:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.BtcP2wpkhAccountStruct=e.BtcMethod=e.BtcP2wpkhAddressStruct=void 0;const n=r(6586),i=r(7251),o=r(5417),s=r(4520);var a;e.BtcP2wpkhAddressStruct=(0,i.refine)((0,i.string)(),\"BtcP2wpkhAddressStruct\",(t=>{try{n.bech32.decode(t)}catch(t){return new Error(`Could not decode P2WPKH address: ${t.message}`)}return!0})),function(t){t.SendMany=\"btc_sendmany\"}(a=e.BtcMethod||(e.BtcMethod={})),e.BtcP2wpkhAccountStruct=(0,s.object)({...o.KeyringAccountStruct.schema,address:e.BtcP2wpkhAddressStruct,type:(0,i.literal)(`${o.BtcAccountType.P2wpkh}`),methods:(0,i.array)((0,i.enums)([`${a.SendMany}`]))})},1360:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},322:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(4943),e)},4943:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.EthUserOperationPatchStruct=e.EthBaseUserOperationStruct=e.EthBaseTransactionStruct=e.EthUserOperationStruct=void 0;const n=r(4520),i=r(6580),o=r(6879);e.EthUserOperationStruct=(0,n.object)({sender:o.EthAddressStruct,nonce:o.EthUint256Struct,initCode:o.EthBytesStruct,callData:o.EthBytesStruct,callGasLimit:o.EthUint256Struct,verificationGasLimit:o.EthUint256Struct,preVerificationGas:o.EthUint256Struct,maxFeePerGas:o.EthUint256Struct,maxPriorityFeePerGas:o.EthUint256Struct,paymasterAndData:o.EthBytesStruct,signature:o.EthBytesStruct}),e.EthBaseTransactionStruct=(0,n.object)({to:o.EthAddressStruct,value:o.EthUint256Struct,data:o.EthBytesStruct}),e.EthBaseUserOperationStruct=(0,n.object)({nonce:o.EthUint256Struct,initCode:o.EthBytesStruct,callData:o.EthBytesStruct,gasLimits:(0,n.exactOptional)((0,n.object)({callGasLimit:o.EthUint256Struct,verificationGasLimit:o.EthUint256Struct,preVerificationGas:o.EthUint256Struct})),dummyPaymasterAndData:o.EthBytesStruct,dummySignature:o.EthBytesStruct,bundlerUrl:i.UrlStruct}),e.EthUserOperationPatchStruct=(0,n.object)({paymasterAndData:o.EthBytesStruct,callGasLimit:(0,n.exactOptional)(o.EthUint256Struct),verificationGasLimit:(0,n.exactOptional)(o.EthUint256Struct),preVerificationGas:(0,n.exactOptional)(o.EthUint256Struct)})},6034:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(322),e),i(r(6879),e),i(r(1267),e)},6879:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.EthErc4337AccountStruct=e.EthEoaAccountStruct=e.EthMethod=e.EthUint256Struct=e.EthAddressStruct=e.EthBytesStruct=void 0;const n=r(7251),i=r(5417),o=r(4520);var s;e.EthBytesStruct=(0,o.definePattern)(\"EthBytes\",/^0x[0-9a-f]*$/iu),e.EthAddressStruct=(0,o.definePattern)(\"EthAddress\",/^0x[0-9a-f]{40}$/iu),e.EthUint256Struct=(0,o.definePattern)(\"EthUint256\",/^0x([1-9a-f][0-9a-f]*|0)$/iu),function(t){t.PersonalSign=\"personal_sign\",t.Sign=\"eth_sign\",t.SignTransaction=\"eth_signTransaction\",t.SignTypedDataV1=\"eth_signTypedData_v1\",t.SignTypedDataV3=\"eth_signTypedData_v3\",t.SignTypedDataV4=\"eth_signTypedData_v4\",t.PrepareUserOperation=\"eth_prepareUserOperation\",t.PatchUserOperation=\"eth_patchUserOperation\",t.SignUserOperation=\"eth_signUserOperation\"}(s=e.EthMethod||(e.EthMethod={})),e.EthEoaAccountStruct=(0,o.object)({...i.KeyringAccountStruct.schema,address:e.EthAddressStruct,type:(0,n.literal)(`${i.EthAccountType.Eoa}`),methods:(0,n.array)((0,n.enums)([`${s.PersonalSign}`,`${s.Sign}`,`${s.SignTransaction}`,`${s.SignTypedDataV1}`,`${s.SignTypedDataV3}`,`${s.SignTypedDataV4}`]))}),e.EthErc4337AccountStruct=(0,o.object)({...i.KeyringAccountStruct.schema,address:e.EthAddressStruct,type:(0,n.literal)(`${i.EthAccountType.Erc4337}`),methods:(0,n.array)((0,n.enums)([`${s.PersonalSign}`,`${s.Sign}`,`${s.SignTypedDataV1}`,`${s.SignTypedDataV3}`,`${s.SignTypedDataV4}`,`${s.PrepareUserOperation}`,`${s.PatchUserOperation}`,`${s.SignUserOperation}`]))})},1267:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.isEvmAccountType=void 0;const n=r(5417);e.isEvmAccountType=function(t){return t===n.EthAccountType.Eoa||t===n.EthAccountType.Erc4337}},4433:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringEvent=void 0,function(t){t.AccountCreated=\"notify:accountCreated\",t.AccountUpdated=\"notify:accountUpdated\",t.AccountDeleted=\"notify:accountDeleted\",t.RequestApproved=\"notify:requestApproved\",t.RequestRejected=\"notify:requestRejected\"}(e.KeyringEvent||(e.KeyringEvent={}))},7962:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(5417),e),i(r(5238),e),i(r(1360),e),i(r(6034),e),i(r(4433),e),i(r(7470),e),i(r(1236),e),i(r(4071),e),i(r(3060),e),i(r(5524),e),i(r(4520),e)},2582:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.RejectRequestResponseStruct=e.RejectRequestRequestStruct=e.ApproveRequestResponseStruct=e.ApproveRequestRequestStruct=e.SubmitRequestResponseStruct=e.SubmitRequestRequestStruct=e.GetRequestResponseStruct=e.GetRequestRequestStruct=e.ListRequestsResponseStruct=e.ListRequestsRequestStruct=e.ExportAccountResponseStruct=e.ExportAccountRequestStruct=e.DeleteAccountResponseStruct=e.DeleteAccountRequestStruct=e.UpdateAccountResponseStruct=e.UpdateAccountRequestStruct=e.FilterAccountChainsResponseStruct=e.FilterAccountChainsStruct=e.GetAccountBalancesResponseStruct=e.GetAccountBalancesRequestStruct=e.CreateAccountResponseStruct=e.CreateAccountRequestStruct=e.GetAccountResponseStruct=e.GetAccountRequestStruct=e.ListAccountsResponseStruct=e.ListAccountsRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(5417),s=r(4520),a=r(6580),c=r(1925),u={jsonrpc:(0,i.literal)(\"2.0\"),id:(0,i.union)([(0,i.string)(),(0,i.number)(),(0,i.literal)(null)])};e.ListAccountsRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_listAccounts\")}),e.ListAccountsResponseStruct=(0,i.array)(o.KeyringAccountStruct),e.GetAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_getAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.GetAccountResponseStruct=o.KeyringAccountStruct,e.CreateAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_createAccount\"),params:(0,s.object)({options:(0,i.record)((0,i.string)(),n.JsonStruct)})}),e.CreateAccountResponseStruct=o.KeyringAccountStruct,e.GetAccountBalancesRequestStruct=(0,s.object)({...u,method:(0,i.literal)(`${c.KeyringRpcMethod.GetAccountBalances}`),params:(0,s.object)({id:a.UuidStruct,assets:(0,i.array)(o.CaipAssetTypeStruct)})}),e.GetAccountBalancesResponseStruct=(0,i.record)(o.CaipAssetTypeStruct,o.BalanceStruct),e.FilterAccountChainsStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_filterAccountChains\"),params:(0,s.object)({id:a.UuidStruct,chains:(0,i.array)((0,i.string)())})}),e.FilterAccountChainsResponseStruct=(0,i.array)((0,i.string)()),e.UpdateAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_updateAccount\"),params:(0,s.object)({account:o.KeyringAccountStruct})}),e.UpdateAccountResponseStruct=(0,i.literal)(null),e.DeleteAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_deleteAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.DeleteAccountResponseStruct=(0,i.literal)(null),e.ExportAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_exportAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.ExportAccountResponseStruct=o.KeyringAccountDataStruct,e.ListRequestsRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_listRequests\")}),e.ListRequestsResponseStruct=(0,i.array)(o.KeyringRequestStruct),e.GetRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_getRequest\"),params:(0,s.object)({id:a.UuidStruct})}),e.GetRequestResponseStruct=o.KeyringRequestStruct,e.SubmitRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_submitRequest\"),params:o.KeyringRequestStruct}),e.SubmitRequestResponseStruct=o.KeyringResponseStruct,e.ApproveRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_approveRequest\"),params:(0,s.object)({id:a.UuidStruct,data:(0,i.record)((0,i.string)(),n.JsonStruct)})}),e.ApproveRequestResponseStruct=(0,i.literal)(null),e.RejectRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_rejectRequest\"),params:(0,s.object)({id:a.UuidStruct})}),e.RejectRequestResponseStruct=(0,i.literal)(null)},6796:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},7841:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(6796),e)},3005:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.RequestRejectedEventStruct=e.RequestApprovedEventStruct=e.AccountDeletedEventStruct=e.AccountUpdatedEventStruct=e.AccountCreatedEventStruct=void 0;const n=r(2049),i=r(7251),o=r(5417),s=r(4433),a=r(4520),c=r(6580);e.AccountCreatedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountCreated}`),params:(0,a.object)({account:o.KeyringAccountStruct,accountNameSuggestion:(0,a.exactOptional)((0,i.string)()),displayConfirmation:(0,a.exactOptional)((0,i.boolean)())})}),e.AccountUpdatedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountUpdated}`),params:(0,a.object)({account:o.KeyringAccountStruct})}),e.AccountDeletedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountDeleted}`),params:(0,a.object)({id:c.UuidStruct})}),e.RequestApprovedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.RequestApproved}`),params:(0,a.object)({id:c.UuidStruct,result:n.JsonStruct})}),e.RequestRejectedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.RequestRejected}`),params:(0,a.object)({id:c.UuidStruct})})},7470:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(2582),e),i(r(7841),e),i(r(3005),e),i(r(1925),e),i(r(3699),e)},1925:(t,e)=>{\"use strict\";var r;Object.defineProperty(e,\"__esModule\",{value:!0}),e.isKeyringRpcMethod=e.KeyringRpcMethod=void 0,function(t){t.ListAccounts=\"keyring_listAccounts\",t.GetAccount=\"keyring_getAccount\",t.CreateAccount=\"keyring_createAccount\",t.GetAccountBalances=\"keyring_getAccountBalances\",t.FilterAccountChains=\"keyring_filterAccountChains\",t.UpdateAccount=\"keyring_updateAccount\",t.DeleteAccount=\"keyring_deleteAccount\",t.ExportAccount=\"keyring_exportAccount\",t.ListRequests=\"keyring_listRequests\",t.GetRequest=\"keyring_getRequest\",t.SubmitRequest=\"keyring_submitRequest\",t.ApproveRequest=\"keyring_approveRequest\",t.RejectRequest=\"keyring_rejectRequest\"}(r=e.KeyringRpcMethod||(e.KeyringRpcMethod={})),e.isKeyringRpcMethod=function(t){return Object.values(r).includes(t)}},3699:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.InternalAccountStruct=e.InternalAccountStructs=e.InternalBtcP2wpkhAccountStruct=e.InternalEthErc4337AccountStruct=e.InternalEthEoaAccountStruct=e.InternalAccountMetadataStruct=void 0;const n=r(7251),i=r(5417),o=r(5787),s=r(6879),a=r(4520);function c(t){return(0,a.object)({...t.schema,...e.InternalAccountMetadataStruct.schema})}e.InternalAccountMetadataStruct=(0,a.object)({metadata:(0,a.object)({name:(0,n.string)(),snap:(0,a.exactOptional)((0,a.object)({id:(0,n.string)(),enabled:(0,n.boolean)(),name:(0,n.string)()})),lastSelected:(0,a.exactOptional)((0,n.number)()),importTime:(0,n.number)(),keyring:(0,a.object)({type:(0,n.string)()})})}),e.InternalEthEoaAccountStruct=c(s.EthEoaAccountStruct),e.InternalEthErc4337AccountStruct=c(s.EthErc4337AccountStruct),e.InternalBtcP2wpkhAccountStruct=c(o.BtcP2wpkhAccountStruct),e.InternalAccountStructs={[`${i.EthAccountType.Eoa}`]:e.InternalEthEoaAccountStruct,[`${i.EthAccountType.Erc4337}`]:e.InternalEthErc4337AccountStruct,[`${i.BtcAccountType.P2wpkh}`]:e.InternalBtcP2wpkhAccountStruct},e.InternalAccountStruct=(0,a.object)({...i.KeyringAccountStruct.schema,...e.InternalAccountMetadataStruct.schema})},3060:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.handleKeyringRequest=e.MethodNotSupportedError=void 0;const n=r(7251),i=r(2582),o=r(1925),s=r(5978);class a extends Error{constructor(t){super(`Method not supported: ${t}`)}}e.MethodNotSupportedError=a,e.handleKeyringRequest=async function(t,e){try{return await async function(t,e){switch((0,n.assert)(e,s.JsonRpcRequestStruct),e.method){case o.KeyringRpcMethod.ListAccounts:return(0,n.assert)(e,i.ListAccountsRequestStruct),t.listAccounts();case o.KeyringRpcMethod.GetAccount:return(0,n.assert)(e,i.GetAccountRequestStruct),t.getAccount(e.params.id);case o.KeyringRpcMethod.CreateAccount:return(0,n.assert)(e,i.CreateAccountRequestStruct),t.createAccount(e.params.options);case o.KeyringRpcMethod.GetAccountBalances:if(void 0===t.getAccountBalances)throw new a(e.method);return(0,n.assert)(e,i.GetAccountBalancesRequestStruct),t.getAccountBalances(e.params.id,e.params.assets);case o.KeyringRpcMethod.FilterAccountChains:return(0,n.assert)(e,i.FilterAccountChainsStruct),t.filterAccountChains(e.params.id,e.params.chains);case o.KeyringRpcMethod.UpdateAccount:return(0,n.assert)(e,i.UpdateAccountRequestStruct),t.updateAccount(e.params.account);case o.KeyringRpcMethod.DeleteAccount:return(0,n.assert)(e,i.DeleteAccountRequestStruct),t.deleteAccount(e.params.id);case o.KeyringRpcMethod.ExportAccount:if(void 0===t.exportAccount)throw new a(e.method);return(0,n.assert)(e,i.ExportAccountRequestStruct),t.exportAccount(e.params.id);case o.KeyringRpcMethod.ListRequests:if(void 0===t.listRequests)throw new a(e.method);return(0,n.assert)(e,i.ListRequestsRequestStruct),t.listRequests();case o.KeyringRpcMethod.GetRequest:if(void 0===t.getRequest)throw new a(e.method);return(0,n.assert)(e,i.GetRequestRequestStruct),t.getRequest(e.params.id);case o.KeyringRpcMethod.SubmitRequest:return(0,n.assert)(e,i.SubmitRequestRequestStruct),t.submitRequest(e.params);case o.KeyringRpcMethod.ApproveRequest:if(void 0===t.approveRequest)throw new a(e.method);return(0,n.assert)(e,i.ApproveRequestRequestStruct),t.approveRequest(e.params.id,e.params.data);case o.KeyringRpcMethod.RejectRequest:if(void 0===t.rejectRequest)throw new a(e.method);return(0,n.assert)(e,i.RejectRequestRequestStruct),t.rejectRequest(e.params.id);default:throw new a(e.method)}}(t,e)}catch(t){const e=t instanceof Error&&\"string\"==typeof t.message?t.message:\"An unknown error occurred while handling the keyring request\";throw new Error(e)}}},5524:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.emitSnapKeyringEvent=void 0,e.emitSnapKeyringEvent=async function(t,e,r){await t.request({method:\"snap_manageAccounts\",params:{method:e,params:{...r}}})}},4520:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.strictMask=e.definePattern=e.exactOptional=e.object=void 0;const n=r(7251);function i(t){return t.path[t.path.length-1]in t.branch[t.branch.length-2]}e.object=function(t){return(0,n.object)(t)},e.exactOptional=function(t){return new n.Struct({...t,validator:(e,r)=>!i(r)||t.validator(e,r),refiner:(e,r)=>!i(r)||t.refiner(e,r)})},e.definePattern=function(t,e){return(0,n.define)(t,(t=>\"string\"==typeof t&&e.test(t)))},e.strictMask=function(t,e,r){return(0,n.assert)(t,e,r),t}},6580:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(8401),e),i(r(7765),e)},8401:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.StringNumberStruct=e.UrlStruct=e.UuidStruct=void 0;const n=r(7251),i=r(4520);e.UuidStruct=(0,i.definePattern)(\"UuidV4\",/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu),e.UrlStruct=(0,n.define)(\"Url\",(t=>{try{const e=new URL(t);return\"http:\"===e.protocol||\"https:\"===e.protocol}catch(t){return!1}})),e.StringNumberStruct=(0,i.definePattern)(\"StringNumber\",/^\\d+(\\.\\d+)?$/u)},7765:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.expectTrue=void 0,e.expectTrue=function(){}},1275:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n,i=r(124),o=((n=i)&&n.__esModule?n:{default:n}).default.call(void 0,\"metamask\");e.createProjectLogger=function(t){return o.extend(t)},e.createModuleLogger=function(t,e){return t.extend(e)}},5244:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r=(t,e,r)=>{if(!e.has(t))throw TypeError(\"Cannot \"+r)};e.__privateGet=(t,e,n)=>(r(t,e,\"read from private field\"),n?n.call(t):e.get(t)),e.__privateAdd=(t,e,r)=>{if(e.has(t))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(t):e.set(t,r)},e.__privateSet=(t,e,n,i)=>(r(t,e,\"write to private field\"),i?i.call(t,n):e.set(t,n),n)},3631:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(932),i=r(2722),o=r(7251),s=o.refine.call(void 0,o.string.call(void 0),\"Version\",(t=>null!==i.valid.call(void 0,t)||`Expected SemVer version, got \"${t}\"`)),a=o.refine.call(void 0,o.string.call(void 0),\"Version range\",(t=>null!==i.validRange.call(void 0,t)||`Expected SemVer range, got \"${t}\"`));e.VersionStruct=s,e.VersionRangeStruct=a,e.isValidSemVerVersion=function(t){return o.is.call(void 0,t,s)},e.isValidSemVerRange=function(t){return o.is.call(void 0,t,a)},e.assertIsSemVerVersion=function(t){n.assertStruct.call(void 0,t,s)},e.assertIsSemVerRange=function(t){n.assertStruct.call(void 0,t,a)},e.gtVersion=function(t,e){return i.gt.call(void 0,t,e)},e.gtRange=function(t,e){return i.gtr.call(void 0,t,e)},e.satisfiesVersionRange=function(t,e){return i.satisfies.call(void 0,t,e,{includePrerelease:!0})}},9116:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r,n=((r=n||{})[r.Millisecond=1]=\"Millisecond\",r[r.Second=1e3]=\"Second\",r[r.Minute=6e4]=\"Minute\",r[r.Hour=36e5]=\"Hour\",r[r.Day=864e5]=\"Day\",r[r.Week=6048e5]=\"Week\",r[r.Year=31536e6]=\"Year\",r),i=(t,e)=>{if(!(t=>Number.isInteger(t)&&t>=0)(t))throw new Error(`\"${e}\" must be a non-negative integer. Received: \"${t}\".`)};e.Duration=n,e.inMilliseconds=function(t,e){return i(t,\"count\"),t*e},e.timeSince=function(t){return i(t,\"timestamp\"),Date.now()-t}},7982:()=>{},1848:(t,e,r)=>{\"use strict\";function n(t,e){return null!=t?t:e()}Object.defineProperty(e,\"__esModule\",{value:!0});var i=r(932),o=r(7251);e.base64=(t,e={})=>{const r=n(e.paddingRequired,(()=>!1)),s=n(e.characterSet,(()=>\"base64\"));let a,c;return\"base64\"===s?a=String.raw`[A-Za-z0-9+\\/]`:(i.assert.call(void 0,\"base64url\"===s),a=String.raw`[-_A-Za-z0-9]`),c=r?new RegExp(`^(?:${a}{4})*(?:${a}{3}=|${a}{2}==)?$`,\"u\"):new RegExp(`^(?:${a}{4})*(?:${a}{2,3}|${a}{3}=|${a}{2}==)?$`,\"u\"),o.pattern.call(void 0,t,c)}},932:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(1486),i=r(7251);function o(t,e){return Boolean(\"string\"==typeof function(t){let e,r=t[0],n=1;for(;nr.call(e,...t))),e=void 0)}return r}([t,\"optionalAccess\",t=>t.prototype,\"optionalAccess\",t=>t.constructor,\"optionalAccess\",t=>t.name]))?new t({message:e}):t({message:e})}var s=class extends Error{constructor(t){super(t.message),this.code=\"ERR_ASSERTION\"}};e.AssertionError=s,e.assert=function(t,e=\"Assertion failed.\",r=s){if(!t){if(e instanceof Error)throw e;throw o(r,e)}},e.assertStruct=function(t,e,r=\"Assertion failed\",a=s){try{i.assert.call(void 0,t,e)}catch(t){throw o(a,`${r}: ${function(t){return n.getErrorMessage.call(void 0,t).replace(/\\.$/u,\"\")}(t)}.`)}},e.assertExhaustive=function(t){throw new Error(\"Invalid branch reached. Should be detected during compilation.\")}},9705:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.createDeferredPromise=function({suppressUnhandledRejection:t=!1}={}){let e,r;const n=new Promise(((t,n)=>{e=t,r=n}));return t&&n.catch((t=>{})),{promise:n,resolve:e,reject:r}}},1203:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(5363),i=r(932),o=r(7251),s=o.union.call(void 0,[o.number.call(void 0),o.bigint.call(void 0),o.string.call(void 0),n.StrictHexStruct]),a=o.coerce.call(void 0,o.number.call(void 0),s,Number),c=o.coerce.call(void 0,o.bigint.call(void 0),s,BigInt),u=(o.union.call(void 0,[n.StrictHexStruct,o.instance.call(void 0,Uint8Array)]),o.coerce.call(void 0,o.instance.call(void 0,Uint8Array),o.union.call(void 0,[n.StrictHexStruct]),n.hexToBytes)),f=o.coerce.call(void 0,n.StrictHexStruct,o.instance.call(void 0,Uint8Array),n.bytesToHex);e.createNumber=function(t){try{const e=o.create.call(void 0,t,a);return i.assert.call(void 0,Number.isFinite(e),`Expected a number-like value, got \"${t}\".`),e}catch(e){if(e instanceof o.StructError)throw new Error(`Expected a number-like value, got \"${t}\".`);throw e}},e.createBigInt=function(t){try{return o.create.call(void 0,t,c)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a number-like value, got \"${String(t.value)}\".`);throw t}},e.createBytes=function(t){if(\"string\"==typeof t&&\"0x\"===t.toLowerCase())return new Uint8Array;try{return o.create.call(void 0,t,u)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a bytes-like value, got \"${String(t.value)}\".`);throw t}},e.createHex=function(t){if(t instanceof Uint8Array&&0===t.length||\"string\"==typeof t&&\"0x\"===t.toLowerCase())return\"0x\";try{return o.create.call(void 0,t,f)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a bytes-like value, got \"${String(t.value)}\".`);throw t}}},1508:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(1848),i=r(7251),o=i.size.call(void 0,n.base64.call(void 0,i.string.call(void 0),{paddingRequired:!0}),44,44);e.ChecksumStruct=o},1423:()=>{},1486:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(6526),i=r(9756);function o(t){return\"object\"==typeof t&&null!==t&&\"code\"in t}function s(t){return\"object\"==typeof t&&null!==t&&\"message\"in t}e.isErrorWithCode=o,e.isErrorWithMessage=s,e.isErrorWithStack=function(t){return\"object\"==typeof t&&null!==t&&\"stack\"in t},e.getErrorMessage=function(t){return s(t)&&\"string\"==typeof t.message?t.message:n.isNullOrUndefined.call(void 0,t)?\"\":String(t)},e.wrapError=function(t,e){if((r=t)instanceof Error||n.isObject.call(void 0,r)&&\"Error\"===r.constructor.name){let r;return r=2===Error.length?new Error(e,{cause:t}):new(0,i.ErrorWithCause)(e,{cause:t}),o(t)&&(r.code=t.code),r}var r;return e.length>0?new Error(`${String(t)}: ${e}`):new Error(String(t))}},8383:()=>{},7427:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(932),i=r(6526),o=r(7251),s=t=>o.object.call(void 0,t);function a({path:t,branch:e}){const r=t[t.length-1];return i.hasProperty.call(void 0,e[e.length-2],r)}function c(t){return new(0,o.Struct)({...t,type:`optional ${t.type}`,validator:(e,r)=>!a(r)||t.validator(e,r),refiner:(e,r)=>!a(r)||t.refiner(e,r)})}var u=o.union.call(void 0,[o.literal.call(void 0,null),o.boolean.call(void 0),o.define.call(void 0,\"finite number\",(t=>o.is.call(void 0,t,o.number.call(void 0))&&Number.isFinite(t))),o.string.call(void 0),o.array.call(void 0,o.lazy.call(void 0,(()=>u))),o.record.call(void 0,o.string.call(void 0),o.lazy.call(void 0,(()=>u)))]),f=o.coerce.call(void 0,u,o.any.call(void 0),(t=>(n.assertStruct.call(void 0,t,u),JSON.parse(JSON.stringify(t,((t,e)=>{if(\"__proto__\"!==t&&\"constructor\"!==t)return e}))))));function h(t){return o.create.call(void 0,t,f)}var l=o.literal.call(void 0,\"2.0\"),p=o.nullable.call(void 0,o.union.call(void 0,[o.number.call(void 0),o.string.call(void 0)])),d=s({code:o.integer.call(void 0),message:o.string.call(void 0),data:c(f),stack:c(o.string.call(void 0))}),y=o.union.call(void 0,[o.record.call(void 0,o.string.call(void 0),f),o.array.call(void 0,f)]),g=s({id:p,jsonrpc:l,method:o.string.call(void 0),params:c(y)}),b=s({jsonrpc:l,method:o.string.call(void 0),params:c(y)});var w=o.object.call(void 0,{id:p,jsonrpc:l,result:o.optional.call(void 0,o.unknown.call(void 0)),error:o.optional.call(void 0,d)}),m=s({id:p,jsonrpc:l,result:f}),v=s({id:p,jsonrpc:l,error:d}),E=o.union.call(void 0,[m,v]);e.object=s,e.exactOptional=c,e.UnsafeJsonStruct=u,e.JsonStruct=f,e.isValidJson=function(t){try{return h(t),!0}catch(t){return!1}},e.getSafeJson=h,e.getJsonSize=function(t){n.assertStruct.call(void 0,t,f,\"Invalid JSON value\");const e=JSON.stringify(t);return(new TextEncoder).encode(e).byteLength},e.jsonrpc2=\"2.0\",e.JsonRpcVersionStruct=l,e.JsonRpcIdStruct=p,e.JsonRpcErrorStruct=d,e.JsonRpcParamsStruct=y,e.JsonRpcRequestStruct=g,e.JsonRpcNotificationStruct=b,e.isJsonRpcNotification=function(t){return o.is.call(void 0,t,b)},e.assertIsJsonRpcNotification=function(t,e){n.assertStruct.call(void 0,t,b,\"Invalid JSON-RPC notification\",e)},e.isJsonRpcRequest=function(t){return o.is.call(void 0,t,g)},e.assertIsJsonRpcRequest=function(t,e){n.assertStruct.call(void 0,t,g,\"Invalid JSON-RPC request\",e)},e.PendingJsonRpcResponseStruct=w,e.JsonRpcSuccessStruct=m,e.JsonRpcFailureStruct=v,e.JsonRpcResponseStruct=E,e.isPendingJsonRpcResponse=function(t){return o.is.call(void 0,t,w)},e.assertIsPendingJsonRpcResponse=function(t,e){n.assertStruct.call(void 0,t,w,\"Invalid pending JSON-RPC response\",e)},e.isJsonRpcResponse=function(t){return o.is.call(void 0,t,E)},e.assertIsJsonRpcResponse=function(t,e){n.assertStruct.call(void 0,t,E,\"Invalid JSON-RPC response\",e)},e.isJsonRpcSuccess=function(t){return o.is.call(void 0,t,m)},e.assertIsJsonRpcSuccess=function(t,e){n.assertStruct.call(void 0,t,m,\"Invalid JSON-RPC success response\",e)},e.isJsonRpcFailure=function(t){return o.is.call(void 0,t,v)},e.assertIsJsonRpcFailure=function(t,e){n.assertStruct.call(void 0,t,v,\"Invalid JSON-RPC failure response\",e)},e.isJsonRpcError=function(t){return o.is.call(void 0,t,d)},e.assertIsJsonRpcError=function(t,e){n.assertStruct.call(void 0,t,d,\"Invalid JSON-RPC error\",e)},e.getJsonRpcIdValidator=function(t){const{permitEmptyString:e,permitFractions:r,permitNull:n}={permitEmptyString:!0,permitFractions:!1,permitNull:!0,...t};return t=>Boolean(\"number\"==typeof t&&(r||Number.isInteger(t))||\"string\"==typeof t&&(e||t.length>0)||n&&null===t)}},5363:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});var i=r(932),o=r(448),s=r(7251),a=r(6710),c=48,u=58,f=87;var h=function(){const t=[];return()=>{if(0===t.length)for(let e=0;e<256;e++)t.push(e.toString(16).padStart(2,\"0\"));return t}}();function l(t){return t instanceof Uint8Array}function p(t){i.assert.call(void 0,l(t),\"Value must be a Uint8Array.\")}function d(t){if(p(t),0===t.length)return\"0x\";const e=h(),r=new Array(t.length);for(let n=0;nr.call(e,...t))),e=void 0)}return r}([t,\"optionalAccess\",t=>t.toLowerCase,\"optionalCall\",t=>t()]))return new Uint8Array;x(t);const e=R(t).toLowerCase(),r=e.length%2==0?e:`0${e}`,n=new Uint8Array(r.length/2);for(let t=0;t=BigInt(0),\"Value must be a non-negative bigint.\");return g(t.toString(16))}function w(t){i.assert.call(void 0,\"number\"==typeof t,\"Value must be a number.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative number.\"),i.assert.call(void 0,Number.isSafeInteger(t),\"Value is not a safe integer. Use `bigIntToBytes` instead.\");return g(t.toString(16))}function m(t){return i.assert.call(void 0,\"string\"==typeof t,\"Value must be a string.\"),(new TextEncoder).encode(t)}function v(t){if(\"bigint\"==typeof t)return b(t);if(\"number\"==typeof t)return w(t);if(\"string\"==typeof t)return t.startsWith(\"0x\")?g(t):m(t);if(l(t))return t;throw new TypeError(`Unsupported value type: \"${typeof t}\".`)}var E=s.pattern.call(void 0,s.string.call(void 0),/^(?:0x)?[0-9a-f]+$/iu),_=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-f]+$/iu),S=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-f]{40}$/u),A=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-fA-F]{40}$/u);function I(t){return s.is.call(void 0,t,E)}function T(t){return s.is.call(void 0,t,_)}function x(t){i.assert.call(void 0,I(t),\"Value must be a hexadecimal string.\")}function O(t){i.assert.call(void 0,s.is.call(void 0,t,A),\"Invalid hex address.\");const e=R(t.toLowerCase()),r=R(d(o.keccak_256.call(void 0,e)));return`0x${e.split(\"\").map(((t,e)=>{const n=r[e];return i.assert.call(void 0,s.is.call(void 0,n,s.string.call(void 0)),\"Hash shorter than address.\"),parseInt(n,16)>7?t.toUpperCase():t})).join(\"\")}`}function k(t){return!!s.is.call(void 0,t,A)&&O(t)===t}function P(t){return t.startsWith(\"0x\")?t:t.startsWith(\"0X\")?`0x${t.substring(2)}`:`0x${t}`}function R(t){return t.startsWith(\"0x\")||t.startsWith(\"0X\")?t.substring(2):t}e.HexStruct=E,e.StrictHexStruct=_,e.HexAddressStruct=S,e.HexChecksumAddressStruct=A,e.isHexString=I,e.isStrictHexString=T,e.assertIsHexString=x,e.assertIsStrictHexString=function(t){i.assert.call(void 0,T(t),'Value must be a hexadecimal string, starting with \"0x\".')},e.isValidHexAddress=function(t){return s.is.call(void 0,t,S)||k(t)},e.getChecksumAddress=O,e.isValidChecksumAddress=k,e.add0x=P,e.remove0x=R,e.isBytes=l,e.assertIsBytes=p,e.bytesToHex=d,e.bytesToBigInt=y,e.bytesToSignedBigInt=function(t){p(t);let e=BigInt(0);for(const r of t)e=(e<0,\"Byte length must be greater than 0.\"),i.assert.call(void 0,function(t,e){i.assert.call(void 0,e>0);const r=t>>BigInt(31);return!((~t&r)+(t&~r)>>BigInt(8*e-1))}(t,e),\"Byte length is too small to represent the given value.\");let r=t;const n=new Uint8Array(e);for(let t=0;t>=BigInt(8);return n.reverse()},e.numberToBytes=w,e.stringToBytes=m,e.base64ToBytes=function(t){return i.assert.call(void 0,\"string\"==typeof t,\"Value must be a string.\"),a.base64.decode(t)},e.valueToBytes=v,e.concatBytes=function(t){const e=new Array(t.length);let r=0;for(let n=0;n{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r,n=((r=n||{})[r.Null=4]=\"Null\",r[r.Comma=1]=\"Comma\",r[r.Wrapper=1]=\"Wrapper\",r[r.True=4]=\"True\",r[r.False=5]=\"False\",r[r.Quote=1]=\"Quote\",r[r.Colon=1]=\"Colon\",r[r.Date=24]=\"Date\",r),i=/\"|\\\\|\\n|\\r|\\t/gu;function o(t){return t.charCodeAt(0)<=127}e.isNonEmptyArray=function(t){return Array.isArray(t)&&t.length>0},e.isNullOrUndefined=function(t){return null==t},e.isObject=function(t){return Boolean(t)&&\"object\"==typeof t&&!Array.isArray(t)},e.hasProperty=(t,e)=>Object.hasOwnProperty.call(t,e),e.getKnownPropertyNames=function(t){return Object.getOwnPropertyNames(t)},e.JsonSize=n,e.ESCAPE_CHARACTERS_REGEXP=i,e.isPlainObject=function(t){if(\"object\"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}},e.isASCII=o,e.calculateStringSize=function(t){return t.split(\"\").reduce(((t,e)=>o(e)?t+1:t+2),0)+(e=t.match(i),r=()=>[],null!=e?e:r()).length;var e,r},e.calculateNumberSize=function(t){return t.toString().length}},1305:()=>{},3207:()=>{},1535:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(5363),i=r(932);e.numberToHex=t=>(i.assert.call(void 0,\"number\"==typeof t,\"Value must be a number.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative number.\"),i.assert.call(void 0,Number.isSafeInteger(t),\"Value is not a safe integer. Use `bigIntToHex` instead.\"),n.add0x.call(void 0,t.toString(16))),e.bigIntToHex=t=>(i.assert.call(void 0,\"bigint\"==typeof t,\"Value must be a bigint.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative bigint.\"),n.add0x.call(void 0,t.toString(16))),e.hexToNumber=t=>{n.assertIsHexString.call(void 0,t);const e=parseInt(t,16);return i.assert.call(void 0,Number.isSafeInteger(e),\"Value is not a safe integer. Use `hexToBigInt` instead.\"),e},e.hexToBigInt=t=>(n.assertIsHexString.call(void 0,t),BigInt(n.add0x.call(void 0,t)))},2489:(t,e,r)=>{\"use strict\";function n(t){let e,r=t[0],n=1;for(;nr.call(e,...t))),e=void 0)}return r}Object.defineProperty(e,\"__esModule\",{value:!0});var i,o=r(7251),s=/^(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})$/u,a=/^[-a-z0-9]{3,8}$/u,c=/^[-_a-zA-Z0-9]{1,32}$/u,u=/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})):(?[-.%a-zA-Z0-9]{1,128})$/u,f=/^[-.%a-zA-Z0-9]{1,128}$/u,h=o.pattern.call(void 0,o.string.call(void 0),s),l=o.pattern.call(void 0,o.string.call(void 0),a),p=o.pattern.call(void 0,o.string.call(void 0),c),d=o.pattern.call(void 0,o.string.call(void 0),u),y=o.pattern.call(void 0,o.string.call(void 0),f),g=((i=g||{}).Eip155=\"eip155\",i);function b(t){return o.is.call(void 0,t,l)}function w(t){return o.is.call(void 0,t,p)}e.CAIP_CHAIN_ID_REGEX=s,e.CAIP_NAMESPACE_REGEX=a,e.CAIP_REFERENCE_REGEX=c,e.CAIP_ACCOUNT_ID_REGEX=u,e.CAIP_ACCOUNT_ADDRESS_REGEX=f,e.CaipChainIdStruct=h,e.CaipNamespaceStruct=l,e.CaipReferenceStruct=p,e.CaipAccountIdStruct=d,e.CaipAccountAddressStruct=y,e.KnownCaipNamespace=g,e.isCaipChainId=function(t){return o.is.call(void 0,t,h)},e.isCaipNamespace=b,e.isCaipReference=w,e.isCaipAccountId=function(t){return o.is.call(void 0,t,d)},e.isCaipAccountAddress=function(t){return o.is.call(void 0,t,y)},e.parseCaipChainId=function(t){const e=s.exec(t);if(!n([e,\"optionalAccess\",t=>t.groups]))throw new Error(\"Invalid CAIP chain ID.\");return{namespace:e.groups.namespace,reference:e.groups.reference}},e.parseCaipAccountId=function(t){const e=u.exec(t);if(!n([e,\"optionalAccess\",t=>t.groups]))throw new Error(\"Invalid CAIP account ID.\");return{address:e.groups.accountAddress,chainId:e.groups.chainId,chain:{namespace:e.groups.namespace,reference:e.groups.reference}}},e.toCaipChainId=function(t,e){if(!b(t))throw new Error(`Invalid \"namespace\", must match: ${a.toString()}`);if(!w(e))throw new Error(`Invalid \"reference\", must match: ${c.toString()}`);return`${t}:${e}`}},1584:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n,i,o=r(5244),s=class{constructor(t){o.__privateAdd.call(void 0,this,n,void 0),o.__privateSet.call(void 0,this,n,new Map(t)),Object.freeze(this)}get size(){return o.__privateGet.call(void 0,this,n).size}[Symbol.iterator](){return o.__privateGet.call(void 0,this,n)[Symbol.iterator]()}entries(){return o.__privateGet.call(void 0,this,n).entries()}forEach(t,e){return o.__privateGet.call(void 0,this,n).forEach(((r,n,i)=>t.call(e,r,n,this)))}get(t){return o.__privateGet.call(void 0,this,n).get(t)}has(t){return o.__privateGet.call(void 0,this,n).has(t)}keys(){return o.__privateGet.call(void 0,this,n).keys()}values(){return o.__privateGet.call(void 0,this,n).values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map((([t,e])=>`${String(t)} => ${String(e)}`)).join(\", \")} `:\"\"}}`}};n=new WeakMap;var a=class{constructor(t){o.__privateAdd.call(void 0,this,i,void 0),o.__privateSet.call(void 0,this,i,new Set(t)),Object.freeze(this)}get size(){return o.__privateGet.call(void 0,this,i).size}[Symbol.iterator](){return o.__privateGet.call(void 0,this,i)[Symbol.iterator]()}entries(){return o.__privateGet.call(void 0,this,i).entries()}forEach(t,e){return o.__privateGet.call(void 0,this,i).forEach(((r,n,i)=>t.call(e,r,n,this)))}has(t){return o.__privateGet.call(void 0,this,i).has(t)}keys(){return o.__privateGet.call(void 0,this,i).keys()}values(){return o.__privateGet.call(void 0,this,i).values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map((t=>String(t))).join(\", \")} `:\"\"}}`}};i=new WeakMap,Object.freeze(s),Object.freeze(s.prototype),Object.freeze(a),Object.freeze(a.prototype),e.FrozenMap=s,e.FrozenSet=a},2049:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),r(7982);var n=r(1535);r(8383);var i=r(9705),o=r(9116);r(3207);var s=r(3631),a=r(7427);r(1305);var c=r(1275),u=r(2489),f=r(1508),h=r(1848),l=r(1203),p=r(5363),d=r(932),y=r(1486),g=r(6526),b=r(1584);r(5244),r(1423),e.AssertionError=d.AssertionError,e.CAIP_ACCOUNT_ADDRESS_REGEX=u.CAIP_ACCOUNT_ADDRESS_REGEX,e.CAIP_ACCOUNT_ID_REGEX=u.CAIP_ACCOUNT_ID_REGEX,e.CAIP_CHAIN_ID_REGEX=u.CAIP_CHAIN_ID_REGEX,e.CAIP_NAMESPACE_REGEX=u.CAIP_NAMESPACE_REGEX,e.CAIP_REFERENCE_REGEX=u.CAIP_REFERENCE_REGEX,e.CaipAccountAddressStruct=u.CaipAccountAddressStruct,e.CaipAccountIdStruct=u.CaipAccountIdStruct,e.CaipChainIdStruct=u.CaipChainIdStruct,e.CaipNamespaceStruct=u.CaipNamespaceStruct,e.CaipReferenceStruct=u.CaipReferenceStruct,e.ChecksumStruct=f.ChecksumStruct,e.Duration=o.Duration,e.ESCAPE_CHARACTERS_REGEXP=g.ESCAPE_CHARACTERS_REGEXP,e.FrozenMap=b.FrozenMap,e.FrozenSet=b.FrozenSet,e.HexAddressStruct=p.HexAddressStruct,e.HexChecksumAddressStruct=p.HexChecksumAddressStruct,e.HexStruct=p.HexStruct,e.JsonRpcErrorStruct=a.JsonRpcErrorStruct,e.JsonRpcFailureStruct=a.JsonRpcFailureStruct,e.JsonRpcIdStruct=a.JsonRpcIdStruct,e.JsonRpcNotificationStruct=a.JsonRpcNotificationStruct,e.JsonRpcParamsStruct=a.JsonRpcParamsStruct,e.JsonRpcRequestStruct=a.JsonRpcRequestStruct,e.JsonRpcResponseStruct=a.JsonRpcResponseStruct,e.JsonRpcSuccessStruct=a.JsonRpcSuccessStruct,e.JsonRpcVersionStruct=a.JsonRpcVersionStruct,e.JsonSize=g.JsonSize,e.JsonStruct=a.JsonStruct,e.KnownCaipNamespace=u.KnownCaipNamespace,e.PendingJsonRpcResponseStruct=a.PendingJsonRpcResponseStruct,e.StrictHexStruct=p.StrictHexStruct,e.UnsafeJsonStruct=a.UnsafeJsonStruct,e.VersionRangeStruct=s.VersionRangeStruct,e.VersionStruct=s.VersionStruct,e.add0x=p.add0x,e.assert=d.assert,e.assertExhaustive=d.assertExhaustive,e.assertIsBytes=p.assertIsBytes,e.assertIsHexString=p.assertIsHexString,e.assertIsJsonRpcError=a.assertIsJsonRpcError,e.assertIsJsonRpcFailure=a.assertIsJsonRpcFailure,e.assertIsJsonRpcNotification=a.assertIsJsonRpcNotification,e.assertIsJsonRpcRequest=a.assertIsJsonRpcRequest,e.assertIsJsonRpcResponse=a.assertIsJsonRpcResponse,e.assertIsJsonRpcSuccess=a.assertIsJsonRpcSuccess,e.assertIsPendingJsonRpcResponse=a.assertIsPendingJsonRpcResponse,e.assertIsSemVerRange=s.assertIsSemVerRange,e.assertIsSemVerVersion=s.assertIsSemVerVersion,e.assertIsStrictHexString=p.assertIsStrictHexString,e.assertStruct=d.assertStruct,e.base64=h.base64,e.base64ToBytes=p.base64ToBytes,e.bigIntToBytes=p.bigIntToBytes,e.bigIntToHex=n.bigIntToHex,e.bytesToBase64=p.bytesToBase64,e.bytesToBigInt=p.bytesToBigInt,e.bytesToHex=p.bytesToHex,e.bytesToNumber=p.bytesToNumber,e.bytesToSignedBigInt=p.bytesToSignedBigInt,e.bytesToString=p.bytesToString,e.calculateNumberSize=g.calculateNumberSize,e.calculateStringSize=g.calculateStringSize,e.concatBytes=p.concatBytes,e.createBigInt=l.createBigInt,e.createBytes=l.createBytes,e.createDataView=p.createDataView,e.createDeferredPromise=i.createDeferredPromise,e.createHex=l.createHex,e.createModuleLogger=c.createModuleLogger,e.createNumber=l.createNumber,e.createProjectLogger=c.createProjectLogger,e.exactOptional=a.exactOptional,e.getChecksumAddress=p.getChecksumAddress,e.getErrorMessage=y.getErrorMessage,e.getJsonRpcIdValidator=a.getJsonRpcIdValidator,e.getJsonSize=a.getJsonSize,e.getKnownPropertyNames=g.getKnownPropertyNames,e.getSafeJson=a.getSafeJson,e.gtRange=s.gtRange,e.gtVersion=s.gtVersion,e.hasProperty=g.hasProperty,e.hexToBigInt=n.hexToBigInt,e.hexToBytes=p.hexToBytes,e.hexToNumber=n.hexToNumber,e.inMilliseconds=o.inMilliseconds,e.isASCII=g.isASCII,e.isBytes=p.isBytes,e.isCaipAccountAddress=u.isCaipAccountAddress,e.isCaipAccountId=u.isCaipAccountId,e.isCaipChainId=u.isCaipChainId,e.isCaipNamespace=u.isCaipNamespace,e.isCaipReference=u.isCaipReference,e.isErrorWithCode=y.isErrorWithCode,e.isErrorWithMessage=y.isErrorWithMessage,e.isErrorWithStack=y.isErrorWithStack,e.isHexString=p.isHexString,e.isJsonRpcError=a.isJsonRpcError,e.isJsonRpcFailure=a.isJsonRpcFailure,e.isJsonRpcNotification=a.isJsonRpcNotification,e.isJsonRpcRequest=a.isJsonRpcRequest,e.isJsonRpcResponse=a.isJsonRpcResponse,e.isJsonRpcSuccess=a.isJsonRpcSuccess,e.isNonEmptyArray=g.isNonEmptyArray,e.isNullOrUndefined=g.isNullOrUndefined,e.isObject=g.isObject,e.isPendingJsonRpcResponse=a.isPendingJsonRpcResponse,e.isPlainObject=g.isPlainObject,e.isStrictHexString=p.isStrictHexString,e.isValidChecksumAddress=p.isValidChecksumAddress,e.isValidHexAddress=p.isValidHexAddress,e.isValidJson=a.isValidJson,e.isValidSemVerRange=s.isValidSemVerRange,e.isValidSemVerVersion=s.isValidSemVerVersion,e.jsonrpc2=a.jsonrpc2,e.numberToBytes=p.numberToBytes,e.numberToHex=n.numberToHex,e.object=a.object,e.parseCaipAccountId=u.parseCaipAccountId,e.parseCaipChainId=u.parseCaipChainId,e.remove0x=p.remove0x,e.satisfiesVersionRange=s.satisfiesVersionRange,e.signedBigIntToBytes=p.signedBigIntToBytes,e.stringToBytes=p.stringToBytes,e.timeSince=o.timeSince,e.toCaipChainId=u.toCaipChainId,e.valueToBytes=p.valueToBytes,e.wrapError=y.wrapError},2028:()=>{},3011:()=>{},3951:()=>{},7251:(t,e,r)=>{\"use strict\";r.r(e),r.d(e,{Struct:()=>f,StructError:()=>n,any:()=>I,array:()=>T,assert:()=>h,assign:()=>g,bigint:()=>x,boolean:()=>O,coerce:()=>J,create:()=>l,date:()=>k,defaulted:()=>Y,define:()=>b,deprecated:()=>w,dynamic:()=>m,empty:()=>Q,enums:()=>P,func:()=>R,instance:()=>B,integer:()=>C,intersection:()=>N,is:()=>d,lazy:()=>v,literal:()=>L,map:()=>U,mask:()=>p,max:()=>et,min:()=>rt,never:()=>j,nonempty:()=>nt,nullable:()=>M,number:()=>H,object:()=>F,omit:()=>E,optional:()=>D,partial:()=>_,pattern:()=>it,pick:()=>S,record:()=>$,refine:()=>st,regexp:()=>K,set:()=>V,size:()=>ot,string:()=>G,struct:()=>A,trimmed:()=>Z,tuple:()=>q,type:()=>W,union:()=>X,unknown:()=>z,validate:()=>y});class n extends TypeError{constructor(t,e){let r;const{message:n,explanation:i,...o}=t,{path:s}=t,a=0===s.length?n:`At path: ${s.join(\".\")} -- ${n}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function i(t){return\"object\"==typeof t&&null!=t}function o(t){if(\"[object Object]\"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function s(t){return\"symbol\"==typeof t?t.toString():\"string\"==typeof t?JSON.stringify(t):`${t}`}function a(t,e,r,n){if(!0===t)return;!1===t?t={}:\"string\"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:a}=r,{refinement:c,message:u=`Expected a value of type \\`${a}\\`${c?` with refinement \\`${c}\\``:\"\"}, but received: \\`${s(n)}\\``}=t;return{value:n,type:a,refinement:c,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*c(t,e,r,n){var o;i(o=t)&&\"function\"==typeof o[Symbol.iterator]||(t=[t]);for(const i of t){const t=a(i,e,r,n);t&&(yield t)}}function*u(t,e,r={}){const{path:n=[],branch:o=[t],coerce:s=!1,mask:a=!1}=r,c={path:n,branch:o};if(s&&(t=e.coercer(t,c),a&&\"type\"!==e.type&&i(e.schema)&&i(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let f=\"valid\";for(const n of e.validator(t,c))n.explanation=r.message,f=\"not_valid\",yield[n,void 0];for(let[h,l,p]of e.entries(t,c)){const e=u(l,p,{path:void 0===h?n:[...n,h],branch:void 0===h?o:[...o,l],coerce:s,mask:a,message:r.message});for(const r of e)r[0]?(f=null!=r[0].refinement?\"not_refined\":\"not_valid\",yield[r[0],void 0]):s&&(l=r[1],void 0===h?t=l:t instanceof Map?t.set(h,l):t instanceof Set?t.add(l):i(t)&&(void 0!==l||h in t)&&(t[h]=l))}if(\"not_valid\"!==f)for(const n of e.refiner(t,c))n.explanation=r.message,f=\"not_refined\",yield[n,void 0];\"valid\"===f&&(yield[void 0,t])}class f{constructor(t){const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>c(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>c(i(t,e),e,this,t):()=>[]}assert(t,e){return h(t,this,e)}create(t,e){return l(t,this,e)}is(t){return d(t,this)}mask(t,e){return p(t,this,e)}validate(t,e={}){return y(t,this,e)}}function h(t,e,r){const n=y(t,e,{message:r});if(n[0])throw n[0]}function l(t,e,r){const n=y(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function p(t,e,r){const n=y(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function d(t,e){return!y(t,e)[0]}function y(t,e,r={}){const i=u(t,e,r),o=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(i);if(o[0]){return[new n(o[0],(function*(){for(const t of i)t[0]&&(yield t[0])})),void 0]}return[void 0,o[1]]}function g(...t){const e=\"type\"===t[0].type,r=t.map((t=>t.schema)),n=Object.assign({},...r);return e?W(n):F(n)}function b(t,e){return new f({type:t,schema:null,validator:e})}function w(t,e){return new f({...t,refiner:(e,r)=>void 0===e||t.refiner(e,r),validator:(r,n)=>void 0===r||(e(r,n),t.validator(r,n))})}function m(t){return new f({type:\"dynamic\",schema:null,*entries(e,r){const n=t(e,r);yield*n.entries(e,r)},validator:(e,r)=>t(e,r).validator(e,r),coercer:(e,r)=>t(e,r).coercer(e,r),refiner:(e,r)=>t(e,r).refiner(e,r)})}function v(t){let e;return new f({type:\"lazy\",schema:null,*entries(r,n){e??(e=t()),yield*e.entries(r,n)},validator:(r,n)=>(e??(e=t()),e.validator(r,n)),coercer:(r,n)=>(e??(e=t()),e.coercer(r,n)),refiner:(r,n)=>(e??(e=t()),e.refiner(r,n))})}function E(t,e){const{schema:r}=t,n={...r};for(const t of e)delete n[t];return\"type\"===t.type?W(n):F(n)}function _(t){const e=t instanceof f?{...t.schema}:{...t};for(const t in e)e[t]=D(e[t]);return F(e)}function S(t,e){const{schema:r}=t,n={};for(const t of e)n[t]=r[t];return F(n)}function A(t,e){return console.warn(\"superstruct@0.11 - The `struct` helper has been renamed to `define`.\"),b(t,e)}function I(){return b(\"any\",(()=>!0))}function T(t){return new f({type:\"array\",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||`Expected an array value, but received: ${s(t)}`})}function x(){return b(\"bigint\",(t=>\"bigint\"==typeof t))}function O(){return b(\"boolean\",(t=>\"boolean\"==typeof t))}function k(){return b(\"date\",(t=>t instanceof Date&&!isNaN(t.getTime())||`Expected a valid \\`Date\\` object, but received: ${s(t)}`))}function P(t){const e={},r=t.map((t=>s(t))).join();for(const r of t)e[r]=r;return new f({type:\"enums\",schema:e,validator:e=>t.includes(e)||`Expected one of \\`${r}\\`, but received: ${s(e)}`})}function R(){return b(\"func\",(t=>\"function\"==typeof t||`Expected a function, but received: ${s(t)}`))}function B(t){return b(\"instance\",(e=>e instanceof t||`Expected a \\`${t.name}\\` instance, but received: ${s(e)}`))}function C(){return b(\"integer\",(t=>\"number\"==typeof t&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${s(t)}`))}function N(t){return new f({type:\"intersection\",schema:null,*entries(e,r){for(const n of t)yield*n.entries(e,r)},*validator(e,r){for(const n of t)yield*n.validator(e,r)},*refiner(e,r){for(const n of t)yield*n.refiner(e,r)}})}function L(t){const e=s(t),r=typeof t;return new f({type:\"literal\",schema:\"string\"===r||\"number\"===r||\"boolean\"===r?t:null,validator:r=>r===t||`Expected the literal \\`${e}\\`, but received: ${s(r)}`})}function U(t,e){return new f({type:\"map\",schema:null,*entries(r){if(t&&e&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,t],yield[n,i,e]},coercer:t=>t instanceof Map?new Map(t):t,validator:t=>t instanceof Map||`Expected a \\`Map\\` object, but received: ${s(t)}`})}function j(){return b(\"never\",(()=>!1))}function M(t){return new f({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function H(){return b(\"number\",(t=>\"number\"==typeof t&&!isNaN(t)||`Expected a number, but received: ${s(t)}`))}function F(t){const e=t?Object.keys(t):[],r=j();return new f({type:\"object\",schema:t||null,*entries(n){if(t&&i(n)){const i=new Set(Object.keys(n));for(const r of e)i.delete(r),yield[r,n[r],t[r]];for(const t of i)yield[t,n[t],r]}},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`,coercer:t=>i(t)?{...t}:t})}function D(t){return new f({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function $(t,e){return new f({type:\"record\",schema:null,*entries(r){if(i(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`})}function K(){return b(\"regexp\",(t=>t instanceof RegExp))}function V(t){return new f({type:\"set\",schema:null,*entries(e){if(t&&e instanceof Set)for(const r of e)yield[r,r,t]},coercer:t=>t instanceof Set?new Set(t):t,validator:t=>t instanceof Set||`Expected a \\`Set\\` object, but received: ${s(t)}`})}function G(){return b(\"string\",(t=>\"string\"==typeof t||`Expected a string, but received: ${s(t)}`))}function q(t){const e=j();return new f({type:\"tuple\",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;iArray.isArray(t)||`Expected an array, but received: ${s(t)}`})}function W(t){const e=Object.keys(t);return new f({type:\"type\",schema:t,*entries(r){if(i(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`,coercer:t=>i(t)?{...t}:t})}function X(t){const e=t.map((t=>t.type)).join(\" | \");return new f({type:\"union\",schema:null,coercer(e){for(const r of t){const[t,n]=r.validate(e,{coerce:!0});if(!t)return n}return e},validator(r,n){const i=[];for(const e of t){const[...t]=u(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return[`Expected the value to satisfy a union of \\`${e}\\`, but received: ${s(r)}`,...i]}})}function z(){return b(\"unknown\",(()=>!0))}function J(t,e,r){return new f({...t,coercer:(n,i)=>d(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}function Y(t,e,r={}){return J(t,z(),(t=>{const n=\"function\"==typeof e?e():e;if(void 0===t)return n;if(!r.strict&&o(t)&&o(n)){const e={...t};let r=!1;for(const t in n)void 0===e[t]&&(e[t]=n[t],r=!0);if(r)return e}return t}))}function Z(t){return J(t,G(),(t=>t.trim()))}function Q(t){return st(t,\"empty\",(e=>{const r=tt(e);return 0===r||`Expected an empty ${t.type} but received one with a size of \\`${r}\\``}))}function tt(t){return t instanceof Map||t instanceof Set?t.size:t.length}function et(t,e,r={}){const{exclusive:n}=r;return st(t,\"max\",(r=>n?rn?r>e:r>=e||`Expected a ${t.type} greater than ${n?\"\":\"or equal to \"}${e} but received \\`${r}\\``))}function nt(t){return st(t,\"nonempty\",(e=>tt(e)>0||`Expected a nonempty ${t.type} but received an empty one`))}function it(t,e){return st(t,\"pattern\",(r=>e.test(r)||`Expected a ${t.type} matching \\`/${e.source}/\\` but received \"${r}\"`))}function ot(t,e,r=e){const n=`Expected a ${t.type}`,i=e===r?`of \\`${e}\\``:`between \\`${e}\\` and \\`${r}\\``;return st(t,\"size\",(t=>{if(\"number\"==typeof t||t instanceof Date)return e<=t&&t<=r||`${n} ${i} but received \\`${t}\\``;if(t instanceof Map||t instanceof Set){const{size:o}=t;return e<=o&&o<=r||`${n} with a size ${i} but received one with a size of \\`${o}\\``}{const{length:o}=t;return e<=o&&o<=r||`${n} with a length ${i} but received one with a length of \\`${o}\\``}}))}function st(t,e,r){return new f({...t,*refiner(n,i){yield*t.refiner(n,i);const o=c(r(n,i),i,t,n);for(const t of o)yield{...t,refinement:e}}})}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if(\"object\"==typeof globalThis)return globalThis;try{return this||new Function(\"return this\")()}catch(t){if(\"object\"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})};var n={};(()=>{\"use strict\";r.r(n),r.d(n,{onKeyringRequest:()=>Zn,onRpcRequest:()=>Yn,validateOrigin:()=>Jn});var t=r(7962);function e(t){return Boolean(t)&&\"object\"==typeof t&&!Array.isArray(t)}var i=(t,e)=>Object.hasOwnProperty.call(t,e);var o,s=((o=s||{})[o.Null=4]=\"Null\",o[o.Comma=1]=\"Comma\",o[o.Wrapper=1]=\"Wrapper\",o[o.True=4]=\"True\",o[o.False=5]=\"False\",o[o.Quote=1]=\"Quote\",o[o.Colon=1]=\"Colon\",o[o.Date=24]=\"Date\",o);function a(t){if(\"object\"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}}Error;var c=r(7251);function u(t){return function(t){return function(t){return\"object\"==typeof t&&null!==t&&\"message\"in t}(t)&&\"string\"==typeof t.message?t.message:null==t?\"\":String(t)}(t).replace(/\\.$/u,\"\")}function f(t,e){return r=t,Boolean(\"string\"==typeof r?.prototype?.constructor?.name)?new t({message:e}):t({message:e});var r}var h=class extends Error{constructor(t){super(t.message),this.code=\"ERR_ASSERTION\"}};function l(t,e=\"Assertion failed.\",r=h){if(!t){if(e instanceof Error)throw e;throw f(r,e)}}function p(t,e,r=\"Assertion failed\",n=h){try{(0,c.assert)(t,e)}catch(t){throw f(n,`${r}: ${u(t)}.`)}}var d=t=>(0,c.object)(t);function y({path:t,branch:e}){const r=t[t.length-1];return i(e[e.length-2],r)}function g(t){return new c.Struct({...t,type:`optional ${t.type}`,validator:(e,r)=>!y(r)||t.validator(e,r),refiner:(e,r)=>!y(r)||t.refiner(e,r)})}var b=(0,c.union)([(0,c.literal)(null),(0,c.boolean)(),(0,c.define)(\"finite number\",(t=>(0,c.is)(t,(0,c.number)())&&Number.isFinite(t))),(0,c.string)(),(0,c.array)((0,c.lazy)((()=>b))),(0,c.record)((0,c.string)(),(0,c.lazy)((()=>b)))]),w=(0,c.coerce)(b,(0,c.any)(),(t=>(p(t,b),JSON.parse(JSON.stringify(t,((t,e)=>{if(\"__proto__\"!==t&&\"constructor\"!==t)return e}))))));function m(t){try{return function(t){(0,c.create)(t,w)}(t),!0}catch{return!1}}var v=(0,c.literal)(\"2.0\"),E=(0,c.nullable)((0,c.union)([(0,c.number)(),(0,c.string)()])),_=d({code:(0,c.integer)(),message:(0,c.string)(),data:g(w),stack:g((0,c.string)())}),S=(0,c.union)([(0,c.record)((0,c.string)(),w),(0,c.array)(w)]);d({id:E,jsonrpc:v,method:(0,c.string)(),params:g(S)}),d({jsonrpc:v,method:(0,c.string)(),params:g(S)});(0,c.object)({id:E,jsonrpc:v,result:(0,c.optional)((0,c.unknown)()),error:(0,c.optional)(_)});var A=d({id:E,jsonrpc:v,result:w}),I=d({id:E,jsonrpc:v,error:_});(0,c.union)([A,I]);var T=r(2763),x={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},O={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},k={\"-32700\":{standard:\"JSON RPC 2.0\",message:\"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.\"},\"-32600\":{standard:\"JSON RPC 2.0\",message:\"The JSON sent is not a valid Request object.\"},\"-32601\":{standard:\"JSON RPC 2.0\",message:\"The method does not exist / is not available.\"},\"-32602\":{standard:\"JSON RPC 2.0\",message:\"Invalid method parameter(s).\"},\"-32603\":{standard:\"JSON RPC 2.0\",message:\"Internal JSON-RPC error.\"},\"-32000\":{standard:\"EIP-1474\",message:\"Invalid input.\"},\"-32001\":{standard:\"EIP-1474\",message:\"Resource not found.\"},\"-32002\":{standard:\"EIP-1474\",message:\"Resource unavailable.\"},\"-32003\":{standard:\"EIP-1474\",message:\"Transaction rejected.\"},\"-32004\":{standard:\"EIP-1474\",message:\"Method not supported.\"},\"-32005\":{standard:\"EIP-1474\",message:\"Request limit exceeded.\"},4001:{standard:\"EIP-1193\",message:\"User rejected the request.\"},4100:{standard:\"EIP-1193\",message:\"The requested account and/or method has not been authorized by the user.\"},4200:{standard:\"EIP-1193\",message:\"The requested method is not supported by this Ethereum provider.\"},4900:{standard:\"EIP-1193\",message:\"The provider is disconnected from all chains.\"},4901:{standard:\"EIP-1193\",message:\"The provider is disconnected from the specified chain.\"}},P=x.internal,R=\"Unspecified error message. This is a bug, please report it.\",B=(C(P),\"Unspecified server error.\");function C(t,e=R){if(function(t){return Number.isInteger(t)}(t)){const e=t.toString();if(i(k,e))return k[e].message;if(function(t){return t>=-32099&&t<=-32e3}(t))return B}return e}function N(t){return Array.isArray(t)?t.map((t=>m(t)?t:e(t)?L(t):null)):e(t)?L(t):m(t)?t:null}function L(t){return Object.getOwnPropertyNames(t).reduce(((e,r)=>{const n=t[r];return m(n)&&(e[r]=n),e}),{})}var U=r(282),j=class extends Error{constructor(t,e,r){if(!Number.isInteger(t))throw new Error('\"code\" must be an integer.');if(!e||\"string\"!=typeof e)throw new Error('\"message\" must be a non-empty string.');super(e),this.code=t,void 0!==r&&(this.data=r)}serialize(){const t={code:this.code,message:this.message};return void 0!==this.data&&(t.data=this.data,a(this.data)&&(t.data.cause=N(this.data.cause))),this.stack&&(t.stack=this.stack),t}toString(){return U(this.serialize(),H,2)}},M=class extends j{constructor(t,e,r){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('\"code\" must be an integer such that: 1000 <= code <= 4999');super(t,e,r)}};function H(t,e){if(\"[Circular]\"!==e)return e}var F=t=>rt(x.parse,t),D=t=>rt(x.invalidRequest,t),$=t=>rt(x.invalidParams,t),K=t=>rt(x.methodNotFound,t),V=t=>rt(x.internal,t),G=t=>rt(x.invalidInput,t),q=t=>rt(x.resourceNotFound,t),W=t=>rt(x.resourceUnavailable,t),X=t=>rt(x.transactionRejected,t),z=t=>rt(x.methodNotSupported,t),J=t=>rt(x.limitExceeded,t),Y=t=>nt(O.userRejectedRequest,t),Z=t=>nt(O.unauthorized,t),Q=t=>nt(O.unsupportedMethod,t),tt=t=>nt(O.disconnected,t),et=t=>nt(O.chainDisconnected,t);function rt(t,e){const[r,n]=it(e);return new j(t,r??C(t),n)}function nt(t,e){const[r,n]=it(e);return new M(t,r??C(t),n)}function it(t){if(t){if(\"string\"==typeof t)return[t];if(\"object\"==typeof t&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&\"string\"!=typeof e)throw new Error(\"Must specify string message.\");return[e??void 0,r]}}return[]}r(1048).Buffer;!function(){const t=[]}();(0,c.pattern)((0,c.string)(),/^(?:0x)?[0-9a-f]+$/iu),(0,c.pattern)((0,c.string)(),/^0x[0-9a-f]+$/iu),(0,c.pattern)((0,c.string)(),/^0x[0-9a-f]{40}$/u);var ot=(0,c.pattern)((0,c.string)(),/^0x[0-9a-fA-F]{40}$/u);var st,at,ct,ut,ft=(t,e,r)=>{if(!e.has(t))throw TypeError(\"Cannot \"+r)},ht=(t,e,r)=>(ft(t,e,\"read from private field\"),r?r.call(t):e.get(t)),lt=(t,e,r)=>{if(e.has(t))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(t):e.set(t,r)},pt=(t,e,r,n)=>(ft(t,e,\"write to private field\"),n?n.call(t,r):e.set(t,r),r),dt=class extends Error{constructor(t,r={}){const n=function(t){if(e(t)&&i(t,\"message\")&&\"string\"==typeof t.message)return t.message;return String(t)}(t);super(n),lt(this,st,void 0),lt(this,at,void 0),lt(this,ct,void 0),lt(this,ut,void 0),pt(this,at,n),pt(this,st,function(t){if(e(t)&&i(t,\"code\")&&\"number\"==typeof t.code&&Number.isInteger(t.code))return t.code;return-32603}(t));const o={...wt(t),...r};Object.keys(o).length>0&&pt(this,ct,o),pt(this,ut,super.stack)}get name(){return\"SnapError\"}get code(){return ht(this,st)}get message(){return ht(this,at)}get data(){return ht(this,ct)}get stack(){return ht(this,ut)}toJSON(){return{code:gt,message:bt,data:{cause:{code:this.code,message:this.message,stack:this.stack,...this.data?{data:this.data}:{}}}}}serialize(){return this.toJSON()}};function yt(t){return class extends dt{constructor(e,r){if(\"object\"==typeof e){const r=t();return void super({code:r.code,message:r.message,data:e})}const n=t(e);super({code:n.code,message:n.message,data:r})}}}st=new WeakMap,at=new WeakMap,ct=new WeakMap,ut=new WeakMap;var gt=-31002,bt=\"Snap Error\";function wt(t){return e(t)&&i(t,\"data\")&&\"object\"==typeof t.data&&null!==t.data&&m(t.data)&&!Array.isArray(t.data)?t.data:{}}function mt(t){return(0,c.define)(JSON.stringify(t),(0,c.literal)(t).validator)}function vt(t){return mt(t)}function Et(t){return function([t,...e]){const r=(0,c.union)([t,...e]);return new c.Struct({...r,schema:[t,...e]})}(t)}function _t(t){try{return function(t){try{const r=t.trim();l(r.length>0);const n=new T.XMLParser({ignoreAttributes:!1,parseAttributeValue:!0}).parse(r,!0);return l(i(n,\"svg\")),e(n.svg)?n.svg:{}}catch{throw new Error(\"Snap icon must be a valid SVG.\")}}(t),!0}catch{return!1}}var St=yt(V),At=yt(G),It=yt($),Tt=yt(D),xt=yt(J),Ot=yt(K),kt=yt(z),Pt=yt(F),Rt=yt(q),Bt=yt(W),Ct=yt(X),Nt=yt(et),Lt=yt(tt),Ut=yt(Z),jt=yt(Q),Mt=yt(Y);function Ht(t,e,r=[]){return(...n)=>{if(1===n.length&&a(n[0])){const r={...n[0],type:t};return p(r,e,`Invalid ${t} component`),r}const i=r.reduce(((t,e,r)=>void 0!==n[r]?{...t,[e]:n[r]}:t),{type:t});return p(i,e,`Invalid ${t} component`),i}}var Ft,Dt=((Ft=Dt||{}).Copyable=\"copyable\",Ft.Divider=\"divider\",Ft.Heading=\"heading\",Ft.Panel=\"panel\",Ft.Spinner=\"spinner\",Ft.Text=\"text\",Ft.Image=\"image\",Ft.Row=\"row\",Ft.Address=\"address\",Ft.Button=\"button\",Ft.Input=\"input\",Ft.Form=\"form\",Ft),$t=(0,c.object)({type:(0,c.string)()}),Kt=(0,c.assign)($t,(0,c.object)({value:(0,c.unknown)()})),Vt=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"address\"),value:ot})),Gt=(Ht(\"address\",Vt,[\"value\"]),(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"copyable\"),value:(0,c.string)(),sensitive:(0,c.optional)((0,c.boolean)())}))),qt=(Ht(\"copyable\",Gt,[\"value\",\"sensitive\"]),(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"divider\")}))),Wt=Ht(\"divider\",qt),Xt=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"heading\"),value:(0,c.string)()})),zt=Ht(\"heading\",Xt,[\"value\"]);var Jt,Yt,Zt,Qt,te=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"image\"),value:(0,c.refine)((0,c.string)(),\"SVG\",(t=>!!_t(t)||\"Value is not a valid SVG.\"))})),ee=(Ht(\"image\",te,[\"value\"]),(Jt=ee||{}).Primary=\"primary\",Jt.Secondary=\"secondary\",Jt),re=((Yt=re||{}).Button=\"button\",Yt.Submit=\"submit\",Yt),ne=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"button\"),value:(0,c.string)(),variant:(0,c.optional)((0,c.union)([vt(\"primary\"),vt(\"secondary\")])),buttonType:(0,c.optional)((0,c.union)([vt(\"button\"),vt(\"submit\")])),name:(0,c.optional)((0,c.string)())})),ie=(Ht(\"button\",ne,[\"value\",\"buttonType\",\"name\",\"variant\"]),(Zt=ie||{}).Text=\"text\",Zt.Number=\"number\",Zt.Password=\"password\",Zt),oe=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"input\"),value:(0,c.optional)((0,c.string)()),name:(0,c.string)(),inputType:(0,c.optional)((0,c.union)([vt(\"text\"),vt(\"password\"),vt(\"number\")])),placeholder:(0,c.optional)((0,c.string)()),label:(0,c.optional)((0,c.string)()),error:(0,c.optional)((0,c.string)())})),se=(Ht(\"input\",oe,[\"name\",\"inputType\",\"placeholder\",\"value\",\"label\"]),(0,c.union)([oe,ne])),ae=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"form\"),children:(0,c.array)(se),name:(0,c.string)()})),ce=(Ht(\"form\",ae,[\"name\",\"children\"]),(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"text\"),value:(0,c.string)(),markdown:(0,c.optional)((0,c.boolean)())}))),ue=Ht(\"text\",ce,[\"value\",\"markdown\"]),fe=((Qt=fe||{}).Default=\"default\",Qt.Critical=\"critical\",Qt.Warning=\"warning\",Qt),he=(0,c.union)([te,ce,Vt]),le=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"row\"),variant:(0,c.optional)((0,c.union)([vt(\"default\"),vt(\"critical\"),vt(\"warning\")])),label:(0,c.string)(),value:he})),pe=Ht(\"row\",le,[\"label\",\"value\",\"variant\"]),de=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"spinner\")})),ye=(Ht(\"spinner\",de),(0,c.assign)($t,(0,c.object)({children:(0,c.array)((0,c.lazy)((()=>we)))}))),ge=(0,c.assign)(ye,(0,c.object)({type:(0,c.literal)(\"panel\")})),be=Ht(\"panel\",ge,[\"children\"]),we=(0,c.union)([Gt,qt,Xt,te,ge,de,ce,le,Vt,oe,ae,ne]);var me,ve,Ee,_e,Se,Ae,Ie=((me=Ie||{}).Critical=\"critical\",me),Te=((ve=Te||{}).ButtonClickEvent=\"ButtonClickEvent\",ve.FormSubmitEvent=\"FormSubmitEvent\",ve.InputChangeEvent=\"InputChangeEvent\",ve),xe=(0,c.object)({type:(0,c.string)(),name:(0,c.optional)((0,c.string)())}),Oe=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"ButtonClickEvent\"),name:(0,c.optional)((0,c.string)())})),ke=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"FormSubmitEvent\"),value:(0,c.record)((0,c.string)(),(0,c.nullable)((0,c.string)())),name:(0,c.string)()})),Pe=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"InputChangeEvent\"),name:(0,c.string)(),value:(0,c.string)()})),Re=((0,c.union)([Oe,ke,Pe]),(Ee=Re||{}).Alert=\"alert\",Ee.Confirmation=\"confirmation\",Ee.Prompt=\"prompt\",Ee),Be=((_e=Be||{}).Base64=\"base64\",_e.Hex=\"hex\",_e.Utf8=\"utf8\",_e),Ce=((Se=Ce||{}).ClearState=\"clear\",Se.GetState=\"get\",Se.UpdateState=\"update\",Se),Ne=((Ae=Ne||{}).InApp=\"inApp\",Ae.Native=\"native\",Ae),Le=Et([(0,c.string)(),(0,c.number)()]),Ue=je((0,c.string)());(0,c.object)({type:(0,c.string)(),props:(0,c.record)((0,c.string)(),w),key:(0,c.nullable)(Le)});function je(t){return Et([t,(0,c.array)(t)])}function Me(t,e={}){return(0,c.object)({type:mt(t),props:(0,c.object)(e),key:(0,c.nullable)(Le)})}var He,Fe,De=Me(\"Button\",{children:Ue,name:(0,c.optional)((0,c.string)()),type:(0,c.optional)(Et([mt(\"button\"),mt(\"submit\")])),variant:(0,c.optional)(Et([mt(\"primary\"),mt(\"destructive\")])),disabled:(0,c.optional)((0,c.boolean)())}),$e=Me(\"Input\",{name:(0,c.string)(),type:(0,c.optional)(Et([mt(\"text\"),mt(\"password\"),mt(\"number\")])),value:(0,c.optional)((0,c.string)()),placeholder:(0,c.optional)((0,c.string)())}),Ke=Me(\"Option\",{value:(0,c.string)(),children:(0,c.string)()}),Ve=Me(\"Dropdown\",{name:(0,c.string)(),value:(0,c.optional)((0,c.string)()),children:je(Ke)}),Ge=Me(\"Field\",{label:(0,c.optional)((0,c.string)()),error:(0,c.optional)((0,c.string)()),children:Et([(0,c.tuple)([$e,De]),$e,Ve])}),qe=Me(\"Form\",{children:je(Et([Ge,De])),name:(0,c.string)()}),We=Me(\"Bold\",{children:je((0,c.nullable)(Et([(0,c.string)(),(0,c.lazy)((()=>Xe))])))}),Xe=Me(\"Italic\",{children:je((0,c.nullable)(Et([(0,c.string)(),(0,c.lazy)((()=>We))])))}),ze=Et([We,Xe]),Je=Me(\"Address\",{address:ot}),Ye=Me(\"Box\",{children:je((0,c.nullable)((0,c.lazy)((()=>ar)))),direction:(0,c.optional)(Et([mt(\"horizontal\"),mt(\"vertical\")])),alignment:(0,c.optional)(Et([mt(\"start\"),mt(\"center\"),mt(\"end\"),mt(\"space-between\"),mt(\"space-around\")]))}),Ze=Me(\"Copyable\",{value:(0,c.string)(),sensitive:(0,c.optional)((0,c.boolean)())}),Qe=Me(\"Divider\"),tr=Me(\"Value\",{value:(0,c.string)(),extra:(0,c.string)()}),er=Me(\"Heading\",{children:Ue}),rr=Me(\"Image\",{src:(0,c.string)(),alt:(0,c.optional)((0,c.string)())}),nr=Me(\"Link\",{href:(0,c.string)(),children:je((0,c.nullable)(Et([ze,(0,c.string)()])))}),ir=Me(\"Text\",{children:je((0,c.nullable)(Et([(0,c.string)(),We,Xe,nr])))}),or=Me(\"Row\",{label:(0,c.string)(),children:Et([Je,rr,ir,tr]),variant:(0,c.optional)(Et([mt(\"default\"),mt(\"warning\"),mt(\"error\")]))}),sr=Me(\"Spinner\"),ar=Et([De,$e,qe,We,Xe,Je,Ye,Ze,Qe,er,rr,nr,or,sr,ir,Ve]),cr=ar,ur=(Et([De,$e,Ge,qe,We,Xe,Je,Ye,Ze,Qe,er,rr,nr,or,sr,ir,Ve,Ke,tr]),(0,c.record)((0,c.string)(),(0,c.nullable)((0,c.string)())));(0,c.record)((0,c.string)(),(0,c.union)([ur,(0,c.nullable)((0,c.string)())])),(0,c.union)([we,cr]),(0,c.record)((0,c.string)(),w);!function(t){t.Mainnet=\"bip122:000000000019d6689c085ae165831e93\",t.Testnet=\"bip122:000000000933ea01ad0ee984209779ba\"}(He||(He={})),function(t){t.Btc=\"bip122:000000000019d6689c085ae165831e93/slip44:0\",t.TBtc=\"bip122:000000000933ea01ad0ee984209779ba/slip44:0\"}(Fe||(Fe={}));const fr={onChainService:{dataClient:{options:{apiKey:\"A___agdRpkDchYPuxqWhXfFidteuWj4m\"}}},wallet:{defaultAccountIndex:0,defaultAccountType:\"bip122:p2wpkh\"},avaliableNetworks:Object.values(He),avaliableAssets:Object.values(Fe),unit:\"BTC\",explorer:{[He.Mainnet]:\"https://blockstream.info/address/${address}\",[He.Testnet]:\"https://blockstream.info/testnet/address/${address}\"},logLevel:\"6\"},hr={randomUUID:\"undefined\"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let lr;const pr=new Uint8Array(16);function dr(){if(!lr&&(lr=\"undefined\"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!lr))throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");return lr(pr)}const yr=[];for(let t=0;t<256;++t)yr.push((t+256).toString(16).slice(1));function gr(t,e=0){return yr[t[e+0]]+yr[t[e+1]]+yr[t[e+2]]+yr[t[e+3]]+\"-\"+yr[t[e+4]]+yr[t[e+5]]+\"-\"+yr[t[e+6]]+yr[t[e+7]]+\"-\"+yr[t[e+8]]+yr[t[e+9]]+\"-\"+yr[t[e+10]]+yr[t[e+11]]+yr[t[e+12]]+yr[t[e+13]]+yr[t[e+14]]+yr[t[e+15]]}const br=function(t,e,r){if(hr.randomUUID&&!e&&!t)return hr.randomUUID();const n=(t=t||{}).random||(t.rng||dr)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(let t=0;t<16;++t)e[r+t]=n[t];return e}return gr(n)};class wr extends Error{name;constructor(t){super(t),Object.defineProperty(this,\"name\",{value:new.target.name,enumerable:!1,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace(this,this.constructor)}}function mr(t,e){return t instanceof e?t:new e(t.message)}function vr(t){return[dt,Ot,Mt,kt,Ot,Pt,Rt,Bt,Ct,Nt,Lt,Ut,jt,St,At,It,Tt,xt].some((e=>t instanceof e))}var Er=r(1048);function _r(t,e=!0){try{return Er.Buffer.from(e?function(t){return t.startsWith(\"0x\")?t.substring(2):t}(t):t,\"hex\")}catch(t){throw new Error(\"Unable to convert hex string to buffer\")}}function Sr(t,e){try{return t.toString(e)}catch(t){throw new Error(\"Unable to convert buffer to string\")}}const Ar=(0,c.enums)(fr.avaliableAssets),Ir=(0,c.enums)(fr.avaliableNetworks),Tr=(0,c.pattern)((0,c.string)(),/^(?!0\\d)(\\d+(\\.\\d+)?)$/u),xr=(new Error(\"timeout while waiting for mutex to become available\"),new Error(\"mutex already locked\"),new Error(\"request for lock canceled\"));var Or=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};class kr{constructor(t,e=xr){if(this._maxConcurrency=t,this._cancelError=e,this._queue=[],this._waiters=[],t<=0)throw new Error(\"semaphore must be initialized to a positive value\");this._value=t}acquire(){const t=this.isLocked(),e=new Promise(((t,e)=>this._queue.push({resolve:t,reject:e})));return t||this._dispatch(),e}runExclusive(t){return Or(this,void 0,void 0,(function*(){const[e,r]=yield this.acquire();try{return yield t(e)}finally{r()}}))}waitForUnlock(){return Or(this,void 0,void 0,(function*(){if(!this.isLocked())return Promise.resolve();return new Promise((t=>this._waiters.push({resolve:t})))}))}isLocked(){return this._value<=0}release(){if(this._maxConcurrency>1)throw new Error(\"this method is unavailable on semaphores with concurrency > 1; use the scoped release returned by acquire instead\");if(this._currentReleaser){const t=this._currentReleaser;this._currentReleaser=void 0,t()}}cancel(){this._queue.forEach((t=>t.reject(this._cancelError))),this._queue=[]}_dispatch(){const t=this._queue.shift();if(!t)return;let e=!1;this._currentReleaser=()=>{e||(e=!0,this._value++,this._resolveWaiters(),this._dispatch())},t.resolve([this._value--,this._currentReleaser])}_resolveWaiters(){this._waiters.forEach((t=>t.resolve())),this._waiters=[]}}var Pr=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};class Rr{constructor(t){this._semaphore=new kr(1,t)}acquire(){return Pr(this,void 0,void 0,(function*(){const[,t]=yield this._semaphore.acquire();return t}))}runExclusive(t){return this._semaphore.runExclusive((()=>t()))}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Br=new Rr;var Cr;!function(t){t[t.ERROR=1]=\"ERROR\",t[t.WARN=2]=\"WARN\",t[t.INFO=3]=\"INFO\",t[t.DEBUG=4]=\"DEBUG\",t[t.TRACE=5]=\"TRACE\",t[t.ALL=6]=\"ALL\",t[t.OFF=0]=\"OFF\"}(Cr||(Cr={}));const Nr=(t,...e)=>{};const Lr=new class{log;warn;error;debug;info;trace;#t=Cr.OFF;set logLevel(t){this.#t=t,this.init()}get logLevel(){return this.#t}init(){this.error=console.error.bind(console),this.warn=console.warn.bind(console),this.info=console.info.bind(console),this.debug=console.debug.bind(console),this.trace=console.trace.bind(console),this.log=console.log.bind(console),this.#t{const e=await this.get();await t(e),await this.set(e)}))}async withTransaction(t){await this.mtx.runExclusive((async()=>{if(await this.#n(),!this.#e.current||!this.#e.orgState||!this.#e.id)throw new Error(\"Failed to begin transaction\");Lr.info(`SnapStateManager.withTransaction [${this.#r}]: begin transaction`);try{await t(this.#e.current),await this.set(this.#e.current)}catch(t){throw Lr.info(`SnapStateManager.withTransaction [${this.#r}]: error : ${JSON.stringify(t.message)}`),await this.#i(),t}finally{this.#o()}}))}async commit(){if(!this.#e.current||!this.#e.orgState)throw new Error(\"Failed to commit transaction\");this.#e.hasCommited=!0,await this.set(this.#e.current)}async#n(){this.#e={id:br(),orgState:await this.get(),current:await this.get(),isRollingBack:!1,hasCommited:!1}}async#i(){try{this.#e.hasCommited&&!this.#e.isRollingBack&&this.#e.orgState&&(Lr.info(`SnapStateManager.rollback [${this.#r}]: attemp to rollback state`),this.#e.isRollingBack=!0,await this.set(this.#e.orgState))}catch(t){throw Lr.info(`SnapStateManager.rollback [${this.#r}]: error : ${JSON.stringify(t)}`),new Error(\"Failed to rollback state\")}}#o(){this.#e.orgState=void 0,this.#e.current=void 0,this.#e.id=void 0,this.#e.isRollingBack=!1,this.#e.hasCommited=!1}get#r(){return this.#e.id??\"\"}}function jr(t,e){try{(0,c.assert)(t,e)}catch(t){throw new It(t.message)}}function Mr(t,e){try{(0,c.assert)(t,e)}catch(t){throw new dt(\"Invalid Response\")}}var Hr=1e6,Fr=1e6,Dr=\"[big.js] \",$r=Dr+\"Invalid \",Kr=$r+\"decimal places\",Vr=$r+\"rounding mode\",Gr=Dr+\"Division by zero\",qr={},Wr=void 0,Xr=/^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i;function zr(t,e,r,n){var i=t.c;if(r===Wr&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(Vr);if(e<1)n=3===r&&(n||!!i[0])||0===e&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(n||i[1]!==Wr))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e=5||2===r&&(i[e]>5||5===i[e]&&(n||i[e+1]!==Wr||1&i[e-1]))||3===r&&(n||!!i[0]),i.length=e,n)for(;++i[--e]>9;)if(i[e]=0,0===e){++t.e,i.unshift(1);break}for(e=i.length;!i[--e];)i.pop()}return t}function Jr(t,e,r){var n=t.e,i=t.c.join(\"\"),o=i.length;if(e)i=i.charAt(0)+(o>1?\".\"+i.slice(1):\"\")+(n<0?\"e\":\"e+\")+n;else if(n<0){for(;++n;)i=\"0\"+i;i=\"0.\"+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+=\"0\";else n1&&(i=i.charAt(0)+\".\"+i.slice(1));return t.s<0&&r?\"-\"+i:i}qr.abs=function(){var t=new this.constructor(this);return t.s=1,t},qr.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,s=t.s,a=r.e,c=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(e=o<0,a!=c)return a>c^e?1:-1;for(s=(a=n.length)<(c=i.length)?a:c,o=-1;++oi[o]^e?1:-1;return a==c?0:a>c^e?1:-1},qr.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,o=e.s==t.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>Hr)throw Error(Kr);if(!i[0])throw Error(Gr);if(!n[0])return t.s=o,t.c=[t.e=0],t;var a,c,u,f,h,l=i.slice(),p=a=i.length,d=n.length,y=n.slice(0,a),g=y.length,b=t,w=b.c=[],m=0,v=s+(b.e=e.e-t.e)+1;for(b.s=o,o=v<0?0:v,l.unshift(0);g++g?1:-1;else for(h=-1,f=0;++hy[h]?1:-1;break}if(!(f<0))break;for(c=g==a?i:l;g;){if(y[--g]v&&zr(b,v,r.RM,y[0]!==Wr),b},qr.eq=function(t){return 0===this.cmp(t)},qr.gt=function(t){return this.cmp(t)>0},qr.gte=function(t){return this.cmp(t)>-1},qr.lt=function(t){return this.cmp(t)<0},qr.lte=function(t){return this.cmp(t)<1},qr.minus=qr.sub=function(t){var e,r,n,i,o=this,s=o.constructor,a=o.s,c=(t=new s(t)).s;if(a!=c)return t.s=-c,o.plus(t);var u=o.c.slice(),f=o.e,h=t.c,l=t.e;if(!u[0]||!h[0])return h[0]?t.s=-c:u[0]?t=new s(o):t.s=1,t;if(a=f-l){for((i=a<0)?(a=-a,n=u):(l=f,n=h),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(r=((i=u.length0)for(;c--;)u[e++]=0;for(c=e;r>a;){if(u[--r]0?(c=s,n=u):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-u.length<0&&(n=u,u=a,a=n),e=u.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+u[e]+r)/10|0;for(r&&(a.unshift(r),++c),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=c,t},qr.pow=function(t){var e=this,r=new e.constructor(\"1\"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>Fr)throw Error($r+\"exponent\");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},qr.prec=function(t,e){if(t!==~~t||t<1||t>Hr)throw Error($r+\"precision\");return zr(new this.constructor(this),t,e)},qr.round=function(t,e){if(t===Wr)t=0;else if(t!==~~t||t<-Hr||t>Hr)throw Error(Kr);return zr(new this.constructor(this),t+this.e+1,e)},qr.sqrt=function(){var t,e,r,n=this,i=n.constructor,o=n.s,s=n.e,a=new i(\"0.5\");if(!n.c[0])return new i(n);if(o<0)throw Error(Dr+\"No square root\");0===(o=Math.sqrt(n+\"\"))||o===1/0?((e=n.c.join(\"\")).length+s&1||(e+=\"0\"),s=((s+1)/2|0)-(s<0||1&s),t=new i(((o=Math.sqrt(e))==1/0?\"5e\":(o=o.toExponential()).slice(0,o.indexOf(\"e\")+1))+s)):t=new i(o+\"\"),s=t.e+(i.DP+=4);do{r=t,t=a.times(r.plus(n.div(r)))}while(r.c.slice(0,s).join(\"\")!==t.c.slice(0,s).join(\"\"));return zr(t,(i.DP-=4)+t.e+1,i.RM)},qr.times=qr.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,s=i.length,a=o.length,c=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=c+u,sc;)a=e[u]+o[c]*i[u-c-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},qr.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==Wr){if(t!==~~t||t<0||t>Hr)throw Error(Kr);for(r=zr(new r.constructor(r),++t,e);r.c.lengthHr)throw Error(Kr);for(t=t+(r=zr(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length=e.PE,!!t.c[0])},qr.toNumber=function(){var t=Number(Jr(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(Dr+\"Imprecise conversion\");return t},qr.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==Wr){if(t!==~~t||t<1||t>Hr)throw Error($r+\"precision\");for(r=zr(new n(r),t,e);r.c.length=n.PE,!!i)},qr.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(Dr+\"valueOf disallowed\");return Jr(t,t.e<=e.NE||t.e>=e.PE,!0)};var Yr=function t(){function e(r){var n=this;if(!(n instanceof e))return r===Wr?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if(\"string\"!=typeof r){if(!0===e.strict&&\"bigint\"!=typeof r)throw TypeError($r+\"value\");r=0===r&&1/r<0?\"-0\":String(r)}!function(t,e){var r,n,i;if(!Xr.test(e))throw Error($r+\"number\");t.s=\"-\"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf(\".\"))>-1&&(e=e.replace(\".\",\"\"));(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length);for(i=e.length,n=0;n0&&\"0\"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=qr,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();const Zr=Yr,Qr=21e14;function tn(t,e=!1){if(\"number\"==typeof t&&!Number.isInteger(t))throw new Error(\"satsToBtc must be called on an integer number\");const r=new Zr(t).div(1e8).toFixed(8);return e?`${r} ${fr.unit}`:r}function en(t){const e=t.split(\".\");if(e.length>1&&e[1].length>8)throw new Error(\"BTC amount is out of range\");const r=new Zr(t).times(1e8);if(r.lt(0)||r.gt(Qr))throw new Error(\"BTC amount is out of range\");return BigInt(r.toFixed(0))}class rn extends wr{}class nn extends wr{}var on,sn,an,cn=r(7612);class un{_dataClient;_options;constructor(t,e){this._dataClient=t,this._options=e}get network(){return this._options.network}async getBalances(t,e){try{if(e.length>1)throw new nn(\"Only one asset is supported\");if(!new Set(Object.values(Fe)).has(e[0])||this.network===cn.o8.testnet&&e[0]!==Fe.TBtc||this.network===cn.o8.bitcoin&&e[0]!==Fe.Btc)throw new nn(\"Invalid asset\");const r=await this._dataClient.getBalances(t);return t.reduce(((t,n)=>(t.balances[n]={[e[0]]:{amount:BigInt(r[n])}},t)),{balances:{}})}catch(t){throw mr(t,nn)}}async getFeeRates(){try{const t=await this._dataClient.getFeeRates();return{fees:Object.entries(t).map((([t,e])=>({type:t,rate:BigInt(e)})))}}catch(t){throw mr(t,nn)}}async getTransactionStatus(t){try{return await this._dataClient.getTransactionStatus(t)}catch(t){throw new nn(t)}}async getDataForTransaction(t){try{return{data:{utxos:await this._dataClient.getUtxos(t)}}}catch(t){throw mr(t,nn)}}async broadcastTransaction(t){try{return{transactionId:await this._dataClient.sendTransaction(t)}}catch(t){throw mr(t,nn)}}listTransactions(){throw new Error(\"Method not implemented.\")}}!function(t){t.Fast=\"fast\",t.Medium=\"medium\",t.Slow=\"slow\"}(on||(on={})),function(t){t.Confirmed=\"confirmed\",t.Pending=\"pending\",t.Failed=\"failed\"}(sn||(sn={}));class fn{_options;constructor(t){this._options=t}get baseUrl(){switch(this._options.network){case cn.o8.bitcoin:return\"https://api.blockchair.com/bitcoin\";case cn.o8.testnet:return\"https://api.blockchair.com/bitcoin/testnet\";default:throw new Error(\"Invalid network\")}}getApiUrl(t){const e=new URL(`${this.baseUrl}${t}`);return this._options.apiKey&&e.searchParams.append(\"key\",this._options.apiKey),e.toString()}async get(t){const e=await fetch(this.getApiUrl(t),{method:\"GET\"});if(!e.ok)throw new Error(`Failed to fetch data from blockchair: ${e.statusText}`);return e.json()}async post(t,e){const r=await fetch(this.getApiUrl(t),{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(e)});if(400==r.status){const t=await r.json();throw new Error(`Failed to post data from blockchair: ${t.context.error}`)}if(!r.ok)throw new Error(`Failed to post data from blockchair: ${r.statusText}`);return r.json()}async getTxDashboardData(t){try{Lr.info(\"[BlockChairClient.getTxDashboardData] start:\");const e=await this.get(`/dashboards/transaction/${t}`);return Lr.info(`[BlockChairClient.getTxDashboardData] response: ${JSON.stringify(e)}`),e}catch(t){throw Lr.info(`[BlockChairClient.getTxDashboardData] error: ${t.message}`),mr(t,rn)}}async getBalances(t){try{Lr.info(`[BlockChairClient.getBalance] start: { addresses : ${JSON.stringify(t)} }`);const e=await this.get(`/addresses/balances?addresses=${t.join(\",\")}`);return Lr.info(`[BlockChairClient.getBalance] response: ${JSON.stringify(e)}`),t.reduce(((t,r)=>(t[r]=e.data[r]??0,t)),{})}catch(t){throw Lr.info(`[BlockChairClient.getBalance] error: ${t.message}`),mr(t,rn)}}async getUtxos(t,e){try{let r=!0,n=0;const i=1e3,o=[];for(;r;){let s=`/dashboards/address/${t}?limit=0,${i}&offset=0,${n}`;e||(s+=\"&state=latest\");const a=await this.get(s);if(Lr.info(`[BlockChairClient.getUtxos] response: ${JSON.stringify(a)}`),!Object.prototype.hasOwnProperty.call(a.data,t))throw new Error(\"Data not avaiable\");a.data[t].utxo.forEach((t=>{o.push({block:t.block_id,txHash:t.transaction_hash,index:t.index,value:t.value})})),n+=1,a.data[t].utxo.lengththis.validateInputs(t,e,r))))throw new dn(\"Invalid signature to sign the PSBT's inputs\")}catch(t){throw mr(t,dn)}}finalize(){try{this._psbt.finalizeAllInputs();const t=this._psbt.extractTransaction().toHex();if(this._psbt.extractTransaction().weight()>4e5)throw new dn(\"Transaction is too large\");return t}catch(t){throw mr(t,dn)}}validateInputs(t,e,r){return xn.fromPublicKey(t).verify(e,r)}}class kn{publicKey;fingerprint;_node;constructor(t,e){this._node=t,this.publicKey=this._node.publicKey,this.fingerprint=e??this._node.fingerprint}derivePath(t){try{let e=t.split(\"/\");\"m\"===e[0]&&(e=e.slice(1));const r=e.reduce(((t,e)=>{let r;return e.endsWith(\"'\")?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this._node);return new kn(r,this.fingerprint)}catch(t){throw new Error(\"Unable to derive path\")}}async sign(t){return this._node.sign(t)}verify(t,e){return this._node.verify(t,e)}}class Pn{sender;_change;_recipients;_outputTotal;_txFee;_feeRate;constructor(t,e){this.feeRate=e,this.txFee=0,this.sender=t,this._recipients=[],this._outputTotal=BigInt(0)}addRecipients(t){for(const e of t)this.addRecipient(e)}addRecipient(t){this._outputTotal+=t.bigIntValue,this._recipients.push({address:t.address,value:t.bigIntValue})}addChange(t){this._change={address:t.address,value:t.bigIntValue}}set txFee(t){this._txFee=\"number\"==typeof t?BigInt(t):t}get txFee(){return this._txFee}set feeRate(t){this._feeRate=\"number\"==typeof t?BigInt(t):t}get feeRate(){return this._feeRate}get total(){return this._outputTotal+(this.change?BigInt(this.change.value):BigInt(0))+this.txFee}get recipients(){return this._recipients}get change(){return this._change}}class Rn{_value;script;txHash;index;block;constructor(t,e){this.script=e,this._value=BigInt(t.value),this.index=t.index,this.txHash=t.txHash,this.block=t.block}get value(){return Number(this._value)}get bigIntValue(){return this._value}}class Bn{_value;script;address;constructor(t,e,r){this.value=t,this.address=e,this.script=r}get value(){return Number(this._value)}set value(t){this._value=\"number\"==typeof t?BigInt(t):t}get bigIntValue(){return this._value}}class Cn{_deriver;_network;constructor(t,e){this._deriver=t,this._network=e}async unlock(t,e){try{const r=this.getAccountCtor(e??an.P2wpkh),n=await this._deriver.getRoot(r.path),i=await this._deriver.getChild(n,t),o=[\"m\",\"0'\",\"0\",`${t}`].join(\"/\");return new r(Sr(n.fingerprint,\"hex\"),t,o,Sr(i.publicKey,\"hex\"),this._network,r.scriptType,`bip122:${r.scriptType.toLowerCase()}`,this.getHdSigner(n))}catch(t){throw mr(t,ln)}}async createTransaction(t,e,r){const n=t.script,{scriptType:i}=t,o=r.utxos.map((t=>new Rn(t,n))),s=e.map((t=>{if(bn(t.value,i))throw new pn(\"Transaction amount too small\");const e=function(t,e){try{return cn.hl.toOutputScript(t,e)}catch(t){throw new Error(\"Destination address has no matching Script\")}}(t.address,this._network);return new Bn(t.value,t.address,e)})),a=Math.max(1,r.fee),c=new Tn(a),u=new Bn(0,t.address,n),f=c.selectCoins(o,s,u),h=new On(this._network);h.addInputs(f.inputs,r.replaceable,t.hdPath,_r(t.pubkey,!1),_r(t.mfp,!1));const l=new Pn(t.address,a);for(const t of f.outputs)h.addOutput(t),l.addRecipient(t);f.change&&(bn(u.value,i)?Lr.warn(\"[BtcWallet.createTransaction] Change is too small, adding to fees\"):(h.addOutput(f.change),l.addChange(f.change)));const p=await h.signDummy(t.signer);return l.txFee=p.getFee(),{tx:h.toBase64(),txInfo:l}}async signTransaction(t,e){const r=On.fromBase64(this._network,e);return await r.signNVerify(t),r.finalize()}getHdSigner(t){return new kn(t,t.fingerprint)}getAccountCtor(t){let e=t;switch(t.includes(\"bip122:\")&&(e=t.split(\":\")[1]),e.toLowerCase()){case an.P2wpkh.toLowerCase():return mn;case an.P2shP2wkh.toLowerCase():return vn;default:throw new ln(\"Invalid script type\")}}}class Nn{static createOnChainServiceProvider(t){var e,r;const n=gn(t),i=new fn({network:n,apiKey:null===(r=fr.onChainService.dataClient.options)||void 0===r||null===(e=r.apiKey)||void 0===e?void 0:e.toString()});return new un(i,{network:n})}static createWallet(t){const e=gn(t);return new Cn(new Sn(e),e)}}class Ln extends Ur{async get(){return super.get().then((t=>(t||(t={walletIds:[],wallets:{}}),t.walletIds||(t.walletIds=[]),t.wallets||(t.wallets={}),t)))}async listAccounts(){try{const t=await this.get();return t.walletIds.map((e=>t.wallets[e].account))}catch(t){throw mr(t,Error)}}async addWallet(t){try{await this.update((async e=>{const{id:r,address:n}=t.account;if(this.isAccountExist(e,r)||this.getAccountByAddress(e,n))throw new Error(`Account address ${n} already exists`);e.wallets[r]=t,e.walletIds.push(r)}))}catch(t){throw mr(t,Error)}}async updateAccount(t){try{await this.update((async e=>{if(!this.isAccountExist(e,t.id))throw new Error(`Account id ${t.id} does not exist`);const r=e.wallets[t.id].account;if(r.address.toLowerCase()!==t.address.toLowerCase()||r.type!==t.type)throw new Error(\"Account address or type is immutable\");e.wallets[t.id].account=t}))}catch(t){throw mr(t,Error)}}async removeAccounts(t){try{await this.update((async e=>{const r=new Set;for(const n of t){if(!this.isAccountExist(e,n))throw new Error(`Account id ${n} does not exist`);r.add(n)}r.forEach((t=>delete e.wallets[t])),e.walletIds=e.walletIds.filter((t=>!r.has(t)))}))}catch(t){throw mr(t,Error)}}async getAccount(t){try{var e;return(null===(e=(await this.get()).wallets[t])||void 0===e?void 0:e.account)??null}catch(t){throw mr(t,Error)}}async getWallet(t){try{return(await this.get()).wallets[t]??null}catch(t){throw mr(t,Error)}}getAccountByAddress(t,e){var r;return(null===(r=Object.values(t.wallets).find((t=>t.account.address.toString()===e.toLowerCase())))||void 0===r?void 0:r.account)??null}isAccountExist(t,e){return Object.prototype.hasOwnProperty.call(t.wallets,e)}}(0,c.object)({scope:Ir});const Un=(0,c.object)({assets:(0,c.array)(Ar),scope:Ir});(0,c.object)({assets:(0,c.record)(Ar,(0,c.object)({amount:Tr,unit:(0,c.enums)([fr.unit])}))});const jn=(0,c.object)({transactionId:(0,c.string)(),scope:Ir}),Mn=(0,c.object)({status:(0,c.enums)(Object.values(sn))});const Hn=(0,c.refine)((0,c.record)(t.BtcP2wpkhAddressStruct,(0,c.string)()),\"TransactionAmountStuct\",(t=>{if(0===Object.entries(t).length)return\"Transaction must have at least one recipient\";for(const e of Object.values(t)){const t=parseFloat(e);if(Number.isNaN(t)||t<=0||!Number.isFinite(t))return\"Invalid amount for send\";try{en(e)}catch(t){return\"Invalid amount for send\"}}return!0})),Fn=(0,c.object)({amounts:Hn,comment:(0,c.string)(),subtractFeeFrom:(0,c.array)(t.BtcP2wpkhAddressStruct),replaceable:(0,c.boolean)(),dryrun:(0,c.optional)((0,c.boolean)()),scope:Ir}),Dn=(0,c.object)({txId:(0,c.nonempty)((0,c.string)()),txHash:(0,c.optional)((0,c.string)())});async function $n(t,e){try{jr(e,Fn);const{dryrun:r,scope:n}=e,i=Nn.createOnChainServiceProvider(n),o=Nn.createWallet(n),s=await i.getFeeRates();if(0===s.fees.length)throw new Error(\"No fee rates available\");const a=Math.max(Number(s.fees[s.fees.length-1].rate),1),c=Object.entries(e.amounts).map((([t,e])=>({address:t,value:en(e)}))),u=await i.getDataForTransaction(t.address),{tx:f,txInfo:h}=await o.createTransaction(t,c,{utxos:u.data.utxos,fee:a,subtractFeeFrom:e.subtractFeeFrom,replaceable:e.replaceable});if(!await async function(t,e,r){const n=\"Send Request\",i=\"Review the request before proceeding. Once the transaction is made, it's irreversible.\",o=\"Recipient\",s=\"Amount\",a=\"Comment\",c=\"Network fee\",u=\"Total\",f=\"Requested by\",h=[be([zt(n),ue(i),pe(f,ue(\"[portfolio.metamask.io](https://portfolio.metamask.io/)\"))]),Wt()],l=t.recipients.length+(t.change?1:0)>1;let p=0;const d=t=>{const e=[];e.push(pe(l?`${o} ${p+1}`:o,ue(`[${function(t){return function(t,e,r,n=\"...\"){return t?`${t.substring(0,e)}${n}${t.substring(t.length-r)}`:t}(t,5,3)}(t.address)}](${function(t,e){switch(e){case He.Mainnet:return fr.explorer[He.Mainnet].replace(\"${address}\",t);case He.Testnet:return fr.explorer[He.Testnet].replace(\"${address}\",t);default:throw new Error(\"Invalid Chain ID\")}}(t.address,r)})`))),e.push(pe(s,ue(tn(t.value,!0),!1))),p+=1,h.push(be(e)),h.push(Wt())};t.recipients.forEach(d),t.change&&[t.change].forEach(d);const y=[];e.trim().length>0&&y.push(pe(a,ue(e.trim(),!1)));return y.push(pe(c,ue(`${tn(t.txFee,!0)}`,!1))),y.push(pe(u,ue(`${tn(t.total,!0)}`,!1))),h.push(be(y)),await async function(t){return snap.request({method:\"snap_dialog\",params:{type:\"confirmation\",content:be(t)}})}(h)}(h,e.comment,n))throw new Mt;const l=await o.signTransaction(t.signer,f);if(r)return{txId:\"\",txHash:l};const p={txId:(await i.broadcastTransaction(l)).transactionId};return Mr(p,Dn),p}catch(t){if(Lr.error(\"Failed to send the transaction\",t),vr(t))throw t;if(t instanceof pn)throw t;throw new Error(\"Failed to send the transaction\")}}const Kn=(0,c.object)({scope:Ir});class Vn{_stateMgr;_options;_methods=[\"btc_sendmany\"];constructor(t,e){this._stateMgr=t,this._options=e}async listAccounts(){try{return await this._stateMgr.listAccounts()}catch(t){throw new Error(t)}}async getAccount(t){try{return await this._stateMgr.getAccount(t)??void 0}catch(t){throw new Error(t)}}async createAccount(e){try{(0,c.assert)(e,Kn);const r=this.getBtcWallet(e.scope),n=this._options.defaultIndex,i=fr.wallet.defaultAccountType,o=await this.discoverAccount(r,n,i);Lr.info(`[BtcKeyring.createAccount] Account unlocked: ${o.address}`);const s=this.newKeyringAccount(o,{scope:e.scope,index:n});return Lr.info(`[BtcKeyring.createAccount] Keyring account data: ${JSON.stringify(s)}`),await this._stateMgr.withTransaction((async()=>{await this._stateMgr.addWallet({account:s,hdPath:o.hdPath,index:o.index,scope:e.scope}),await this.#c(t.KeyringEvent.AccountCreated,{account:s})})),s}catch(t){if(Lr.info(`[BtcKeyring.createAccount] Error: ${t.message}`),t instanceof c.StructError)throw new Error(\"Invalid params to create an account\");throw new Error(t)}}async filterAccountChains(t,e){throw new Error(\"Method not implemented.\")}async updateAccount(e){try{await this._stateMgr.withTransaction((async()=>{await this._stateMgr.updateAccount(e),await this.#c(t.KeyringEvent.AccountUpdated,{account:e})}))}catch(t){throw Lr.info(`[BtcKeyring.updateAccount] Error: ${t.message}`),new Error(t)}}async deleteAccount(e){try{await this._stateMgr.withTransaction((async()=>{await this._stateMgr.removeAccounts([e]),await this.#c(t.KeyringEvent.AccountDeleted,{id:e})}))}catch(t){throw Lr.info(`[BtcKeyring.deleteAccount] Error: ${t.message}`),new Error(t)}}async submitRequest(t){return{pending:!1,result:await this.handleSubmitRequest(t)}}async handleSubmitRequest(t){const{scope:e,account:r}=t,{method:n,params:i}=t.request,o=await this.getWalletData(r);if(o.scope!==e)throw new Error(\"Account's scope does not match with the request's scope\");const s=this.getBtcWallet(o.scope),a=await this.discoverAccount(s,o.index,o.account.type);if(this.verifyIfAccountValid(a,o.account),\"btc_sendmany\"===n)return await $n(a,{...i,scope:o.scope});throw new Ot(n)}async#c(e,r){this._options.emitEvents&&await(0,t.emitSnapKeyringEvent)(snap,e,r)}async getAccountBalances(t,e){try{const r=await this.getWalletData(t),n=this.getBtcWallet(r.scope),i=await this.discoverAccount(n,r.index,r.account.type);return this.verifyIfAccountValid(i,r.account),await async function(t,e){try{jr(e,Un),(0,c.assert)(e,Un);const{assets:r,scope:n}=e,i=Nn.createOnChainServiceProvider(n),o=[t.address],s=new Set(o),a=new Set(r),u=await i.getBalances(o,r),f=Object.entries(u.balances),h=new Map;for(const[t,e]of f)if(s.has(t))for(const t in e){if(!a.has(t))continue;const{amount:r}=e[t];let n=h.get(t);n&&(n+=r),h.set(t,n??r)}const l=Object.fromEntries([...h.entries()].map((([t,e])=>[t,{amount:tn(e),unit:fr.unit}])));return Mr(e,Un),l}catch(t){if(Lr.error(\"Failed to get balances\",t),vr(t))throw t;throw new Error(\"Fail to get the balances\")}}(i,{assets:e,scope:r.scope})}catch(t){throw Lr.info(`[BtcKeyring.getAccountBalances] Error: ${t.message}`),new Error(t)}}async getWalletData(t){const e=await this._stateMgr.getWallet(t);if(!e)throw new Error(\"Account not found\");return e}getBtcWallet(t){return Nn.createWallet(t)}async discoverAccount(t,e,r){return await t.unlock(e,r)}verifyIfAccountValid(t,e){if(!t||t.address!==e.address)throw new Error(\"Account not found\")}newKeyringAccount(t,e){return{type:t.type,id:br(),address:t.address,options:{...e},methods:this._methods}}}var Gn;!function(t){t.GetTransactionStatus=\"chain_getTransactionStatus\",t.CreateAccount=\"chain_createAccount\"}(Gn||(Gn={}));const qn=new Set([t.KeyringRpcMethod.ListAccounts,t.KeyringRpcMethod.GetAccount,t.KeyringRpcMethod.CreateAccount,t.KeyringRpcMethod.FilterAccountChains,t.KeyringRpcMethod.ListRequests,t.KeyringRpcMethod.GetRequest,t.KeyringRpcMethod.ApproveRequest,t.KeyringRpcMethod.RejectRequest,t.KeyringRpcMethod.SubmitRequest,t.KeyringRpcMethod.GetAccountBalances,Gn.GetTransactionStatus]),Wn=new Set([t.KeyringRpcMethod.ListAccounts,t.KeyringRpcMethod.GetAccount,t.KeyringRpcMethod.CreateAccount,t.KeyringRpcMethod.FilterAccountChains,t.KeyringRpcMethod.UpdateAccount,t.KeyringRpcMethod.DeleteAccount,t.KeyringRpcMethod.ListRequests,t.KeyringRpcMethod.GetRequest,t.KeyringRpcMethod.ApproveRequest,t.KeyringRpcMethod.RejectRequest,t.KeyringRpcMethod.SubmitRequest,t.KeyringRpcMethod.GetAccountBalances,Gn.GetTransactionStatus]),Xn=[\"https://portfolio.metamask.io\",\"https://portfolio-builds.metafi-dev.codefi.network\",\"https://dev.portfolio.metamask.io\",\"https://ramps-dev.portfolio.metamask.io\"],zn=new Map([]);for(const t of Xn)zn.set(t,qn);zn.set(\"metamask\",Wn),zn.set(\"http://localhost:3000\",new Set([...qn,Gn.CreateAccount]));const Jn=(t,e)=>{var r;if(!t)throw new Ut(\"Origin not found\");if(!(null===(r=zn.get(t))||void 0===r?void 0:r.has(e)))throw new Ut(\"Permission denied\")},Yn=async({origin:t,request:e})=>{Lr.logLevel=parseInt(fr.logLevel,10);try{const{method:r}=e;switch(Jn(t,r),r){case Gn.CreateAccount:return await async function(t){const e=new Vn(new Ln,{defaultIndex:fr.wallet.defaultAccountIndex,emitEvents:!1});return await e.createAccount({scope:t.scope})}(e.params);case Gn.GetTransactionStatus:return await async function(t){try{jr(t,jn);const{scope:e,transactionId:r}=t,n=Nn.createOnChainServiceProvider(e),i={status:(await n.getTransactionStatus(r)).status};return Mr(i,Mn),i}catch(t){if(Lr.error(\"Failed to get transaction status\",t),vr(t))throw t;throw new Error(\"Fail to get the transaction status\")}}(e.params);default:throw new Ot(r)}}catch(t){let e=t;throw vr(t)||(e=new dt(t)),Lr.error(`onRpcRequest error: ${JSON.stringify(e.toJSON(),null,2)}`),e}},Zn=async({origin:e,request:r})=>{Lr.logLevel=parseInt(fr.logLevel,10);try{Jn(e,r.method);const n=new Vn(new Ln,{defaultIndex:fr.wallet.defaultAccountIndex,emitEvents:!0});return await(0,t.handleKeyringRequest)(n,r)}catch(t){let e=t;throw vr(t)||(e=new dt(t)),Lr.error(`onKeyringRequest error: ${JSON.stringify(e.toJSON(),null,2)}`),e}}})();var i=exports;for(var o in n)i[o]=n[o];n.__esModule&&Object.defineProperty(i,\"__esModule\",{value:!0})})();"}],"removable":false} \ No newline at end of file diff --git a/app/scripts/snaps/preinstalled-snaps.ts b/app/scripts/snaps/preinstalled-snaps.ts index 4d94e8a86354..bc3bbab76880 100644 --- a/app/scripts/snaps/preinstalled-snaps.ts +++ b/app/scripts/snaps/preinstalled-snaps.ts @@ -1,7 +1,7 @@ import type { PreinstalledSnap } from '@metamask/snaps-controllers'; import MessageSigningSnap from '@metamask/message-signing-snap/dist/preinstalled-snap.json'; ///: BEGIN:ONLY_INCLUDE_IF(build-flask) -import BitcoinManagerSnap from '@consensys/bitcoin-manager-snap/dist/preinstalled-snap.json'; +import BitcoinManagerSnap from './bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json'; ///: END:ONLY_INCLUDE_IF const PREINSTALLED_SNAPS: readonly PreinstalledSnap[] = Object.freeze([ diff --git a/package.json b/package.json index 80004d72de66..d57e25eaeaff 100644 --- a/package.json +++ b/package.json @@ -260,7 +260,6 @@ "dependencies": { "@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", "@blockaid/ppom_release": "^1.4.8", - "@consensys/bitcoin-manager-snap": "0.1.4-rc4", "@contentful/rich-text-html-renderer": "^16.3.5", "@ensdomains/content-hash": "^2.5.7", "@ethereumjs/tx": "^4.1.1", diff --git a/yarn.lock b/yarn.lock index 1c02f865d9df..035e63c8c6a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1710,16 +1710,6 @@ __metadata: languageName: node linkType: hard -"@bitcoinerlab/secp256k1@npm:^1.1.1": - version: 1.1.1 - resolution: "@bitcoinerlab/secp256k1@npm:1.1.1" - dependencies: - "@noble/hashes": "npm:^1.1.5" - "@noble/secp256k1": "npm:^1.7.1" - checksum: 10/708fad4b2bff19411ee13b18821085a86ec70d9dae79965768f1e2c2de4fe887fb47522dbfe7ca5f2ff25a900aa909420c648bfadda1217795053bbcf248ec49 - languageName: node - linkType: hard - "@blockaid/ppom_release@npm:^1.4.8": version: 1.4.8 resolution: "@blockaid/ppom_release@npm:1.4.8" @@ -1768,27 +1758,6 @@ __metadata: languageName: node linkType: hard -"@consensys/bitcoin-manager-snap@npm:0.1.4-rc4": - version: 0.1.4-rc4 - resolution: "@consensys/bitcoin-manager-snap@npm:0.1.4-rc4" - dependencies: - "@bitcoinerlab/secp256k1": "npm:^1.1.1" - "@metamask/key-tree": "npm:^9.0.0" - "@metamask/keyring-api": "npm:^8.0.0" - "@metamask/snaps-sdk": "npm:^4.0.0" - async-mutex: "npm:^0.3.2" - big.js: "npm:^6.2.1" - bip32: "npm:^4.0.0" - bitcoinjs-lib: "npm:^6.1.5" - buffer: "npm:^6.0.3" - coinselect: "npm:^3.1.13" - ecpair: "npm:^2.1.0" - superstruct: "npm:^1.0.3" - uuid: "npm:^9.0.1" - checksum: 10/dc66b27f71e330195547ecad6de39a2886b34347ec536567423c9b12a483ef9e409d4ad8372e9362d8a37dfcb72267f09da5f2705dc8c75735b7dd8eaec7b400 - languageName: node - linkType: hard - "@contentful/rich-text-html-renderer@npm:^16.3.5": version: 16.3.5 resolution: "@contentful/rich-text-html-renderer@npm:16.3.5" @@ -5627,7 +5596,7 @@ __metadata: languageName: node linkType: hard -"@metamask/key-tree@npm:^9.0.0, @metamask/key-tree@npm:^9.1.1": +"@metamask/key-tree@npm:^9.1.1": version: 9.1.1 resolution: "@metamask/key-tree@npm:9.1.1" dependencies: @@ -6677,7 +6646,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.1.2, @noble/hashes@npm:^1.1.5, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0": +"@noble/hashes@npm:1.4.0, @noble/hashes@npm:^1.1.2, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.3.1, @noble/hashes@npm:^1.3.2, @noble/hashes@npm:^1.3.3, @noble/hashes@npm:^1.4.0": version: 1.4.0 resolution: "@noble/hashes@npm:1.4.0" checksum: 10/e156e65794c473794c52fa9d06baf1eb20903d0d96719530f523cc4450f6c721a957c544796e6efd0197b2296e7cd70efeb312f861465e17940a3e3c7e0febc6 @@ -6698,7 +6667,7 @@ __metadata: languageName: node linkType: hard -"@noble/secp256k1@npm:^1.7.0, @noble/secp256k1@npm:^1.7.1": +"@noble/secp256k1@npm:^1.7.0": version: 1.7.1 resolution: "@noble/secp256k1@npm:1.7.1" checksum: 10/214d4756c20ed20809d948d0cc161e95664198cb127266faf747fd7deffe5444901f05fe9f833787738f2c6e60b09e544c2f737f42f73b3699e3999ba15b1b63 @@ -12541,7 +12510,7 @@ __metadata: languageName: node linkType: hard -"async-mutex@npm:^0.3.1, async-mutex@npm:^0.3.2": +"async-mutex@npm:^0.3.1": version: 0.3.2 resolution: "async-mutex@npm:0.3.2" dependencies: @@ -13070,13 +13039,6 @@ __metadata: languageName: node linkType: hard -"big.js@npm:^6.2.1": - version: 6.2.1 - resolution: "big.js@npm:6.2.1" - checksum: 10/1d4b621451de712cab20464a26f22b2eee5e7daf0ee88c49dfbfa76061ec37cff2257751e8c3fc183c231bcffac2f006e33af930d8f49b03c758890080b76ada - languageName: node - linkType: hard - "bigint-buffer@npm:^1.1.5": version: 1.1.5 resolution: "bigint-buffer@npm:1.1.5" @@ -13129,25 +13091,6 @@ __metadata: languageName: node linkType: hard -"bip174@npm:^2.1.1": - version: 2.1.1 - resolution: "bip174@npm:2.1.1" - checksum: 10/b90da3f9fe5b076a3d7b125a9dd39345a8cd8ece2dcc328a19c92948a60d7242886235bc94712935c71a9c5bc445b98a3570dca8881d19d421fc88a30b150b46 - languageName: node - linkType: hard - -"bip32@npm:^4.0.0": - version: 4.0.0 - resolution: "bip32@npm:4.0.0" - dependencies: - "@noble/hashes": "npm:^1.2.0" - "@scure/base": "npm:^1.1.1" - typeforce: "npm:^1.11.5" - wif: "npm:^2.0.6" - checksum: 10/f2da719618b26e2fdec3d0bc4945cf7dc435ff93eaeebc0b6b70b8911e7a33128cf77c4c0bce45be679c5f2a96aa5128dbed329193a9f88d755ff9c90185b6a0 - languageName: node - linkType: hard - "bip66@npm:^1.1.5": version: 1.1.5 resolution: "bip66@npm:1.1.5" @@ -13164,20 +13107,6 @@ __metadata: languageName: node linkType: hard -"bitcoinjs-lib@npm:^6.1.5": - version: 6.1.6 - resolution: "bitcoinjs-lib@npm:6.1.6" - dependencies: - "@noble/hashes": "npm:^1.2.0" - bech32: "npm:^2.0.0" - bip174: "npm:^2.1.1" - bs58check: "npm:^3.0.1" - typeforce: "npm:^1.11.3" - varuint-bitcoin: "npm:^1.1.2" - checksum: 10/18057362e92756aacb3fdbb996beddb134406a998515fdab86d221a96fb203a9345e4c25e8151a788df169eae0cbb271c467d5669f40f2bc9fce487721061928 - languageName: node - linkType: hard - "bitwise@npm:^2.0.4": version: 2.1.0 resolution: "bitwise@npm:2.1.0" @@ -13675,7 +13604,7 @@ __metadata: languageName: node linkType: hard -"bs58check@npm:2.1.2, bs58check@npm:<3.0.0, bs58check@npm:^2.1.2": +"bs58check@npm:2.1.2, bs58check@npm:^2.1.2": version: 2.1.2 resolution: "bs58check@npm:2.1.2" dependencies: @@ -14603,13 +14532,6 @@ __metadata: languageName: node linkType: hard -"coinselect@npm:^3.1.13": - version: 3.1.13 - resolution: "coinselect@npm:3.1.13" - checksum: 10/84450a8d0c2472152ebfe0dbef6d3cfb641d015f0865058f5ac646b03461da5f118cf0709f2385845d8005ea3d617ede8001af777724e4756837299a0e0be6a6 - languageName: node - linkType: hard - "collapse-white-space@npm:^1.0.2": version: 1.0.5 resolution: "collapse-white-space@npm:1.0.5" @@ -16744,17 +16666,6 @@ __metadata: languageName: node linkType: hard -"ecpair@npm:^2.1.0": - version: 2.1.0 - resolution: "ecpair@npm:2.1.0" - dependencies: - randombytes: "npm:^2.1.0" - typeforce: "npm:^1.18.0" - wif: "npm:^2.0.6" - checksum: 10/06a9dfe50ac4528e6f61ce709218baf3261b28ce2ae05273c590a1e9646481699e36df97ca1dbe5c0ffc91753da543b8778f4341db24dc6c74e9046fcb975b3e - languageName: node - linkType: hard - "ee-first@npm:1.1.1": version: 1.1.1 resolution: "ee-first@npm:1.1.1" @@ -25239,7 +25150,6 @@ __metadata: "@babel/register": "npm:^7.22.15" "@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch" "@blockaid/ppom_release": "npm:^1.4.8" - "@consensys/bitcoin-manager-snap": "npm:0.1.4-rc4" "@contentful/rich-text-html-renderer": "npm:^16.3.5" "@ensdomains/content-hash": "npm:^2.5.7" "@ethereumjs/tx": "npm:^4.1.1" @@ -34240,7 +34150,7 @@ __metadata: languageName: node linkType: hard -"typeforce@npm:^1.11.3, typeforce@npm:^1.11.5, typeforce@npm:^1.18.0": +"typeforce@npm:^1.18.0": version: 1.18.0 resolution: "typeforce@npm:1.18.0" checksum: 10/dbf98c75b1d57e56e33c1e1271d5505e67981f4e6a2e2e6e8e31160b58777fea1726160810b6c606517db16476805b7dce315926ba2d4859b9a56cab05b7a41f @@ -35883,15 +35793,6 @@ __metadata: languageName: node linkType: hard -"wif@npm:^2.0.6": - version: 2.0.6 - resolution: "wif@npm:2.0.6" - dependencies: - bs58check: "npm:<3.0.0" - checksum: 10/c8d7581664532d9ab6d163ee5194a9bec71b089a6e50d54d6ec57a9bd714fcf84bc8d9f22f4cfc7c297fc6ad10b973b8e83eca5c41240163fc61f44b5154b7da - languageName: node - linkType: hard - "wif@npm:^4.0.0": version: 4.0.0 resolution: "wif@npm:4.0.0" From f471e36957935057de962614e5a4118d06bdd7eb Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Wed, 3 Jul 2024 11:07:07 +0200 Subject: [PATCH 16/75] refactor(btc): remove shared/constants/bitcoin-manager-snap.ts --- shared/constants/bitcoin-manager-snap.ts | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 shared/constants/bitcoin-manager-snap.ts diff --git a/shared/constants/bitcoin-manager-snap.ts b/shared/constants/bitcoin-manager-snap.ts deleted file mode 100644 index 821f54ae6ea0..000000000000 --- a/shared/constants/bitcoin-manager-snap.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { SnapId } from '@metamask/snaps-sdk'; - -export const BITCOIN_MANAGER_SNAP_ID: SnapId = - 'local:http://localhost:8080' as SnapId; - -// FIXME: This one should probably somewhere else with other CAIP-2 chain ID identifiers! -export const BITCOIN_MANAGER_SCOPE_MAINNET = - 'bip122:000000000019d6689c085ae165831e93'; From 397e05be1d6d570d92af11e59034ea94a6296454 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:43:32 -0400 Subject: [PATCH 17/75] chore: add copy --- app/_locales/en/messages.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index fd81cdbd0979..f92a3e08eb9d 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -298,6 +298,19 @@ "addSnapAccountsDescription": { "message": "Turning on this feature will give you the option to add the new Beta account Snaps right from your account list. If you install an account Snap, remember that it is a third-party service." }, + "experimentalBitcoinSectionTitle": { + "message": "Bitcoin" + }, + "experimentalBitcoinFeatureToggleTitle": { + "message": "Enable \"Add Bitcoin Account (Beta)\"" + }, + "experimentalBitcoinFeatureToggleDescription": { + "message": "Turning on this feature will give you the option to add a Bitcoin Account to your MetaMask Extension derived from your existing Secret Recovery Phrase. This is an experimental Beta feature, so you should use it at your own risk. To give us feedback on this new Bitcoin experience, please fill out this $1.", + "description": "$1 is the link to a product feedback form" + }, + "form": { + "message": "form" + }, "addSuggestedNFTs": { "message": "Add suggested NFTs" }, From 266dbbd48bcf75b5178accd12566a345cc3edcdb Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Wed, 3 Jul 2024 21:45:40 -0400 Subject: [PATCH 18/75] feat: add experimental BTC toggle --- app/scripts/controllers/preferences.js | 14 + app/scripts/lib/setupSentry.js | 1 + app/scripts/metamask-controller.js | 4 + .../experimental-tab.component.js | 259 ++++++++---------- .../experimental-tab.container.js | 4 + ui/selectors/selectors.js | 10 + ui/store/actions.ts | 8 + 7 files changed, 161 insertions(+), 139 deletions(-) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index cfa5907a5194..64f065e99a40 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -61,6 +61,7 @@ export default class PreferencesController { useRequestQueue: true, openSeaEnabled: true, // todo set this to true securityAlertsEnabled: true, + bitcoinSupportEnabled: false, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) addSnapAccountEnabled: false, ///: END:ONLY_INCLUDE_IF @@ -290,6 +291,19 @@ export default class PreferencesController { } ///: END:ONLY_INCLUDE_IF + /** + * Setter for the `bitcoinSupportEnabled` property. + * + * @param {boolean} bitcoinSupportEnabled - Whether or not the user wants to + * enable the "Add Bitcoin account" button. + */ + setBitcoinSupportEnabled(bitcoinSupportEnabled) { + console.log({ bitcoinSupportEnabled }); + this.store.updateState({ + bitcoinSupportEnabled, + }); + } + /** * Setter for the `useExternalNameSources` property * diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index 695b995ddaa8..2d0df8f78994 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -424,6 +424,7 @@ export const SENTRY_UI_STATE = { welcomeScreenSeen: true, confirmationExchangeRates: true, useSafeChainsListValidation: true, + bitcoinSupportEnabled: false, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) addSnapAccountEnabled: false, snapsAddSnapAccountModalDismissed: false, diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 7550b19e98d6..07f1e89e6116 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -3016,6 +3016,10 @@ export default class MetamaskController extends EventEmitter { preferencesController, ), ///: END:ONLY_INCLUDE_IF + setBitcoinSupportEnabled: + preferencesController.setBitcoinSupportEnabled.bind( + preferencesController, + ), setUseExternalNameSources: preferencesController.setUseExternalNameSources.bind( preferencesController, diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.js b/ui/pages/settings/experimental-tab/experimental-tab.component.js index fd84fe7a1369..01a7dc56c73b 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.js @@ -36,6 +36,8 @@ export default class ExperimentalTab extends PureComponent { }; static propTypes = { + bitcoinSupportEnabled: PropTypes.bool, + setBitcoinSupportEnabled: PropTypes.func, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) addSnapAccountEnabled: PropTypes.bool, setAddSnapAccountEnabled: PropTypes.func, @@ -71,36 +73,55 @@ export default class ExperimentalTab extends PureComponent { handleSettingsRefs(t, t('experimental'), this.settingsRefs); } - renderTogglePetnames() { - const { t } = this.context; - const { petnamesEnabled, setPetnamesEnabled } = this.props; - + renderToggleSection({ + title, + description, + toggleValue, + toggleCallback, + toggleDataTestId, + toggleOffLabel, + toggleOnLabel, + }) { return (
- {t('petnamesEnabledToggle')} + {title}
- {t('petnamesEnabledToggleDescription')} + {description}
setPetnamesEnabled(!value)} - offLabel={t('off')} - onLabel={t('on')} - dataTestId="toggle-petnames" + value={toggleValue} + onToggle={toggleCallback} + offLabel={toggleOffLabel} + onLabel={toggleOnLabel} + dataTestId={toggleDataTestId} />
); } + renderTogglePetnames() { + const { t } = this.context; + const { petnamesEnabled, setPetnamesEnabled } = this.props; + + return this.renderToggleSection({ + title: t('petnamesEnabledToggle'), + description: t('petnamesEnabledToggleDescription'), + toggleValue: petnamesEnabled, + toggleCallback: (value) => setPetnamesEnabled(!value), + toggleDataTestId: 'toggle-petnames', + toggleOffLabel: t('off'), + toggleOnLabel: t('on'), + }); + } + renderToggleRedesignedConfirmations() { const { t } = this.context; const { @@ -108,30 +129,15 @@ export default class ExperimentalTab extends PureComponent { setRedesignedConfirmationsEnabled, } = this.props; - return ( - -
- {t('redesignedConfirmationsEnabledToggle')} -
- {t('redesignedConfirmationsToggleDescription')} -
-
- -
- setRedesignedConfirmationsEnabled(!value)} - offLabel={t('off')} - onLabel={t('on')} - dataTestId="toggle-redesigned-confirmations" - /> -
-
- ); + return this.renderToggleSection({ + title: t('redesignedConfirmationsEnabledToggle'), + description: t('redesignedConfirmationsToggleDescription'), + toggleValue: redesignedConfirmationsEnabled, + toggleCallback: (value) => setRedesignedConfirmationsEnabled(!value), + toggleDataTestId: 'toggle-redesigned-confirmations', + toggleOffLabel: t('off'), + toggleOnLabel: t('on'), + }); } ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) @@ -150,60 +156,24 @@ export default class ExperimentalTab extends PureComponent { > {t('snaps')} - -
- {t('snapAccounts')} -
- - {t('snapAccountsDescription')} - - -
- - {t('addSnapAccountToggle')} - -
- { - trackEvent({ - event: MetaMetricsEventName.AddSnapAccountEnabled, - category: MetaMetricsEventCategory.Settings, - properties: { - enabled: !value, - }, - }); - setAddSnapAccountEnabled(!value); - }} - /> -
-
- - {t('addSnapAccountsDescription')} - -
-
-
+ {this.renderToggleSection({ + title: t('addSnapAccountToggle'), + description: t('addSnapAccountsDescription'), + toggleValue: addSnapAccountEnabled, + toggleCallback: (value) => { + trackEvent({ + event: MetaMetricsEventName.AddSnapAccountEnabled, + category: MetaMetricsEventCategory.Settings, + properties: { + enabled: !value, + }, + }); + setAddSnapAccountEnabled(!value); + }, + toggleDataTestId: 'add-account-snap-toggle-button', + toggleOffLabel: t('off'), + toggleOnLabel: t('on'), + })} ); } @@ -212,75 +182,86 @@ export default class ExperimentalTab extends PureComponent { renderToggleRequestQueue() { const { t } = this.context; const { useRequestQueue, setUseRequestQueue } = this.props; - return ( - -
- {t('toggleRequestQueueField')} -
- {t('toggleRequestQueueDescription')} -
-
- -
- setUseRequestQueue(!value)} - offLabel={t('toggleRequestQueueOff')} - onLabel={t('toggleRequestQueueOn')} - /> -
-
- ); + return this.renderToggleSection({ + title: t('toggleRequestQueueField'), + description: t('toggleRequestQueueDescription'), + toggleValue: useRequestQueue || false, + toggleCallback: (value) => setUseRequestQueue(!value), + toggleDataTestId: 'experimental-setting-toggle-request-queue', + toggleOffLabel: t('toggleRequestQueueOff'), + toggleOnLabel: t('toggleRequestQueueOn'), + }); } renderNotificationsToggle() { const { t } = this.context; const { featureNotificationsEnabled, setFeatureNotificationsEnabled } = this.props; - return ( - -
- {t('notificationsFeatureToggle')} -
- {t('notificationsFeatureToggleDescription')} -
-
-
- setFeatureNotificationsEnabled(!value)} - offLabel={t('off')} - onLabel={t('on')} - dataTestId="toggle-notifications" - /> -
-
- ); + return this.renderToggleSection({ + title: t('notificationsFeatureToggle'), + description: t('notificationsFeatureToggleDescription'), + toggleValue: featureNotificationsEnabled, + toggleCallback: (value) => setFeatureNotificationsEnabled(!value), + toggleDataTestId: 'toggle-notifications', + toggleOffLabel: t('off'), + toggleOnLabel: t('on'), + }); + } + + renderBitcoinSupport() { + const { t } = this.context; + const { bitcoinSupportEnabled, setBitcoinSupportEnabled } = this.props; + + return this.renderToggleSection({ + title: t('experimentalBitcoinFeatureToggleTitle'), + description: t('experimentalBitcoinFeatureToggleDescription', [ + + {t('form')} + , + ]), + toggleValue: bitcoinSupportEnabled, + toggleCallback: (value) => setBitcoinSupportEnabled(!value), + toggleDataTestId: 'bitcoin-accounts-toggle', + toggleOffLabel: t('off'), + toggleOnLabel: t('on'), + }); } render() { + const { t } = this.context; return (
{this.renderTogglePetnames()} {this.renderToggleRedesignedConfirmations()} {process.env.NOTIFICATIONS ? this.renderNotificationsToggle() : null} + {this.renderToggleRequestQueue()} + {/* Section: Account Management Snaps */} { ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) this.renderKeyringSnapsToggle() ///: END:ONLY_INCLUDE_IF } - {this.renderToggleRequestQueue()} + {/* Section: Bitcoin Accounts */} + {process.env.BTC_BETA_SUPPORT && ( + <> + + {t('experimentalBitcoinSectionTitle')} + + {this.renderBitcoinSupport()} + + )}
); } diff --git a/ui/pages/settings/experimental-tab/experimental-tab.container.js b/ui/pages/settings/experimental-tab/experimental-tab.container.js index f6f23dcecc2e..229e908dbc2d 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.container.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.container.js @@ -2,6 +2,7 @@ import { compose } from 'redux'; import { connect } from 'react-redux'; import { withRouter } from 'react-router-dom'; import { + setBitcoinSupportEnabled, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) setAddSnapAccountEnabled, ///: END:ONLY_INCLUDE_IF @@ -11,6 +12,7 @@ import { setRedesignedConfirmationsEnabled, } from '../../../store/actions'; import { + getIsBitcoinSupportEnabled, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) getIsAddSnapAccountEnabled, ///: END:ONLY_INCLUDE_IF @@ -25,6 +27,7 @@ const mapStateToProps = (state) => { const petnamesEnabled = getPetnamesEnabled(state); const featureNotificationsEnabled = getFeatureNotificationsEnabled(state); return { + bitcoinSupportEnabled: getIsBitcoinSupportEnabled(state), ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) addSnapAccountEnabled: getIsAddSnapAccountEnabled(state), ///: END:ONLY_INCLUDE_IF @@ -37,6 +40,7 @@ const mapStateToProps = (state) => { const mapDispatchToProps = (dispatch) => { return { + setBitcoinSupportEnabled: (val) => setBitcoinSupportEnabled(val), ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) setAddSnapAccountEnabled: (val) => setAddSnapAccountEnabled(val), ///: END:ONLY_INCLUDE_IF diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 01bd146e263e..d01a62cf3c3f 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -2267,6 +2267,16 @@ export function getIsAddSnapAccountEnabled(state) { } ///: END:ONLY_INCLUDE_IF +/** + * Get the state of the `bitcoinSupportEnabled` flag. + * + * @param {*} state + * @returns The state of the `bitcoinSupportEnabled` flag. + */ +export function getIsBitcoinSupportEnabled(state) { + return state.metamask.bitcoinSupportEnabled; +} + export function getIsCustomNetwork(state) { const chainId = getCurrentChainId(state); diff --git a/ui/store/actions.ts b/ui/store/actions.ts index dfdae2ddb02f..2dff0b97a469 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -4958,6 +4958,14 @@ export function setSecurityAlertsEnabled(val: boolean): void { } } +export async function setBitcoinSupportEnabled(value: boolean) { + try { + await submitRequestToBackground('setBitcoinSupportEnabled', [value]); + } catch (error) { + logErrorWithMessage(error); + } +} + ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) export async function setAddSnapAccountEnabled(value: boolean): Promise { try { From 4d034c1880a8d252b0d2444754e13dd4887ca22f Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Thu, 4 Jul 2024 10:38:31 +0200 Subject: [PATCH 19/75] chore(deps): use bitcoin-manager-snap@0.1.4-rc5 as a dependency --- .../bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json | 1 - app/scripts/snaps/preinstalled-snaps.ts | 2 +- package.json | 1 + yarn.lock | 8 ++++++++ 4 files changed, 10 insertions(+), 2 deletions(-) delete mode 100644 app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json diff --git a/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json b/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json deleted file mode 100644 index 238392b18ab7..000000000000 --- a/app/scripts/snaps/bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json +++ /dev/null @@ -1 +0,0 @@ -{"snapId":"npm:@consensys/bitcoin-manager-snap","manifest":{"version":"0.1.4-rc4","description":"A MetaMask snap to manage Bitcoin","proposedName":"Bitcoin Manager","repository":{"type":"git","url":"https://github.com/MetaMask/bitcoin.git"},"source":{"shasum":"QOQ8JIPH6mEZUppVP94GxVdmReCCNGTwwl2wAnLLQaI=","location":{"npm":{"filePath":"dist/bundle.js","iconPath":"images/icon.svg","packageName":"@consensys/bitcoin-manager-snap","registry":"https://registry.npmjs.org/"}}},"initialConnections":{"http://localhost:3000":{},"https://ramps-dev.portfolio.metamask.io":{},"https://portfolio.metamask.io":{},"https://portfolio-builds.metafi-dev.codefi.network":{},"https://dev.portfolio.metamask.io":{}},"initialPermissions":{"endowment:rpc":{"dapps":true,"snaps":false},"endowment:keyring":{"allowedOrigins":["http://localhost:3000","https://ramps-dev.portfolio.metamask.io","https://portfolio.metamask.io","https://portfolio-builds.metafi-dev.codefi.network","https://dev.portfolio.metamask.io"]},"snap_getBip32Entropy":[{"path":["m","84'","0'"],"curve":"secp256k1"},{"path":["m","84'","1'"],"curve":"secp256k1"}],"endowment:network-access":{},"snap_manageAccounts":{},"snap_manageState":{},"snap_dialog":{}},"manifestVersion":"0.1"},"files":[{"path":"images/icon.svg","value":"\n\n\n\n\n\n\n\n\n\n"},{"path":"dist/bundle.js","value":"(()=>{var t={242:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer,i=r(4261),o=r(4347),s=r(7651);var a,c,u=(a=i,c=Object.create(null),a&&Object.keys(a).forEach((function(t){if(\"default\"!==t){var e=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(c,t,e.get?e:{enumerable:!0,get:function(){return a[t]}})}})),c.default=a,Object.freeze(c));const f=\"Expected Private\",h=\"Expected Point\",l=\"Expected Tweak\",p=\"Expected Signature\",d=\"Expected Extra Data (32 bytes)\",y=\"Expected Scalar\";u.utils.hmacSha256Sync=(t,...e)=>o.hmac(s.sha256,t,u.utils.concatBytes(...e)),u.utils.sha256Sync=(...t)=>s.sha256(u.utils.concatBytes(...t));const g=u.utils._normalizePrivateKey,b=32,w=32,m=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),v=32,E=new Uint8Array(32),_=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function S(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]=0)}function T(t){return t instanceof Uint8Array&&64===t.length&&S(t.subarray(0,32),m)<0&&S(t.subarray(32,64),m)<0}function x(t){return t instanceof Uint8Array&&64===t.length&&S(t.subarray(0,32),_)<0}function O(t){return t instanceof Uint8Array&&t.length===b}function k(t){return void 0===t||t instanceof Uint8Array&&t.length===v}function P(t){if(\"string\"!=typeof t)throw new TypeError(\"hexToNumber: expected string, got \"+typeof t);return BigInt(`0x${t}`)}function R(t){let e;if(\"bigint\"==typeof t)e=t;else if(\"number\"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if(\"string\"==typeof t){if(64!==t.length)throw new Error(\"Expected 32 bytes of private scalar\");e=P(t)}else{if(!(t instanceof Uint8Array))throw new TypeError(\"Expected valid private scalar\");if(32!==t.length)throw new Error(\"Expected 32 bytes of private scalar\");r=t,e=P(u.utils.bytesToHex(r))}var r;if(e<0)throw new Error(\"Expected private scalar >= 0\");return e}const B=(t,e,r)=>{const n=u.Point.fromHex(t),i=R(e),o=u.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error(\"Tweaked point at infinity\");return o.toRawBytes(r)};function C(t,e){return void 0===t?void 0===e||j(e):!!t}function N(t){try{return t()}catch(t){return null}}function L(t,e){if(32===t.length!==e)return!1;try{return!!u.Point.fromHex(t)}catch(t){return!1}}function U(t){return L(t,!1)}function j(t){return L(t,!1)&&33===t.length}function M(t){return u.utils.isValidPrivateKey(t)}function H(t){return L(t,!0)}function F(t){if(!U(t))throw new Error(h);return t.slice(1,33)}function D(t,e){if(!M(t))throw new Error(f);return N((()=>u.getPublicKey(t,C(e))))}e.isPoint=U,e.isPointCompressed=j,e.isPrivate=M,e.isXOnlyPoint=H,e.pointAdd=function(t,e,r){if(!U(t)||!U(e))throw new Error(h);return N((()=>{const n=u.Point.fromHex(t),i=u.Point.fromHex(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(C(r,t))}))},e.pointAddScalar=function(t,e,r){if(!U(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>B(t,e,C(r,t))))},e.pointCompress=function(t,e){if(!U(t))throw new Error(h);return u.Point.fromHex(t).toRawBytes(C(e,t))},e.pointFromScalar=D,e.pointMultiply=function(t,e,r){if(!U(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>((t,e,r)=>{const n=u.Point.fromHex(t),i=\"string\"==typeof e?e:u.utils.bytesToHex(e),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)})(t,e,C(r,t))))},e.privateAdd=function(t,e){if(!1===M(t))throw new Error(f);if(!1===I(e))throw new Error(l);return N((()=>((t,e)=>{const r=g(t),n=R(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r+n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.privateNegate=function(t){if(!1===M(t))throw new Error(f);return(t=>{const e=g(t),r=u.utils._bigintTo32Bytes(u.CURVE.n-e);return u.utils.isValidPrivateKey(r)?r:null})(t)},e.privateSub=function(t,e){if(!1===M(t))throw new Error(f);if(!1===I(e))throw new Error(l);return N((()=>((t,e)=>{const r=g(t),n=R(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r-n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.recover=function(t,e,r,n){if(!O(t))throw new Error(\"Expected Hash\");if(!T(e)||!function(t){return!(A(t.subarray(0,32))||A(t.subarray(32,64)))}(e))throw new Error(p);if(2&r&&!x(e))throw new Error(\"Bad Recovery Id\");if(!H(e.subarray(0,32)))throw new Error(p);return u.recoverPublicKey(t,e,r,C(n))},e.sign=function(t,e,r){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);return u.signSync(t,e,{der:!1,extraEntropy:r})},e.signRecoverable=function(t,e,r){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);const[n,i]=u.signSync(t,e,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}},e.signSchnorr=function(t,e,r=n.alloc(32,0)){if(!M(e))throw new Error(f);if(!O(t))throw new Error(y);if(!k(r))throw new Error(d);return u.schnorr.signSync(t,e,r)},e.verify=function(t,e,r,n){if(!U(e))throw new Error(h);if(!T(r))throw new Error(p);if(!O(t))throw new Error(y);return u.verify(r,t,e,{strict:n})},e.verifySchnorr=function(t,e,r){if(!H(e))throw new Error(h);if(!T(r))throw new Error(p);if(!O(t))throw new Error(y);return u.schnorr.verifySync(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!H(t))throw new Error(h);if(!I(e))throw new Error(l);return N((()=>{const r=B(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=F,e.xOnlyPointFromScalar=function(t){if(!M(t))throw new Error(f);return F(D(t))}},4857:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(4857),i=r(9019);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},4347:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(4857),i=r(9019);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),\"function\"!=typeof this.iHash.update)throw new Error(\"Expected instance of class which extends utils.Hash\");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;tnew o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},7651:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(8822),i=r(9019),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},9019:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(4605),i=r(4857);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},8460:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function i(t,...e){if(!((r=t)instanceof Uint8Array||null!=r&&\"object\"==typeof r&&\"Uint8Array\"===r.constructor.name))throw new Error(\"Expected Uint8Array\");var r;if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function o(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function a(t,e){i(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.add=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=e.split=e.fromBig=void 0;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;oBigInt(t>>>0)<>>0);e.toBig=s;const a=(t,e,r)=>t>>>r;e.shrSH=a;const c=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=c;const u=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=u;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const h=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=h;const l=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=l;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<>>32-r;e.rotlSH=y;const g=(t,e,r)=>e<>>32-r;e.rotlSL=g;const b=(t,e,r)=>e<>>64-r;e.rotlBH=b;const w=(t,e,r)=>t<>>64-r;function m(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w,e.add=m;const v=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=v;const E=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=E;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const A=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=A;const I=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=I;const T={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:h,rotrBL:l,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:g,rotlBH:b,rotlBL:w,add:m,add3L:v,add3H:E,add4L:_,add4H:S,add5H:I,add5L:A};e.default=T},6910:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},448:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.shake256=e.shake128=e.keccak_512=e.keccak_384=e.keccak_256=e.keccak_224=e.sha3_512=e.sha3_384=e.sha3_256=e.sha3_224=e.Keccak=e.keccakP=void 0;const n=r(8460),i=r(8081),o=r(9074),[s,a,c]=[[],[],[]],u=BigInt(0),f=BigInt(1),h=BigInt(2),l=BigInt(7),p=BigInt(256),d=BigInt(113);for(let t=0,e=f,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],s.push(2*(5*n+r)),a.push((t+1)*(t+2)/2%64);let i=u;for(let t=0;t<7;t++)e=(e<>l)*d)%p,e&h&&(i^=f<<(f<r>32?(0,i.rotlBH)(t,e,r):(0,i.rotlSH)(t,e,r),w=(t,e,r)=>r>32?(0,i.rotlBL)(t,e,r):(0,i.rotlSL)(t,e,r);function m(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,i=(e+2)%10,o=r[i],s=r[i+1],a=b(o,s,1)^r[n],c=w(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=c}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=a[r],o=b(e,i,n),c=w(e,i,n),u=s[r];e=t[u],i=t[u+1],t[u]=o,t[u+1]=c}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=y[n],t[1]^=g[n]}r.fill(0)}e.keccakP=m;class v extends o.Hash{constructor(t,e,r,i=!1,s=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,n.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error(\"Sha3 supports only keccak-f1600 function\");this.state=new Uint8Array(200),this.state32=(0,o.u32)(this.state)}keccak(){m(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){(0,n.exists)(this);const{blockLen:e,state:r}=this,i=(t=(0,o.toBytes)(t)).length;for(let n=0;n=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error(\"XOF is not possible for this instance\");return this.writeInto(t)}xof(t){return(0,n.number)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,n.output)(t,this),this.finished)throw new Error(\"digest() was already called\");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return t||(t=new v(e,r,n,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=o,t.destroyed=this.destroyed,t}}e.Keccak=v;const E=(t,e,r)=>(0,o.wrapConstructor)((()=>new v(e,t,r)));e.sha3_224=E(6,144,28),e.sha3_256=E(6,136,32),e.sha3_384=E(6,104,48),e.sha3_512=E(6,72,64),e.keccak_224=E(1,144,28),e.keccak_256=E(1,136,32),e.keccak_384=E(1,104,48),e.keccak_512=E(1,72,64);const _=(t,e,r)=>(0,o.wrapXOFConstructorWithOpts)(((n={})=>new v(e,t,void 0===n.dkLen?r:n.dkLen,!0)));e.shake128=_(31,168,16),e.shake256=_(31,136,32)},9074:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const n=r(6910);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error(\"Non little-endian hardware is not supported\");const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){if(!i(t))throw new Error(\"Uint8Array expected\");let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},4261:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const n=r(2028),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),c=BigInt(8),u=Object.freeze({a:i,b:BigInt(7),P:BigInt(\"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\"),n:BigInt(\"0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"),h:o,Gx:BigInt(\"55066263022277343669578718895168534326250603453777594175500187360389116729240\"),Gy:BigInt(\"32670510020758816978083085130507043184471273380659243275938904335757337482424\"),beta:BigInt(\"0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee\")});e.CURVE=u;const f=(t,e)=>(t+e/s)/e,h={beta:BigInt(\"0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee\"),splitScalar(t){const{n:e}=u,r=BigInt(\"0x3086d221a7d46bcde86c90e49284eb15\"),n=-o*BigInt(\"0xe4437ed6010e88286f547fa90abfe4c3\"),i=BigInt(\"0x114ca50f7a8e2f3f657c1108d9d44cfd8\"),s=r,a=BigInt(\"0x100000000000000000000000000000000\"),c=f(s*t,e),h=f(-n*t,e);let l=H(t-c*r-h*i,e),p=H(-c*n-h*s,e);const d=l>a,y=p>a;if(d&&(l=e-l),y&&(p=e-p),l>a||p>a)throw new Error(\"splitScalarEndo: Endomorphism failed, k=\"+t);return{k1neg:d,k1:l,k2neg:y,k2:p}}},l=32,p=32,d=l+1,y=2*l+1;function g(t){const{a:e,b:r}=u,n=H(t*t),i=H(n*t);return H(i+e*t+r)}const b=u.a===i;class w extends Error{constructor(t){super(t)}}function m(t){if(!(t instanceof v))throw new TypeError(\"JacobianPoint expected\")}class v{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof S))throw new TypeError(\"JacobianPoint#fromAffine: expected Point\");return t.equals(S.ZERO)?v.ZERO:new v(t.x,t.y,o)}static toAffineBatch(t){const e=function(t,e=u.P){const r=new Array(t.length),n=t.reduce(((t,n,o)=>n===i?t:(r[o]=t,H(t*n,e))),o),s=D(n,e);return t.reduceRight(((t,n,o)=>n===i?t:(r[o]=H(t*r[o],e),H(t*n,e))),s),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return v.toAffineBatch(t).map(v.fromAffine)}equals(t){m(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:s}=t,a=H(n*n),c=H(s*s),u=H(e*c),f=H(i*a),h=H(H(r*s)*c),l=H(H(o*n)*a);return u===f&&h===l}negate(){return new v(this.x,H(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=H(t*t),i=H(e*e),o=H(i*i),u=t+i,f=H(s*(H(u*u)-n-o)),h=H(a*n),l=H(h*h),p=H(l-s*f),d=H(h*(f-p)-c*o),y=H(s*e*r);return new v(p,d,y)}add(t){m(t);const{x:e,y:r,z:n}=this,{x:o,y:a,z:c}=t;if(o===i||a===i)return this;if(e===i||r===i)return t;const u=H(n*n),f=H(c*c),h=H(e*f),l=H(o*u),p=H(H(r*c)*f),d=H(H(a*n)*u),y=H(l-h),g=H(d-p);if(y===i)return g===i?this.double():v.ZERO;const b=H(y*y),w=H(y*b),E=H(h*b),_=H(g*g-w-s*E),S=H(g*(E-_)-p*w),A=H(n*c*y);return new v(_,S,A)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=v.ZERO;if(\"bigint\"==typeof t&&t===i)return e;let r=M(t);if(r===o)return this;if(!b){let t=e,n=this;for(;r>i;)r&o&&(t=t.add(n)),n=n.double(),r>>=o;return t}let{k1neg:n,k1:s,k2neg:a,k2:c}=h.splitScalar(r),u=e,f=e,l=this;for(;s>i||c>i;)s&o&&(u=u.add(l)),c&o&&(f=f.add(l)),l=l.double(),s>>=o,c>>=o;return n&&(u=u.negate()),a&&(f=f.negate()),f=new v(H(f.x*h.beta),f.y,f.z),u.add(f)}precomputeWindow(t){const e=b?128/t+1:256/t+1,r=[];let n=this,i=n;for(let o=0;o>=h,a>c&&(a-=f,t+=o);const l=r,p=r+Math.abs(a)-1,d=e%2!=0,y=a<0;0===a?s=s.add(E(d,n[l])):i=i.add(E(y,n[p]))}return{p:i,f:s}}multiply(t,e){let r,n,i=M(t);if(b){const{k1neg:t,k1:o,k2neg:s,k2:a}=h.splitScalar(i);let{p:c,f:u}=this.wNAF(o,e),{p:f,f:l}=this.wNAF(a,e);c=E(t,c),f=E(s,f),f=new v(H(f.x*h.beta),f.y,f.z),r=c.add(f),n=u.add(l)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return v.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(v.ZERO);null==t&&(t=i?c:D(n));const s=t,a=H(s*s),u=H(a*s),f=H(e*a),h=H(r*u),l=H(n*s);if(i)return S.ZERO;if(l!==o)throw new Error(\"invZ was invalid\");return new S(f,h)}}function E(t,e){const r=e.negate();return t?r:e}v.BASE=new v(u.Gx,u.Gy,o),v.ZERO=new v(i,o,i);const _=new WeakMap;class S{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,_.delete(this)}hasEvenY(){return this.y%s===i}static fromCompressedHex(t){const e=32===t.length,r=U(e?t:t.subarray(1));if(!W(r))throw new Error(\"Point is not on curve\");let n=function(t){const{P:e}=u,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),c=BigInt(44),f=BigInt(88),h=t*t*t%e,l=h*h*t%e,p=F(l,a)*l%e,d=F(p,a)*l%e,y=F(d,s)*h%e,g=F(y,n)*y%e,b=F(g,i)*g%e,w=F(b,c)*b%e,m=F(w,f)*w%e,v=F(m,c)*b%e,E=F(v,a)*l%e,_=F(E,o)*g%e,S=F(_,r)*h%e,A=F(S,s);if(A*A%e!==t)throw new Error(\"Cannot find square root\");return A}(g(r));const i=(n&o)===o;if(e)i&&(n=H(-n));else{1==(1&t[0])!==i&&(n=H(-n))}const c=new S(r,n);return c.assertValidity(),c}static fromUncompressedHex(t){const e=U(t.subarray(1,l+1)),r=U(t.subarray(l+1,2*l+1)),n=new S(e,r);return n.assertValidity(),n}static fromHex(t){const e=j(t),r=e.length,n=e[0];if(r===l)return this.fromCompressedHex(e);if(r===d&&(2===n||3===n))return this.fromCompressedHex(e);if(r===y&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-${d} compressed bytes or ${y} uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return S.BASE.multiply(z(t))}static fromSignature(t,e,r){const{r:n,s:i}=Y(e);if(![0,1,2,3].includes(r))throw new Error(\"Cannot recover: invalid recovery bit\");const o=$(j(t)),{n:s}=u,a=2===r||3===r?n+s:n,c=D(a,s),f=H(-o*c,s),h=H(i*c,s),l=1&r?\"03\":\"02\",p=S.fromHex(l+R(a)),d=S.BASE.multiplyAndAddUnsafe(p,f,h);if(!d)throw new Error(\"Cannot recover signature: point at infinify\");return d.assertValidity(),d}toRawBytes(t=!1){return L(this.toHex(t))}toHex(t=!1){const e=R(this.x);if(t){return`${this.hasEvenY()?\"02\":\"03\"}${e}`}return`04${e}${R(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t=\"Point is not on elliptic curve\",{x:e,y:r}=this;if(!W(e)||!W(r))throw new Error(t);const n=H(r*r);if(H(n-g(e))!==i)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new S(this.x,H(-this.y))}double(){return v.fromAffine(this).double().toAffine()}add(t){return v.fromAffine(this).add(v.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return v.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=v.fromAffine(this),s=e===i||e===o||this!==S.BASE?n.multiplyUnsafe(e):n.multiply(e),a=v.fromAffine(t).multiplyUnsafe(r),c=s.add(a);return c.equals(v.ZERO)?void 0:c.toAffine()}}function A(t){return Number.parseInt(t[0],16)>=8?\"00\"+t:t}function I(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${k(t)}`);const e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error(\"Invalid signature integer: wrong length\");if(0===r[0]&&r[1]<=127)throw new Error(\"Invalid signature integer: trailing length\");return{data:U(r),left:t.subarray(e+2)}}e.Point=S,S.BASE=new S(u.Gx,u.Gy),S.ZERO=new S(i,i);class T{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,r=\"Signature.fromCompact\";if(\"string\"!=typeof t&&!e)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=e?k(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new T(N(n.slice(0,64)),N(n.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if(\"string\"!=typeof t&&!e)throw new TypeError(\"Signature.fromDER: Expected string or Uint8Array\");const{r,s:n}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${k(t)}`);if(t[1]!==t.length-2)throw new Error(\"Invalid signature: incorrect length\");const{data:e,left:r}=I(t.subarray(2)),{data:n,left:i}=I(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${k(i)}`);return{r:e,s:n}}(e?t:L(t));return new T(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!q(t))throw new Error(\"Invalid Signature: r must be 0 < r < n\");if(!q(e))throw new Error(\"Invalid Signature: s must be 0 < s < n\")}hasHighS(){const t=u.n>>o;return this.s>t}normalizeS(){return this.hasHighS()?new T(this.r,H(-this.s,u.n)):this}toDERRawBytes(){return L(this.toDERHex())}toDERHex(){const t=A(C(this.s)),e=A(C(this.r)),r=t.length/2,n=e.length/2,i=C(r),o=C(n);return`30${C(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return L(this.toCompactHex())}toCompactHex(){return R(this.r)+R(this.s)}}function x(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error(\"Uint8Array list expected\");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;ee.toString(16).padStart(2,\"0\")));function k(t){if(!(t instanceof Uint8Array))throw new Error(\"Expected Uint8Array\");let e=\"\";for(let r=0;r0)return BigInt(t);if(\"bigint\"==typeof t&&q(t))return t;throw new TypeError(\"Expected valid private scalar: 0 < scalar < curve.n\")}function H(t,e=u.P){const r=t%e;return r>=i?r:e+r}function F(t,e){const{P:r}=u;let n=t;for(;e-- >i;)n*=n,n%=r;return n}function D(t,e=u.P){if(t===i||e<=i)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=H(t,e),n=e,s=i,a=o,c=o,f=i;for(;r!==i;){const t=n/r,e=n%r,i=s-c*t,o=a-f*t;n=r,r=e,s=c,a=f,c=i,f=o}if(n!==o)throw new Error(\"invert: does not exist\");return H(s,e)}function $(t,e=!1){const r=function(t){const e=8*t.length-8*p,r=U(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=u;return r>=n?r-n:r}let K,V;class G{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,\"number\"!=typeof t||t<2)throw new Error(\"hashLen must be a number\");if(\"number\"!=typeof e||e<2)throw new Error(\"qByteLen must be a number\");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return e.utils.hmacSha256(this.k,...t)}hmacSync(...t){return V(this.k,...t)}checkSync(){if(\"function\"!=typeof V)throw new w(\"hmacSha256Sync needs to be set\")}incr(){if(this.counter>=1e3)throw new Error(\"Tried 1,000 k values for sign(), all were invalid\");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),0!==t.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),0!==t.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t0)e=BigInt(t);else if(\"string\"==typeof t){if(t.length!==2*p)throw new Error(\"Expected 32 bytes of private key\");e=N(t)}else{if(!(t instanceof Uint8Array))throw new TypeError(\"Expected valid private key\");if(t.length!==p)throw new Error(\"Expected 32 bytes of private key\");e=U(t)}if(!q(e))throw new Error(\"Expected private key: 0 < key < n\");return e}function J(t){return t instanceof S?(t.assertValidity(),t):S.fromHex(t)}function Y(t){if(t instanceof T)return t.assertValidity(),t;try{return T.fromDER(t)}catch(e){return T.fromCompact(t)}}function Z(t){const e=t instanceof Uint8Array,r=\"string\"==typeof t,n=(e||r)&&t.length;return e?n===d||n===y:r?n===2*d||n===2*y:t instanceof S}function Q(t){return U(t.length>l?t.slice(0,l):t)}function tt(t){const e=Q(t),r=H(e,u.n);return et(r{t=j(t);const e=p+8;if(t.length1024)throw new Error(\"Expected valid bytes of private key as per FIPS 186\");return B(H(U(t),u.n-o)+o)},randomBytes:(t=32)=>{if(lt.web)return lt.web.getRandomValues(new Uint8Array(t));if(lt.node){const{randomBytes:e}=lt.node;return Uint8Array.from(e(t))}throw new Error(\"The environment doesn't have randomBytes function\")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(p+8)),precompute(t=8,e=S.BASE){const r=e===S.BASE?e:new S(e.x,e.y);return r._setWindowSize(t),r.multiply(a),r},sha256:async(...t)=>{if(lt.web){const e=await lt.web.subtle.digest(\"SHA-256\",x(...t));return new Uint8Array(e)}if(lt.node){const{createHash:e}=lt.node,r=e(\"sha256\");return t.forEach((t=>r.update(t))),Uint8Array.from(r.digest())}throw new Error(\"The environment doesn't have sha256 function\")},hmacSha256:async(t,...e)=>{if(lt.web){const r=await lt.web.subtle.importKey(\"raw\",t,{name:\"HMAC\",hash:{name:\"SHA-256\"}},!1,[\"sign\"]),n=x(...e),i=await lt.web.subtle.sign(\"HMAC\",r,n);return new Uint8Array(i)}if(lt.node){const{createHmac:r}=lt.node,n=r(\"sha256\",t);return e.forEach((t=>n.update(t))),Uint8Array.from(n.digest())}throw new Error(\"The environment doesn't have hmac-sha256 function\")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...r)=>{let n=dt[t];if(void 0===n){const r=await e.utils.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=x(r,r),dt[t]=n}return e.utils.sha256(n,...r)},taggedHashSync:(t,...e)=>{if(\"function\"!=typeof K)throw new w(\"sha256Sync is undefined, you need to set it\");let r=dt[t];if(void 0===r){const e=K(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=x(e,e),dt[t]=r}return K(r,...e)},_JacobianPoint:v},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get:()=>K,set(t){K||(K=t)}},hmacSha256Sync:{configurable:!1,get:()=>V,set(t){V||(V=t)}}})},6710:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function n(...t){const e=(t,e)=>r=>t(e(r)),r=Array.from(t).reverse().reduce(((t,r)=>t?e(t,r.encode):r.encode),void 0),n=t.reduce(((t,r)=>t?e(t,r.decode):r.decode),void 0);return{encode:r,decode:n}}function i(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&\"number\"!=typeof e[0])throw new Error(\"alphabet.encode input should be an array of numbers\");return e.map((e=>{if(r(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&\"string\"!=typeof e[0])throw new Error(\"alphabet.decode input should be array of strings\");return e.map((e=>{if(\"string\"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: \"${e}\". Allowed: ${t}`);return r}))}}}function o(t=\"\"){if(\"string\"!=typeof t)throw new Error(\"join separator should be string\");return{encode:e=>{if(!Array.isArray(e)||e.length&&\"string\"!=typeof e[0])throw new Error(\"join.encode input should be array of strings\");for(let t of e)if(\"string\"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if(\"string\"!=typeof e)throw new Error(\"join.decode input should be string\");return e.split(t)}}}function s(t,e=\"=\"){if(r(t),\"string\"!=typeof e)throw new Error(\"padding chr should be string\");return{encode(r){if(!Array.isArray(r)||r.length&&\"string\"!=typeof r[0])throw new Error(\"padding.encode input should be array of strings\");for(let t of r)if(\"string\"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&\"string\"!=typeof r[0])throw new Error(\"padding.encode input should be array of strings\");for(let t of r)if(\"string\"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let n=r.length;if(n*t%8)throw new Error(\"Invalid padding: string should have whole number of bytes\");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error(\"Invalid padding: string has too much padding\");return r.slice(0,n)}}}function a(t){if(\"function\"!=typeof t)throw new Error(\"normalize fn should be function\");return{encode:t=>t,decode:e=>t(e)}}function c(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error(\"convertRadix: data should be array\");if(!t.length)return[];let i=0;const o=[],s=Array.from(t);for(s.forEach((t=>{if(r(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)}));;){let t=0,r=!0;for(let o=i;oe?u(e,t%e):t,f=(t,e)=>t+(e-u(t,e));function h(t,e,n,i){if(!Array.isArray(t))throw new Error(\"convertRadix2: data should be array\");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(f(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${f(e,n)}`);let o=0,s=0;const a=2**n-1,c=[];for(const i of t){if(r(i),i>=2**e)throw new Error(`convertRadix2: invalid data word=${i} from=${e}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)c.push((o>>s-n&a)>>>0);o&=2**s-1}if(o=o<=e)throw new Error(\"Excess padding\");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&c.push(o>>>0),c}function l(t){return r(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error(\"radix.encode input should be Uint8Array\");return c(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&\"number\"!=typeof e[0])throw new Error(\"radix.decode input should be array of strings\");return Uint8Array.from(c(e,t,256))}}}function p(t,e=!1){if(r(t),t<=0||t>32)throw new Error(\"radix2: bits should be in (0..32]\");if(f(8,t)>32||f(t,8)>32)throw new Error(\"radix2: carry overflow\");return{encode:r=>{if(!(r instanceof Uint8Array))throw new Error(\"radix2.encode input should be Uint8Array\");return h(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&\"number\"!=typeof r[0])throw new Error(\"radix2.decode input should be array of strings\");return Uint8Array.from(h(r,t,8,e))}}}function d(t){if(\"function\"!=typeof t)throw new Error(\"unsafeWrapper fn should be function\");return function(...e){try{return t.apply(null,e)}catch(t){}}}function y(t,e){if(r(t),\"function\"!=typeof e)throw new Error(\"checksum fn should be function\");return{encode(r){if(!(r instanceof Uint8Array))throw new Error(\"checksum.encode: input should be Uint8Array\");const n=e(r).slice(0,t),i=new Uint8Array(r.length+t);return i.set(r),i.set(n,r.length),i},decode(r){if(!(r instanceof Uint8Array))throw new Error(\"checksum.decode: input should be Uint8Array\");const n=r.slice(0,-t),i=e(n).slice(0,t),o=r.slice(-t);for(let e=0;et.toUpperCase().replace(/O/g,\"0\").replace(/[IL]/g,\"1\")))),e.base64=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"),s(6),o(\"\")),e.base64url=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\"),s(6),o(\"\")),e.base64urlnopad=n(p(6),i(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\"),o(\"\"));const g=t=>n(l(58),i(t),o(\"\"));e.base58=g(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\"),e.base58flickr=g(\"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ\"),e.base58xrp=g(\"rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz\");const b=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let r=\"\";for(let n=0;nn(y(4,(e=>t(t(e)))),e.base58);const w=n(i(\"qpzry9x8gf2tvdw0s3jn54khce6mua7l\"),o(\"\")),m=[996825010,642813549,513874426,1027748829,705979059];function v(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t>t&1)&&(r^=m[t]);return r}function E(t,e,r=1){const n=t.length;let i=1;for(let e=0;e126)throw new Error(`Invalid prefix (${t})`);i=v(i)^r>>5}i=v(i);for(let e=0;er)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${r})`);const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())throw new Error(\"String must be lowercase or uppercase\");const i=(t=n).lastIndexOf(\"1\");if(0===i||-1===i)throw new Error('Letter \"1\" must be present between prefix and data only');const o=t.slice(0,i),s=t.slice(i+1);if(s.length<6)throw new Error(\"Data must be at least 6 characters long\");const a=w.decode(s).slice(0,-6),c=E(o,a,e);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected \"${c}\"`);return{prefix:o,words:a}}return{encode:function(t,r,n=90){if(\"string\"!=typeof t)throw new Error(\"bech32.encode prefix should be string, not \"+typeof t);if(!Array.isArray(r)||r.length&&\"number\"!=typeof r[0])throw new Error(\"bech32.encode words should be array of numbers, not \"+typeof r);const i=t.length+7+r.length;if(!1!==n&&i>n)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=t.toLowerCase(),s=E(o,r,e);return`${o}1${w.encode(r)}${s}`},decode:s,decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:d(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}e.bech32=_(\"bech32\"),e.bech32m=_(\"bech32m\"),e.utf8={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},e.hex=n(p(4),i(\"0123456789abcdef\"),o(\"\"),a((t=>{if(\"string\"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));const S={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},A=\"Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr\";e.bytesToString=(t,e)=>{if(\"string\"!=typeof t||!S.hasOwnProperty(t))throw new TypeError(A);if(!(e instanceof Uint8Array))throw new TypeError(\"bytesToString() expects Uint8Array\");return S[t].encode(e)},e.str=e.bytesToString;e.stringToBytes=(t,e)=>{if(!S.hasOwnProperty(t))throw new TypeError(A);if(\"string\"!=typeof e)throw new TypeError(\"stringToBytes() expects string\");return S[t].decode(e)},e.bytes=e.stringToBytes},9784:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError(\"Alphabet too long\");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,p=s-1;(0!==h||l>>0,f[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error(\"Non-zero carry\");o=l,r++}for(var d=s-o;d!==s&&0===f[d];)d++;var y=n.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var g=i;d!==s;)y[g++]=f[d++];return y}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError(\"Expected Buffer\");if(0===e.length)return\"\";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var l=e[o],p=0,d=u-1;(0!==l||p>>0,h[d]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error(\"Non-zero carry\");i=p,o++}for(var y=u-i;y!==u&&0===h[y];)y++;for(var g=c.repeat(r);y{\"use strict\";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],c=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,c)),f=0,h=c>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===c&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===c&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,u=n-i;au?u:a+s));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+\"==\")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+\"=\"));return o.join(\"\")};for(var r=[],n=[],i=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,o=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error(\"Invalid string. Length must be a multiple of 4\");var r=t.indexOf(\"=\");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,n){for(var i,o,s=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join(\"\")}n[\"-\".charCodeAt(0)]=62,n[\"_\".charCodeAt(0)]=63},6586:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.bech32m=e.bech32=void 0;const r=\"qpzry9x8gf2tvdw0s3jn54khce6mua7l\",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r126)return\"Invalid prefix (\"+t+\")\";e=i(e)^n>>5}e=i(e);for(let r=0;r=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)return\"Excess padding\";if(i<r)return\"Exceeds length limit\";const s=t.toLowerCase(),a=t.toUpperCase();if(t!==s&&t!==a)return\"Mixed-case string \"+t;const c=(t=s).lastIndexOf(\"1\");if(-1===c)return\"No separator character for \"+t;if(0===c)return\"Missing prefix for \"+t;const u=t.slice(0,c),f=t.slice(c+1);if(f.length<6)return\"Data too short\";let h=o(u);if(\"string\"==typeof h)return h;const l=[];for(let t=0;t=f.length||l.push(r)}return h!==e?\"Invalid checksum for \"+t:{prefix:u,words:l}}return e=\"bech32\"===t?1:734539939,{decodeUnsafe:function(t,e){const r=s(t,e);if(\"object\"==typeof r)return r},decode:function(t,e){const r=s(t,e);if(\"object\"==typeof r)return r;throw new Error(r)},encode:function(t,n,s){if(s=s||90,t.length+7+n.length>s)throw new TypeError(\"Exceeds length limit\");let a=o(t=t.toLowerCase());if(\"string\"==typeof a)throw new Error(a);let c=t+\"1\";for(let t=0;t>5!=0)throw new Error(\"Non 5-bit word\");a=i(a)^e,c+=r.charAt(e)}for(let t=0;t<6;++t)a=i(a);a^=e;for(let t=0;t<6;++t){c+=r.charAt(a>>5*(5-t)&31)}return c},toWords:a,fromWordsUnsafe:c,fromWords:u}}e.bech32=f(\"bech32\"),e.bech32m=f(\"bech32m\")},3162:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});const n=r(6808);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter((t=>t.key.toString(\"hex\")===n))[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function s(t){const e=new Set;return t.forEach((t=>{const r=t.key.toString(\"hex\");if(e.has(r))throw new Error(\"Combine: KeyValue Map keys should be unique\");e.add(r)})),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),a=t.slice(1);if(0===a.length)throw new Error(\"Combine: Nothing to combine\");const c=o(e);if(void 0===c)throw new Error(\"Combine: Self missing transaction\");const u=s(r.globalKeyVals),f=r.inputKeyVals.map(s),h=r.outputKeyVals.map(s);for(const t of a){const e=o(t);if(void 0===e||!e.toBuffer().equals(c.toBuffer()))throw new Error(\"Combine: One of the Psbts does not have the same transaction.\");const a=n.psbtToKeyVals(t);s(a.globalKeyVals).forEach(i(u,r.globalKeyVals,a.globalKeyVals));a.inputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(f[e],r.inputKeyVals[e],a.inputKeyVals[e]))));a.outputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(h[e],r.outputKeyVals[e],a.outputKeyVals[e]))))}return n.psbtFromKeyVals(c,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},9977:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error(\"Decode Error: could not decode globalXpub with key 0x\"+t.key.toString(\"hex\"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error(\"Decode Error: globalXpub has invalid extended pubkey in key 0x\"+t.key.toString(\"hex\"));if(t.value.length/4%1!=0)throw new Error(\"Decode Error: Global GLOBAL_XPUB value length should be multiple of 4\");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:\"m\"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+=\"/\"+o.toString(10)+(i?\"'\":\"\")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split(\"/\"),s=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e=\"'\"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:r,value:s}},e.expected=\"{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }\",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&\"string\"==typeof i&&!!i.match(/^m(\\/\\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.extendedPubkey.equals(e.extendedPubkey))).length)}},3398:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},6317:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});const n=r(9889),i=r(9977),o=r(3398),s=r(7312),a=r(1661),c=r(8730),u=r(5098),f=r(4474),h=r(9175),l=r(7279),p=r(7544),d=r(241),y=r(3155),g=r(4709),b=r(9574),w=r(6896),m=r(437),v=r(5400),E=r(2751),_=r(9632),S=r(9079),A={unsignedTx:o,globalXpub:i,checkPubkey:m.makeChecker([])};e.globals=A;const I={nonWitnessUtxo:c,partialSig:u,sighashType:h,finalScriptSig:s,finalScriptWitness:a,porCommitment:f,witnessUtxo:g,bip32Derivation:w.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:l,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:E.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:_.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=I;const T={bip32Derivation:w.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:E.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:b,tapInternalKey:_.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},7312:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error(\"Decode Error: could not decode finalScriptSig with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},1661:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error(\"Decode Error: could not decode finalScriptWitness with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},8730:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error(\"Decode Error: could not decode nonWitnessUtxo with key 0x\"+t.key.toString(\"hex\"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected=\"Buffer\",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},5098:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error(\"Decode Error: could not decode partialSig with key 0x\"+t.key.toString(\"hex\"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error(\"Decode Error: partialSig has invalid pubkey in key 0x\"+t.key.toString(\"hex\"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected=\"{ pubkey: Buffer; signature: Buffer; }\",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}},4474:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error(\"Decode Error: could not decode porCommitment with key 0x\"+t.key.toString(\"hex\"));return t.value.toString(\"utf8\")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,\"utf8\")}},e.expected=\"string\",e.check=function(t){return\"string\"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}},9175:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error(\"Decode Error: could not decode sighashType with key 0x\"+t.key.toString(\"hex\"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected=\"number\",e.check=function(t){return\"number\"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},7279:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapKeySig with key 0x\"+t.key.toString(\"hex\"));if(!o(t.value))throw new Error(\"Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature\");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected=\"Buffer\",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},7544:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error(\"Decode Error: could not decode tapLeafScript with key 0x\"+t.key.toString(\"hex\"));if((t.key.length-2)%32!=0)throw new Error(\"Decode Error: tapLeafScript has invalid control block in key 0x\"+t.key.toString(\"hex\"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error(\"Decode Error: tapLeafScript bad leaf version in key 0x\"+t.key.toString(\"hex\"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected=\"{ controlBlock: Buffer; leafVersion: number, script: Buffer; }\",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.controlBlock.equals(e.controlBlock))).length)}},241:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapMerkleRoot with key 0x\"+t.key.toString(\"hex\"));if(!o(t.value))throw new Error(\"Decode Error: tapMerkleRoot not a 32-byte hash\");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected=\"Buffer\",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},3155:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error(\"Decode Error: could not decode tapScriptSig with key 0x\"+t.key.toString(\"hex\"));if(65!==t.key.length)throw new Error(\"Decode Error: tapScriptSig has invalid key 0x\"+t.key.toString(\"hex\"));if(64!==t.value.length&&65!==t.value.length)throw new Error(\"Decode Error: tapScriptSig has invalid signature in key 0x\"+t.key.toString(\"hex\"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected=\"{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }\",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString(\"hex\")+e.leafHash.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash))).length)}},4709:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889),o=r(5962),s=r(2715);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error(\"Decode Error: could not decode witnessUtxo with key 0x\"+t.key.toString(\"hex\"));const e=o.readUInt64LE(t.value,0);let r=8;const n=s.decode(t.value,r);r+=s.encodingLength(n);const a=t.value.slice(r);if(a.length!==n)throw new Error(\"Decode Error: WITNESS_UTXO script is not proper length\");return{script:a,value:e}},e.encode=function(t){const{script:e,value:r}=t,a=s.encodingLength(e.length),c=n.allocUnsafe(8+a+e.length);return o.writeUInt64LE(c,r,0),s.encode(e.length,c,8),e.copy(c,8+a),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:c}},e.expected=\"{ script: Buffer; value: number; }\",e.check=function(t){return n.isBuffer(t.script)&&\"number\"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},9574:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(9889),o=r(2715);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error(\"Decode Error: could not decode tapTree with key 0x\"+t.key.toString(\"hex\"));let e=0;const r=[];for(;e[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script])));return{key:e,value:n.concat(r)}},e.expected=\"{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }\",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every((t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script)))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},6896:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=t=>33===t.length&&[2,3].includes(t[0])||65===t.length&&4===t[0];e.makeConverter=function(t,e=i){return{decode:function(r){if(r.key[0]!==t)throw new Error(\"Decode Error: could not decode bip32Derivation with key 0x\"+r.key.toString(\"hex\"));const n=r.key.slice(1);if(!e(n))throw new Error(\"Decode Error: bip32Derivation has invalid pubkey in key 0x\"+r.key.toString(\"hex\"));if(r.value.length/4%1!=0)throw new Error(\"Decode Error: Input BIP32_DERIVATION value length should be multiple of 4\");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:\"m\"};for(const t of(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+=\"/\"+o.toString(10)+(n?\"'\":\"\")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split(\"/\"),s=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e=\"'\"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:i,value:s}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&\"string\"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:\"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }\",canAddToArray:function(t,e,r){const n=e.pubkey.toString(\"hex\");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}}}},437:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error(\"Format Error: invalid pubkey in key 0x\"+e.key.toString(\"hex\"));return r}}},5400:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error(\"Decode Error: could not decode redeemScript with key 0x\"+e.key.toString(\"hex\"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.redeemScript}}}},2751:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(2715),o=r(6896),s=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,s);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),s=new Array(r);for(let e=0,i=n;en.isBuffer(t)&&32===t.length))&&e.check(t)},expected:\"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }\",canAddToArray:e.canAddToArray}}},9632:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t||1!==e.key.length)throw new Error(\"Decode Error: could not decode tapInternalKey with key 0x\"+e.key.toString(\"hex\"));if(32!==e.value.length)throw new Error(\"Decode Error: tapInternalKey not a 32-byte x-only pubkey\");return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)&&32===t.length},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.tapInternalKey}}}},9079:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error(\"Decode Error: could not decode witnessScript with key 0x\"+e.key.toString(\"hex\"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:\"Buffer\",canAdd:function(t,e){return!!t&&!!e&&void 0===t.witnessScript}}}},5962:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(2715);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),s=i.encodingLength(r),a=n.allocUnsafe(o+e+s+r);return i.encode(e,a,0),t.key.copy(a,o),i.encode(r,a,o+e),t.value.copy(a,o+e+s),a}function s(t,e){if(\"number\"!=typeof t)throw new Error(\"cannot write a non-number as a number\");if(t<0)throw new Error(\"specified a negative value for writing an unsigned value\");if(t>e)throw new Error(\"RangeError: value out of range\");if(Math.floor(t)!==t)throw new Error(\"value has a fractional component\")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError(\"value out of range\")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.encode=function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError(\"buffer must be a Buffer instance\");return i||(i=0),e<253?(r.writeUInt8(e,i),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError(\"buffer must be a Buffer instance\");r||(r=0);const i=e.readUInt8(r);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===i)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),i=4294967296*e.readUInt32LE(r+5)+n;return o(i),i}},e.encodingLength=s},4112:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317),o=r(5962),s=r(2715),a=r(9889);function c(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString(\"hex\")}`)}function u(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const s={unsignedTx:t};let u=0;for(const t of e)switch(t.key[0]){case a.GlobalTypes.UNSIGNED_TX:if(c(\"global\",t.key,a.GlobalTypes.UNSIGNED_TX),u>0)throw new Error(\"Format Error: GlobalMap has multiple UNSIGNED_TX\");u++;break;case a.GlobalTypes.GLOBAL_XPUB:void 0===s.globalXpub&&(s.globalXpub=[]),s.globalXpub.push(i.globals.globalXpub.decode(t));break;default:s.unknownKeyVals||(s.unknownKeyVals=[]),s.unknownKeyVals.push(t)}const f=r.length,h=n.length,l=[],p=[];for(const t of o.range(f)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case a.InputTypes.NON_WITNESS_UTXO:if(c(\"input\",n.key,a.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error(\"Format Error: Input has multiple NON_WITNESS_UTXO\");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case a.InputTypes.WITNESS_UTXO:if(c(\"input\",n.key,a.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error(\"Format Error: Input has multiple WITNESS_UTXO\");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case a.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case a.InputTypes.SIGHASH_TYPE:if(c(\"input\",n.key,a.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error(\"Format Error: Input has multiple SIGHASH_TYPE\");e.sighashType=i.inputs.sighashType.decode(n);break;case a.InputTypes.REDEEM_SCRIPT:if(c(\"input\",n.key,a.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error(\"Format Error: Input has multiple REDEEM_SCRIPT\");e.redeemScript=i.inputs.redeemScript.decode(n);break;case a.InputTypes.WITNESS_SCRIPT:if(c(\"input\",n.key,a.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error(\"Format Error: Input has multiple WITNESS_SCRIPT\");e.witnessScript=i.inputs.witnessScript.decode(n);break;case a.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case a.InputTypes.FINAL_SCRIPTSIG:c(\"input\",n.key,a.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case a.InputTypes.FINAL_SCRIPTWITNESS:c(\"input\",n.key,a.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case a.InputTypes.POR_COMMITMENT:c(\"input\",n.key,a.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case a.InputTypes.TAP_KEY_SIG:c(\"input\",n.key,a.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case a.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case a.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case a.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case a.InputTypes.TAP_INTERNAL_KEY:c(\"input\",n.key,a.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case a.InputTypes.TAP_MERKLE_ROOT:c(\"input\",n.key,a.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}l.push(e)}for(const t of o.range(h)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case a.OutputTypes.REDEEM_SCRIPT:if(c(\"output\",r.key,a.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error(\"Format Error: Output has multiple REDEEM_SCRIPT\");e.redeemScript=i.outputs.redeemScript.decode(r);break;case a.OutputTypes.WITNESS_SCRIPT:if(c(\"output\",r.key,a.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error(\"Format Error: Output has multiple WITNESS_SCRIPT\");e.witnessScript=i.outputs.witnessScript.decode(r);break;case a.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case a.OutputTypes.TAP_INTERNAL_KEY:c(\"output\",r.key,a.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case a.OutputTypes.TAP_TREE:c(\"output\",r.key,a.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case a.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:s,inputs:l,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=s.decode(t,r);r+=s.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function c(){if(r>=t.length)throw new Error(\"Format Error: Unexpected End of PSBT\");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error(\"Format Error: Invalid Magic Number\");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error(\"Format Error: Magic Number must be followed by 0xff separator\");const f=[],h={};for(;!c();){const t=i(),e=t.key.toString(\"hex\");if(h[e])throw new Error(\"Format Error: Keys must be unique for global keymap: key \"+e);h[e]=1,f.push(t)}const l=f.filter((t=>t.key[0]===a.GlobalTypes.UNSIGNED_TX));if(1!==l.length)throw new Error(\"Format Error: Only one UNSIGNED_TX allowed\");const p=e(l[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),g=[],b=[];for(const t of o.range(d)){const e={},r=[];for(;!c();){const n=i(),o=n.key.toString(\"hex\");if(e[o])throw new Error(\"Format Error: Keys must be unique for each input: input index \"+t+\" key \"+o);e[o]=1,r.push(n)}g.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!c();){const n=i(),o=n.key.toString(\"hex\");if(e[o])throw new Error(\"Format Error: Keys must be unique for each output: output index \"+t+\" key \"+o);e[o]=1,r.push(n)}b.push(r)}return u(p,{globalMapKeyVals:f,inputKeyVals:g,outputKeyVals:b})},e.checkKeyBuffer=c,e.psbtFromKeyVals=u},6808:(t,e,r)=>{\"use strict\";function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,\"__esModule\",{value:!0}),n(r(4112)),n(r(2673))},2673:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317),o=r(5962);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:s,outputKeyVals:a}=c({globalMap:t,inputs:e,outputs:r}),u=o.keyValsToBuffer(i),f=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),h=f(s),l=f(a),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,u].concat(h,l))};const s=(t,e)=>t.key.compare(e.key);function a(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if(\"unknownKeyVals\"===n)return t;const o=e[n];if(void 0===o)return t;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((t=>t.key.toString(\"hex\"))).forEach((t=>{if(r.has(t))throw new Error(\"Serialize Error: Duplicate key: \"+t);r.add(t)})),t.concat(s)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString(\"hex\")))):[];return n.concat(i).sort(s)}function c({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:a(t,i.globals),inputKeyVals:e.map((t=>a(t,i.inputs))),outputKeyVals:r.map((t=>a(t,i.outputs)))}}e.psbtToKeyVals=c},7003:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(3162),o=r(6808),s=r(9889),a=r(2431);e.Psbt=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,\"base64\");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,\"hex\");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString(\"base64\")}toHex(){return this.toBuffer().toString(\"hex\")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return a.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=a.checkForInput(this.inputs,t);return a.updateInput(e,r),this}updateOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return a.checkHasKey(t,this.globalMap.unknownKeyVals,a.getEnumLength(s.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=a.checkForInput(this.inputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error(\"unknownKeyVals must be an Array\");return e.forEach((t=>this.addUnknownKeyValToInput(r,t))),a.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error(\"unknownKeyVals must be an Array\");return e.forEach((t=>this.addUnknownKeyValToOutput(r,t))),a.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=a.checkForInput(this.inputs,t);a.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))[\"witnessUtxo\",\"nonWitnessUtxo\",\"finalScriptSig\",\"finalScriptWitness\",\"unknownKeyVals\"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},9889:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),function(t){t[t.UNSIGNED_TX=0]=\"UNSIGNED_TX\",t[t.GLOBAL_XPUB=1]=\"GLOBAL_XPUB\"}(e.GlobalTypes||(e.GlobalTypes={})),e.GLOBAL_TYPE_NAMES=[\"unsignedTx\",\"globalXpub\"],function(t){t[t.NON_WITNESS_UTXO=0]=\"NON_WITNESS_UTXO\",t[t.WITNESS_UTXO=1]=\"WITNESS_UTXO\",t[t.PARTIAL_SIG=2]=\"PARTIAL_SIG\",t[t.SIGHASH_TYPE=3]=\"SIGHASH_TYPE\",t[t.REDEEM_SCRIPT=4]=\"REDEEM_SCRIPT\",t[t.WITNESS_SCRIPT=5]=\"WITNESS_SCRIPT\",t[t.BIP32_DERIVATION=6]=\"BIP32_DERIVATION\",t[t.FINAL_SCRIPTSIG=7]=\"FINAL_SCRIPTSIG\",t[t.FINAL_SCRIPTWITNESS=8]=\"FINAL_SCRIPTWITNESS\",t[t.POR_COMMITMENT=9]=\"POR_COMMITMENT\",t[t.TAP_KEY_SIG=19]=\"TAP_KEY_SIG\",t[t.TAP_SCRIPT_SIG=20]=\"TAP_SCRIPT_SIG\",t[t.TAP_LEAF_SCRIPT=21]=\"TAP_LEAF_SCRIPT\",t[t.TAP_BIP32_DERIVATION=22]=\"TAP_BIP32_DERIVATION\",t[t.TAP_INTERNAL_KEY=23]=\"TAP_INTERNAL_KEY\",t[t.TAP_MERKLE_ROOT=24]=\"TAP_MERKLE_ROOT\"}(e.InputTypes||(e.InputTypes={})),e.INPUT_TYPE_NAMES=[\"nonWitnessUtxo\",\"witnessUtxo\",\"partialSig\",\"sighashType\",\"redeemScript\",\"witnessScript\",\"bip32Derivation\",\"finalScriptSig\",\"finalScriptWitness\",\"porCommitment\",\"tapKeySig\",\"tapScriptSig\",\"tapLeafScript\",\"tapBip32Derivation\",\"tapInternalKey\",\"tapMerkleRoot\"],function(t){t[t.REDEEM_SCRIPT=0]=\"REDEEM_SCRIPT\",t[t.WITNESS_SCRIPT=1]=\"WITNESS_SCRIPT\",t[t.BIP32_DERIVATION=2]=\"BIP32_DERIVATION\",t[t.TAP_INTERNAL_KEY=5]=\"TAP_INTERNAL_KEY\",t[t.TAP_TREE=6]=\"TAP_TREE\",t[t.TAP_BIP32_DERIVATION=7]=\"TAP_BIP32_DERIVATION\"}(e.OutputTypes||(e.OutputTypes={})),e.OUTPUT_TYPE_NAMES=[\"redeemScript\",\"witnessScript\",\"bip32Derivation\",\"tapInternalKey\",\"tapTree\",\"tapBip32Derivation\"]},2431:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});const i=r(6317);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function s(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function a(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function c(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:s,canAddToArray:c,check:u,expected:f}=i[t+\"s\"][n]||{};if(u)if(!!c){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(u)||a(t,n,f,o);const e=r[n]||[],i=new Set;if(!o.every((t=>c(e,t,i))))throw new Error(\"Can not add duplicate data to array\");r[n]=e.concat(o)}else{if(u(o)||a(t,n,f,o),!s(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=s,e.checkHasKey=function(t,e,r){if(t.key[0]e.key.equals(t.key))).length)throw new Error(`Duplicate Key: ${t.key.toString(\"hex\")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach((t=>{Number(isNaN(Number(t)))&&e++})),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,s=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=c(\"global\"),e.updateInput=c(\"input\"),e.updateOutput=c(\"output\"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=s(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error(\"Set Version: Invalid Transaction\");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error(\"Set Locktime: Invalid Transaction\");return e.writeUInt32LE(t,e.length-4),e}},3678:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(3678),i=r(1752);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.add=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=e.split=e.fromBig=void 0;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;oBigInt(t>>>0)<>>0);e.toBig=s;const a=(t,e,r)=>t>>>r;e.shrSH=a;const c=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=c;const u=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=u;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const h=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=h;const l=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=l;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<>>32-r;e.rotlSH=y;const g=(t,e,r)=>e<>>32-r;e.rotlSL=g;const b=(t,e,r)=>e<>>64-r;e.rotlBH=b;const w=(t,e,r)=>t<>>64-r;function m(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w,e.add=m;const v=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=v;const E=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=E;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const A=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=A;const I=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=I;const T={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:c,rotrSH:u,rotrSL:f,rotrBH:h,rotrBL:l,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:g,rotlBH:b,rotlBL:w,add:m,add3L:v,add3H:E,add4L:_,add4H:S,add5H:I,add5L:A};e.default=T},8280:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},4966:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(3678),i=r(1752);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),\"function\"!=typeof this.iHash.update)throw new Error(\"Expected instance of class which extends utils.Hash\");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;tnew o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},2985:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(7653),i=r(1752),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),a=s.map((t=>(9*t+5)%16));let c=[s],u=[a];for(let t=0;t<4;t++)for(let e of[c,u])e.push(e[t].map((t=>o[t])));const f=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),l=u.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const g=new Uint32Array(16);class b extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)g[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,a=0|this.h2,f=a,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=p[t],_=d[t],S=c[t],A=u[t],I=h[t],T=l[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,a,b)+g[S[e]]+E,I[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(a,10),a=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,s,f,w)+g[A[t]]+_,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(f,10),f=s,s=r}}this.set(this.h1+a+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+f|0)}roundClean(){g.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=b,e.ripemd160=(0,i.wrapConstructor)((()=>new b))},4458:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(7653),i=r(1752),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},4787:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha384=e.sha512_256=e.sha512_224=e.sha512=e.SHA512=void 0;const n=r(7653),i=r(6079),o=r(1752),[s,a]=i.default.split([\"0x428a2f98d728ae22\",\"0x7137449123ef65cd\",\"0xb5c0fbcfec4d3b2f\",\"0xe9b5dba58189dbbc\",\"0x3956c25bf348b538\",\"0x59f111f1b605d019\",\"0x923f82a4af194f9b\",\"0xab1c5ed5da6d8118\",\"0xd807aa98a3030242\",\"0x12835b0145706fbe\",\"0x243185be4ee4b28c\",\"0x550c7dc3d5ffb4e2\",\"0x72be5d74f27b896f\",\"0x80deb1fe3b1696b1\",\"0x9bdc06a725c71235\",\"0xc19bf174cf692694\",\"0xe49b69c19ef14ad2\",\"0xefbe4786384f25e3\",\"0x0fc19dc68b8cd5b5\",\"0x240ca1cc77ac9c65\",\"0x2de92c6f592b0275\",\"0x4a7484aa6ea6e483\",\"0x5cb0a9dcbd41fbd4\",\"0x76f988da831153b5\",\"0x983e5152ee66dfab\",\"0xa831c66d2db43210\",\"0xb00327c898fb213f\",\"0xbf597fc7beef0ee4\",\"0xc6e00bf33da88fc2\",\"0xd5a79147930aa725\",\"0x06ca6351e003826f\",\"0x142929670a0e6e70\",\"0x27b70a8546d22ffc\",\"0x2e1b21385c26c926\",\"0x4d2c6dfc5ac42aed\",\"0x53380d139d95b3df\",\"0x650a73548baf63de\",\"0x766a0abb3c77b2a8\",\"0x81c2c92e47edaee6\",\"0x92722c851482353b\",\"0xa2bfe8a14cf10364\",\"0xa81a664bbc423001\",\"0xc24b8b70d0f89791\",\"0xc76c51a30654be30\",\"0xd192e819d6ef5218\",\"0xd69906245565a910\",\"0xf40e35855771202a\",\"0x106aa07032bbd1b8\",\"0x19a4c116b8d2d0c8\",\"0x1e376c085141ab53\",\"0x2748774cdf8eeb99\",\"0x34b0bcb5e19b48a8\",\"0x391c0cb3c5c95a63\",\"0x4ed8aa4ae3418acb\",\"0x5b9cca4f7763e373\",\"0x682e6ff3d6b2b8a3\",\"0x748f82ee5defb2fc\",\"0x78a5636f43172f60\",\"0x84c87814a1f0ab72\",\"0x8cc702081a6439ec\",\"0x90befffa23631e28\",\"0xa4506cebde82bde9\",\"0xbef9a3f7b2c67915\",\"0xc67178f2e372532b\",\"0xca273eceea26619c\",\"0xd186b8c721c0c207\",\"0xeada7dd6cde0eb1e\",\"0xf57d4f7fee6ed178\",\"0x06f067aa72176fba\",\"0x0a637dc5a2c898a6\",\"0x113f9804bef90dae\",\"0x1b710b35131c471b\",\"0x28db77f523047d84\",\"0x32caab7b40c72493\",\"0x3c9ebe0a15c9bebc\",\"0x431d67c49c100d4c\",\"0x4cc5d4becb3e42b6\",\"0x597f299cfc657e2a\",\"0x5fcb6fab3ad6faec\",\"0x6c44198c4a475817\"].map((t=>BigInt(t)))),c=new Uint32Array(80),u=new Uint32Array(80);class f extends n.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:f,Fl:h,Gh:l,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,s,a,c,u,f,h,l,p,d,y]}set(t,e,r,n,i,o,s,a,c,u,f,h,l,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|f,this.Fl=0|h,this.Gh=0|l,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)c[r]=t.getUint32(e),u[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|c[t-15],r=0|u[t-15],n=i.default.rotrSH(e,r,1)^i.default.rotrSH(e,r,8)^i.default.shrSH(e,r,7),o=i.default.rotrSL(e,r,1)^i.default.rotrSL(e,r,8)^i.default.shrSL(e,r,7),s=0|c[t-2],a=0|u[t-2],f=i.default.rotrSH(s,a,19)^i.default.rotrBH(s,a,61)^i.default.shrSH(s,a,6),h=i.default.rotrSL(s,a,19)^i.default.rotrBL(s,a,61)^i.default.shrSL(s,a,6),l=i.default.add4L(o,h,u[t-7],u[t-16]),p=i.default.add4H(l,n,f,c[t-7],c[t-16]);c[t]=0|p,u[t]=0|l}let{Ah:r,Al:n,Bh:o,Bl:f,Ch:h,Cl:l,Dh:p,Dl:d,Eh:y,El:g,Fh:b,Fl:w,Gh:m,Gl:v,Hh:E,Hl:_}=this;for(let t=0;t<80;t++){const e=i.default.rotrSH(y,g,14)^i.default.rotrSH(y,g,18)^i.default.rotrBH(y,g,41),S=i.default.rotrSL(y,g,14)^i.default.rotrSL(y,g,18)^i.default.rotrBL(y,g,41),A=y&b^~y&m,I=g&w^~g&v,T=i.default.add5L(_,S,I,a[t],u[t]),x=i.default.add5H(T,E,e,A,s[t],c[t]),O=0|T,k=i.default.rotrSH(r,n,28)^i.default.rotrBH(r,n,34)^i.default.rotrBH(r,n,39),P=i.default.rotrSL(r,n,28)^i.default.rotrBL(r,n,34)^i.default.rotrBL(r,n,39),R=r&o^r&h^o&h,B=n&f^n&l^f&l;E=0|m,_=0|v,m=0|b,v=0|w,b=0|y,w=0|g,({h:y,l:g}=i.default.add(0|p,0|d,0|x,0|O)),p=0|h,d=0|l,h=0|o,l=0|f,o=0|r,f=0|n;const C=i.default.add3L(O,P,B);r=i.default.add3H(C,x,k,R),n=0|C}({h:r,l:n}=i.default.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:f}=i.default.add(0|this.Bh,0|this.Bl,0|o,0|f)),({h,l}=i.default.add(0|this.Ch,0|this.Cl,0|h,0|l)),({h:p,l:d}=i.default.add(0|this.Dh,0|this.Dl,0|p,0|d)),({h:y,l:g}=i.default.add(0|this.Eh,0|this.El,0|y,0|g)),({h:b,l:w}=i.default.add(0|this.Fh,0|this.Fl,0|b,0|w)),({h:m,l:v}=i.default.add(0|this.Gh,0|this.Gl,0|m,0|v)),({h:E,l:_}=i.default.add(0|this.Hh,0|this.Hl,0|E,0|_)),this.set(r,n,o,f,h,l,p,d,y,g,b,w,m,v,E,_)}roundClean(){c.fill(0),u.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}e.SHA512=f;class h extends f{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class l extends f{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class p extends f{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}e.sha512=(0,o.wrapConstructor)((()=>new f)),e.sha512_224=(0,o.wrapConstructor)((()=>new h)),e.sha512_256=(0,o.wrapConstructor)((()=>new l)),e.sha384=(0,o.wrapConstructor)((()=>new p))},1752:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(8280),i=r(3678);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},3803:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.BIP32Factory=void 0;const i=r(1772),o=r(8899),s=r(6710),a=r(4458),c=r(973),u=r(6952),f=(0,s.base58check)(a.sha256),h=t=>f.encode(Uint8Array.from(t)),l=t=>n.from(f.decode(t));e.BIP32Factory=function(t){(0,o.testEcc)(t);const e=c.BufferN(32),r=c.compile({wif:c.UInt8,bip32:{public:c.UInt32,private:c.UInt32}}),s={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},a=2147483648,f=Math.pow(2,31)-1;function p(t){return c.String(t)&&null!==t.match(/^(m\\/)?(\\d+'?\\/)*\\d+'?$/)}function d(t){return c.UInt32(t)&&t<=f}class y{constructor(t,e){this.__D=t,this.__Q=e,this.lowR=!1}get publicKey(){return void 0===this.__Q&&(this.__Q=n.from(t.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error(\"Missing private key\");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.privateKey));{let r=n.from(t.sign(e,this.privateKey));const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=n.from(t.sign(e,this.privateKey,i));return r}}signSchnorr(e){if(!this.privateKey)throw new Error(\"Missing private key\");if(!t.signSchnorr)throw new Error(\"signSchnorr not supported by ecc library\");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error(\"verifySchnorr not supported by ecc library\");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}}class g extends y{constructor(t,e,n,i,o=0,s=0,a=0){super(t,e),this.chainCode=n,this.network=i,this.__DEPTH=o,this.__INDEX=s,this.__PARENT_FINGERPRINT=a,c(r,i)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return i.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return m(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=n.allocUnsafe(78);return r.writeUInt32BE(e,0),r.writeUInt8(this.depth,4),r.writeUInt32BE(this.parentFingerprint,5),r.writeUInt32BE(this.index,9),this.chainCode.copy(r,13),this.isNeutered()?this.publicKey.copy(r,45):(r.writeUInt8(0,45),this.privateKey.copy(r,46)),h(r)}toWIF(){if(!this.privateKey)throw new TypeError(\"Missing private key\");return u.encode(this.network.wif,this.privateKey,!0)}derive(e){c(c.UInt32,e);const r=e>=a,o=n.allocUnsafe(37);if(r){if(this.isNeutered())throw new TypeError(\"Missing private key for hardened child key\");o[0]=0,this.privateKey.copy(o,1),o.writeUInt32BE(e,33)}else this.publicKey.copy(o,0),o.writeUInt32BE(e,33);const s=i.hmacSHA512(this.chainCode,o),u=s.slice(0,32),f=s.slice(32);if(!t.isPrivate(u))return this.derive(e+1);let h;if(this.isNeutered()){const r=n.from(t.pointAddScalar(this.publicKey,u,!0));if(null===r)return this.derive(e+1);h=m(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}else{const r=n.from(t.privateAdd(this.privateKey,u));if(null==r)return this.derive(e+1);h=w(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}return h}deriveHardened(t){return c(d,t),this.derive(t+a)}derivePath(t){c(p,t);let e=t.split(\"/\");if(\"m\"===e[0]){if(this.parentFingerprint)throw new TypeError(\"Expected master, got child\");e=e.slice(1)}return e.reduce(((t,e)=>{let r;return\"'\"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error(\"xOnlyPointAddTweak not supported by ecc library\");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error(\"Cannot tweak public key!\");const s=n.from([0===o.parity?2:3]),a=n.concat([s,o.xOnlyPubkey]);return new y(void 0,a)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&1==(1&this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error(\"privateNegate not supported by ecc library\")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error(\"Invalid tweaked private key!\");return new y(n.from(o),void 0)}}function b(t,e,r){return w(t,e,r)}function w(r,n,i,o,a,u){if(c({privateKey:e,chainCode:e},{privateKey:r,chainCode:n}),i=i||s,!t.isPrivate(r))throw new TypeError(\"Private key not in range [1, n)\");return new g(r,void 0,n,i,o,a,u)}function m(r,n,i,o,a,u){if(c({publicKey:c.BufferN(33),chainCode:e},{publicKey:r,chainCode:n}),i=i||s,!t.isPoint(r))throw new TypeError(\"Point is not on the curve\");return new g(void 0,r,n,i,o,a,u)}return{fromSeed:function(t,e){if(c(c.Buffer,t),t.length<16)throw new TypeError(\"Seed should be at least 128 bits\");if(t.length>64)throw new TypeError(\"Seed should be at most 512 bits\");e=e||s;const r=i.hmacSHA512(n.from(\"Bitcoin seed\",\"utf8\"),t);return b(r.slice(0,32),r.slice(32),e)},fromBase58:function(t,e){const r=l(t);if(78!==r.length)throw new TypeError(\"Invalid buffer length\");e=e||s;const n=r.readUInt32BE(0);if(n!==e.bip32.private&&n!==e.bip32.public)throw new TypeError(\"Invalid network version\");const i=r[4],o=r.readUInt32BE(5);if(0===i&&0!==o)throw new TypeError(\"Invalid parent fingerprint\");const a=r.readUInt32BE(9);if(0===i&&0!==a)throw new TypeError(\"Invalid index\");const c=r.slice(13,45);let u;if(n===e.bip32.private){if(0!==r.readUInt8(45))throw new TypeError(\"Invalid private key\");u=w(r.slice(46,78),c,e,i,a,o)}else{u=m(r.slice(45,78),c,e,i,a,o)}return u},fromPublicKey:function(t,e,r){return m(t,e,r)},fromPrivateKey:b}}},1772:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.hmacSHA512=e.hash160=void 0;const i=r(4966),o=r(2985),s=r(4458),a=r(4787);e.hash160=function(t){const e=(0,s.sha256)(Uint8Array.from(t));return n.from((0,o.ripemd160)(e))},e.hmacSHA512=function(t,e){return n.from((0,i.hmac)(a.sha512,t,e))}},3553:(t,e,r)=>{\"use strict\";e.Pr=void 0;var n=r(3803);Object.defineProperty(e,\"Pr\",{enumerable:!0,get:function(){return n.BIP32Factory}})},8899:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,\"hex\");function o(t){if(!t)throw new Error(\"ecc library invalid\")}e.testEcc=function(t){if(o(t.isPoint(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(!t.isPoint(i(\"030000000000000000000000000000000000000000000000000000000000000005\"))),o(t.isPrivate(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(!t.isPrivate(i(\"0000000000000000000000000000000000000000000000000000000000000000\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142\"))),o(n.from(t.pointFromScalar(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99\"))),t.xOnlyPointAddTweak){o(null===t.xOnlyPointAddTweak(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\")));let e=t.xOnlyPointAddTweak(i(\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\"),i(\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\"));o(n.from(e.xOnlyPubkey).equals(i(\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"))&&1===e.parity),e=t.xOnlyPointAddTweak(i(\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\"),i(\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\"))}o(n.from(t.pointAddScalar(i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"0000000000000000000000000000000000000000000000000000000000000003\"))).equals(i(\"02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\"))),o(n.from(t.privateAdd(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"),i(\"0000000000000000000000000000000000000000000000000000000000000002\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),t.privateNegate&&(o(n.from(t.privateNegate(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(n.from(t.privateNegate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateNegate(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792\")))),o(n.from(t.sign(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))).equals(i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),o(t.verify(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),t.signSchnorr&&o(n.from(t.signSchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9\"),i(\"c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906\"))).equals(i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\"))),t.verifySchnorr&&o(t.verifySchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8\"),i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\")))}},3877:(t,e)=>{\"use strict\";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if(\"boolean\"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error(\"Uint8Array expected\");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if(\"function\"!=typeof t||\"function\"!=typeof t.create)throw new Error(\"Hash should be wrapped by utils.wrapConstructor\");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error(\"Hash instance has been destroyed\");if(e&&t.finished)throw new Error(\"Hash#digest() has already been called\")}function c(t,e){o(t);const r=e.outputLen;if(t.length{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(3877),i=r(775);e.Chi=(t,e,r)=>t&e^~t&r;e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error(\"_sha2: outputLen should be aligned to 32bit\");const f=u/4,h=this.get();if(f>h.length)throw new Error(\"_sha2: outputLen bigger than state\");for(let t=0;t{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.crypto=void 0,e.crypto=\"object\"==typeof globalThis&&\"crypto\"in globalThis?globalThis.crypto:void 0},742:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(1810),i=r(775),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),a=s.map((t=>(9*t+5)%16));let c=[s],u=[a];for(let t=0;t<4;t++)for(let e of[c,u])e.push(e[t].map((t=>o[t])));const f=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),l=u.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const g=new Uint32Array(16);class b extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)g[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,a=0|this.h2,f=a,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=p[t],_=d[t],S=c[t],A=u[t],I=h[t],T=l[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,a,b)+g[S[e]]+E,I[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(a,10),a=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,s,f,w)+g[A[t]]+_,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(f,10),f=s,s=r}}this.set(this.h1+a+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+f|0)}roundClean(){g.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=b,e.ripemd160=(0,i.wrapConstructor)((()=>new b))},3293:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha1=void 0;const n=r(1810),i=r(775),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),s=new Uint32Array(80);class a extends n.HashMD{constructor(){super(64,20,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4]}get(){const{A:t,B:e,C:r,D:n,E:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)s[t]=(0,i.rotl)(s[t-3]^s[t-8]^s[t-14]^s[t-16],1);let{A:r,B:o,C:a,D:c,E:u}=this;for(let t=0;t<80;t++){let e,f;t<20?(e=(0,n.Chi)(o,a,c),f=1518500249):t<40?(e=o^a^c,f=1859775393):t<60?(e=(0,n.Maj)(o,a,c),f=2400959708):(e=o^a^c,f=3395469782);const h=(0,i.rotl)(r,5)+e+u+f+s[t]|0;u=c,c=a,a=(0,i.rotl)(o,30),o=r,r=h}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,c=c+this.D|0,u=u+this.E|0,this.set(r,o,a,c,u)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.sha1=(0,i.wrapConstructor)((()=>new a))},5743:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.sha224=e.sha256=void 0;const n=r(1810),i=r(775),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class c extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:c,D:u,E:f,F:h,G:l,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,l)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,c)|0;p=l,l=h,h=f,f=u+e|0,u=c,c=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,u=u+this.D|0,f=f+this.E|0,h=h+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(r,s,c,u,f,h,l,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new c)),e.sha224=(0,i.wrapConstructor)((()=>new u))},775:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(8713),i=r(3877);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&\"object\"==typeof t&&\"Uint8Array\"===t.constructor.name};e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);e.rotr=(t,e)=>t<<32-e|t>>>e;e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;re.toString(16).padStart(2,\"0\")));e.bytesToHex=function(t){(0,i.bytes)(t);let e=\"\";for(let r=0;r=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}e.hexToBytes=function(t){if(\"string\"!=typeof t)throw new Error(\"hex string expected, got \"+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error(\"padded hex string expected, got unpadded hex of length \"+e);const n=new Uint8Array(r);for(let e=0,i=0;e{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&tt().update(u(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(u(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&\"function\"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error(\"crypto.getRandomValues must be defined\")}},7748:t=>{\"use strict\";t.exports=function(t){if(t.length>=255)throw new TypeError(\"Alphabet too long\");for(var e=new Uint8Array(256),r=0;r>>0,u=new Uint8Array(o);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,l=o-1;(0!==f||h>>0,u[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error(\"Non-zero carry\");i=h,r++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var d=new Uint8Array(n+(o-p)),y=n;p!==o;)d[y++]=u[p++];return d}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError(\"Expected Uint8Array\");if(0===e.length)return\"\";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var c=(o-i)*u+1>>>0,f=new Uint8Array(c);i!==o;){for(var h=e[i],l=0,p=c-1;(0!==h||l>>0,f[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error(\"Non-zero carry\");n=l,i++}for(var d=c-n;d!==c&&0===f[d];)d++;for(var y=a.repeat(r);d{const n=r(7748);t.exports=n(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\")},5940:(t,e,r)=>{\"use strict\";var n=r(8155);t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),i=t(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error(\"Invalid checksum\");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},7329:(t,e,r)=>{\"use strict\";var{sha256:n}=r(5743),i=r(5940);t.exports=i((function(t){return n(n(t))}))},3348:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.toOutputScript=e.fromOutputScript=e.toBech32=e.toBase58Check=e.fromBech32=e.fromBase58Check=void 0;const i=r(2529),o=r(8614),s=r(4009),a=r(5593),c=r(6586),u=r(7329),f=40,h=2,l=16,p=2,d=80,y=\"WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.\";function g(t){const e=n.from(u.decode(t));if(e.length<21)throw new TypeError(t+\" is too short\");if(e.length>21)throw new TypeError(t+\" is too long\");return{version:e.readUInt8(0),hash:e.slice(1)}}function b(t){let e,r;try{e=c.bech32.decode(t)}catch(t){}if(e){if(r=e.words[0],0!==r)throw new TypeError(t+\" uses wrong encoding\")}else if(e=c.bech32m.decode(t),r=e.words[0],0===r)throw new TypeError(t+\" uses wrong encoding\");const i=c.bech32.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:n.from(i)}}function w(t,e,r){const n=c.bech32.toWords(t);return n.unshift(e),0===e?c.bech32.encode(r,n):c.bech32m.encode(r,n)}e.fromBase58Check=g,e.fromBech32=b,e.toBase58Check=function(t,e){(0,a.typeforce)((0,a.tuple)(a.Hash160bit,a.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),u.encode(r)},e.toBech32=w,e.fromOutputScript=function(t,e){e=e||i.bitcoin;try{return o.p2pkh({output:t,network:e}).address}catch(t){}try{return o.p2sh({output:t,network:e}).address}catch(t){}try{return o.p2wpkh({output:t,network:e}).address}catch(t){}try{return o.p2wsh({output:t,network:e}).address}catch(t){}try{return o.p2tr({output:t,network:e}).address}catch(t){}try{return function(t,e){const r=t.slice(2);if(r.lengthf)throw new TypeError(\"Invalid program length for segwit address\");const n=t[0]-d;if(nl)throw new TypeError(\"Invalid version for segwit address\");if(t[1]!==r.length)throw new TypeError(\"Invalid script for segwit address\");return console.warn(y),w(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(s.toASM(t)+\" has no matching Address\")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=g(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===e.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=b(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+\" has an invalid prefix\");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=p&&n.version<=l&&n.data.length>=h&&n.data.length<=f)return console.warn(y),s.compile([n.version+d,n.data])}}throw new Error(t+\" has no matching Script\")}},195:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=e.check=void 0,e.check=function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;const e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;const r=t[5+e];return 0!==r&&(6+e+r===t.length&&(!(128&t[4])&&(!(e>1&&0===t[4]&&!(128&t[5]))&&(!(128&t[e+6])&&!(r>1&&0===t[e+6]&&!(128&t[e+7]))))))},e.decode=function(t){if(t.length<8)throw new Error(\"DER sequence length is too short\");if(t.length>72)throw new Error(\"DER sequence length is too long\");if(48!==t[0])throw new Error(\"Expected DER sequence\");if(t[1]!==t.length-2)throw new Error(\"DER sequence length is invalid\");if(2!==t[2])throw new Error(\"Expected DER integer\");const e=t[3];if(0===e)throw new Error(\"R length is zero\");if(5+e>=t.length)throw new Error(\"R length is too long\");if(2!==t[4+e])throw new Error(\"Expected DER integer (2)\");const r=t[5+e];if(0===r)throw new Error(\"S length is zero\");if(6+e+r!==t.length)throw new Error(\"S length is invalid\");if(128&t[4])throw new Error(\"R value is negative\");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error(\"R value excessively padded\");if(128&t[e+6])throw new Error(\"S value is negative\");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error(\"S value excessively padded\");return{r:t.slice(4,4+e),s:t.slice(6+e)}},e.encode=function(t,e){const r=t.length,i=e.length;if(0===r)throw new Error(\"R length is zero\");if(0===i)throw new Error(\"S length is zero\");if(r>33)throw new Error(\"R length is too long\");if(i>33)throw new Error(\"S length is too long\");if(128&t[0])throw new Error(\"R value is negative\");if(128&e[0])throw new Error(\"S value is negative\");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error(\"R value excessively padded\");if(i>1&&0===e[0]&&!(128&e[1]))throw new Error(\"S value excessively padded\");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=t.length,t.copy(o,4),o[4+r]=2,o[5+r]=e.length,e.copy(o,6+r),o}},1169:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Block=void 0;const i=r(3831),o=r(6891),s=r(7992),a=r(3063),c=r(5593),{typeforce:u}=c,f=new TypeError(\"Cannot compute merkle root for zero transactions\"),h=new TypeError(\"Cannot compute witness commit for non-segwit block\");class l{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(t){if(t.length<80)throw new Error(\"Buffer too small (< 80 bytes)\");const e=new i.BufferReader(t),r=new l;if(r.version=e.readInt32(),r.prevHash=e.readSlice(32),r.merkleRoot=e.readSlice(32),r.timestamp=e.readUInt32(),r.bits=e.readUInt32(),r.nonce=e.readUInt32(),80===t.length)return r;const n=()=>{const t=a.Transaction.fromBuffer(e.buffer.slice(e.offset),!0);return e.offset+=t.byteLength(),t},o=e.readVarInt();r.transactions=[];for(let t=0;t>24)-3,r=8388607&t,i=n.alloc(32,0);return i.writeUIntBE(r,29-e,3),i}static calculateMerkleRoot(t,e){if(u([{getHash:c.Function}],t),0===t.length)throw f;if(e&&!p(t))throw h;const r=t.map((t=>t.getHash(e))),i=(0,s.fastMerkleRoot)(r,o.hash256);return e?o.hash256(n.concat([i,t[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!p(this.transactions))return null;const t=this.transactions[0].outs.filter((t=>t.script.slice(0,6).equals(n.from(\"6a24aa21a9ed\",\"hex\")))).map((t=>t.script.slice(6,38)));if(0===t.length)return null;const e=t[t.length-1];return e instanceof n&&32===e.length?e:null}hasWitnessCommit(){return this.witnessCommit instanceof n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(t=this.transactions)instanceof Array&&t.some((t=>\"object\"==typeof t&&t.ins instanceof Array&&t.ins.some((t=>\"object\"==typeof t&&t.witness instanceof Array&&t.witness.length>0))));var t}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(t,e=!0){return t||!this.transactions?80:80+i.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((t,r)=>t+r.byteLength(e)),0)}getHash(){return o.hash256(this.toBuffer(!0))}getId(){return(0,i.reverseBuffer)(this.getHash()).toString(\"hex\")}getUTCDate(){const t=new Date(0);return t.setUTCSeconds(this.timestamp),t}toBuffer(t){const e=n.allocUnsafe(this.byteLength(t)),r=new i.BufferWriter(e);return r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),t||!this.transactions||(i.varuint.encode(this.transactions.length,e,r.offset),r.offset+=i.varuint.encode.bytes,this.transactions.forEach((t=>{const n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}toHex(t){return this.toBuffer(t).toString(\"hex\")}checkTxRoots(){const t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&(this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit()))}checkProofOfWork(){const t=(0,i.reverseBuffer)(this.getHash()),e=l.calculateTarget(this.bits);return t.compare(e)<=0}__checkMerkleRoot(){if(!this.transactions)throw f;const t=l.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw f;if(!this.hasWitnessCommit())throw h;const t=l.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}function p(t){return t instanceof Array&&t[0]&&t[0].ins&&t[0].ins instanceof Array&&t[0].ins[0]&&t[0].ins[0].witness&&t[0].ins[0].witness instanceof Array&&t[0].ins[0].witness.length>0}e.Block=l},3831:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.BufferReader=e.BufferWriter=e.cloneBuffer=e.reverseBuffer=e.writeUInt64LE=e.readUInt64LE=e.varuint=void 0;const i=r(5593),{typeforce:o}=i,s=r(7820);function a(t,e){if(\"number\"!=typeof t)throw new Error(\"cannot write a non-number as a number\");if(t<0)throw new Error(\"specified a negative value for writing an unsigned value\");if(t>e)throw new Error(\"RangeError: value out of range\");if(Math.floor(t)!==t)throw new Error(\"value has a fractional component\")}function c(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r}function u(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}e.varuint=s,e.readUInt64LE=c,e.writeUInt64LE=u,e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;nthis.writeVarSlice(t)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}e.BufferWriter=f;e.BufferReader=class{constructor(t,e=0){this.buffer=t,this.offset=e,o(i.tuple(i.Buffer,i.UInt32),[t,e])}readUInt8(){const t=this.buffer.readUInt8(this.offset);return this.offset++,t}readInt32(){const t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}readUInt32(){const t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}readUInt64(){const t=c(this.buffer,this.offset);return this.offset+=8,t}readVarInt(){const t=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,t}readSlice(t){if(this.buffer.length{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const i=r(742),o=r(3293),s=r(5743);function a(t){return n.from((0,s.sha256)(Uint8Array.from(t)))}e.ripemd160=function(t){return n.from((0,i.ripemd160)(Uint8Array.from(t)))},e.sha1=function(t){return n.from((0,o.sha1)(Uint8Array.from(t)))},e.sha256=a,e.hash160=function(t){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(t))))},e.TAGS=[\"BIP0340/challenge\",\"BIP0340/aux\",\"BIP0340/nonce\",\"TapLeaf\",\"TapBranch\",\"TapSighash\",\"TapTweak\",\"KeyAgg list\",\"KeyAgg coefficient\"],e.TAGGED_HASH_PREFIXES={\"BIP0340/challenge\":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),\"BIP0340/aux\":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),\"BIP0340/nonce\":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),\"KeyAgg list\":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),\"KeyAgg coefficient\":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},e.taggedHash=function(t,r){return a(n.concat([e.TAGGED_HASH_PREFIXES[t],r]))}},6313:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.getEccLib=e.initEccLib=void 0;const i={};e.initEccLib=function(t){var e;t?t!==i.eccLib&&(s(\"function\"==typeof(e=t).isXOnlyPoint),s(e.isXOnlyPoint(o(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),s(e.isXOnlyPoint(o(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e\"))),s(e.isXOnlyPoint(o(\"f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9\"))),s(e.isXOnlyPoint(o(\"0000000000000000000000000000000000000000000000000000000000000001\"))),s(!e.isXOnlyPoint(o(\"0000000000000000000000000000000000000000000000000000000000000000\"))),s(!e.isXOnlyPoint(o(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\"))),s(\"function\"==typeof e.xOnlyPointAddTweak),a.forEach((t=>{const r=e.xOnlyPointAddTweak(o(t.pubkey),o(t.tweak));null===t.result?s(null===r):(s(null!==r),s(r.parity===t.parity),s(n.from(r.xOnlyPubkey).equals(o(t.result))))})),i.eccLib=t):i.eccLib=t},e.getEccLib=function(){if(!i.eccLib)throw new Error(\"No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance\");return i.eccLib};const o=t=>n.from(t,\"hex\");function s(t){if(!t)throw new Error(\"ecc library invalid\")}const a=[{pubkey:\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\",tweak:\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\",parity:-1,result:null},{pubkey:\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\",tweak:\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\",parity:1,result:\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"},{pubkey:\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\",tweak:\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\",parity:0,result:\"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c\"}]},7612:(t,e,r)=>{\"use strict\";e.ZX=e.iL=e.KT=e.o8=e.hl=void 0;const n=r(3348);e.hl=n;r(6891);const i=r(2529);e.o8=i;const o=r(8614);e.KT=o;r(4009);var s=r(1169);var a=r(6689);Object.defineProperty(e,\"iL\",{enumerable:!0,get:function(){return a.Psbt}});var c=r(8156);var u=r(3063);Object.defineProperty(e,\"ZX\",{enumerable:!0,get:function(){return u.Transaction}});var f=r(6313)},7992:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.fastMerkleRoot=void 0,e.fastMerkleRoot=function(t,e){if(!Array.isArray(t))throw TypeError(\"Expected values Array\");if(\"function\"!=typeof e)throw TypeError(\"Expected digest Function\");let r=t.length;const i=t.concat();for(;r>1;){let t=0;for(let o=0;o{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.testnet=e.regtest=e.bitcoin=void 0,e.bitcoin={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.regtest={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bcrt\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},e.testnet={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"tb\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},8156:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.REVERSE_OPS=e.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};e.OPS=r;const n={};e.REVERSE_OPS=n;for(const t of Object.keys(r)){n[r[t]]=t}},5247:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(1048),i=r(6313),o=r(6891),s=r(3831),a=r(5593);e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128;function c(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return o.taggedHash(\"TapLeaf\",n.Buffer.concat([n.Buffer.from([r]),h(t.output)]))}function u(t,e){return o.taggedHash(\"TapTweak\",n.Buffer.concat(e?[t,e]:[t]))}function f(t,e){return o.taggedHash(\"TapBranch\",n.Buffer.concat([t,e]))}function h(t){const e=s.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return s.varuint.encode(t.length,r),n.Buffer.concat([r,t])}e.rootHashFromPath=function(t,e){if(t.length<33)throw new TypeError(`The control-block length is too small. Got ${t.length}, expected min 33.`);const r=(t.length-33)/32;let n=e;for(let e=0;et.hash.compare(e.hash)));const[n,i]=r;return{hash:f(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function t(e,r){if(\"left\"in(n=e)&&\"right\"in n){const n=t(e.left,r);if(void 0!==n)return[...n,e.right.hash];const i=t(e.right,r);if(void 0!==i)return[...i,e.left.hash]}else if(e.hash.equals(r))return[];var n},e.tapleafHash=c,e.tapTweakHash=u,e.tweakKey=function(t,e){if(!n.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;const r=u(t,e),o=(0,i.getEccLib)().xOnlyPointAddTweak(t,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},271:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2data=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;e.p2data=function(t,e){if(!t.data&&!t.output)throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},t);const r={name:\"embed\",network:t.network||n.bitcoin};if(s.prop(r,\"output\",(()=>{if(t.data)return i.compile([a.OP_RETURN].concat(t.data))})),s.prop(r,\"data\",(()=>{if(t.output)return i.decompile(t.output).slice(1)})),e.validate&&t.output){const e=i.decompile(t.output);if(e[0]!==a.OP_RETURN)throw new TypeError(\"Output is invalid\");if(!e.slice(1).every(o.typeforce.Buffer))throw new TypeError(\"Output is invalid\");if(t.data&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.data,r.data))throw new TypeError(\"Data mismatch\")}return Object.assign(r,t)}},8614:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const n=r(271);Object.defineProperty(e,\"embed\",{enumerable:!0,get:function(){return n.p2data}});const i=r(2810);Object.defineProperty(e,\"p2ms\",{enumerable:!0,get:function(){return i.p2ms}});const o=r(5643);Object.defineProperty(e,\"p2pk\",{enumerable:!0,get:function(){return o.p2pk}});const s=r(9379);Object.defineProperty(e,\"p2pkh\",{enumerable:!0,get:function(){return s.p2pkh}});const a=r(2129);Object.defineProperty(e,\"p2sh\",{enumerable:!0,get:function(){return a.p2sh}});const c=r(7090);Object.defineProperty(e,\"p2wpkh\",{enumerable:!0,get:function(){return c.p2wpkh}});const u=r(2366);Object.defineProperty(e,\"p2wsh\",{enumerable:!0,get:function(){return u.p2wsh}});const f=r(1992);Object.defineProperty(e,\"p2tr\",{enumerable:!0,get:function(){return f.p2tr}})},9158:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.value=e.prop=void 0,e.prop=function(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){const t=r.call(this);return this[e]=t,t},set(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})},e.value=function(t){let e;return()=>(void 0!==e||(e=t()),e)}},2810:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2ms=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS,c=a.OP_RESERVED;function u(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}e.p2ms=function(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError(\"Not enough data\");function r(t){return i.isCanonicalScriptSignature(t)||void 0!==(e.allowIncomplete&&t===a.OP_0)}e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const f={network:t.network||n.bitcoin};let h=[],l=!1;function p(t){l||(l=!0,h=i.decompile(t),f.m=h[0]-c,f.n=h[h.length-2]-c,f.pubkeys=h.slice(1,-2))}if(s.prop(f,\"output\",(()=>{if(t.m&&f.n&&t.pubkeys)return i.compile([].concat(c+t.m,t.pubkeys,c+f.n,a.OP_CHECKMULTISIG))})),s.prop(f,\"m\",(()=>{if(f.output)return p(f.output),f.m})),s.prop(f,\"n\",(()=>{if(f.pubkeys)return f.pubkeys.length})),s.prop(f,\"pubkeys\",(()=>{if(t.output)return p(t.output),f.pubkeys})),s.prop(f,\"signatures\",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),s.prop(f,\"input\",(()=>{if(t.signatures)return i.compile([a.OP_0].concat(t.signatures))})),s.prop(f,\"witness\",(()=>{if(f.input)return[]})),s.prop(f,\"name\",(()=>{if(f.m&&f.n)return`p2ms(${f.m} of ${f.n})`})),e.validate){if(t.output){if(p(t.output),!o.typeforce.Number(h[0]))throw new TypeError(\"Output is invalid\");if(!o.typeforce.Number(h[h.length-2]))throw new TypeError(\"Output is invalid\");if(h[h.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError(\"Output is invalid\");if(f.m<=0||f.n>16||f.m>f.n||f.n!==h.length-3)throw new TypeError(\"Output is invalid\");if(!f.pubkeys.every((t=>(0,o.isPoint)(t))))throw new TypeError(\"Output is invalid\");if(void 0!==t.m&&t.m!==f.m)throw new TypeError(\"m mismatch\");if(void 0!==t.n&&t.n!==f.n)throw new TypeError(\"n mismatch\");if(t.pubkeys&&!u(t.pubkeys,f.pubkeys))throw new TypeError(\"Pubkeys mismatch\")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError(\"Pubkey count mismatch\");if(f.n=t.pubkeys.length,f.nf.m)throw new TypeError(\"Too many signatures provided\")}if(t.input){if(t.input[0]!==a.OP_0)throw new TypeError(\"Input is invalid\");if(0===f.signatures.length||!f.signatures.every(r))throw new TypeError(\"Input has invalid signature(s)\");if(t.signatures&&!u(t.signatures,f.signatures))throw new TypeError(\"Signature mismatch\");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError(\"Signature count mismatch\")}}return Object.assign(f,t)}},5643:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2pk=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;e.p2pk=function(t,e){if(!(t.input||t.output||t.pubkey||t.input||t.signature))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const r=s.value((()=>i.decompile(t.input))),c={name:\"p2pk\",network:t.network||n.bitcoin};if(s.prop(c,\"output\",(()=>{if(t.pubkey)return i.compile([t.pubkey,a.OP_CHECKSIG])})),s.prop(c,\"pubkey\",(()=>{if(t.output)return t.output.slice(1,-1)})),s.prop(c,\"signature\",(()=>{if(t.input)return r()[0]})),s.prop(c,\"input\",(()=>{if(t.signature)return i.compile([t.signature])})),s.prop(c,\"witness\",(()=>{if(c.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==a.OP_CHECKSIG)throw new TypeError(\"Output is invalid\");if(!(0,o.isPoint)(c.pubkey))throw new TypeError(\"Output pubkey is invalid\");if(t.pubkey&&!t.pubkey.equals(c.pubkey))throw new TypeError(\"Pubkey mismatch\")}if(t.signature&&t.input&&!t.input.equals(c.input))throw new TypeError(\"Signature mismatch\");if(t.input){if(1!==r().length)throw new TypeError(\"Input is invalid\");if(!i.isCanonicalScriptSignature(c.signature))throw new TypeError(\"Input has invalid signature\")}}return Object.assign(c,t)}},9379:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2pkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(7329),f=s.OPS;e.p2pkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(25)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),input:a.typeforce.maybe(a.typeforce.Buffer)},t);const r=c.value((()=>{const e=n.from(u.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),h=c.value((()=>s.decompile(t.input))),l=t.network||o.bitcoin,p={name:\"p2pkh\",network:l};if(c.prop(p,\"address\",(()=>{if(!p.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(l.pubKeyHash,0),p.hash.copy(t,1),u.encode(t)})),c.prop(p,\"hash\",(()=>t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),c.prop(p,\"output\",(()=>{if(p.hash)return s.compile([f.OP_DUP,f.OP_HASH160,p.hash,f.OP_EQUALVERIFY,f.OP_CHECKSIG])})),c.prop(p,\"pubkey\",(()=>{if(t.input)return h()[1]})),c.prop(p,\"signature\",(()=>{if(t.input)return h()[0]})),c.prop(p,\"input\",(()=>{if(t.pubkey&&t.signature)return s.compile([t.signature,t.pubkey])})),c.prop(p,\"witness\",(()=>{if(p.input)return[]})),e.validate){let e=n.from([]);if(t.address){if(r().version!==l.pubKeyHash)throw new TypeError(\"Invalid version or Network mismatch\");if(20!==r().hash.length)throw new TypeError(\"Invalid address\");e=r().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==f.OP_DUP||t.output[1]!==f.OP_HASH160||20!==t.output[2]||t.output[23]!==f.OP_EQUALVERIFY||t.output[24]!==f.OP_CHECKSIG)throw new TypeError(\"Output is invalid\");const r=t.output.slice(3,23);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.input){const r=h();if(2!==r.length)throw new TypeError(\"Input is invalid\");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError(\"Input has invalid signature\");if(!(0,a.isPoint)(r[1]))throw new TypeError(\"Input has invalid pubkey\");if(t.signature&&!t.signature.equals(r[0]))throw new TypeError(\"Signature mismatch\");if(t.pubkey&&!t.pubkey.equals(r[1]))throw new TypeError(\"Pubkey mismatch\");const n=i.hash160(r[1]);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\")}}return Object.assign(p,t)}},2129:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2sh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(7329),f=s.OPS;e.p2sh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(23)),redeem:a.typeforce.maybe({network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||o.bitcoin);const h={network:r},l=c.value((()=>{const e=n.from(u.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),p=c.value((()=>s.decompile(t.input))),d=c.value((()=>{const e=p(),i=e[e.length-1];return{network:r,output:i===f.OP_FALSE?n.from([]):i,input:s.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(c.prop(h,\"address\",(()=>{if(!h.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(h.network.scriptHash,0),h.hash.copy(t,1),u.encode(t)})),c.prop(h,\"hash\",(()=>t.output?t.output.slice(2,22):t.address?l().hash:h.redeem&&h.redeem.output?i.hash160(h.redeem.output):void 0)),c.prop(h,\"output\",(()=>{if(h.hash)return s.compile([f.OP_HASH160,h.hash,f.OP_EQUAL])})),c.prop(h,\"redeem\",(()=>{if(t.input)return d()})),c.prop(h,\"input\",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return s.compile([].concat(s.decompile(t.redeem.input),t.redeem.output))})),c.prop(h,\"witness\",(()=>h.redeem&&h.redeem.witness?h.redeem.witness:h.input?[]:void 0)),c.prop(h,\"name\",(()=>{const t=[\"p2sh\"];return void 0!==h.redeem&&void 0!==h.redeem.name&&t.push(h.redeem.name),t.join(\"-\")})),e.validate){let e=n.from([]);if(t.address){if(l().version!==r.scriptHash)throw new TypeError(\"Invalid version or Network mismatch\");if(20!==l().hash.length)throw new TypeError(\"Invalid address\");e=l().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==f.OP_HASH160||20!==t.output[1]||t.output[22]!==f.OP_EQUAL)throw new TypeError(\"Output is invalid\");const r=t.output.slice(2,22);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}const o=t=>{if(t.output){const r=s.decompile(t.output);if(!r||r.length<1)throw new TypeError(\"Redeem.output too short\");if(t.output.byteLength>520)throw new TypeError(\"Redeem.output unspendable if larger than 520 bytes\");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError(\"Redeem.output unspendable with more than 201 non-push ops\");const n=i.hash160(t.output);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\");e=n}if(t.input){const e=t.input.length>0,r=t.witness&&t.witness.length>0;if(!e&&!r)throw new TypeError(\"Empty input\");if(e&&r)throw new TypeError(\"Input and witness provided\");if(e){const e=s.decompile(t.input);if(!s.isPushOnly(e))throw new TypeError(\"Non push-only scriptSig\")}}};if(t.input){const t=p();if(!t||t.length<1)throw new TypeError(\"Input too short\");if(!n.isBuffer(d().output))throw new TypeError(\"Input is invalid\");o(d())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError(\"Network mismatch\");if(t.input){const e=d();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError(\"Redeem.output mismatch\");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError(\"Redeem.input mismatch\")}o(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,t.witness))throw new TypeError(\"Witness and redeem.witness mismatch\")}return Object.assign(h,t)}},1992:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2tr=void 0;const n=r(1048),i=r(2529),o=r(4009),s=r(5593),a=r(6313),c=r(5247),u=r(9158),f=r(6586),h=o.OPS;e.p2tr=function(t,e){if(!(t.address||t.output||t.pubkey||t.internalPubkey||t.witness&&t.witness.length>1))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},t);const r=u.value((()=>{const e=f.bech32m.decode(t.address),r=e.words.shift(),i=f.bech32m.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.Buffer.from(i)}})),l=u.value((()=>{if(t.witness&&t.witness.length)return t.witness.length>=2&&80===t.witness[t.witness.length-1][0]?t.witness.slice(0,-1):t.witness.slice()})),p=u.value((()=>t.scriptTree?(0,c.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),d=t.network||i.bitcoin,y={name:\"p2tr\",network:d};if(u.prop(y,\"address\",(()=>{if(!y.pubkey)return;const t=f.bech32m.toWords(y.pubkey);return t.unshift(1),f.bech32m.encode(d.bech32,t)})),u.prop(y,\"hash\",(()=>{const t=p();if(t)return t.hash;const e=l();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&s.TAPLEAF_VERSION_MASK,n=e[e.length-2],i=(0,c.tapleafHash)({output:n,version:r});return(0,c.rootHashFromPath)(t,i)}return null})),u.prop(y,\"output\",(()=>{if(y.pubkey)return o.compile([h.OP_1,y.pubkey])})),u.prop(y,\"redeemVersion\",(()=>t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:c.LEAF_VERSION_TAPSCRIPT)),u.prop(y,\"redeem\",(()=>{const t=l();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&s.TAPLEAF_VERSION_MASK}})),u.prop(y,\"pubkey\",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(y.internalPubkey){const t=(0,c.tweakKey)(y.internalPubkey,y.hash);if(t)return t.x}})),u.prop(y,\"internalPubkey\",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=l();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),u.prop(y,\"signature\",(()=>{if(t.signature)return t.signature;const e=l();return e&&1===e.length?e[0]:void 0})),u.prop(y,\"witness\",(()=>{if(t.witness)return t.witness;const e=p();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,c.tapleafHash)({output:t.redeem.output,version:y.redeemVersion}),i=(0,c.findScriptPath)(e,r);if(!i)return;const o=(0,c.tweakKey)(t.internalPubkey,e.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([y.redeemVersion|o.parity]),t.internalPubkey].concat(i));return[t.redeem.output,s]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(d&&d.bech32!==r().prefix)throw new TypeError(\"Invalid prefix or Network mismatch\");if(1!==r().version)throw new TypeError(\"Invalid address version\");if(32!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.pubkey){if(e.length>0&&!e.equals(t.pubkey))throw new TypeError(\"Pubkey mismatch\");e=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==h.OP_1||32!==t.output[1])throw new TypeError(\"Output is invalid\");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError(\"Pubkey mismatch\");e=t.output.slice(2)}if(t.internalPubkey){const r=(0,c.tweakKey)(t.internalPubkey,y.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError(\"Pubkey mismatch\");e=r.x}if(e&&e.length&&!(0,a.getEccLib)().isXOnlyPoint(e))throw new TypeError(\"Invalid pubkey for p2tr\");const i=p();if(t.hash&&i&&!t.hash.equals(i.hash))throw new TypeError(\"Hash mismatch\");if(t.redeem&&t.redeem.output&&i){const e=(0,c.tapleafHash)({output:t.redeem.output,version:y.redeemVersion});if(!(0,c.findScriptPath)(i,e))throw new TypeError(\"Redeem script not in tree\")}const u=l();if(t.redeem&&y.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==y.redeem.redeemVersion)throw new TypeError(\"Redeem.redeemVersion and witness mismatch\");if(t.redeem.output){if(0===o.decompile(t.redeem.output).length)throw new TypeError(\"Redeem.output is invalid\");if(y.redeem.output&&!t.redeem.output.equals(y.redeem.output))throw new TypeError(\"Redeem.output and witness mismatch\")}if(t.redeem.witness&&y.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,y.redeem.witness))throw new TypeError(\"Redeem.witness and witness mismatch\")}if(u&&u.length)if(1===u.length){if(t.signature&&!t.signature.equals(u[0]))throw new TypeError(\"Signature mismatch\")}else{const r=u[u.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(i))throw new TypeError(\"Internal pubkey mismatch\");if(!(0,a.getEccLib)().isXOnlyPoint(i))throw new TypeError(\"Invalid internalPubkey for p2tr witness\");const o=r[0]&s.TAPLEAF_VERSION_MASK,f=u[u.length-2],h=(0,c.tapleafHash)({output:f,version:o}),l=(0,c.rootHashFromPath)(r,h),p=(0,c.tweakKey)(i,l);if(!p)throw new TypeError(\"Invalid outputKey for p2tr witness\");if(e.length&&!e.equals(p.x))throw new TypeError(\"Pubkey mismatch for p2tr witness\");if(p.parity!==(1&r[0]))throw new Error(\"Incorrect parity\")}}return Object.assign(y,t)}},7090:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2wpkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(6586),f=s.OPS,h=n.alloc(0);e.p2wpkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(22)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=c.value((()=>{const e=u.bech32.decode(t.address),r=e.words.shift(),i=u.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),l=t.network||o.bitcoin,p={name:\"p2wpkh\",network:l};if(c.prop(p,\"address\",(()=>{if(!p.hash)return;const t=u.bech32.toWords(p.hash);return t.unshift(0),u.bech32.encode(l.bech32,t)})),c.prop(p,\"hash\",(()=>t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),c.prop(p,\"output\",(()=>{if(p.hash)return s.compile([f.OP_0,p.hash])})),c.prop(p,\"pubkey\",(()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0)),c.prop(p,\"signature\",(()=>{if(t.witness)return t.witness[0]})),c.prop(p,\"input\",(()=>{if(p.witness)return h})),c.prop(p,\"witness\",(()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){let e=n.from([]);if(t.address){if(l&&l.bech32!==r().prefix)throw new TypeError(\"Invalid prefix or Network mismatch\");if(0!==r().version)throw new TypeError(\"Invalid address version\");if(20!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==f.OP_0||20!==t.output[1])throw new TypeError(\"Output is invalid\");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError(\"Hash mismatch\");e=t.output.slice(2)}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");if(e=r,!(0,a.isPoint)(t.pubkey)||33!==t.pubkey.length)throw new TypeError(\"Invalid pubkey for p2wpkh\")}if(t.witness){if(2!==t.witness.length)throw new TypeError(\"Witness is invalid\");if(!s.isCanonicalScriptSignature(t.witness[0]))throw new TypeError(\"Witness has invalid signature\");if(!(0,a.isPoint)(t.witness[1])||33!==t.witness[1].length)throw new TypeError(\"Witness has invalid pubkey\");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError(\"Signature mismatch\");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError(\"Pubkey mismatch\");const r=i.hash160(t.witness[1]);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\")}}return Object.assign(p,t)}},2366:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.p2wsh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),c=r(9158),u=r(6586),f=s.OPS,h=n.alloc(0);function l(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,a.isPoint)(t))}e.p2wsh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError(\"Not enough data\");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),output:a.typeforce.maybe(a.typeforce.BufferN(34)),redeem:a.typeforce.maybe({input:a.typeforce.maybe(a.typeforce.Buffer),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.BufferN(0)),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=c.value((()=>{const e=u.bech32.decode(t.address),r=e.words.shift(),i=u.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),p=c.value((()=>s.decompile(t.redeem.input)));let d=t.network;d||(d=t.redeem&&t.redeem.network||o.bitcoin);const y={network:d};if(c.prop(y,\"address\",(()=>{if(!y.hash)return;const t=u.bech32.toWords(y.hash);return t.unshift(0),u.bech32.encode(d.bech32,t)})),c.prop(y,\"hash\",(()=>t.output?t.output.slice(2):t.address?r().data:y.redeem&&y.redeem.output?i.sha256(y.redeem.output):void 0)),c.prop(y,\"output\",(()=>{if(y.hash)return s.compile([f.OP_0,y.hash])})),c.prop(y,\"redeem\",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:h,witness:t.witness.slice(0,-1)}})),c.prop(y,\"input\",(()=>{if(y.witness)return h})),c.prop(y,\"witness\",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=s.toStack(p());return y.redeem=Object.assign({witness:e},t.redeem),y.redeem.input=h,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),c.prop(y,\"name\",(()=>{const t=[\"p2wsh\"];return void 0!==y.redeem&&void 0!==y.redeem.name&&t.push(y.redeem.name),t.join(\"-\")})),e.validate){let e=n.from([]);if(t.address){if(r().prefix!==d.bech32)throw new TypeError(\"Invalid prefix or Network mismatch\");if(0!==r().version)throw new TypeError(\"Invalid address version\");if(32!==r().data.length)throw new TypeError(\"Invalid address data\");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError(\"Hash mismatch\");e=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==f.OP_0||32!==t.output[1])throw new TypeError(\"Output is invalid\");const r=t.output.slice(2);if(e.length>0&&!e.equals(r))throw new TypeError(\"Hash mismatch\");e=r}if(t.redeem){if(t.redeem.network&&t.redeem.network!==d)throw new TypeError(\"Network mismatch\");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError(\"Ambiguous witness source\");if(t.redeem.output){const r=s.decompile(t.redeem.output);if(!r||r.length<1)throw new TypeError(\"Redeem.output is invalid\");if(t.redeem.output.byteLength>3600)throw new TypeError(\"Redeem.output unspendable if larger than 3600 bytes\");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError(\"Redeem.output unspendable with more than 201 non-push ops\");const n=i.sha256(t.redeem.output);if(e.length>0&&!e.equals(n))throw new TypeError(\"Hash mismatch\");e=n}if(t.redeem.input&&!s.isPushOnly(p()))throw new TypeError(\"Non push-only scriptSig\");if(t.witness&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.witness,t.redeem.witness))throw new TypeError(\"Witness and redeem.witness mismatch\");if(t.redeem.input&&p().some(l)||t.redeem.output&&(s.decompile(t.redeem.output)||[]).some(l))throw new TypeError(\"redeem.input or redeem.output contains uncompressed pubkey\")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError(\"Witness and redeem.output mismatch\");if(t.witness.some(l)||(s.decompile(e)||[]).some(l))throw new TypeError(\"Witness contains uncompressed pubkey\")}}return Object.assign(y,t)}},6689:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Psbt=void 0;const i=r(7003),o=r(2715),s=r(2431),a=r(3348),c=r(3831),u=r(2529),f=r(8614),h=r(5247),l=r(4009),p=r(3063),d=r(6412),y=r(8990),g={network:u.bitcoin,maximumFeeRate:5e3};class b{static fromBase64(t,e={}){const r=n.from(t,\"base64\");return this.fromBuffer(r,e)}static fromHex(t,e={}){const r=n.from(t,\"hex\");return this.fromBuffer(r,e)}static fromBuffer(t,e={}){const r=i.Psbt.fromBuffer(t,w),n=new b(e,r);var o,s;return o=n.__CACHE.__TX,s=n.__CACHE,o.ins.forEach((t=>{x(s,t)})),n}constructor(t={},e=new i.Psbt(new m)){this.data=e,this.opts=Object.assign({},g,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(t,e,r,n)=>Object.defineProperty(t,e,{enumerable:r,writable:n});r(this,\"__CACHE\",!1,!0),r(this,\"opts\",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map((t=>({hash:(0,c.cloneBuffer)(t.hash),index:t.index,sequence:t.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((t=>{let e;try{e=(0,a.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,c.cloneBuffer)(t.script),value:t.value,address:e}}))}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){const t=b.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){A(t),this.opts.maximumFeeRate=t}setVersion(t){A(t),I(this.data.inputs,\"setVersion\");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){A(t),I(this.data.inputs,\"setLocktime\");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){A(e),I(this.data.inputs,\"setInputSequence\");const r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error(\"Input index too high\");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach((t=>this.addInput(t))),this}addInput(t){if(arguments.length>1||!t||void 0===t.hash||void 0===t.index)throw new Error(\"Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]\");(0,d.checkTaprootInputFields)(t,t,\"addInput\"),I(this.data.inputs,\"addInput\"),t.witnessScript&&X(t.witnessScript);const e=this.__CACHE;this.data.addInput(t);x(e,e.__TX.ins[e.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&D(this.__CACHE,n,r),e.__FEE=void 0,e.__FEE_RATE=void 0,e.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach((t=>this.addOutput(t))),this}addOutput(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error(\"Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]\");I(this.data.inputs,\"addOutput\");const{address:e}=t;if(\"string\"==typeof e){const{network:r}=this.opts,n=(0,a.toOutputScript)(e,r);t=Object.assign(t,{script:n})}(0,d.checkTaprootOutputFields)(t,t,\"addOutput\");const r=this.__CACHE;return this.data.addOutput(t),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(_))throw new Error(\"Not finalized\");const e=this.__CACHE;if(t||function(t,e,r){const n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,e,this.opts),e.__EXTRACTED_TX)return e.__EXTRACTED_TX;const r=e.__TX.clone();return $(this.data.inputs,r,e,!0),r}getFeeRate(){return R(\"__FEE_RATE\",\"fee rate\",this.data.inputs,this.__CACHE)}getFee(){return R(\"__FEE\",\"fee\",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,s.checkForInput)(this.data.inputs,0),J(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(r)?this._finalizeTaprootInput(t,r,void 0,e):this._finalizeInput(t,r,e)}finalizeTaprootInput(t,e,r=d.tapScriptFinalizer){const n=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,e,r=B){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(t,e,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){const o=K(r,e,t),s=n.ins[t].index;i.script=o.outs[s].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);(e.witnessScript||(0,y.isP2WPKH)(i.script))&&(i.isSegwit=!0);return i}(t,e,this.__CACHE);if(!n)throw new Error(`No script found for input #${t}`);!function(t){if(!t.sighashType||!t.partialSig)return;const{partialSig:e,sighashType:r}=t;e.forEach((t=>{const{hashType:e}=l.signature.decode(t.signature);if(r!==e)throw new Error(\"Signature sighash does not match input sighash type\")}))}(e);const{finalScriptSig:a,finalScriptWitness:c}=r(t,e,n,s,i,o);if(a&&this.data.updateInput(t,{finalScriptSig:a}),c&&this.data.updateInput(t,{finalScriptWitness:c}),!a&&!c)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,e,r,n=d.tapScriptFinalizer){if(!e.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(e.tapKeySig){const r=f.p2tr({output:e.witnessUtxo.script,signature:e.tapKeySig}),n=(0,y.witnessStackToScriptWitness)(r.witness);this.data.updateInput(t,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(t,e,r);this.data.updateInput(t,{finalScriptWitness:i})}return this.data.clearFinalizedInput(t),this}getInputType(t){const e=(0,s.checkForInput)(this.data.inputs,t),r=W(V(t,e,this.__CACHE),t,\"input\",e.redeemScript||function(t){if(!t)return;const e=l.decompile(t);if(!e)return;const r=e[e.length-1];if(!n.isBuffer(r)||q(r)||(i=r,l.isCanonicalScriptSignature(i)))return;var i;if(!l.decompile(r))return;return r}(e.finalScriptSig),e.witnessScript||function(t){if(!t)return;const e=F(t),r=e[e.length-1];if(q(r))return;if(!l.decompile(r))return;return r}(e.finalScriptWitness));return(\"raw\"===r.type?\"\":r.type+\"-\")+z(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=V(r,e,n),{meaningfulScript:o}=W(i,r,\"input\",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,s.checkForInput)(this.data.inputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(t,e){return function(t,e,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=W(i,r,\"output\",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,s.checkForOutput)(this.data.outputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){(0,s.checkForInput)(this.data.inputs,0);return J(this.data.inputs.length).map((e=>this.validateSignaturesOfInput(e,t))).reduce(((t,e)=>!0===e&&t),!0)}validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t];return(0,d.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}_validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error(\"No signatures to validate\");if(\"function\"!=typeof e)throw new Error(\"Need validator function to validate signatures\");const o=r?i.filter((t=>t.pubkey.equals(r))):i;if(o.length<1)throw new Error(\"No signatures for this pubkey\");const s=[];let a,c,u;for(const r of o){const i=l.signature.decode(r.signature),{hash:o,script:f}=u!==i.hashType?N(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:c};u=i.hashType,a=o,c=f,T(r.pubkey,f,\"verify\"),s.push(e(r.pubkey,o,i.signature))}return s.every((t=>!0===t))}validateSignaturesOfTaprootInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error(\"No signatures to validate\");if(\"function\"!=typeof e)throw new Error(\"Need validator function to validate signatures\");const s=(r=r&&(0,d.toXOnly)(r))?j(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=L(t,e,n);r&&i.push(r)}if(e.tapScriptSig){const t=e.tapScriptSig.map((t=>t.pubkey));i.push(...t)}const o=i.map((i=>j(t,e,r,i,n)));return o.flat()}(t,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error(\"No signatures for this pubkey\");const a=s.find((t=>!t.leafHash));let c=0;if(i&&a){if(!e(a.pubkey,a.hash,U(i)))return!1;c++}if(o)for(const t of o){const r=s.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,U(t.signature)))return!1;c++}}return c>0}signAllInputsHD(t,e=[p.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error(\"Need HDSigner to sign input\");const r=[];for(const n of J(this.data.inputs.length))try{this.signInputHD(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error(\"No inputs were signed\");return this}signAllInputsHDAsync(t,e=[p.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!t||!t.publicKey||!t.fingerprint)return n(new Error(\"Need HDSigner to sign input\"));const i=[],o=[];for(const r of J(this.data.inputs.length))o.push(this.signInputHDAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error(\"No inputs were signed\"));r()}))}))}signInputHD(t,e,r=[p.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error(\"Need HDSigner to sign input\");return H(t,this.data.inputs,e).forEach((e=>this.signInput(t,e,r))),this}signInputHDAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!e||!e.publicKey||!e.fingerprint)return i(new Error(\"Need HDSigner to sign input\"));const o=H(t,this.data.inputs,e).map((e=>this.signInputAsync(t,e,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(t,e){if(!t||!t.publicKey)throw new Error(\"Need Signer to sign input\");const r=[];for(const n of J(this.data.inputs.length))try{this.signInput(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error(\"No inputs were signed\");return this}signAllInputsAsync(t,e){return new Promise(((r,n)=>{if(!t||!t.publicKey)return n(new Error(\"Need Signer to sign input\"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error(\"No inputs were signed\"));r()}))}))}signInput(t,e,r){if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}signTaprootInput(t,e,r,n){if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInput(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=C(this.data.inputs,t,e.publicKey,this.__CACHE,r),o=[{pubkey:e.publicKey,signature:l.signature.encode(e.sign(n),i)}];return this.data.updateInput(t,{partialSig:o}),this}_signTaprootInput(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=o.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],a=o.filter((t=>!!t.leafHash)).map((t=>({pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash})));return s&&this.data.updateInput(t,{tapKeySig:s}),a.length&&this.data.updateInput(t,{tapScriptSig:a}),this}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInputAsync(t,n,e,void 0,r):this._signInputAsync(t,e,r)}))}signTaprootInputAsync(t,e,r,n){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error(\"Need Signer to sign input\");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInputAsync(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}))}_signInputAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=C(this.data.inputs,t,e.publicKey,this.__CACHE,r);return Promise.resolve(e.sign(n)).then((r=>{const n=[{pubkey:e.publicKey,signature:l.signature.encode(r,i)}];this.data.updateInput(t,{partialSig:n})}))}async _signTaprootInputAsync(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=[],a=o.filter((t=>!t.leafHash))[0];if(a){const t=Promise.resolve(r.signSchnorr(a.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));s.push(t)}const c=o.filter((t=>!!t.leafHash));if(c.length){const t=c.map((t=>Promise.resolve(r.signSchnorr(t.hash)).then((n=>({tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]})))));s.push(...t)}return Promise.all(s).then((e=>{e.forEach((e=>this.data.updateInput(t,e)))}))}checkTaprootHashesForSig(t,e,r,n,i){if(\"function\"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const o=j(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${t} with the key ${r.publicKey.toString(\"hex\")}`);return o}toBuffer(){return v(this.__CACHE),this.data.toBuffer()}toHex(){return v(this.__CACHE),this.data.toHex()}toBase64(){return v(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&X(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,\"updateInput\"),this.data.updateInput(t,e),e.nonWitnessUtxo&&D(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,e){const r=this.data.outputs[t];return(0,d.checkTaprootOutputFields)(r,e,\"updateOutput\"),this.data.updateOutput(t,e),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,e){return this.data.addUnknownKeyValToInput(t,e),this}addUnknownKeyValToOutput(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}e.Psbt=b;const w=t=>new m(t);class m{constructor(t=n.from([2,0,0,0,0,0,0,0,0,0])){this.tx=p.Transaction.fromBuffer(t),function(t){if(!t.ins.every((t=>t.script&&0===t.script.length&&t.witness&&0===t.witness.length)))throw new Error(\"Format Error: Transaction ScriptSigs are not empty\")}(this.tx),Object.defineProperty(this,\"tx\",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!n.isBuffer(t.hash)&&\"string\"!=typeof t.hash||\"number\"!=typeof t.index)throw new Error(\"Error adding input.\");const e=\"string\"==typeof t.hash?(0,c.reverseBuffer)(n.from(t.hash,\"hex\")):t.hash;this.tx.addInput(e,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!n.isBuffer(t.script)||\"number\"!=typeof t.value)throw new Error(\"Error adding output.\");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function v(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error(\"Not BIP174 compliant, can not export\")}function E(t,e,r){if(!e)return!1;let n;if(n=r?r.map((t=>{const r=function(t){if(65===t.length){const e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((t=>t.pubkey.equals(r)))})).filter((t=>!!t)):e,n.length>t)throw new Error(\"Too many signatures\");return n.length===t}function _(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function S(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function A(t){if(\"number\"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error(\"Invalid 32 bit integer\")}function I(t,e){t.forEach((t=>{if((0,d.isTaprootInput)(t)?(0,d.checkTaprootInputForSigs)(t,e):(0,y.checkInputForSig)(t,e))throw new Error(\"Can not modify transaction, signatures exist.\")}))}function T(t,e,r){if(!(0,y.pubkeyInScript)(t,e))throw new Error(`Can not ${r} for this input with the key ${t.toString(\"hex\")}`)}function x(t,e){const r=(0,c.reverseBuffer)(n.from(e.hash)).toString(\"hex\")+\":\"+e.index;if(t.__TX_IN_CACHE[r])throw new Error(\"Duplicate input detected.\");t.__TX_IN_CACHE[r]=1}function O(t,e){return(r,n,i,o)=>{const s=t({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${e} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const k=O(f.p2sh,\"Redeem script\"),P=O(f.p2wsh,\"Witness script\");function R(t,e,r,n){if(!r.every(_))throw new Error(`PSBT must be finalized to calculate ${e}`);if(\"__FEE_RATE\"===t&&n.__FEE_RATE)return n.__FEE_RATE;if(\"__FEE\"===t&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),$(r,i,n,o),\"__FEE_RATE\"===t?n.__FEE_RATE:\"__FEE\"===t?n.__FEE:void 0}function B(t,e,r,n,i,o){const s=z(r);if(!function(t,e,r){switch(r){case\"pubkey\":case\"pubkeyhash\":case\"witnesspubkeyhash\":return E(1,t.partialSig);case\"multisig\":const r=f.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,s))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,o){let s,a;const c=function(t,e,r){let n;switch(e){case\"multisig\":const e=function(t,e){const r=f.p2ms({output:t});return r.pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=f.p2ms({output:t,signatures:e});break;case\"pubkey\":n=f.p2pk({output:t,signature:r[0].signature});break;case\"pubkeyhash\":n=f.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case\"witnesspubkeyhash\":n=f.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),u=o?f.p2wsh({redeem:c}):null,h=i?f.p2sh({redeem:u||c}):null;n?(a=u?(0,y.witnessStackToScriptWitness)(u.witness):(0,y.witnessStackToScriptWitness)(c.witness),h&&(s=h.input)):s=h?h.input:c.input;return{finalScriptSig:s,finalScriptWitness:a}}(r,s,e.partialSig,n,i,o)}function C(t,e,r,n,i){const o=(0,s.checkForInput)(t,e),{hash:a,sighashType:c,script:u}=N(e,o,n,!1,i);return T(r,u,\"sign\"),{hash:a,sighashType:c}}function N(t,e,r,n,i){const o=r.__TX,s=e.sighashType||p.Transaction.SIGHASH_ALL;let a,c;if(M(s,i),e.nonWitnessUtxo){const n=K(r,e,t),i=o.ins[t].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const a=o.ins[t].index;c=n.outs[a]}else{if(!e.witnessUtxo)throw new Error(\"Need a Utxo input item for signing\");c=e.witnessUtxo}const{meaningfulScript:u,type:h}=W(c.script,t,\"input\",e.redeemScript,e.witnessScript);if([\"p2sh-p2wsh\",\"p2wsh\"].indexOf(h)>=0)a=o.hashForWitnessV0(t,u,c.value,s);else if((0,y.isP2WPKH)(u)){const e=f.p2pkh({hash:u.slice(2)}).output;a=o.hashForWitnessV0(t,e,c.value,s)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${t} has witnessUtxo but non-segwit script: ${u.toString(\"hex\")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn(\"Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecesor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\\n*********************\\nPROCEED WITH CAUTION!\\n*********************\"),a=o.hashForSignature(t,u,s)}return{script:u,sighashType:s,hash:a}}function L(t,e,r){const{script:n}=G(t,e,r);return(0,y.isP2TR)(n)?n.subarray(2,34):null}function U(t){return 64===t.length?t:t.subarray(0,64)}function j(t,e,r,i,o,s,a){const c=o.__TX,u=e.sighashType||p.Transaction.SIGHASH_DEFAULT;M(u,a);const f=r.map(((t,e)=>G(e,t,o))),l=f.map((t=>t.script)),g=f.map((t=>t.value)),b=[];if(e.tapInternalKey&&!s){const r=L(t,e,o)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=c.hashForWitnessV1(t,l,g,u);b.push({pubkey:i,hash:e})}}const w=(e.tapLeafScript||[]).filter((t=>(0,y.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,h.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!s||s.equals(t.hash))).map((e=>{const r=c.hashForWitnessV1(t,l,g,p.Transaction.SIGHASH_DEFAULT,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return b.concat(w)}function M(t,e){if(e&&e.indexOf(t)<0){const e=function(t){let e=t&p.Transaction.SIGHASH_ANYONECANPAY?\"SIGHASH_ANYONECANPAY | \":\"\";switch(31&t){case p.Transaction.SIGHASH_ALL:e+=\"SIGHASH_ALL\";break;case p.Transaction.SIGHASH_SINGLE:e+=\"SIGHASH_SINGLE\";break;case p.Transaction.SIGHASH_NONE:e+=\"SIGHASH_NONE\"}return e}(t);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${e}`)}}function H(t,e,r){const n=(0,s.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error(\"Need bip32Derivation to sign with HD\");const i=n.bip32Derivation.map((t=>t.masterFingerprint.equals(r.fingerprint)?t:void 0)).filter((t=>!!t));if(0===i.length)throw new Error(\"Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint\");return i.map((t=>{const e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error(\"pubkey did not match bip32Derivation\");return e}))}function F(t){let e=0;function r(){const r=o.decode(t,e);return e+=o.decode.bytes,r}function n(){return n=r(),e+=n,t.slice(e-n,e);var n}return function(){const t=r(),e=[];for(let r=0;r{if(n&&t.finalScriptSig&&(e.ins[o].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[o].witness=F(t.finalScriptWitness)),t.witnessUtxo)i+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=K(r,t,o),s=e.ins[o].index,a=n.outs[s];i+=a.value}}));const o=e.outs.reduce(((t,e)=>t+e.value),0),s=i-o;if(s<0)throw new Error(\"Outputs are spending more than Inputs\");const a=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/a)}function K(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||D(t,e,r),n[r]}function V(t,e,r){const{script:n}=G(t,e,r);return n}function G(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=K(r,e,t).outs[r.__TX.ins[t].index];return{script:n.script,value:n.value}}throw new Error(\"Can't find pubkey in input without Utxo data\")}function q(t){return 33===t.length&&l.isCanonicalPubKey(t)}function W(t,e,r,n,i){const o=(0,y.isP2SHScript)(t),s=o&&n&&(0,y.isP2WSHScript)(n),a=(0,y.isP2WSHScript)(t);if(o&&void 0===n)throw new Error(\"scriptPubkey is P2SH but redeemScript missing\");if((a||s)&&void 0===i)throw new Error(\"scriptPubkey or redeemScript is P2WSH but witnessScript missing\");let c;return s?(c=i,k(e,t,n,r),P(e,n,i,r),X(c)):a?(c=i,P(e,t,i,r),X(c)):o?(c=n,k(e,t,n,r)):c=t,{meaningfulScript:c,type:s?\"p2sh-p2wsh\":o?\"p2sh\":a?\"p2wsh\":\"raw\"}}function X(t){if((0,y.isP2WPKH)(t)||(0,y.isP2SHScript)(t))throw new Error(\"P2WPKH or P2SH can not be contained within P2WSH\")}function z(t){return(0,y.isP2WPKH)(t)?\"witnesspubkeyhash\":(0,y.isP2PKH)(t)?\"pubkeyhash\":(0,y.isP2MS)(t)?\"multisig\":(0,y.isP2PK)(t)?\"pubkey\":\"nonstandard\"}function J(t){return[...Array(t).keys()]}},6412:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.checkTaprootInputForSigs=e.tapTreeFromList=e.tapTreeToList=e.tweakInternalPubKey=e.checkTaprootOutputFields=e.checkTaprootInputFields=e.isTaprootOutput=e.isTaprootInput=e.serializeTaprootSignature=e.tapScriptFinalizer=e.toXOnly=void 0;const i=r(5593),o=r(3063),s=r(8990),a=r(5247),c=r(8614),u=r(8990);function f(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,s.isP2TR)(t.witnessUtxo.script))}function h(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,s.isP2TR)(e))}function l(t=[]){return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){let e;for(const r of t)if(e=y(r,e),!e)throw new Error(\"No room left to insert tapleaf in tree\");return e}(t)}function p(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function d(t,e=[],r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error(\"Max taptree depth exceeded.\");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||a.LEAF_VERSION_TAPSCRIPT,script:t.output}),e):(t[0]&&d(t[0],e,r+1),t[1]&&d(t[1],e,r+1),e):[]}function y(t,e,r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error(\"Max taptree depth exceeded.\");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if((0,i.isTapleaf)(e))return;const n=y(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];const o=y(t,e&&e[1],r+1);return o?[e&&e[0],o]:void 0}function g(t,e){if(!e)return!0;const r=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(0,a.rootHashFromPath)(t.controlBlock,r).equals(e)}function b(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}e.toXOnly=t=>32===t.length?t:t.slice(1,33),e.tapScriptFinalizer=function(t,e,r){const n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${e}. No tapleaf script signature provided.`);const n=(t.tapLeafScript||[]).sort(((t,e)=>t.controlBlock.length-e.controlBlock.length)).find((e=>function(t,e,r){const n=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((t=>t.leafHash.equals(n)))}(e,t.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`);return n}(e,t,r);try{const t=function(t,e){const r=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((t=>t.leafHash.equals(r))).map((t=>function(t,e){return Object.assign({positionInScript:(0,s.pubkeyPositionInScript)(e.pubkey,t)},e)}(e.script,t))).sort(((t,e)=>e.positionInScript-t.positionInScript)).map((t=>t.signature))}(e,n),r=t.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,s.witnessStackToScriptWitness)(r)}}catch(e){throw new Error(`Can not finalize taproot input #${t}: ${e}`)}},e.serializeTaprootSignature=function(t,e){const r=e?n.from([e]):n.from([]);return n.concat([t,r])},e.isTaprootInput=f,e.isTaprootOutput=h,e.checkTaprootInputFields=function(t,e,r){!function(t,e,r){const n=f(t)&&b(e),i=b(t)&&f(e),o=t===e&&f(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot){if(!(e.tapLeafScript||[]).every((e=>g(e,t.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}}(t,e,r)},e.checkTaprootOutputFields=function(t,e,r){!function(t,e,r){const n=h(t)&&b(e),i=b(t)&&h(e),o=t===e&&h(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e){if(!e.tapTree&&!e.tapInternalKey)return;const r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){const{script:e}=t,i=function(t,e){const r=e&&l(e.leaves),{output:n}=(0,c.p2tr)({internalPubkey:t,scriptTree:r});return n}(r,n);if(e&&!e.equals(i))throw new Error(\"Error adding output. Script or address missmatch.\")}}(t,e)},e.tweakInternalPubKey=function(t,e){const r=e.tapInternalKey,n=r&&(0,a.tweakKey)(r,e.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${t}. Public key: ${r&&r.toString(\"hex\")}`);return n.x},e.tapTreeToList=function(t){if(!(0,i.isTaptree)(t))throw new Error(\"Cannot convert taptree to tapleaf list. Expecting a tapree structure.\");return d(t)},e.tapTreeFromList=l,e.checkTaprootInputForSigs=function(t,e){return function(t){const e=[];t.tapKeySig&&e.push(t.tapKeySig);t.tapScriptSig&&e.push(...t.tapScriptSig.map((t=>t.signature)));if(!e.length){const r=function(t){if(!t)return;const e=t.slice(2);if(64===e.length||65===e.length)return e}(t.finalScriptWitness);r&&e.push(r)}return e}(t).some((t=>(0,u.signatureBlocksAction)(t,p,e)))}},8990:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.signatureBlocksAction=e.checkInputForSig=e.pubkeyInScript=e.pubkeyPositionInScript=e.witnessStackToScriptWitness=e.isP2TR=e.isP2SHScript=e.isP2WSHScript=e.isP2WPKH=e.isP2PKH=e.isP2PK=e.isP2MS=void 0;const i=r(2715),o=r(4009),s=r(3063),a=r(6891),c=r(8614);function u(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function f(t,e){const r=(0,a.hash160)(t),n=t.slice(1,33),i=o.decompile(e);if(null===i)throw new Error(\"Unknown script error\");return i.findIndex((e=>\"number\"!=typeof e&&(e.equals(t)||e.equals(r)||e.equals(n))))}function h(t,e,r){const{hashType:n}=e(t),i=[];n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push(\"addInput\");switch(31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push(\"addOutput\"),i.push(\"setInputSequence\")}return-1===i.indexOf(r)}e.isP2MS=u(c.p2ms),e.isP2PK=u(c.p2pk),e.isP2PKH=u(c.p2pkh),e.isP2WPKH=u(c.p2wpkh),e.isP2WSHScript=u(c.p2wsh),e.isP2SHScript=u(c.p2sh),e.isP2TR=u(c.p2tr),e.witnessStackToScriptWitness=function(t){let e=n.allocUnsafe(0);function r(t){const r=e.length,o=i.encodingLength(t);e=n.concat([e,n.allocUnsafe(o)]),i.encode(t,e,r)}function o(t){r(t.length),function(t){e=n.concat([e,n.from(t)])}(t)}var s;return r((s=t).length),s.forEach(o),e},e.pubkeyPositionInScript=f,e.pubkeyInScript=function(t,e){return-1!==f(t,e)},e.checkInputForSig=function(t,e){return function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){const e=t.finalScriptSig&&o.decompile(t.finalScriptSig)||[],r=t.finalScriptWitness&&o.decompile(t.finalScriptWitness)||[];return e.concat(r).filter((t=>n.isBuffer(t)&&o.isCanonicalScriptSignature(t))).map((t=>({signature:t})))}(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t).some((t=>h(t,o.signature.decode,e)))},e.signatureBlocksAction=h},1213:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.decode=e.encode=e.encodingLength=void 0;const n=r(8156);function i(t){return tt.length)return null;i=t.readUInt8(e+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(e+3>t.length)return null;i=t.readUInt16LE(e+1),o=3}else{if(e+5>t.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error(\"Unexpected opcode\");i=t.readUInt32LE(e+1),o=5}return{opcode:r,number:i,size:o}}},4009:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const i=r(195),o=r(8156);Object.defineProperty(e,\"OPS\",{enumerable:!0,get:function(){return o.OPS}});const s=r(1213),a=r(5333),c=r(1108),u=r(5593),{typeforce:f}=u,h=o.OPS.OP_RESERVED;function l(t){return u.Buffer(t)||function(t){return u.Number(t)&&(t===o.OPS.OP_0||t>=o.OPS.OP_1&&t<=o.OPS.OP_16||t===o.OPS.OP_1NEGATE)}(t)}function p(t){return u.Array(t)&&t.every(l)}function d(t){return 0===t.length?o.OPS.OP_0:1===t.length?t[0]>=1&&t[0]<=16?h+t[0]:129===t[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(t){return n.isBuffer(t)}function g(t){return n.isBuffer(t)}function b(t){if(y(t))return t;f(u.Array,t);const e=t.reduce(((t,e)=>g(e)?1===e.length&&void 0!==d(e)?t+1:t+s.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(g(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=s.encode(r,t.length,i),t.copy(r,i),i+=t.length}else r.writeUInt8(t,i),i+=1})),i!==r.length)throw new Error(\"Could not decode chunks\");return r}function w(t){if(e=t,u.Array(e))return t;var e;f(u.Buffer,t);const r=[];let n=0;for(;no.OPS.OP_0&&e<=o.OPS.OP_PUSHDATA4){const e=s.decode(t,n);if(null===e)return null;if(n+=e.size,n+e.number>t.length)return null;const i=t.slice(n,n+e.number);n+=e.number;const o=d(i);void 0!==o?r.push(o):r.push(i)}else r.push(e),n+=1}return r}function m(t){const e=-129&t;return e>0&&e<4}e.isPushOnly=p,e.countNonPushOnlyOPs=function(t){return t.length-t.filter(l).length},e.compile=b,e.decompile=w,e.toASM=function(t){return y(t)&&(t=w(t)),t.map((t=>{if(g(t)){const e=d(t);if(void 0===e)return t.toString(\"hex\");t=e}return o.REVERSE_OPS[t]})).join(\" \")},e.fromASM=function(t){return f(u.String,t),b(t.split(\" \").map((t=>void 0!==o.OPS[t]?o.OPS[t]:(f(u.Hex,t),n.from(t,\"hex\")))))},e.toStack=function(t){return t=w(t),f(p,t),t.map((t=>g(t)?t:t===o.OPS.OP_0?n.allocUnsafe(0):a.encode(t-h)))},e.isCanonicalPubKey=function(t){return u.isPoint(t)},e.isDefinedHashType=m,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&(!!m(t[t.length-1])&&i.check(t.slice(0,-1)))},e.number=a,e.signature=c},5333:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=void 0,e.decode=function(t,e,r){e=e||4,r=void 0===r||r;const n=t.length;if(0===n)return 0;if(n>e)throw new TypeError(\"Script number overflow\");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error(\"Non-minimally encoded script number\");if(5===n){const e=t.readUInt32LE(0),r=t.readUInt8(4);return 128&r?-(4294967296*(-129&r)+e):4294967296*r+e}let i=0;for(let e=0;e2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),i=n.allocUnsafe(r),o=t<0;for(let t=0;t>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i}},1108:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.encode=e.decode=void 0;const i=r(195),o=r(5593),{typeforce:s}=o,a=n.alloc(1,0);function c(t){let e=0;for(;0===t[e];)++e;return e===t.length?a:128&(t=t.slice(e))[0]?n.concat([a,t],1+t.length):t}function u(t){0===t[0]&&(t=t.slice(1));const e=n.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}e.decode=function(t){const e=t.readUInt8(t.length-1),r=-129&e;if(r<=0||r>=4)throw new Error(\"Invalid hashType \"+e);const o=i.decode(t.slice(0,-1)),s=u(o.r),a=u(o.s);return{signature:n.concat([s,a],64),hashType:e}},e.encode=function(t,e){s({signature:o.BufferN(64),hashType:o.UInt8},{signature:t,hashType:e});const r=-129&e;if(r<=0||r>=4)throw new Error(\"Invalid hashType \"+e);const a=n.allocUnsafe(1);a.writeUInt8(e,0);const u=c(t.slice(0,32)),f=c(t.slice(32,64));return n.concat([i.encode(u,f),a])}},3063:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.Transaction=void 0;const i=r(3831),o=r(6891),s=r(4009),a=r(4009),c=r(5593),{typeforce:u}=c;function f(t){const e=t.length;return i.varuint.encodingLength(e)+e}const h=n.allocUnsafe(0),l=[],p=n.from(\"0000000000000000000000000000000000000000000000000000000000000000\",\"hex\"),d=n.from(\"0000000000000000000000000000000000000000000000000000000000000001\",\"hex\"),y=n.from(\"ffffffffffffffff\",\"hex\"),g={script:h,valueBuffer:y};class b{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,e){const r=new i.BufferReader(t),n=new b;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let a=!1;o===b.ADVANCED_TRANSACTION_MARKER&&s===b.ADVANCED_TRANSACTION_FLAG?a=!0:r.offset-=2;const c=r.readVarInt();for(let t=0;t0!==t.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const e=t&&this.hasWitnesses();return(e?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce(((t,e)=>t+40+f(e.script)),0)+this.outs.reduce(((t,e)=>t+8+f(e.script)),0)+(e?this.ins.reduce(((t,e)=>t+function(t){const e=t.length;return i.varuint.encodingLength(e)+t.reduce(((t,e)=>t+f(e)),0)}(e.witness)),0):0)}clone(){const t=new b;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((t=>({hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}))),t.outs=this.outs.map((t=>({script:t.script,value:t.value}))),t}hashForSignature(t,e,r){if(u(c.tuple(c.UInt32,c.Buffer,c.Number),arguments),t>=this.ins.length)return d;const i=s.compile(s.decompile(e).filter((t=>t!==a.OPS.OP_CODESEPARATOR))),f=this.clone();if((31&r)===b.SIGHASH_NONE)f.outs=[],f.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===b.SIGHASH_SINGLE){if(t>=this.outs.length)return d;f.outs.length=t+1;for(let e=0;e{r!==t&&(e.sequence=0)}))}r&b.SIGHASH_ANYONECANPAY?(f.ins=[f.ins[t]],f.ins[0].script=i):(f.ins.forEach((t=>{t.script=h})),f.ins[t].script=i);const l=n.allocUnsafe(f.byteLength(!1)+4);return l.writeInt32LE(r,l.length-4),f.__toBuffer(l,0,!1),o.hash256(l)}hashForWitnessV1(t,e,r,s,a,l){if(u(c.tuple(c.UInt32,u.arrayOf(c.Buffer),u.arrayOf(c.Satoshi),c.UInt32),arguments),r.length!==this.ins.length||e.length!==this.ins.length)throw new Error(\"Must supply prevout script and value for all inputs\");const p=s===b.SIGHASH_DEFAULT?b.SIGHASH_ALL:s&b.SIGHASH_OUTPUT_MASK,d=(s&b.SIGHASH_INPUT_MASK)===b.SIGHASH_ANYONECANPAY,y=p===b.SIGHASH_NONE,g=p===b.SIGHASH_SINGLE;let w=h,m=h,v=h,E=h,_=h;if(!d){let t=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((e=>{t.writeSlice(e.hash),t.writeUInt32(e.index)})),w=o.sha256(t.end()),t=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach((e=>t.writeUInt64(e))),m=o.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(f).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),v=o.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),E=o.sha256(t.end())}if(y||g){if(g&&t8+f(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),_=o.sha256(e.end())}const S=(a?2:0)+(l?1:0),A=174-(d?49:0)-(y?32:0)+(l?32:0)+(a?37:0),I=i.BufferWriter.withCapacity(A);if(I.writeUInt8(s),I.writeInt32(this.version),I.writeUInt32(this.locktime),I.writeSlice(w),I.writeSlice(m),I.writeSlice(v),I.writeSlice(E),y||g||I.writeSlice(_),I.writeUInt8(S),d){const n=this.ins[t];I.writeSlice(n.hash),I.writeUInt32(n.index),I.writeUInt64(r[t]),I.writeVarSlice(e[t]),I.writeUInt32(n.sequence)}else I.writeUInt32(t);if(l){const t=i.BufferWriter.withCapacity(f(l));t.writeVarSlice(l),I.writeSlice(o.sha256(t.end()))}return g&&I.writeSlice(_),a&&(I.writeSlice(a),I.writeUInt8(0),I.writeUInt32(4294967295)),o.taggedHash(\"TapSighash\",n.concat([n.from([0]),I.end()]))}hashForWitnessV0(t,e,r,s){u(c.tuple(c.UInt32,c.Buffer,c.Satoshi,c.UInt32),arguments);let a,h=n.from([]),l=p,d=p,y=p;if(s&b.SIGHASH_ANYONECANPAY||(h=n.allocUnsafe(36*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeSlice(t.hash),a.writeUInt32(t.index)})),d=o.hash256(h)),s&b.SIGHASH_ANYONECANPAY||(31&s)===b.SIGHASH_SINGLE||(31&s)===b.SIGHASH_NONE||(h=n.allocUnsafe(4*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeUInt32(t.sequence)})),y=o.hash256(h)),(31&s)!==b.SIGHASH_SINGLE&&(31&s)!==b.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+f(e.script)),0);h=n.allocUnsafe(t),a=new i.BufferWriter(h,0),this.outs.forEach((t=>{a.writeUInt64(t.value),a.writeVarSlice(t.script)})),l=o.hash256(h)}else if((31&s)===b.SIGHASH_SINGLE&&t{o.writeSlice(t.hash),o.writeUInt32(t.index),o.writeVarSlice(t.script),o.writeUInt32(t.sequence)})),o.writeVarInt(this.outs.length),this.outs.forEach((t=>{void 0!==t.value?o.writeUInt64(t.value):o.writeSlice(t.valueBuffer),o.writeVarSlice(t.script)})),s&&this.ins.forEach((t=>{o.writeVector(t.witness)})),o.writeUInt32(this.locktime),void 0!==e?t.slice(e,o.offset):t}}e.Transaction=b,b.DEFAULT_SEQUENCE=4294967295,b.SIGHASH_DEFAULT=0,b.SIGHASH_ALL=1,b.SIGHASH_NONE=2,b.SIGHASH_SINGLE=3,b.SIGHASH_ANYONECANPAY=128,b.SIGHASH_OUTPUT_MASK=3,b.SIGHASH_INPUT_MASK=128,b.ADVANCED_TRANSACTION_MARKER=0,b.ADVANCED_TRANSACTION_FLAG=1},5593:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const n=r(1048);e.typeforce=r(973);const i=n.Buffer.alloc(32,0),o=n.Buffer.from(\"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f\",\"hex\");e.isPoint=function(t){if(!n.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;const e=t[0],r=t.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;const s=t.slice(33);return 0!==s.compare(i)&&(!(s.compare(o)>=0)&&(4===e&&65===t.length))};const s=Math.pow(2,31)-1;function a(t){return e.typeforce.String(t)&&!!t.match(/^(m\\/)?(\\d+'?\\/)*\\d+'?$/)}e.UInt31=function(t){return e.typeforce.UInt32(t)&&t<=s},e.BIP32Path=a,a.toJSON=()=>\"BIP32 derivation path\",e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||\"function\"==typeof t.getPublicKey)&&\"function\"==typeof t.sign};function c(t){return!(!t||!(\"output\"in t))&&(!!n.Buffer.isBuffer(t.output)&&(void 0===t.version||(t.version&e.TAPLEAF_VERSION_MASK)===t.version))}e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.ECPoint=e.typeforce.quacksLike(\"Point\"),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=c,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):c(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf},9216:(t,e,r)=>{var n=r(9784);t.exports=n(\"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\")},7639:(t,e,r)=>{\"use strict\";var n=r(9216),i=r(5636).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error(\"Invalid checksum\");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},9848:(t,e,r)=>{\"use strict\";var n=r(3257),i=r(7639);t.exports=i((function(t){var e=n(\"sha256\").update(t).digest();return n(\"sha256\").update(e).digest()}))},1048:(t,e,r)=>{\"use strict\";const n=r(7991),i=r(9318),o=\"function\"==typeof Symbol&&\"function\"==typeof Symbol.for?Symbol.for(\"nodejs.util.inspect.custom\"):null;e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if(\"number\"==typeof t){if(\"string\"==typeof e)throw new TypeError('The \"string\" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,e,r){if(\"string\"==typeof t)return function(t,e){\"string\"==typeof e&&\"\"!==e||(e=\"utf8\");if(!c.isEncoding(e))throw new TypeError(\"Unknown encoding: \"+e);const r=0|y(t,e);let n=a(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(z(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof t);if(z(t,ArrayBuffer)||t&&z(t.buffer,ArrayBuffer))return p(t,e,r);if(\"undefined\"!=typeof SharedArrayBuffer&&(z(t,SharedArrayBuffer)||t&&z(t.buffer,SharedArrayBuffer)))return p(t,e,r);if(\"number\"==typeof t)throw new TypeError('The \"value\" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return c.from(n,e,r);const i=function(t){if(c.isBuffer(t)){const e=0|d(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return\"number\"!=typeof t.length||J(t.length)?a(0):l(t);if(\"Buffer\"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(i)return i;if(\"undefined\"!=typeof Symbol&&null!=Symbol.toPrimitive&&\"function\"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive](\"string\"),e,r);throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof t)}function f(t){if(\"number\"!=typeof t)throw new TypeError('\"size\" argument must be of type number');if(t<0)throw new RangeError('The value \"'+t+'\" is invalid for option \"size\"')}function h(t){return f(t),a(t<0?0:0|d(t))}function l(t){const e=t.length<0?0:0|d(t.length),r=a(e);for(let n=0;n=s)throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\"+s.toString(16)+\" bytes\");return 0|t}function y(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||z(t,ArrayBuffer))return t.byteLength;if(\"string\"!=typeof t)throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case\"ascii\":case\"latin1\":case\"binary\":return r;case\"utf8\":case\"utf-8\":return q(t).length;case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return 2*r;case\"hex\":return r>>>1;case\"base64\":return W(t).length;default:if(i)return n?-1:q(t).length;e=(\"\"+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return\"\";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return\"\";if((r>>>=0)<=(e>>>=0))return\"\";for(t||(t=\"utf8\");;)switch(t){case\"hex\":return P(this,e,r);case\"utf8\":case\"utf-8\":return T(this,e,r);case\"ascii\":return O(this,e,r);case\"latin1\":case\"binary\":return k(this,e,r);case\"base64\":return I(this,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return R(this,e,r);default:if(n)throw new TypeError(\"Unknown encoding: \"+t);t=(t+\"\").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if(\"string\"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if(\"string\"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if(\"number\"==typeof e)return e&=255,\"function\"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError(\"val must be string, number or Buffer\")}function m(t,e,r,n,i){let o,s=1,a=t.length,c=e.length;if(void 0!==n&&(\"ucs2\"===(n=String(n).toLowerCase())||\"ucs-2\"===n||\"utf16le\"===n||\"utf-16le\"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;ni&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function I(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(o=c));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r=\"\",n=0;for(;nn.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!c.isBuffer(e))throw new TypeError('\"list\" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},c.byteLength=y,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError(\"Buffer size must be a multiple of 16-bits\");for(let e=0;er&&(t+=\" ... \"),\"\"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(t,e,r,n,i){if(z(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError(\"out of range index\");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),u=this.slice(n,i),f=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n=\"utf8\")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError(\"Attempt to write outside buffer bounds\");n||(n=\"utf8\");let o=!1;for(;;)switch(n){case\"hex\":return v(this,t,e,r);case\"utf8\":case\"utf-8\":return E(this,t,e,r);case\"ascii\":case\"latin1\":case\"binary\":return _(this,t,e,r);case\"base64\":return S(this,t,e,r);case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return A(this,t,e,r);default:if(o)throw new TypeError(\"Unknown encoding: \"+n);n=(\"\"+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:\"Buffer\",data:Array.prototype.slice.call(this._arr||this,0)}};const x=4096;function O(t,e,r){let n=\"\";r=Math.min(t.length,r);for(let i=e;in)&&(r=n);let i=\"\";for(let n=e;nr)throw new RangeError(\"Trying to access beyond buffer length\")}function C(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('\"buffer\" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError(\"Index out of range\")}function N(t,e,r,n,i){$(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function L(t,e,r,n,i){$(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError(\"Index out of range\");if(r<0)throw new RangeError(\"Index out of range\")}function j(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return e=+e,r>>>=0,o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||B(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=Z((function(t){K(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||B(t,e,this.length);let n=this[t],i=1,o=0;for(;++o=i&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||B(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return t>>>=0,e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||B(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=Z((function(t){K(t>>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,\"offset\");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||B(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||B(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||B(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){C(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,!n){C(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=Z((function(t,e=0){return N(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeBigUInt64BE=Z((function(t,e=0){return L(this,t,e,BigInt(0),BigInt(\"0xffffffffffffffff\"))})),c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=Z((function(t,e=0){return N(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeBigInt64BE=Z((function(t,e=0){return L(this,t,e,-BigInt(\"0x8000000000000000\"),BigInt(\"0x7fffffffffffffff\"))})),c.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(!c.isBuffer(t))throw new TypeError(\"argument should be a Buffer\");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError(\"Index out of range\");if(n<0)throw new RangeError(\"sourceEnd out of bounds\");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),\"number\"==typeof t)for(i=e;i=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function $(t,e,r,n,i,o){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new H.ERR_OUT_OF_RANGE(\"value\",i,t)}!function(t,e,r){K(e,\"offset\"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(n,i,o)}function K(t,e){if(\"number\"!=typeof t)throw new H.ERR_INVALID_ARG_TYPE(e,\"number\",t)}function V(t,e,r){if(Math.floor(t)!==t)throw K(t,r),new H.ERR_OUT_OF_RANGE(r||\"offset\",\"an integer\",t);if(e<0)throw new H.ERR_BUFFER_OUT_OF_BOUNDS;throw new H.ERR_OUT_OF_RANGE(r||\"offset\",`>= ${r?1:0} and <= ${e}`,t)}F(\"ERR_BUFFER_OUT_OF_BOUNDS\",(function(t){return t?`${t} is outside of buffer bounds`:\"Attempt to access memory outside buffer bounds\"}),RangeError),F(\"ERR_INVALID_ARG_TYPE\",(function(t,e){return`The \"${t}\" argument must be of type number. Received type ${typeof e}`}),TypeError),F(\"ERR_OUT_OF_RANGE\",(function(t,e,r){let n=`The value of \"${t}\" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):\"bigint\"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+=\"n\"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error(\"Invalid code point\");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function W(t){return n.toByteArray(function(t){if((t=(t=t.split(\"=\")[0]).trim().replace(G,\"\")).length<2)return\"\";for(;t.length%4!=0;)t+=\"=\";return t}(t))}function X(t,e,r,n){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const Y=function(){const t=\"0123456789abcdef\",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Z(t){return\"undefined\"==typeof BigInt?Q:t}function Q(){throw new Error(\"BigInt not supported\")}},7589:(t,e,r)=>{var n=r(5636).Buffer,i=r(1983).Transform,o=r(8888).I;function s(t){i.call(this),this.hashMode=\"string\"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(5615)(s,i),s.prototype.update=function(t,e,r){\"string\"==typeof t&&(t=n.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error(\"trying to get auth tag in unsupported state\")},s.prototype.setAuthTag=function(){throw new Error(\"trying to set auth tag in unsupported state\")},s.prototype.setAAD=function(){throw new Error(\"trying to set aad in unsupported state\")},s.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error(\"can't switch encodings\");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=s},7232:(t,e,r)=>{var n=r(366);t.exports=function(t,e,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],e),o=0,s=[],a=n.sumOrNaN(e),c=0;cu.value){if(c===t.length-1)return{fee:r*(i+f)}}else if(i+=f,o+=l,s.push(u),!(o{var n=r(366);t.exports=function(t,e,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],e),o=0,s=[],a=n.sumOrNaN(e),c=n.dustThreshold({},r),u=0;ua+l+c)&&(i+=h,o+=p,s.push(f),!(o{var n=r(7232),i=r(2379),o=r(366);function s(t,e){return t.value-e*o.inputBytes(t)}t.exports=function(t,e,r){t=t.concat().sort((function(t,e){return s(e,r)-s(t,r)}));var o=i(t,e,r);return o.inputs?o:n(t,e,r)}},366:t=>{var e=10,r=41,n=107,i=9,o=25;function s(t){return r+(t.script?t.script.length:n)}function a(t){return i+(t.script?t.script.length:o)}function c(t,e){return s({})*e}function u(t,r){return e+t.reduce((function(t,e){return t+s(e)}),0)+r.reduce((function(t,e){return t+a(e)}),0)}function f(t){return\"number\"!=typeof t?NaN:isFinite(t)?Math.floor(t)!==t||t<0?NaN:t:NaN}function h(t){return t.reduce((function(t,e){return t+f(e.value)}),0)}var l=a({});t.exports={dustThreshold:c,finalize:function(t,e,r){var n=u(t,e),i=r*(n+l),o=h(t)-(h(e)+i);o>c(0,r)&&(e=e.concat({value:o}));var s=h(t)-h(e);return isFinite(s)?{inputs:t,outputs:e,fee:s}:{fee:r*n}},inputBytes:s,outputBytes:a,sumOrNaN:h,sumForgiving:function(t){return t.reduce((function(t,e){return t+(isFinite(e.value)?e.value:0)}),0)},transactionBytes:u,uintOrNaN:f}},3257:(t,e,r)=>{\"use strict\";var n=r(5615),i=r(3275),o=r(5586),s=r(3229),a=r(7589);function c(t){a.call(this,\"digest\"),this._hash=t}n(c,a),c.prototype._update=function(t){this._hash.update(t)},c.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return\"md5\"===(t=t.toLowerCase())?new i:\"rmd160\"===t||\"ripemd160\"===t?new o:new c(s(t))}},8437:t=>{var e=1e3,r=60*e,n=60*r,i=24*n,o=7*i,s=365.25*i;function a(t,e,r,n){var i=e>=1.5*r;return Math.round(t/r)+\" \"+n+(i?\"s\":\"\")}t.exports=function(t,c){c=c||{};var u=typeof t;if(\"string\"===u&&t.length>0)return function(t){if((t=String(t)).length>100)return;var a=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||\"ms\").toLowerCase()){case\"years\":case\"year\":case\"yrs\":case\"yr\":case\"y\":return c*s;case\"weeks\":case\"week\":case\"w\":return c*o;case\"days\":case\"day\":case\"d\":return c*i;case\"hours\":case\"hour\":case\"hrs\":case\"hr\":case\"h\":return c*n;case\"minutes\":case\"minute\":case\"mins\":case\"min\":case\"m\":return c*r;case\"seconds\":case\"second\":case\"secs\":case\"sec\":case\"s\":return c*e;case\"milliseconds\":case\"millisecond\":case\"msecs\":case\"msec\":case\"ms\":return c;default:return}}(t);if(\"number\"===u&&isFinite(t))return c.long?function(t){var o=Math.abs(t);if(o>=i)return a(t,o,i,\"day\");if(o>=n)return a(t,o,n,\"hour\");if(o>=r)return a(t,o,r,\"minute\");if(o>=e)return a(t,o,e,\"second\");return t+\" ms\"}(t):function(t){var o=Math.abs(t);if(o>=i)return Math.round(t/i)+\"d\";if(o>=n)return Math.round(t/n)+\"h\";if(o>=r)return Math.round(t/r)+\"m\";if(o>=e)return Math.round(t/e)+\"s\";return t+\"ms\"}(t);throw new Error(\"val is not a non-empty string or a valid number. val=\"+JSON.stringify(t))}},124:(t,e,r)=>{e.formatArgs=function(e){if(e[0]=(this.useColors?\"%c\":\"\")+this.namespace+(this.useColors?\" %c\":\" \")+e[0]+(this.useColors?\"%c \":\" \")+\"+\"+t.exports.humanize(this.diff),!this.useColors)return;const r=\"color: \"+this.color;e.splice(1,0,r,\"color: inherit\");let n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(t=>{\"%%\"!==t&&(n++,\"%c\"===t&&(i=n))})),e.splice(i,0,r)},e.save=function(t){try{t?e.storage.setItem(\"debug\",t):e.storage.removeItem(\"debug\")}catch(t){}},e.load=function(){let t;try{t=e.storage.getItem(\"debug\")}catch(t){}!t&&\"undefined\"!=typeof process&&\"env\"in process&&(t=\"false\");return t},e.useColors=function(){if(\"undefined\"!=typeof window&&window.process&&(\"renderer\"===window.process.type||window.process.__nwjs))return!0;if(\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/))return!1;return\"undefined\"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||\"undefined\"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||\"undefined\"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)},e.storage=function(){try{return localStorage}catch(t){}}(),e.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn(\"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.\"))}})(),e.colors=[\"#0000CC\",\"#0000FF\",\"#0033CC\",\"#0033FF\",\"#0066CC\",\"#0066FF\",\"#0099CC\",\"#0099FF\",\"#00CC00\",\"#00CC33\",\"#00CC66\",\"#00CC99\",\"#00CCCC\",\"#00CCFF\",\"#3300CC\",\"#3300FF\",\"#3333CC\",\"#3333FF\",\"#3366CC\",\"#3366FF\",\"#3399CC\",\"#3399FF\",\"#33CC00\",\"#33CC33\",\"#33CC66\",\"#33CC99\",\"#33CCCC\",\"#33CCFF\",\"#6600CC\",\"#6600FF\",\"#6633CC\",\"#6633FF\",\"#66CC00\",\"#66CC33\",\"#9900CC\",\"#9900FF\",\"#9933CC\",\"#9933FF\",\"#99CC00\",\"#99CC33\",\"#CC0000\",\"#CC0033\",\"#CC0066\",\"#CC0099\",\"#CC00CC\",\"#CC00FF\",\"#CC3300\",\"#CC3333\",\"#CC3366\",\"#CC3399\",\"#CC33CC\",\"#CC33FF\",\"#CC6600\",\"#CC6633\",\"#CC9900\",\"#CC9933\",\"#CCCC00\",\"#CCCC33\",\"#FF0000\",\"#FF0033\",\"#FF0066\",\"#FF0099\",\"#FF00CC\",\"#FF00FF\",\"#FF3300\",\"#FF3333\",\"#FF3366\",\"#FF3399\",\"#FF33CC\",\"#FF33FF\",\"#FF6600\",\"#FF6633\",\"#FF9900\",\"#FF9933\",\"#FFCC00\",\"#FFCC33\"],e.log=console.debug||console.log||(()=>{}),t.exports=r(7891)(e);const{formatters:n}=t.exports;n.j=function(t){try{return JSON.stringify(t)}catch(t){return\"[UnexpectedJSONParseError]: \"+t.message}}},7891:(t,e,r)=>{t.exports=function(t){function e(t){let r,i,o,s=null;function a(...t){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,t[0]=e.coerce(t[0]),\"string\"!=typeof t[0]&&t.unshift(\"%O\");let s=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if(\"%%\"===r)return\"%\";s++;const o=e.formatters[i];if(\"function\"==typeof o){const e=t[s];r=o.call(n,e),t.splice(s,1),s--}return r})),e.formatArgs.call(n,t);(n.log||e.log).apply(n,t)}return a.namespace=t,a.useColors=e.useColors(),a.color=e.selectColor(t),a.extend=n,a.destroy=e.destroy,Object.defineProperty(a,\"enabled\",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==e.namespaces&&(i=e.namespaces,o=e.enabled(t)),o),set:t=>{s=t}}),\"function\"==typeof e.init&&e.init(a),a}function n(t,r){const n=e(this.namespace+(void 0===r?\":\":r)+t);return n.log=this.log,n}function i(t){return t.toString().substring(2,t.toString().length-2).replace(/\\.\\*\\?$/,\"*\")}return e.debug=e,e.default=e,e.coerce=function(t){if(t instanceof Error)return t.stack||t.message;return t},e.disable=function(){const t=[...e.names.map(i),...e.skips.map(i).map((t=>\"-\"+t))].join(\",\");return e.enable(\"\"),t},e.enable=function(t){let r;e.save(t),e.namespaces=t,e.names=[],e.skips=[];const n=(\"string\"==typeof t?t:\"\").split(/[\\s,]+/),i=n.length;for(r=0;r{e[r]=t[r]})),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let r=0;for(let e=0;e{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(3540);e.networks=i;const o=r(146),s=r(2644),a=r(6952),c=r(5581),u=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError(\"Private key not in range [1, n)\");return o.typeforce(u,r),new f(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(u,r),new f(void 0,e,r)}(0,c.testEcc)(t);class f{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error(\"Missing private key\");return a.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error(\"Missing private key\");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error(\"Missing private key\");if(!t.signSchnorr)throw new Error(\"signSchnorr not supported by ecc library\");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error(\"verifySchnorr not supported by ecc library\");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const s=t.xOnlyPointAddTweak(i,e);if(!s||null===s.xOnlyPubkey)throw new Error(\"Cannot tweak public key!\");const a=n.from([0===s.parity?2:3]);return r(n.concat([a,s.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3===this.publicKey[0]||4===this.publicKey[0]&&1==(1&this.publicKey[64])?t.privateNegate(this.privateKey):this.privateKey,o=t.privateAdd(i,r);if(!o)throw new Error(\"Invalid tweaked private key!\");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=a.decode(t),s=n.version;if(o.Array(r)){if(!(r=r.filter((t=>s===t.wif)).pop()))throw new Error(\"Unknown network version\")}else if(r=r||i.bitcoin,s!==r.wif)throw new Error(\"Invalid network version\");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(u,r),void 0===r&&(r={});const n=r.rng||s;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},1075:(t,e,r)=>{\"use strict\";e.Ay=void 0;var n=r(2239);Object.defineProperty(e,\"Ay\",{enumerable:!0,get:function(){return n.ECPairFactory}})},3540:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"bc\",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:\"\u0018Bitcoin Signed Message:\\n\",bech32:\"tb\",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},5581:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,\"hex\");function o(t){if(!t)throw new Error(\"ecc library invalid\")}e.testEcc=function(t){o(t.isPoint(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(!t.isPoint(i(\"030000000000000000000000000000000000000000000000000000000000000005\"))),o(t.isPrivate(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(!t.isPrivate(i(\"0000000000000000000000000000000000000000000000000000000000000000\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141\"))),o(!t.isPrivate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142\"))),o(n.from(t.privateAdd(i(\"0000000000000000000000000000000000000000000000000000000000000001\"),i(\"0000000000000000000000000000000000000000000000000000000000000000\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))),o(null===t.privateAdd(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"),i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateAdd(i(\"e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500\"),i(\"b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665\"))).equals(i(\"9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24\"))),o(n.from(t.privateNegate(i(\"0000000000000000000000000000000000000000000000000000000000000001\"))).equals(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))),o(n.from(t.privateNegate(i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e\"))).equals(i(\"0000000000000000000000000000000000000000000000000000000000000003\"))),o(n.from(t.privateNegate(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792\"))),o(n.from(t.pointCompress(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"),!0)).equals(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(n.from(t.pointCompress(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"),!1)).equals(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"))),o(n.from(t.pointCompress(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),!0)).equals(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"))),o(n.from(t.pointCompress(i(\"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),!1)).equals(i(\"0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8\"))),o(n.from(t.pointFromScalar(i(\"b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af\"))).equals(i(\"02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99\"))),o(null===t.xOnlyPointAddTweak(i(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\")));let e=t.xOnlyPointAddTweak(i(\"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b\"),i(\"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac\"));o(n.from(e.xOnlyPubkey).equals(i(\"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf\"))&&1===e.parity),e=t.xOnlyPointAddTweak(i(\"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\"),i(\"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47\")),o(n.from(e.xOnlyPubkey).equals(i(\"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c\"))&&0===e.parity),o(n.from(t.sign(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140\"))).equals(i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),o(t.verify(i(\"5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed\"),i(\"0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"),i(\"54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5\"))),t.signSchnorr&&o(n.from(t.signSchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9\"),i(\"c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906\"))).equals(i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\"))),t.verifySchnorr&&o(t.verifySchnorr(i(\"7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c\"),i(\"dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8\"),i(\"5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7\")))}},146:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(973),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},46:t=>{\"use strict\";var e,r=\"object\"==typeof Reflect?Reflect:null,n=r&&\"function\"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&\"function\"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){\"function\"==typeof t.removeListener&&t.removeListener(\"error\",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),\"error\"!==e&&function(t,e,r){\"function\"==typeof t.on&&y(t,\"error\",e,r)}(t,i,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if(\"function\"!=typeof t)throw new TypeError('The \"listener\" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var i,o,s,u;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit(\"newListener\",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if(\"function\"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(t))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error(\"Possible EventEmitter memory leak detected. \"+s.length+\" \"+String(e)+\" listeners added. Use emitter.setMaxListeners() to increase limit\");f.name=\"MaxListenersExceededWarning\",f.emitter=t,f.type=e,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function l(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:\"function\"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(s=e[0]),s instanceof Error)throw s;var a=new Error(\"Unhandled error.\"+(s?\" (\"+s.message+\")\":\"\"));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if(\"function\"==typeof c)n(c,this,e);else{var u=c.length,f=d(c,u);for(r=0;r=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return l(this,t,!0)},o.prototype.rawListeners=function(t){return l(this,t,!1)},o.listenerCount=function(t,e){return\"function\"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},282:t=>{t.exports=s,s.default=s,s.stable=f,s.stableStringify=f;var e=\"[...]\",r=\"[Circular]\",n=[],i=[];function o(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function s(t,e,r,s){var a;void 0===s&&(s=o()),c(t,\"\",0,[],void 0,0,s);try{a=0===i.length?JSON.stringify(t,e,r):JSON.stringify(t,l(e),r)}catch(t){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function a(t,e,r,o){var s=Object.getOwnPropertyDescriptor(o,r);void 0!==s.get?s.configurable?(Object.defineProperty(o,r,{value:t}),n.push([o,r,e,s])):i.push([e,r,t]):(o[r]=t,n.push([o,r,e]))}function c(t,n,i,o,s,u,f){var h;if(u+=1,\"object\"==typeof t&&null!==t){for(h=0;hf.depthLimit)return void a(e,t,n,s);if(void 0!==f.edgesLimit&&i+1>f.edgesLimit)return void a(e,t,n,s);if(o.push(t),Array.isArray(t))for(h=0;he?1:0}function f(t,e,r,s){void 0===s&&(s=o());var a,c=h(t,\"\",0,[],void 0,0,s)||t;try{a=0===i.length?JSON.stringify(c,e,r):JSON.stringify(c,l(e),r)}catch(t){return JSON.stringify(\"[unable to serialize, circular reference is too complex to analyze]\")}finally{for(;0!==n.length;){var u=n.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return a}function h(t,i,o,s,c,f,l){var p;if(f+=1,\"object\"==typeof t&&null!==t){for(p=0;pl.depthLimit)return void a(e,t,i,c);if(void 0!==l.edgesLimit&&o+1>l.edgesLimit)return void a(e,t,i,c);if(s.push(t),Array.isArray(t))for(p=0;p0)for(var n=0;n{\"use strict\";const n=r(919),i=r(6226),o=r(5181);t.exports={XMLParser:i,XMLValidator:n,XMLBuilder:o}},1209:(t,e)=>{\"use strict\";const r=\":A-Za-z_\\\\u00C0-\\\\u00D6\\\\u00D8-\\\\u00F6\\\\u00F8-\\\\u02FF\\\\u0370-\\\\u037D\\\\u037F-\\\\u1FFF\\\\u200C-\\\\u200D\\\\u2070-\\\\u218F\\\\u2C00-\\\\u2FEF\\\\u3001-\\\\uD7FF\\\\uF900-\\\\uFDCF\\\\uFDF0-\\\\uFFFD\",n=\"[\"+r+\"][\"+(r+\"\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040\")+\"]*\",i=new RegExp(\"^\"+n+\"$\");e.isExist=function(t){return void 0!==t},e.isEmptyObject=function(t){return 0===Object.keys(t).length},e.merge=function(t,e,r){if(e){const n=Object.keys(e),i=n.length;for(let o=0;o{\"use strict\";const n=r(1209),i={allowBooleanAttributes:!1,unpairedTags:[]};function o(t){return\" \"===t||\"\\t\"===t||\"\\n\"===t||\"\\r\"===t}function s(t,e){const r=e;for(;e5&&\"xml\"===n)return d(\"InvalidXml\",\"XML declaration allowed only at the start of the document.\",g(t,e));if(\"?\"==t[e]&&\">\"==t[e+1]){e++;break}}return e}function a(t,e){if(t.length>e+5&&\"-\"===t[e+1]&&\"-\"===t[e+2]){for(e+=3;e\"===t[e+2]){e+=2;break}}else if(t.length>e+8&&\"D\"===t[e+1]&&\"O\"===t[e+2]&&\"C\"===t[e+3]&&\"T\"===t[e+4]&&\"Y\"===t[e+5]&&\"P\"===t[e+6]&&\"E\"===t[e+7]){let r=1;for(e+=8;e\"===t[e]&&(r--,0===r))break}else if(t.length>e+9&&\"[\"===t[e+1]&&\"C\"===t[e+2]&&\"D\"===t[e+3]&&\"A\"===t[e+4]&&\"T\"===t[e+5]&&\"A\"===t[e+6]&&\"[\"===t[e+7])for(e+=8;e\"===t[e+2]){e+=2;break}return e}e.validate=function(t,e){e=Object.assign({},i,e);const r=[];let c=!1,u=!1;\"\\ufeff\"===t[0]&&(t=t.substr(1));for(let i=0;i\"!==t[i]&&\" \"!==t[i]&&\"\\t\"!==t[i]&&\"\\n\"!==t[i]&&\"\\r\"!==t[i];i++)w+=t[i];if(w=w.trim(),\"/\"===w[w.length-1]&&(w=w.substring(0,w.length-1),i--),h=w,!n.isName(h)){let e;return e=0===w.trim().length?\"Invalid space after '<'.\":\"Tag '\"+w+\"' is an invalid name.\",d(\"InvalidTag\",e,g(t,i))}const m=f(t,i);if(!1===m)return d(\"InvalidAttr\",\"Attributes for '\"+w+\"' have open quote.\",g(t,i));let v=m.value;if(i=m.index,\"/\"===v[v.length-1]){const r=i-v.length;v=v.substring(0,v.length-1);const n=l(v,e);if(!0!==n)return d(n.err.code,n.err.msg,g(t,r+n.err.line));c=!0}else if(b){if(!m.tagClosed)return d(\"InvalidTag\",\"Closing tag '\"+w+\"' doesn't have proper closing.\",g(t,i));if(v.trim().length>0)return d(\"InvalidTag\",\"Closing tag '\"+w+\"' can't have attributes or invalid starting.\",g(t,y));{const e=r.pop();if(w!==e.tagName){let r=g(t,e.tagStartPos);return d(\"InvalidTag\",\"Expected closing tag '\"+e.tagName+\"' (opened in line \"+r.line+\", col \"+r.col+\") instead of closing tag '\"+w+\"'.\",g(t,y))}0==r.length&&(u=!0)}}else{const n=l(v,e);if(!0!==n)return d(n.err.code,n.err.msg,g(t,i-v.length+n.err.line));if(!0===u)return d(\"InvalidXml\",\"Multiple possible root nodes found.\",g(t,i));-1!==e.unpairedTags.indexOf(w)||r.push({tagName:w,tagStartPos:y}),c=!0}for(i++;i0)||d(\"InvalidXml\",\"Invalid '\"+JSON.stringify(r.map((t=>t.tagName)),null,4).replace(/\\r?\\n/g,\"\")+\"' found.\",{line:1,col:1}):d(\"InvalidXml\",\"Start tag expected.\",1)};const c='\"',u=\"'\";function f(t,e){let r=\"\",n=\"\",i=!1;for(;e\"===t[e]&&\"\"===n){i=!0;break}r+=t[e]}return\"\"===n&&{value:r,index:e,tagClosed:i}}const h=new RegExp(\"(\\\\s*)([^\\\\s=]+)(\\\\s*=)?(\\\\s*(['\\\"])(([\\\\s\\\\S])*?)\\\\5)?\",\"g\");function l(t,e){const r=n.getAllMatches(t,h),i={};for(let t=0;t{\"use strict\";const n=r(4655),i={attributeNamePrefix:\"@_\",attributesGroupName:!1,textNodeName:\"#text\",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:\" \",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp(\"&\",\"g\"),val:\"&\"},{regex:new RegExp(\">\",\"g\"),val:\">\"},{regex:new RegExp(\"<\",\"g\"),val:\"<\"},{regex:new RegExp(\"'\",\"g\"),val:\"'\"},{regex:new RegExp('\"',\"g\"),val:\""\"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function o(t){this.options=Object.assign({},i,t),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=c),this.processTextOrObjNode=s,this.options.format?(this.indentate=a,this.tagEndChar=\">\\n\",this.newLine=\"\\n\"):(this.indentate=function(){return\"\"},this.tagEndChar=\">\",this.newLine=\"\")}function s(t,e,r){const n=this.j2x(t,r+1);return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,r):this.buildObjectNode(n.val,e,n.attrStr,r)}function a(t){return this.options.indentBy.repeat(t)}function c(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}o.prototype.build=function(t){return this.options.preserveOrder?n(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0).val)},o.prototype.j2x=function(t,e){let r=\"\",n=\"\";for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i))if(void 0===t[i])this.isAttribute(i)&&(n+=\"\");else if(null===t[i])this.isAttribute(i)?n+=\"\":\"?\"===i[0]?n+=this.indentate(e)+\"<\"+i+\"?\"+this.tagEndChar:n+=this.indentate(e)+\"<\"+i+\"/\"+this.tagEndChar;else if(t[i]instanceof Date)n+=this.buildTextValNode(t[i],i,\"\",e);else if(\"object\"!=typeof t[i]){const o=this.isAttribute(i);if(o)r+=this.buildAttrPairStr(o,\"\"+t[i]);else if(i===this.options.textNodeName){let e=this.options.tagValueProcessor(i,\"\"+t[i]);n+=this.replaceEntitiesValue(e)}else n+=this.buildTextValNode(t[i],i,\"\",e)}else if(Array.isArray(t[i])){const r=t[i].length;let o=\"\";for(let s=0;s\"+t+i}},o.prototype.closeTag=function(t){let e=\"\";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e=\"/\"):e=this.options.suppressEmptyNode?\"/\":`>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(n)+`\\x3c!--${t}--\\x3e`+this.newLine;if(\"?\"===e[0])return this.indentate(n)+\"<\"+e+r+\"?\"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),\"\"===i?this.indentate(n)+\"<\"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(n)+\"<\"+e+r+\">\"+i+\"0&&this.options.processEntities)for(let e=0;e{function e(t,s,a,c){let u=\"\",f=!1;for(let h=0;h`,f=!1;continue}if(p===s.commentPropName){u+=c+`\\x3c!--${l[p][0][s.textNodeName]}--\\x3e`,f=!0;continue}if(\"?\"===p[0]){const t=n(l[\":@\"],s),e=\"?xml\"===p?\"\":c;let r=l[p][0][s.textNodeName];r=0!==r.length?\" \"+r:\"\",u+=e+`<${p}${r}${t}?>`,f=!0;continue}let y=c;\"\"!==y&&(y+=s.indentBy);const g=c+`<${p}${n(l[\":@\"],s)}`,b=e(l[p],s,d,y);-1!==s.unpairedTags.indexOf(p)?s.suppressUnpairedNode?u+=g+\">\":u+=g+\"/>\":b&&0!==b.length||!s.suppressEmptyNode?b&&b.endsWith(\">\")?u+=g+`>${b}${c}`:(u+=g+\">\",b&&\"\"!==c&&(b.includes(\"/>\")||b.includes(\"`):u+=g+\"/>\",f=!0}return u}function r(t){const e=Object.keys(t);for(let r=0;r0&&e.processEntities)for(let r=0;r0&&(n=\"\\n\"),e(t,r,\"\",n)}},3233:(t,e,r)=>{const n=r(1209);function i(t,e){let r=\"\";for(;e\"===t[e]){if(l?\"-\"===t[e-1]&&\"-\"===t[e-2]&&(l=!1,n--):n--,0===n)break}else\"[\"===t[e]?h=!0:p+=t[e];else{if(h&&s(t,e))e+=7,[entityName,val,e]=i(t,e+1),-1===val.indexOf(\"&\")&&(r[f(entityName)]={regx:RegExp(`&${entityName};`,\"g\"),val});else if(h&&a(t,e))e+=8;else if(h&&c(t,e))e+=8;else if(h&&u(t,e))e+=9;else{if(!o)throw new Error(\"Invalid DOCTYPE\");l=!0}n++,p=\"\"}if(0!==n)throw new Error(\"Unclosed DOCTYPE\")}return{entities:r,i:e}}},7063:(t,e)=>{const r={preserveOrder:!1,attributeNamePrefix:\"@_\",attributesGroupName:!1,textNodeName:\"#text\",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t}};e.buildOptions=function(t){return Object.assign({},r,t)},e.defaultOptions=r},5139:(t,e,r)=>{\"use strict\";const n=r(1209),i=r(5381),o=r(3233),s=r(8262);function a(t){const e=Object.keys(t);for(let r=0;r0)){s||(t=this.replaceEntitiesValue(t));const n=this.options.tagValueProcessor(e,t,r,i,o);if(null==n)return t;if(typeof n!=typeof t||n!==t)return n;if(this.options.trimValues)return v(t,this.options.parseTagValue,this.options.numberParseOptions);return t.trim()===t?v(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function u(t){if(this.options.removeNSPrefix){const e=t.split(\":\"),r=\"/\"===t.charAt(0)?\"/\":\"\";if(\"xmlns\"===e[0])return\"\";2===e.length&&(t=r+e[1])}return t}const f=new RegExp(\"([^\\\\s=]+)\\\\s*(=\\\\s*(['\\\"])([\\\\s\\\\S]*?)\\\\3)?\",\"gm\");function h(t,e,r){if(!this.options.ignoreAttributes&&\"string\"==typeof t){const r=n.getAllMatches(t,f),i=r.length,o={};for(let t=0;t\",a,\"Closing Tag is not closed.\");let i=t.substring(a+2,e).trim();if(this.options.removeNSPrefix){const t=i.indexOf(\":\");-1!==t&&(i=i.substr(t+1))}this.options.transformTagName&&(i=this.options.transformTagName(i)),r&&(n=this.saveTextToParentTag(n,r,s));const o=s.substring(s.lastIndexOf(\".\")+1);if(i&&-1!==this.options.unpairedTags.indexOf(i))throw new Error(`Unpaired tag can not be used as closing tag: `);let c=0;o&&-1!==this.options.unpairedTags.indexOf(o)?(c=s.lastIndexOf(\".\",s.lastIndexOf(\".\")-1),this.tagsNodeStack.pop()):c=s.lastIndexOf(\".\"),s=s.substring(0,c),r=this.tagsNodeStack.pop(),n=\"\",a=e}else if(\"?\"===t[a+1]){let e=w(t,a,!1,\"?>\");if(!e)throw new Error(\"Pi Tag is not closed.\");if(n=this.saveTextToParentTag(n,r,s),this.options.ignoreDeclaration&&\"?xml\"===e.tagName||this.options.ignorePiTags);else{const t=new i(e.tagName);t.add(this.options.textNodeName,\"\"),e.tagName!==e.tagExp&&e.attrExpPresent&&(t[\":@\"]=this.buildAttributesMap(e.tagExp,s,e.tagName)),this.addChild(r,t,s)}a=e.closeIndex+1}else if(\"!--\"===t.substr(a+1,3)){const e=b(t,\"--\\x3e\",a+4,\"Comment is not closed.\");if(this.options.commentPropName){const i=t.substring(a+4,e-2);n=this.saveTextToParentTag(n,r,s),r.add(this.options.commentPropName,[{[this.options.textNodeName]:i}])}a=e}else if(\"!D\"===t.substr(a+1,2)){const e=o(t,a);this.docTypeEntities=e.entities,a=e.i}else if(\"![\"===t.substr(a+1,2)){const e=b(t,\"]]>\",a,\"CDATA is not closed.\")-2,i=t.substring(a+9,e);n=this.saveTextToParentTag(n,r,s);let o=this.parseTextData(i,r.tagname,s,!0,!1,!0,!0);null==o&&(o=\"\"),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:i}]):r.add(this.options.textNodeName,o),a=e+2}else{let o=w(t,a,this.options.removeNSPrefix),c=o.tagName;const u=o.rawTagName;let f=o.tagExp,h=o.attrExpPresent,l=o.closeIndex;this.options.transformTagName&&(c=this.options.transformTagName(c)),r&&n&&\"!xml\"!==r.tagname&&(n=this.saveTextToParentTag(n,r,s,!1));const p=r;if(p&&-1!==this.options.unpairedTags.indexOf(p.tagname)&&(r=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf(\".\"))),c!==e.tagname&&(s+=s?\".\"+c:c),this.isItStopNode(this.options.stopNodes,s,c)){let e=\"\";if(f.length>0&&f.lastIndexOf(\"/\")===f.length-1)a=o.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(c))a=o.closeIndex;else{const r=this.readStopNodeData(t,u,l+1);if(!r)throw new Error(`Unexpected end of ${u}`);a=r.i,e=r.tagContent}const n=new i(c);c!==f&&h&&(n[\":@\"]=this.buildAttributesMap(f,s,c)),e&&(e=this.parseTextData(e,c,s,!0,h,!0,!0)),s=s.substr(0,s.lastIndexOf(\".\")),n.add(this.options.textNodeName,e),this.addChild(r,n,s)}else{if(f.length>0&&f.lastIndexOf(\"/\")===f.length-1){\"/\"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),f=c):f=f.substr(0,f.length-1),this.options.transformTagName&&(c=this.options.transformTagName(c));const t=new i(c);c!==f&&h&&(t[\":@\"]=this.buildAttributesMap(f,s,c)),this.addChild(r,t,s),s=s.substr(0,s.lastIndexOf(\".\"))}else{const t=new i(c);this.tagsNodeStack.push(r),c!==f&&h&&(t[\":@\"]=this.buildAttributesMap(f,s,c)),this.addChild(r,t,s),r=t}n=\"\",a=l}}else n+=t[a]}return e.child};function p(t,e,r){const n=this.options.updateTag(e.tagname,r,e[\":@\"]);!1===n||(\"string\"==typeof n?(e.tagname=n,t.addChild(e)):t.addChild(e))}const d=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const r=this.docTypeEntities[e];t=t.replace(r.regx,r.val)}for(let e in this.lastEntities){const r=this.lastEntities[e];t=t.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const r=this.htmlEntities[e];t=t.replace(r.regex,r.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function y(t,e,r,n){return t&&(void 0===n&&(n=0===Object.keys(e.child).length),void 0!==(t=this.parseTextData(t,e.tagname,r,!1,!!e[\":@\"]&&0!==Object.keys(e[\":@\"]).length,n))&&\"\"!==t&&e.add(this.options.textNodeName,t),t=\"\"),t}function g(t,e,r){const n=\"*.\"+r;for(const r in t){const i=t[r];if(n===i||e===i)return!0}return!1}function b(t,e,r,n){const i=t.indexOf(e,r);if(-1===i)throw new Error(n);return i+e.length-1}function w(t,e,r,n=\">\"){const i=function(t,e,r=\">\"){let n,i=\"\";for(let o=e;o\",r,`${e} is not closed`);if(t.substring(r+2,o).trim()===e&&(i--,0===i))return{tagContent:t.substring(n,r),i:o};r=o}else if(\"?\"===t[r+1]){r=b(t,\"?>\",r+1,\"StopNode is not closed.\")}else if(\"!--\"===t.substr(r+1,3)){r=b(t,\"--\\x3e\",r+3,\"StopNode is not closed.\")}else if(\"![\"===t.substr(r+1,2)){r=b(t,\"]]>\",r,\"StopNode is not closed.\")-2}else{const n=w(t,r,\">\");if(n){(n&&n.tagName)===e&&\"/\"!==n.tagExp[n.tagExp.length-1]&&i++,r=n.closeIndex}}}function v(t,e,r){if(e&&\"string\"==typeof t){const e=t.trim();return\"true\"===e||\"false\"!==e&&s(t,r)}return n.isExist(t)?t:\"\"}t.exports=class{constructor(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:\"'\"},gt:{regex:/&(gt|#62|#x3E);/g,val:\">\"},lt:{regex:/&(lt|#60|#x3C);/g,val:\"<\"},quot:{regex:/&(quot|#34|#x22);/g,val:'\"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:\"&\"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:\" \"},cent:{regex:/&(cent|#162);/g,val:\"¢\"},pound:{regex:/&(pound|#163);/g,val:\"£\"},yen:{regex:/&(yen|#165);/g,val:\"¥\"},euro:{regex:/&(euro|#8364);/g,val:\"€\"},copyright:{regex:/&(copy|#169);/g,val:\"©\"},reg:{regex:/&(reg|#174);/g,val:\"®\"},inr:{regex:/&(inr|#8377);/g,val:\"₹\"}},this.addExternalEntities=a,this.parseXml=l,this.parseTextData=c,this.resolveNameSpace=u,this.buildAttributesMap=h,this.isItStopNode=g,this.replaceEntitiesValue=d,this.readStopNodeData=m,this.saveTextToParentTag=y,this.addChild=p}}},6226:(t,e,r)=>{const{buildOptions:n}=r(7063),i=r(5139),{prettify:o}=r(896),s=r(919);t.exports=class{constructor(t){this.externalEntities={},this.options=n(t)}parse(t,e){if(\"string\"==typeof t);else{if(!t.toString)throw new Error(\"XML data is accepted in String or Bytes[] form.\");t=t.toString()}if(e){!0===e&&(e={});const r=s.validate(t,e);if(!0!==r)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const r=new i(this.options);r.addExternalEntities(this.externalEntities);const n=r.parseXml(t);return this.options.preserveOrder||void 0===n?n:o(n,this.options)}addEntity(t,e){if(-1!==e.indexOf(\"&\"))throw new Error(\"Entity value can't have '&'\");if(-1!==t.indexOf(\"&\")||-1!==t.indexOf(\";\"))throw new Error(\"An entity must be set without '&' and ';'. Eg. use '#xD' for ' '\");if(\"&\"===e)throw new Error(\"An entity with value '&' is not permitted\");this.externalEntities[t]=e}}},896:(t,e)=>{\"use strict\";function r(t,e,s){let a;const c={};for(let u=0;u0&&(c[e.textNodeName]=a):void 0!==a&&(c[e.textNodeName]=a),c}function n(t){const e=Object.keys(t);for(let t=0;t{\"use strict\";t.exports=class{constructor(t){this.tagname=t,this.child=[],this[\":@\"]={}}add(t,e){\"__proto__\"===t&&(t=\"#__proto__\"),this.child.push({[t]:e})}addChild(t){\"__proto__\"===t.tagname&&(t.tagname=\"#__proto__\"),t[\":@\"]&&Object.keys(t[\":@\"]).length>0?this.child.push({[t.tagname]:t.child,\":@\":t[\":@\"]}):this.child.push({[t.tagname]:t.child})}}},9467:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=r(4156).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(5615)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t,e){if(!n.isBuffer(t)&&\"string\"!=typeof t)throw new TypeError(e+\" must be a string or a buffer\")}(t,\"Data\"),this._finalized)throw new Error(\"Digest already called\");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error(\"_update is not implemented\")},o.prototype.digest=function(t){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error(\"_digest is not implemented\")},t.exports=o},9318:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,c=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=u}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;t[r+p]=255&s,p+=d,s/=256,u-=8);t[r+p-d]|=128*y}},5615:t=>{\"function\"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},3624:(t,e,r)=>{\"use strict\";const n=r(222),i=Symbol(\"max\"),o=Symbol(\"length\"),s=Symbol(\"lengthCalculator\"),a=Symbol(\"allowStale\"),c=Symbol(\"maxAge\"),u=Symbol(\"dispose\"),f=Symbol(\"noDisposeOnSet\"),h=Symbol(\"lruList\"),l=Symbol(\"cache\"),p=Symbol(\"updateAgeOnGet\"),d=()=>1;const y=(t,e,r)=>{const n=t[l].get(e);if(n){const e=n.value;if(g(t,e)){if(w(t,n),!t[a])return}else r&&(t[p]&&(n.value.now=Date.now()),t[h].unshiftNode(n));return e.value}},g=(t,e)=>{if(!e||!e.maxAge&&!t[c])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[c]&&r>t[c]},b=t=>{if(t[o]>t[i])for(let e=t[h].tail;t[o]>t[i]&&null!==e;){const r=e.prev;w(t,e),e=r}},w=(t,e)=>{if(e){const r=e.value;t[u]&&t[u](r.key,r.value),t[o]-=r.length,t[l].delete(r.key),t[h].removeNode(e)}};class m{constructor(t,e,r,n,i){this.key=t,this.value=e,this.length=r,this.now=n,this.maxAge=i||0}}const v=(t,e,r,n)=>{let i=r.value;g(t,i)&&(w(t,r),t[a]||(i=void 0)),i&&e.call(n,i.value,i.key,t)};t.exports=class{constructor(t){if(\"number\"==typeof t&&(t={max:t}),t||(t={}),t.max&&(\"number\"!=typeof t.max||t.max<0))throw new TypeError(\"max must be a non-negative number\");this[i]=t.max||1/0;const e=t.length||d;if(this[s]=\"function\"!=typeof e?d:e,this[a]=t.stale||!1,t.maxAge&&\"number\"!=typeof t.maxAge)throw new TypeError(\"maxAge must be a number\");this[c]=t.maxAge||0,this[u]=t.dispose,this[f]=t.noDisposeOnSet||!1,this[p]=t.updateAgeOnGet||!1,this.reset()}set max(t){if(\"number\"!=typeof t||t<0)throw new TypeError(\"max must be a non-negative number\");this[i]=t||1/0,b(this)}get max(){return this[i]}set allowStale(t){this[a]=!!t}get allowStale(){return this[a]}set maxAge(t){if(\"number\"!=typeof t)throw new TypeError(\"maxAge must be a non-negative number\");this[c]=t,b(this)}get maxAge(){return this[c]}set lengthCalculator(t){\"function\"!=typeof t&&(t=d),t!==this[s]&&(this[s]=t,this[o]=0,this[h].forEach((t=>{t.length=this[s](t.value,t.key),this[o]+=t.length}))),b(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[h].length}rforEach(t,e){e=e||this;for(let r=this[h].tail;null!==r;){const n=r.prev;v(this,t,r,e),r=n}}forEach(t,e){e=e||this;for(let r=this[h].head;null!==r;){const n=r.next;v(this,t,r,e),r=n}}keys(){return this[h].toArray().map((t=>t.key))}values(){return this[h].toArray().map((t=>t.value))}reset(){this[u]&&this[h]&&this[h].length&&this[h].forEach((t=>this[u](t.key,t.value))),this[l]=new Map,this[h]=new n,this[o]=0}dump(){return this[h].map((t=>!g(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[h]}set(t,e,r){if((r=r||this[c])&&\"number\"!=typeof r)throw new TypeError(\"maxAge must be a number\");const n=r?Date.now():0,a=this[s](e,t);if(this[l].has(t)){if(a>this[i])return w(this,this[l].get(t)),!1;const s=this[l].get(t).value;return this[u]&&(this[f]||this[u](t,s.value)),s.now=n,s.maxAge=r,s.value=e,this[o]+=a-s.length,s.length=a,this.get(t),b(this),!0}const p=new m(t,e,a,n,r);return p.length>this[i]?(this[u]&&this[u](t,e),!1):(this[o]+=p.length,this[h].unshift(p),this[l].set(t,this[h].head),b(this),!0)}has(t){if(!this[l].has(t))return!1;const e=this[l].get(t).value;return!g(this,e)}get(t){return y(this,t,!0)}peek(t){return y(this,t,!1)}pop(){const t=this[h].tail;return t?(w(this,t),t.value):null}del(t){w(this,this[l].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const n=t[r],i=n.e||0;if(0===i)this.set(n.k,n.v);else{const t=i-e;t>0&&this.set(n.k,n.v,t)}}}prune(){this[l].forEach(((t,e)=>y(this,e,!1)))}}},3275:(t,e,r)=>{\"use strict\";var n=r(5615),i=r(9467),o=r(5636).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function c(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return c(t+(e&r|~e&n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return c(t+(e&n|r&~n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return c(t+(e^r^n)+i+o|0,s)+e|0}function l(t,e,r,n,i,o,s){return c(t+(r^(e|~n))+i+o|0,s)+e|0}n(a,i),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,o=this._d;r=u(r,n,i,o,t[0],3614090360,7),o=u(o,r,n,i,t[1],3905402710,12),i=u(i,o,r,n,t[2],606105819,17),n=u(n,i,o,r,t[3],3250441966,22),r=u(r,n,i,o,t[4],4118548399,7),o=u(o,r,n,i,t[5],1200080426,12),i=u(i,o,r,n,t[6],2821735955,17),n=u(n,i,o,r,t[7],4249261313,22),r=u(r,n,i,o,t[8],1770035416,7),o=u(o,r,n,i,t[9],2336552879,12),i=u(i,o,r,n,t[10],4294925233,17),n=u(n,i,o,r,t[11],2304563134,22),r=u(r,n,i,o,t[12],1804603682,7),o=u(o,r,n,i,t[13],4254626195,12),i=u(i,o,r,n,t[14],2792965006,17),r=f(r,n=u(n,i,o,r,t[15],1236535329,22),i,o,t[1],4129170786,5),o=f(o,r,n,i,t[6],3225465664,9),i=f(i,o,r,n,t[11],643717713,14),n=f(n,i,o,r,t[0],3921069994,20),r=f(r,n,i,o,t[5],3593408605,5),o=f(o,r,n,i,t[10],38016083,9),i=f(i,o,r,n,t[15],3634488961,14),n=f(n,i,o,r,t[4],3889429448,20),r=f(r,n,i,o,t[9],568446438,5),o=f(o,r,n,i,t[14],3275163606,9),i=f(i,o,r,n,t[3],4107603335,14),n=f(n,i,o,r,t[8],1163531501,20),r=f(r,n,i,o,t[13],2850285829,5),o=f(o,r,n,i,t[2],4243563512,9),i=f(i,o,r,n,t[7],1735328473,14),r=h(r,n=f(n,i,o,r,t[12],2368359562,20),i,o,t[5],4294588738,4),o=h(o,r,n,i,t[8],2272392833,11),i=h(i,o,r,n,t[11],1839030562,16),n=h(n,i,o,r,t[14],4259657740,23),r=h(r,n,i,o,t[1],2763975236,4),o=h(o,r,n,i,t[4],1272893353,11),i=h(i,o,r,n,t[7],4139469664,16),n=h(n,i,o,r,t[10],3200236656,23),r=h(r,n,i,o,t[13],681279174,4),o=h(o,r,n,i,t[0],3936430074,11),i=h(i,o,r,n,t[3],3572445317,16),n=h(n,i,o,r,t[6],76029189,23),r=h(r,n,i,o,t[9],3654602809,4),o=h(o,r,n,i,t[12],3873151461,11),i=h(i,o,r,n,t[15],530742520,16),r=l(r,n=h(n,i,o,r,t[2],3299628645,23),i,o,t[0],4096336452,6),o=l(o,r,n,i,t[7],1126891415,10),i=l(i,o,r,n,t[14],2878612391,15),n=l(n,i,o,r,t[5],4237533241,21),r=l(r,n,i,o,t[12],1700485571,6),o=l(o,r,n,i,t[3],2399980690,10),i=l(i,o,r,n,t[10],4293915773,15),n=l(n,i,o,r,t[1],2240044497,21),r=l(r,n,i,o,t[8],1873313359,6),o=l(o,r,n,i,t[15],4264355552,10),i=l(i,o,r,n,t[6],2734768916,15),n=l(n,i,o,r,t[13],1309151649,21),r=l(r,n,i,o,t[4],4149444226,6),o=l(o,r,n,i,t[11],3174756917,10),i=l(i,o,r,n,t[2],718787259,15),n=l(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=o.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},9756:(t,e,r)=>{\"use strict\";const{ErrorWithCause:n}=r(4525),{findCauseByReference:i,getErrorCause:o,messageWithCauses:s,stackWithCauses:a}=r(2197);t.exports={ErrorWithCause:n,findCauseByReference:i,getErrorCause:o,stackWithCauses:a,messageWithCauses:s}},4525:t=>{\"use strict\";class e extends Error{constructor(t,{cause:r}={}){super(t),this.name=e.name,r&&(this.cause=r),this.message=t}}t.exports={ErrorWithCause:e}},2197:t=>{\"use strict\";const e=t=>{if(t&&\"object\"==typeof t&&\"cause\"in t){if(\"function\"==typeof t.cause){const e=t.cause();return e instanceof Error?e:void 0}return t.cause instanceof Error?t.cause:void 0}},r=(t,n)=>{if(!(t instanceof Error))return\"\";const i=t.stack||\"\";if(n.has(t))return i+\"\\ncauses have become circular...\";const o=e(t);return o?(n.add(t),i+\"\\ncaused by: \"+r(o,n)):i},n=(t,r,i)=>{if(!(t instanceof Error))return\"\";const o=i?\"\":t.message||\"\";if(r.has(t))return o+\": ...\";const s=e(t);if(s){r.add(t);const e=\"cause\"in t&&\"function\"==typeof t.cause;return o+(e?\"\":\": \")+n(s,r,e)}return o};t.exports={findCauseByReference:(t,r)=>{if(!t||!r)return;if(!(t instanceof Error))return;if(!(r.prototype instanceof Error)&&r!==Error)return;const n=new Set;let i=t;for(;i&&!n.has(i);){if(n.add(i),i instanceof r)return i;i=e(i)}},getErrorCause:e,stackWithCauses:t=>r(t,new Set),messageWithCauses:t=>n(t,new Set)}},2644:(t,e,r)=>{\"use strict\";var n=65536,i=4294967295;var o=r(5636).Buffer,s=r.g.crypto||r.g.msCrypto;s&&s.getRandomValues?t.exports=function(t,e){if(t>i)throw new RangeError(\"requested too many random bytes\");var r=o.allocUnsafe(t);if(t>0)if(t>n)for(var a=0;a{\"use strict\";var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return\"string\"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?\"one of \".concat(e,\" \").concat(t.slice(0,r-1).join(\", \"),\", or \")+t[r-1]:2===r?\"one of \".concat(e,\" \").concat(t[0],\" or \").concat(t[1]):\"of \".concat(e,\" \").concat(t[0])}return\"of \".concat(e,\" \").concat(String(t))}r(\"ERR_INVALID_OPT_VALUE\",(function(t,e){return'The value \"'+e+'\" is invalid for option \"'+t+'\"'}),TypeError),r(\"ERR_INVALID_ARG_TYPE\",(function(t,e,r){var i,o,s,a;if(\"string\"==typeof e&&(o=\"not \",e.substr(!s||s<0?0:+s,o.length)===o)?(i=\"must not be\",e=e.replace(/^not /,\"\")):i=\"must be\",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t,\" argument\"))a=\"The \".concat(t,\" \").concat(i,\" \").concat(n(e,\"type\"));else{var c=function(t,e,r){return\"number\"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,\".\")?\"property\":\"argument\";a='The \"'.concat(t,'\" ').concat(c,\" \").concat(i,\" \").concat(n(e,\"type\"))}return a+=\". Received type \".concat(typeof r)}),TypeError),r(\"ERR_STREAM_PUSH_AFTER_EOF\",\"stream.push() after EOF\"),r(\"ERR_METHOD_NOT_IMPLEMENTED\",(function(t){return\"The \"+t+\" method is not implemented\"})),r(\"ERR_STREAM_PREMATURE_CLOSE\",\"Premature close\"),r(\"ERR_STREAM_DESTROYED\",(function(t){return\"Cannot call \"+t+\" after a stream was destroyed\"})),r(\"ERR_MULTIPLE_CALLBACK\",\"Callback called multiple times\"),r(\"ERR_STREAM_CANNOT_PIPE\",\"Cannot pipe, not readable\"),r(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\"),r(\"ERR_STREAM_NULL_VALUES\",\"May not write null values to stream\",TypeError),r(\"ERR_UNKNOWN_ENCODING\",(function(t){return\"Unknown encoding: \"+t}),TypeError),r(\"ERR_STREAM_UNSHIFT_AFTER_END_EVENT\",\"stream.unshift() after end event\"),t.exports.F=e},1265:(t,e,r)=>{\"use strict\";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=u;var i=r(8199),o=r(5291);r(5615)(u,i);for(var s=n(o.prototype),a=0;a{\"use strict\";t.exports=i;var n=r(9415);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(5615)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},8199:(t,e,r)=>{\"use strict\";var n;t.exports=A,A.ReadableState=S;r(46).EventEmitter;var i=function(t,e){return t.listeners(e).length},o=r(4856),s=r(1048).Buffer,a=(void 0!==r.g?r.g:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var c,u=r(3951);c=u&&u.debuglog?u.debuglog(\"stream\"):function(){};var f,h,l,p=r(82),d=r(6527),y=r(9952).getHighWaterMark,g=r(5699).F,b=g.ERR_INVALID_ARG_TYPE,w=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,v=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(5615)(A,o);var E=d.errorOrDestroy,_=[\"error\",\"close\",\"destroy\",\"pause\",\"resume\"];function S(t,e,i){n=n||r(1265),t=t||{},\"boolean\"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,\"readableHighWaterMark\",i),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(8888).I),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function A(t){if(n=n||r(1265),!(this instanceof A))return new A(t);var e=this instanceof n;this._readableState=new S(t,this,e),this.readable=!0,t&&(\"function\"==typeof t.read&&(this._read=t.read),\"function\"==typeof t.destroy&&(this._destroy=t.destroy)),o.call(this)}function I(t,e,r,n,i){c(\"readableAddChunk\",e);var o,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(c(\"onEofChunk\"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?k(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,P(t)))}(t,u);else if(i||(o=function(t,e){var r;n=e,s.isBuffer(n)||n instanceof a||\"string\"==typeof e||void 0===e||t.objectMode||(r=new b(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],e));var n;return r}(u,e)),o)E(t,o);else if(u.objectMode||e&&e.length>0)if(\"string\"==typeof e||u.objectMode||Object.getPrototypeOf(e)===s.prototype||(e=function(t){return s.from(t)}(e)),n)u.endEmitted?E(t,new v):T(t,u,e,!0);else if(u.ended)E(t,new w);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!r?(e=u.decoder.write(e),u.objectMode||0!==e.length?T(t,u,e,!1):R(t,u)):T(t,u,e,!1)}else n||(u.reading=!1,R(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function k(t){var e=t._readableState;c(\"emitReadable\",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c(\"emitReadable\",e.flowing),e.emittedReadable=!0,process.nextTick(P,t))}function P(t){var e=t._readableState;c(\"emitReadable_\",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit(\"readable\"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,U(t)}function R(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(B,t,e))}function B(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount(\"data\")>0&&t.resume()}function N(t){c(\"readable nexttick read 0\"),t.read(0)}function L(t,e){c(\"resume\",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit(\"resume\"),U(t),e.flowing&&!e.reading&&t.read(0)}function U(t){var e=t._readableState;for(c(\"flow\",e.flowing);e.flowing&&null!==t.read(););}function j(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(\"\"):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function M(t){var e=t._readableState;c(\"endReadable\",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(H,e,t))}function H(t,e){if(c(\"endReadableNT\",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit(\"end\"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function F(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return c(\"read: emitReadable\",e.length,e.ended),0===e.length&&e.ended?M(this):k(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,i=e.needReadable;return c(\"need readable\",i),(0===e.length||e.length-t0?j(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit(\"data\",n),n},A.prototype._read=function(t){E(this,new m(\"_read()\"))},A.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,c(\"pipe count=%d opts=%j\",n.pipesCount,e);var o=(!e||!1!==e.end)&&t!==process.stdout&&t!==process.stderr?a:y;function s(e,i){c(\"onunpipe\"),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,c(\"cleanup\"),t.removeListener(\"close\",p),t.removeListener(\"finish\",d),t.removeListener(\"drain\",u),t.removeListener(\"error\",l),t.removeListener(\"unpipe\",s),r.removeListener(\"end\",a),r.removeListener(\"end\",y),r.removeListener(\"data\",h),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}function a(){c(\"onend\"),t.end()}n.endEmitted?process.nextTick(o):r.once(\"end\",o),t.on(\"unpipe\",s);var u=function(t){return function(){var e=t._readableState;c(\"pipeOnDrain\",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,\"data\")&&(e.flowing=!0,U(t))}}(r);t.on(\"drain\",u);var f=!1;function h(e){c(\"ondata\");var i=t.write(e);c(\"dest.write\",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==F(n.pipes,t))&&!f&&(c(\"false write response, pause\",n.awaitDrain),n.awaitDrain++),r.pause())}function l(e){c(\"onerror\",e),y(),t.removeListener(\"error\",l),0===i(t,\"error\")&&E(t,e)}function p(){t.removeListener(\"finish\",d),y()}function d(){c(\"onfinish\"),t.removeListener(\"close\",p),y()}function y(){c(\"unpipe\"),r.unpipe(t)}return r.on(\"data\",h),function(t,e,r){if(\"function\"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,\"error\",l),t.once(\"close\",p),t.once(\"finish\",d),t.emit(\"pipe\",r),n.flowing||(c(\"pipe resume\"),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit(\"unpipe\",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==n.flowing&&this.resume()):\"readable\"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,c(\"on readable\",n.length,n.reading),n.length?k(this):n.reading||process.nextTick(N,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,e){var r=o.prototype.removeListener.call(this,t,e);return\"readable\"===t&&process.nextTick(C,this),r},A.prototype.removeAllListeners=function(t){var e=o.prototype.removeAllListeners.apply(this,arguments);return\"readable\"!==t&&void 0!==t||process.nextTick(C,this),e},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(c(\"resume\"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(L,t,e))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return c(\"call pause flowing=%j\",this._readableState.flowing),!1!==this._readableState.flowing&&(c(\"pause\"),this._readableState.flowing=!1,this.emit(\"pause\")),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on(\"end\",(function(){if(c(\"wrapped end\"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on(\"data\",(function(i){(c(\"wrapped data\"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&\"function\"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o<_.length;o++)t.on(_[o],this.emit.bind(this,_[o]));return this._read=function(e){c(\"wrapped _read\",e),n&&(n=!1,t.resume())},this},\"function\"==typeof Symbol&&(A.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(534)),h(this)}),Object.defineProperty(A.prototype,\"readableHighWaterMark\",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(A.prototype,\"readableBuffer\",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(A.prototype,\"readableFlowing\",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),A._fromList=j,Object.defineProperty(A.prototype,\"readableLength\",{enumerable:!1,get:function(){return this._readableState.length}}),\"function\"==typeof Symbol&&(A.from=function(t,e){return void 0===l&&(l=r(1260)),l(A,t,e)})},9415:(t,e,r)=>{\"use strict\";t.exports=f;var n=r(5699).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,c=r(1265);function u(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit(\"error\",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{\"use strict\";function n(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;t.entry=null;for(;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}var i;t.exports=A,A.WritableState=S;var o={deprecate:r(6732)},s=r(4856),a=r(1048).Buffer,c=(void 0!==r.g?r.g:\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:{}).Uint8Array||function(){};var u,f=r(6527),h=r(9952).getHighWaterMark,l=r(5699).F,p=l.ERR_INVALID_ARG_TYPE,d=l.ERR_METHOD_NOT_IMPLEMENTED,y=l.ERR_MULTIPLE_CALLBACK,g=l.ERR_STREAM_CANNOT_PIPE,b=l.ERR_STREAM_DESTROYED,w=l.ERR_STREAM_NULL_VALUES,m=l.ERR_STREAM_WRITE_AFTER_END,v=l.ERR_UNKNOWN_ENCODING,E=f.errorOrDestroy;function _(){}function S(t,e,o){i=i||r(1265),t=t||{},\"boolean\"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,\"writableHighWaterMark\",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||\"utf8\",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(\"function\"!=typeof i)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(P,t,e),t._writableState.errorEmitted=!0,E(t,n)):(i(n),t._writableState.errorEmitted=!0,E(t,n),P(t,e))}(t,r,n,e,i);else{var o=O(r)||t.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||x(t,r),n?process.nextTick(T,t,r,o,i):T(t,r,o,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function A(t){var e=this instanceof(i=i||r(1265));if(!e&&!u.call(A,this))return new A(t);this._writableState=new S(t,this,e),this.writable=!0,t&&(\"function\"==typeof t.write&&(this._write=t.write),\"function\"==typeof t.writev&&(this._writev=t.writev),\"function\"==typeof t.destroy&&(this._destroy=t.destroy),\"function\"==typeof t.final&&(this._final=t.final)),s.call(this)}function I(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b(\"write\")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function T(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit(\"drain\"))}(t,e),e.pendingcb--,n(),P(t,e)}function x(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,o=new Array(i),s=e.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)o[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;o.allBuffers=c,I(t,e,!0,e.length,o,\"\",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new n(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(I(t,e,!1,e.objectMode?1:u.length,u,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function O(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function k(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit(\"prefinish\"),P(t,e)}))}function P(t,e){var r=O(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||(\"function\"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit(\"prefinish\")):(e.pendingcb++,e.finalCalled=!0,process.nextTick(k,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit(\"finish\"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(5615)(A,s),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,\"buffer\",{get:o.deprecate((function(){return this.getBuffer()}),\"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.\",\"DEP0003\")})}catch(t){}}(),\"function\"==typeof Symbol&&Symbol.hasInstance&&\"function\"==typeof Function.prototype[Symbol.hasInstance]?(u=Function.prototype[Symbol.hasInstance],Object.defineProperty(A,Symbol.hasInstance,{value:function(t){return!!u.call(this,t)||this===A&&(t&&t._writableState instanceof S)}})):u=function(t){return t instanceof this},A.prototype.pipe=function(){E(this,new g)},A.prototype.write=function(t,e,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=t,a.isBuffer(n)||n instanceof c);return s&&!a.isBuffer(t)&&(t=function(t){return a.from(t)}(t)),\"function\"==typeof e&&(r=e,e=null),s?e=\"buffer\":e||(e=i.defaultEncoding),\"function\"!=typeof r&&(r=_),i.ending?function(t,e){var r=new m;E(t,r),process.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var i;return null===r?i=new w:\"string\"==typeof r||e.objectMode||(i=new p(\"chunk\",[\"string\",\"Buffer\"],r)),!i||(E(t,i),process.nextTick(n,i),!1)}(this,i,t,r))&&(i.pendingcb++,o=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||\"string\"!=typeof e||(e=a.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i=\"buffer\",n=s)}var c=e.objectMode?1:n.length;e.length+=c;var u=e.length-1))throw new v(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(A.prototype,\"writableBuffer\",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,\"writableHighWaterMark\",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(t,e,r){r(new d(\"_write()\"))},A.prototype._writev=null,A.prototype.end=function(t,e,r){var n=this._writableState;return\"function\"==typeof t?(r=t,t=null,e=null):\"function\"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,P(t,e),r&&(e.finished?process.nextTick(r):t.once(\"finish\",r));e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(A.prototype,\"writableLength\",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,\"destroyed\",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),A.prototype.destroy=f.destroy,A.prototype._undestroy=f.undestroy,A.prototype._destroy=function(t,e){e(t)}},534:(t,e,r)=>{\"use strict\";var n;function i(t,e,r){return(e=function(t){var e=function(t,e){if(\"object\"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||\"default\");if(\"object\"!=typeof n)return n;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===e?String:Number)(t)}(t,\"string\");return\"symbol\"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=r(4869),s=Symbol(\"lastResolve\"),a=Symbol(\"lastReject\"),c=Symbol(\"error\"),u=Symbol(\"ended\"),f=Symbol(\"lastPromise\"),h=Symbol(\"handlePromise\"),l=Symbol(\"stream\");function p(t,e){return{value:t,done:e}}function d(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(p(r,!1)))}}function y(t){process.nextTick(d,t)}var g=Object.getPrototypeOf((function(){})),b=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(p(void 0,!0));if(this[l].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[c]?r(t[c]):e(p(void 0,!0))}))}));var r,n=this[f];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[u]?r(p(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var i=this[l].read();if(null!==i)return Promise.resolve(p(i,!1));r=new Promise(this[h])}return this[f]=r,r}},Symbol.asyncIterator,(function(){return this})),i(n,\"return\",(function(){var t=this;return new Promise((function(e,r){t[l].destroy(null,(function(t){t?r(t):e(p(void 0,!0))}))}))})),n),g);t.exports=function(t){var e,r=Object.create(b,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,c,{value:null,writable:!0}),i(e,u,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var n=r[l].read();n?(r[f]=null,r[s]=null,r[a]=null,t(p(n,!1))):(r[s]=t,r[a]=e)},writable:!0}),e));return r[f]=null,o(t,(function(t){if(t&&\"ERR_STREAM_PREMATURE_CLOSE\"!==t.code){var e=r[a];return null!==e&&(r[f]=null,r[s]=null,r[a]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[f]=null,r[s]=null,r[a]=null,n(p(void 0,!0))),r[u]=!0})),t.on(\"readable\",y.bind(null,r)),r}},82:(t,e,r)=>{\"use strict\";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:\"unshift\",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:\"shift\",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:\"clear\",value:function(){this.head=this.tail=null,this.length=0}},{key:\"join\",value:function(t){if(0===this.length)return\"\";for(var e=this.head,r=\"\"+e.data;e=e.next;)r+=t+e.data;return r}},{key:\"concat\",value:function(t){if(0===this.length)return c.alloc(0);for(var e,r,n,i=c.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,c.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:\"consume\",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:\"_getBuffer\",value:function(t){var e=c.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:f,value:function(t,e){return u(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&s(e.prototype,r),n&&s(e,n),Object.defineProperty(e,\"prototype\",{writable:!1}),t}()},6527:t=>{\"use strict\";function e(t,e){n(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit(\"close\")}function n(t,e){t.emit(\"error\",e)}t.exports={destroy:function(t,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?o._writableState?o._writableState.errorEmitted?process.nextTick(r,o):(o._writableState.errorEmitted=!0,process.nextTick(e,o,t)):process.nextTick(e,o,t):i?(process.nextTick(r,o),i(t)):process.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit(\"error\",e)}}},4869:(t,e,r)=>{\"use strict\";var n=r(5699).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if(\"function\"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i{t.exports=function(){throw new Error(\"Readable.from is not available in the browser\")}},6815:(t,e,r)=>{\"use strict\";var n;var i=r(5699).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function c(t){t()}function u(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){f||(f=t),t&&l.forEach(c),o||(l.forEach(c),h(f))}))}));return e.reduce(u)}},9952:(t,e,r)=>{\"use strict\";var n=r(5699).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:\"highWaterMark\",o);return Math.floor(o)}return t.objectMode?16:16384}}},4856:(t,e,r)=>{t.exports=r(46).EventEmitter},4156:(t,e,r)=>{(e=t.exports=r(8199)).Stream=e,e.Readable=e,e.Writable=r(5291),e.Duplex=r(1265),e.Transform=r(9415),e.PassThrough=r(4421),e.finished=r(4869),e.pipeline=r(6815)},5586:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer,i=r(5615),o=r(9467),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],c=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],l=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function y(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function w(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}i(p,o),p.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,v=0|this._a,E=0|this._b,_=0|this._c,S=0|this._d,A=0|this._e,I=0;I<80;I+=1){var T,x;I<16?(T=y(r,n,i,o,p,t[a[I]],h[0],u[I]),x=m(v,E,_,S,A,t[c[I]],l[0],f[I])):I<32?(T=g(r,n,i,o,p,t[a[I]],h[1],u[I]),x=w(v,E,_,S,A,t[c[I]],l[1],f[I])):I<48?(T=b(r,n,i,o,p,t[a[I]],h[2],u[I]),x=b(v,E,_,S,A,t[c[I]],l[2],f[I])):I<64?(T=w(r,n,i,o,p,t[a[I]],h[3],u[I]),x=g(v,E,_,S,A,t[c[I]],l[3],f[I])):(T=m(r,n,i,o,p,t[a[I]],h[4],u[I]),x=y(v,E,_,S,A,t[c[I]],l[4],f[I])),r=p,p=o,o=d(i,10),i=n,n=T,v=A,A=S,S=d(_,10),_=E,E=x}var O=this._b+i+S|0;this._b=this._c+o+A|0,this._c=this._d+p+v|0,this._d=this._e+r+E|0,this._e=this._a+n+_|0,this._a=O},p.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},5636:(t,e,r)=>{var n=r(1048),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if(\"number\"==typeof t)throw new TypeError(\"Argument must not be a number\");return i(t,e,r)},s.alloc=function(t,e,r){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");var n=i(t);return void 0!==e?\"string\"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return i(t)},s.allocUnsafeSlow=function(t){if(\"number\"!=typeof t)throw new TypeError(\"Argument must be a number\");return n.SlowBuffer(t)}},1565:(t,e,r)=>{const n=Symbol(\"SemVer ANY\");class i{static get ANY(){return n}constructor(t,e){if(e=o(e),t instanceof i){if(t.loose===!!e.loose)return t;t=t.value}t=t.trim().split(/\\s+/).join(\" \"),u(\"comparator\",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===n?this.value=\"\":this.value=this.operator+this.semver.version,u(\"comp\",this)}parse(t){const e=this.options.loose?s[a.COMPARATORLOOSE]:s[a.COMPARATOR],r=t.match(e);if(!r)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==r[1]?r[1]:\"\",\"=\"===this.operator&&(this.operator=\"\"),r[2]?this.semver=new f(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(t){if(u(\"Comparator.test\",t,this.options.loose),this.semver===n||t===n)return!0;if(\"string\"==typeof t)try{t=new f(t,this.options)}catch(t){return!1}return c(t,this.operator,this.semver,this.options)}intersects(t,e){if(!(t instanceof i))throw new TypeError(\"a Comparator is required\");return\"\"===this.operator?\"\"===this.value||new h(t.value,e).test(this.value):\"\"===t.operator?\"\"===t.value||new h(this.value,e).test(t.semver):(!(e=o(e)).includePrerelease||\"<0.0.0-0\"!==this.value&&\"<0.0.0-0\"!==t.value)&&(!(!e.includePrerelease&&(this.value.startsWith(\"<0.0.0\")||t.value.startsWith(\"<0.0.0\")))&&(!(!this.operator.startsWith(\">\")||!t.operator.startsWith(\">\"))||(!(!this.operator.startsWith(\"<\")||!t.operator.startsWith(\"<\"))||(!(this.semver.version!==t.semver.version||!this.operator.includes(\"=\")||!t.operator.includes(\"=\"))||(!!(c(this.semver,\"<\",t.semver,e)&&this.operator.startsWith(\">\")&&t.operator.startsWith(\"<\"))||!!(c(this.semver,\">\",t.semver,e)&&this.operator.startsWith(\"<\")&&t.operator.startsWith(\">\")))))))}}t.exports=i;const o=r(3990),{safeRe:s,t:a}=r(2841),c=r(4004),u=r(1361),f=r(4517),h=r(7476)},7476:(t,e,r)=>{class n{constructor(t,e){if(e=o(e),t instanceof n)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new n(t.raw,e);if(t instanceof s)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t.trim().split(/\\s+/).join(\" \"),this.set=this.raw.split(\"||\").map((t=>this.parseRange(t.trim()))).filter((t=>t.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const t=this.set[0];if(this.set=this.set.filter((t=>!g(t[0]))),0===this.set.length)this.set=[t];else if(this.set.length>1)for(const t of this.set)if(1===t.length&&b(t[0])){this.set=[t];break}}this.format()}format(){return this.range=this.set.map((t=>t.join(\" \").trim())).join(\"||\").trim(),this.range}toString(){return this.range}parseRange(t){const e=((this.options.includePrerelease&&d)|(this.options.loose&&y))+\":\"+t,r=i.get(e);if(r)return r;const n=this.options.loose,o=n?u[f.HYPHENRANGELOOSE]:u[f.HYPHENRANGE];t=t.replace(o,k(this.options.includePrerelease)),a(\"hyphen replace\",t),t=t.replace(u[f.COMPARATORTRIM],h),a(\"comparator trim\",t),t=t.replace(u[f.TILDETRIM],l),a(\"tilde trim\",t),t=t.replace(u[f.CARETTRIM],p),a(\"caret trim\",t);let c=t.split(\" \").map((t=>m(t,this.options))).join(\" \").split(/\\s+/).map((t=>O(t,this.options)));n&&(c=c.filter((t=>(a(\"loose invalid filter\",t,this.options),!!t.match(u[f.COMPARATORLOOSE]))))),a(\"range list\",c);const b=new Map,w=c.map((t=>new s(t,this.options)));for(const t of w){if(g(t))return[t];b.set(t.value,t)}b.size>1&&b.has(\"\")&&b.delete(\"\");const v=[...b.values()];return i.set(e,v),v}intersects(t,e){if(!(t instanceof n))throw new TypeError(\"a Range is required\");return this.set.some((r=>w(r,e)&&t.set.some((t=>w(t,e)&&r.every((r=>t.every((t=>r.intersects(t,e)))))))))}test(t){if(!t)return!1;if(\"string\"==typeof t)try{t=new c(t,this.options)}catch(t){return!1}for(let e=0;e\"<0.0.0-0\"===t.value,b=t=>\"\"===t.value,w=(t,e)=>{let r=!0;const n=t.slice();let i=n.pop();for(;r&&n.length;)r=n.every((t=>i.intersects(t,e))),i=n.pop();return r},m=(t,e)=>(a(\"comp\",t,e),t=S(t,e),a(\"caret\",t),t=E(t,e),a(\"tildes\",t),t=I(t,e),a(\"xrange\",t),t=x(t,e),a(\"stars\",t),t),v=t=>!t||\"x\"===t.toLowerCase()||\"*\"===t,E=(t,e)=>t.trim().split(/\\s+/).map((t=>_(t,e))).join(\" \"),_=(t,e)=>{const r=e.loose?u[f.TILDELOOSE]:u[f.TILDE];return t.replace(r,((e,r,n,i,o)=>{let s;return a(\"tilde\",t,e,r,n,i,o),v(r)?s=\"\":v(n)?s=`>=${r}.0.0 <${+r+1}.0.0-0`:v(i)?s=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:o?(a(\"replaceTilde pr\",o),s=`>=${r}.${n}.${i}-${o} <${r}.${+n+1}.0-0`):s=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,a(\"tilde return\",s),s}))},S=(t,e)=>t.trim().split(/\\s+/).map((t=>A(t,e))).join(\" \"),A=(t,e)=>{a(\"caret\",t,e);const r=e.loose?u[f.CARETLOOSE]:u[f.CARET],n=e.includePrerelease?\"-0\":\"\";return t.replace(r,((e,r,i,o,s)=>{let c;return a(\"caret\",t,e,r,i,o,s),v(r)?c=\"\":v(i)?c=`>=${r}.0.0${n} <${+r+1}.0.0-0`:v(o)?c=\"0\"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:s?(a(\"replaceCaret pr\",s),c=\"0\"===r?\"0\"===i?`>=${r}.${i}.${o}-${s} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}-${s} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o}-${s} <${+r+1}.0.0-0`):(a(\"no pr\"),c=\"0\"===r?\"0\"===i?`>=${r}.${i}.${o}${n} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o} <${+r+1}.0.0-0`),a(\"caret return\",c),c}))},I=(t,e)=>(a(\"replaceXRanges\",t,e),t.split(/\\s+/).map((t=>T(t,e))).join(\" \")),T=(t,e)=>{t=t.trim();const r=e.loose?u[f.XRANGELOOSE]:u[f.XRANGE];return t.replace(r,((r,n,i,o,s,c)=>{a(\"xRange\",t,r,n,i,o,s,c);const u=v(i),f=u||v(o),h=f||v(s),l=h;return\"=\"===n&&l&&(n=\"\"),c=e.includePrerelease?\"-0\":\"\",u?r=\">\"===n||\"<\"===n?\"<0.0.0-0\":\"*\":n&&l?(f&&(o=0),s=0,\">\"===n?(n=\">=\",f?(i=+i+1,o=0,s=0):(o=+o+1,s=0)):\"<=\"===n&&(n=\"<\",f?i=+i+1:o=+o+1),\"<\"===n&&(c=\"-0\"),r=`${n+i}.${o}.${s}${c}`):f?r=`>=${i}.0.0${c} <${+i+1}.0.0-0`:h&&(r=`>=${i}.${o}.0${c} <${i}.${+o+1}.0-0`),a(\"xRange return\",r),r}))},x=(t,e)=>(a(\"replaceStars\",t,e),t.trim().replace(u[f.STAR],\"\")),O=(t,e)=>(a(\"replaceGTE0\",t,e),t.trim().replace(u[e.includePrerelease?f.GTE0PRE:f.GTE0],\"\")),k=t=>(e,r,n,i,o,s,a,c,u,f,h,l,p)=>`${r=v(n)?\"\":v(i)?`>=${n}.0.0${t?\"-0\":\"\"}`:v(o)?`>=${n}.${i}.0${t?\"-0\":\"\"}`:s?`>=${r}`:`>=${r}${t?\"-0\":\"\"}`} ${c=v(u)?\"\":v(f)?`<${+u+1}.0.0-0`:v(h)?`<${u}.${+f+1}.0-0`:l?`<=${u}.${f}.${h}-${l}`:t?`<${u}.${f}.${+h+1}-0`:`<=${c}`}`.trim(),P=(t,e,r)=>{for(let r=0;r0){const n=t[r].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}},4517:(t,e,r)=>{const n=r(1361),{MAX_LENGTH:i,MAX_SAFE_INTEGER:o}=r(9543),{safeRe:s,t:a}=r(2841),c=r(3990),{compareIdentifiers:u}=r(3806);class f{constructor(t,e){if(e=c(e),t instanceof f){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version}else if(\"string\"!=typeof t)throw new TypeError(`Invalid version. Must be a string. Got type \"${typeof t}\".`);if(t.length>i)throw new TypeError(`version is longer than ${i} characters`);n(\"SemVer\",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;const r=t.trim().match(e.loose?s[a.LOOSE]:s[a.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>o||this.major<0)throw new TypeError(\"Invalid major version\");if(this.minor>o||this.minor<0)throw new TypeError(\"Invalid minor version\");if(this.patch>o||this.patch<0)throw new TypeError(\"Invalid patch version\");r[4]?this.prerelease=r[4].split(\".\").map((t=>{if(/^[0-9]+$/.test(t)){const e=+t;if(e>=0&&e=0;)\"number\"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(e===this.prerelease.join(\".\")&&!1===r)throw new Error(\"invalid increment argument: identifier already exists\");this.prerelease.push(t)}}if(e){let n=[e,t];!1===r&&(n=[e]),0===u(this.prerelease[0],e)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(\".\")}`),this}}t.exports=f},2281:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t.trim().replace(/^[=v]+/,\"\"),e);return r?r.version:null}},4004:(t,e,r)=>{const n=r(8848),i=r(8220),o=r(9761),s=r(2386),a=r(1262),c=r(9639);t.exports=(t,e,r,u)=>{switch(e){case\"===\":return\"object\"==typeof t&&(t=t.version),\"object\"==typeof r&&(r=r.version),t===r;case\"!==\":return\"object\"==typeof t&&(t=t.version),\"object\"==typeof r&&(r=r.version),t!==r;case\"\":case\"=\":case\"==\":return n(t,r,u);case\"!=\":return i(t,r,u);case\">\":return o(t,r,u);case\">=\":return s(t,r,u);case\"<\":return a(t,r,u);case\"<=\":return c(t,r,u);default:throw new TypeError(`Invalid operator: ${e}`)}}},6783:(t,e,r)=>{const n=r(4517),i=r(3955),{safeRe:o,t:s}=r(2841);t.exports=(t,e)=>{if(t instanceof n)return t;if(\"number\"==typeof t&&(t=String(t)),\"string\"!=typeof t)return null;let r=null;if((e=e||{}).rtl){const n=e.includePrerelease?o[s.COERCERTLFULL]:o[s.COERCERTL];let i;for(;(i=n.exec(t))&&(!r||r.index+r[0].length!==t.length);)r&&i.index+i[0].length===r.index+r[0].length||(r=i),n.lastIndex=i.index+i[1].length+i[2].length;n.lastIndex=-1}else r=t.match(e.includePrerelease?o[s.COERCEFULL]:o[s.COERCE]);if(null===r)return null;const a=r[2],c=r[3]||\"0\",u=r[4]||\"0\",f=e.includePrerelease&&r[5]?`-${r[5]}`:\"\",h=e.includePrerelease&&r[6]?`+${r[6]}`:\"\";return i(`${a}.${c}.${u}${f}${h}`,e)}},6106:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r)=>{const i=new n(t,r),o=new n(e,r);return i.compare(o)||i.compareBuild(o)}},2132:(t,e,r)=>{const n=r(7851);t.exports=(t,e)=>n(t,e,!0)},7851:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r)=>new n(t,r).compare(new n(e,r))},3269:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,null,!0),i=n(e,null,!0),o=r.compare(i);if(0===o)return null;const s=o>0,a=s?r:i,c=s?i:r,u=!!a.prerelease.length;if(!!c.prerelease.length&&!u)return c.patch||c.minor?a.patch?\"patch\":a.minor?\"minor\":\"major\":\"major\";const f=u?\"pre\":\"\";return r.major!==i.major?f+\"major\":r.minor!==i.minor?f+\"minor\":r.patch!==i.patch?f+\"patch\":\"prerelease\"}},8848:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>0===n(t,e,r)},9761:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)>0},2386:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)>=0},8868:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r,i,o)=>{\"string\"==typeof r&&(o=i,i=r,r=void 0);try{return new n(t instanceof n?t.version:t,r).inc(e,i,o).version}catch(t){return null}}},1262:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)<0},9639:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(t,e,r)<=0},6381:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).major},1353:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).minor},8220:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>0!==n(t,e,r)},3955:(t,e,r)=>{const n=r(4517);t.exports=(t,e,r=!1)=>{if(t instanceof n)return t;try{return new n(t,e)}catch(t){if(!r)return null;throw t}}},6082:(t,e,r)=>{const n=r(4517);t.exports=(t,e)=>new n(t,e).patch},9428:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,e);return r&&r.prerelease.length?r.prerelease:null}},7555:(t,e,r)=>{const n=r(7851);t.exports=(t,e,r)=>n(e,t,r)},3810:(t,e,r)=>{const n=r(6106);t.exports=(t,e)=>t.sort(((t,r)=>n(r,t,e)))},7229:(t,e,r)=>{const n=r(7476);t.exports=(t,e,r)=>{try{e=new n(e,r)}catch(t){return!1}return e.test(t)}},4042:(t,e,r)=>{const n=r(6106);t.exports=(t,e)=>t.sort(((t,r)=>n(t,r,e)))},8474:(t,e,r)=>{const n=r(3955);t.exports=(t,e)=>{const r=n(t,e);return r?r.version:null}},2722:(t,e,r)=>{const n=r(2841),i=r(9543),o=r(4517),s=r(3806),a=r(3955),c=r(8474),u=r(2281),f=r(8868),h=r(3269),l=r(6381),p=r(1353),d=r(6082),y=r(9428),g=r(7851),b=r(7555),w=r(2132),m=r(6106),v=r(4042),E=r(3810),_=r(9761),S=r(1262),A=r(8848),I=r(8220),T=r(2386),x=r(9639),O=r(4004),k=r(6783),P=r(1565),R=r(7476),B=r(7229),C=r(6364),N=r(5039),L=r(5357),U=r(1280),j=r(7403),M=r(8854),H=r(7226),F=r(7183),D=r(8623),$=r(6486),K=r(583);t.exports={parse:a,valid:c,clean:u,inc:f,diff:h,major:l,minor:p,patch:d,prerelease:y,compare:g,rcompare:b,compareLoose:w,compareBuild:m,sort:v,rsort:E,gt:_,lt:S,eq:A,neq:I,gte:T,lte:x,cmp:O,coerce:k,Comparator:P,Range:R,satisfies:B,toComparators:C,maxSatisfying:N,minSatisfying:L,minVersion:U,validRange:j,outside:M,gtr:H,ltr:F,intersects:D,simplifyRange:$,subset:K,SemVer:o,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers}},9543:t=>{const e=Number.MAX_SAFE_INTEGER||9007199254740991;t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:[\"major\",\"premajor\",\"minor\",\"preminor\",\"patch\",\"prepatch\",\"prerelease\"],SEMVER_SPEC_VERSION:\"2.0.0\",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},1361:t=>{const e=\"object\"==typeof process&&process.env&&/\\bsemver\\b/i.test(\"false\")?(...t)=>console.error(\"SEMVER\",...t):()=>{};t.exports=e},3806:t=>{const e=/^[0-9]+$/,r=(t,r)=>{const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:tr(e,t)}},3990:t=>{const e=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=t=>t?\"object\"!=typeof t?e:t:r},2841:(t,e,r)=>{const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:o}=r(9543),s=r(1361),a=(e=t.exports={}).re=[],c=e.safeRe=[],u=e.src=[],f=e.t={};let h=0;const l=\"[a-zA-Z0-9-]\",p=[[\"\\\\s\",1],[\"\\\\d\",o],[l,i]],d=(t,e,r)=>{const n=(t=>{for(const[e,r]of p)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t})(e),i=h++;s(t,i,e),f[t]=i,u[i]=e,a[i]=new RegExp(e,r?\"g\":void 0),c[i]=new RegExp(n,r?\"g\":void 0)};d(\"NUMERICIDENTIFIER\",\"0|[1-9]\\\\d*\"),d(\"NUMERICIDENTIFIERLOOSE\",\"\\\\d+\"),d(\"NONNUMERICIDENTIFIER\",`\\\\d*[a-zA-Z-]${l}*`),d(\"MAINVERSION\",`(${u[f.NUMERICIDENTIFIER]})\\\\.(${u[f.NUMERICIDENTIFIER]})\\\\.(${u[f.NUMERICIDENTIFIER]})`),d(\"MAINVERSIONLOOSE\",`(${u[f.NUMERICIDENTIFIERLOOSE]})\\\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),d(\"PRERELEASEIDENTIFIER\",`(?:${u[f.NUMERICIDENTIFIER]}|${u[f.NONNUMERICIDENTIFIER]})`),d(\"PRERELEASEIDENTIFIERLOOSE\",`(?:${u[f.NUMERICIDENTIFIERLOOSE]}|${u[f.NONNUMERICIDENTIFIER]})`),d(\"PRERELEASE\",`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\\\.${u[f.PRERELEASEIDENTIFIER]})*))`),d(\"PRERELEASELOOSE\",`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),d(\"BUILDIDENTIFIER\",`${l}+`),d(\"BUILD\",`(?:\\\\+(${u[f.BUILDIDENTIFIER]}(?:\\\\.${u[f.BUILDIDENTIFIER]})*))`),d(\"FULLPLAIN\",`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),d(\"FULL\",`^${u[f.FULLPLAIN]}$`),d(\"LOOSEPLAIN\",`[v=\\\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),d(\"LOOSE\",`^${u[f.LOOSEPLAIN]}$`),d(\"GTLT\",\"((?:<|>)?=?)\"),d(\"XRANGEIDENTIFIERLOOSE\",`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\\\*`),d(\"XRANGEIDENTIFIER\",`${u[f.NUMERICIDENTIFIER]}|x|X|\\\\*`),d(\"XRANGEPLAIN\",`[v=\\\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\\\.(${u[f.XRANGEIDENTIFIER]})(?:\\\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),d(\"XRANGEPLAINLOOSE\",`[v=\\\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),d(\"XRANGE\",`^${u[f.GTLT]}\\\\s*${u[f.XRANGEPLAIN]}$`),d(\"XRANGELOOSE\",`^${u[f.GTLT]}\\\\s*${u[f.XRANGEPLAINLOOSE]}$`),d(\"COERCEPLAIN\",`(^|[^\\\\d])(\\\\d{1,${n}})(?:\\\\.(\\\\d{1,${n}}))?(?:\\\\.(\\\\d{1,${n}}))?`),d(\"COERCE\",`${u[f.COERCEPLAIN]}(?:$|[^\\\\d])`),d(\"COERCEFULL\",u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?`+`(?:${u[f.BUILD]})?(?:$|[^\\\\d])`),d(\"COERCERTL\",u[f.COERCE],!0),d(\"COERCERTLFULL\",u[f.COERCEFULL],!0),d(\"LONETILDE\",\"(?:~>?)\"),d(\"TILDETRIM\",`(\\\\s*)${u[f.LONETILDE]}\\\\s+`,!0),e.tildeTrimReplace=\"$1~\",d(\"TILDE\",`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),d(\"TILDELOOSE\",`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),d(\"LONECARET\",\"(?:\\\\^)\"),d(\"CARETTRIM\",`(\\\\s*)${u[f.LONECARET]}\\\\s+`,!0),e.caretTrimReplace=\"$1^\",d(\"CARET\",`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),d(\"CARETLOOSE\",`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),d(\"COMPARATORLOOSE\",`^${u[f.GTLT]}\\\\s*(${u[f.LOOSEPLAIN]})$|^$`),d(\"COMPARATOR\",`^${u[f.GTLT]}\\\\s*(${u[f.FULLPLAIN]})$|^$`),d(\"COMPARATORTRIM\",`(\\\\s*)${u[f.GTLT]}\\\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=\"$1$2$3\",d(\"HYPHENRANGE\",`^\\\\s*(${u[f.XRANGEPLAIN]})\\\\s+-\\\\s+(${u[f.XRANGEPLAIN]})\\\\s*$`),d(\"HYPHENRANGELOOSE\",`^\\\\s*(${u[f.XRANGEPLAINLOOSE]})\\\\s+-\\\\s+(${u[f.XRANGEPLAINLOOSE]})\\\\s*$`),d(\"STAR\",\"(<|>)?=?\\\\s*\\\\*\"),d(\"GTE0\",\"^\\\\s*>=\\\\s*0\\\\.0\\\\.0\\\\s*$\"),d(\"GTE0PRE\",\"^\\\\s*>=\\\\s*0\\\\.0\\\\.0-0\\\\s*$\")},7226:(t,e,r)=>{const n=r(8854);t.exports=(t,e,r)=>n(t,e,\">\",r)},8623:(t,e,r)=>{const n=r(7476);t.exports=(t,e,r)=>(t=new n(t,r),e=new n(e,r),t.intersects(e,r))},7183:(t,e,r)=>{const n=r(8854);t.exports=(t,e,r)=>n(t,e,\"<\",r)},5039:(t,e,r)=>{const n=r(4517),i=r(7476);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new i(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&-1!==s.compare(t)||(o=t,s=new n(o,r)))})),o}},5357:(t,e,r)=>{const n=r(4517),i=r(7476);t.exports=(t,e,r)=>{let o=null,s=null,a=null;try{a=new i(e,r)}catch(t){return null}return t.forEach((t=>{a.test(t)&&(o&&1!==s.compare(t)||(o=t,s=new n(o,r)))})),o}},1280:(t,e,r)=>{const n=r(4517),i=r(7476),o=r(9761);t.exports=(t,e)=>{t=new i(t,e);let r=new n(\"0.0.0\");if(t.test(r))return r;if(r=new n(\"0.0.0-0\"),t.test(r))return r;r=null;for(let e=0;e{const e=new n(t.semver.version);switch(t.operator){case\">\":0===e.prerelease.length?e.patch++:e.prerelease.push(0),e.raw=e.format();case\"\":case\">=\":s&&!o(e,s)||(s=e);break;case\"<\":case\"<=\":break;default:throw new Error(`Unexpected operation: ${t.operator}`)}})),!s||r&&!o(r,s)||(r=s)}return r&&t.test(r)?r:null}},8854:(t,e,r)=>{const n=r(4517),i=r(1565),{ANY:o}=i,s=r(7476),a=r(7229),c=r(9761),u=r(1262),f=r(9639),h=r(2386);t.exports=(t,e,r,l)=>{let p,d,y,g,b;switch(t=new n(t,l),e=new s(e,l),r){case\">\":p=c,d=f,y=u,g=\">\",b=\">=\";break;case\"<\":p=u,d=h,y=c,g=\"<\",b=\"<=\";break;default:throw new TypeError('Must provide a hilo val of \"<\" or \">\"')}if(a(t,e,l))return!1;for(let r=0;r{t.semver===o&&(t=new i(\">=0.0.0\")),s=s||t,a=a||t,p(t.semver,s.semver,l)?s=t:y(t.semver,a.semver,l)&&(a=t)})),s.operator===g||s.operator===b)return!1;if((!a.operator||a.operator===g)&&d(t,a.semver))return!1;if(a.operator===b&&y(t,a.semver))return!1}return!0}},6486:(t,e,r)=>{const n=r(7229),i=r(7851);t.exports=(t,e,r)=>{const o=[];let s=null,a=null;const c=t.sort(((t,e)=>i(t,e,r)));for(const t of c){n(t,e,r)?(a=t,s||(s=t)):(a&&o.push([s,a]),a=null,s=null)}s&&o.push([s,null]);const u=[];for(const[t,e]of o)t===e?u.push(t):e||t!==c[0]?e?t===c[0]?u.push(`<=${e}`):u.push(`${t} - ${e}`):u.push(`>=${t}`):u.push(\"*\");const f=u.join(\" || \"),h=\"string\"==typeof e.raw?e.raw:String(e);return f.length{const n=r(7476),i=r(1565),{ANY:o}=i,s=r(7229),a=r(7851),c=[new i(\">=0.0.0-0\")],u=[new i(\">=0.0.0\")],f=(t,e,r)=>{if(t===e)return!0;if(1===t.length&&t[0].semver===o){if(1===e.length&&e[0].semver===o)return!0;t=r.includePrerelease?c:u}if(1===e.length&&e[0].semver===o){if(r.includePrerelease)return!0;e=u}const n=new Set;let i,f,p,d,y,g,b;for(const e of t)\">\"===e.operator||\">=\"===e.operator?i=h(i,e,r):\"<\"===e.operator||\"<=\"===e.operator?f=l(f,e,r):n.add(e.semver);if(n.size>1)return null;if(i&&f){if(p=a(i.semver,f.semver,r),p>0)return null;if(0===p&&(\">=\"!==i.operator||\"<=\"!==f.operator))return null}for(const t of n){if(i&&!s(t,String(i),r))return null;if(f&&!s(t,String(f),r))return null;for(const n of e)if(!s(t,String(n),r))return!1;return!0}let w=!(!f||r.includePrerelease||!f.semver.prerelease.length)&&f.semver,m=!(!i||r.includePrerelease||!i.semver.prerelease.length)&&i.semver;w&&1===w.prerelease.length&&\"<\"===f.operator&&0===w.prerelease[0]&&(w=!1);for(const t of e){if(b=b||\">\"===t.operator||\">=\"===t.operator,g=g||\"<\"===t.operator||\"<=\"===t.operator,i)if(m&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===m.major&&t.semver.minor===m.minor&&t.semver.patch===m.patch&&(m=!1),\">\"===t.operator||\">=\"===t.operator){if(d=h(i,t,r),d===t&&d!==i)return!1}else if(\">=\"===i.operator&&!s(i.semver,String(t),r))return!1;if(f)if(w&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===w.major&&t.semver.minor===w.minor&&t.semver.patch===w.patch&&(w=!1),\"<\"===t.operator||\"<=\"===t.operator){if(y=l(f,t,r),y===t&&y!==f)return!1}else if(\"<=\"===f.operator&&!s(f.semver,String(t),r))return!1;if(!t.operator&&(f||i)&&0!==p)return!1}return!(i&&g&&!f&&0!==p)&&(!(f&&b&&!i&&0!==p)&&(!m&&!w))},h=(t,e,r)=>{if(!t)return e;const n=a(t.semver,e.semver,r);return n>0?t:n<0||\">\"===e.operator&&\">=\"===t.operator?e:t},l=(t,e,r)=>{if(!t)return e;const n=a(t.semver,e.semver,r);return n<0?t:n>0||\"<\"===e.operator&&\"<=\"===t.operator?e:t};t.exports=(t,e,r={})=>{if(t===e)return!0;t=new n(t,r),e=new n(e,r);let i=!1;t:for(const n of t.set){for(const t of e.set){const e=f(n,t,r);if(i=i||null!==e,e)continue t}if(i)return!1}return!0}},6364:(t,e,r)=>{const n=r(7476);t.exports=(t,e)=>new n(t,e).set.map((t=>t.map((t=>t.value)).join(\" \").trim().split(\" \")))},7403:(t,e,r)=>{const n=r(7476);t.exports=(t,e)=>{try{return new n(t,e).range||\"*\"}catch(t){return null}}},1229:(t,e,r)=>{var n=r(5636).Buffer;function i(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){\"string\"==typeof t&&(e=e||\"utf8\",t=n.from(t,e));for(var r=this._block,i=this._blockSize,o=t.length,s=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error(\"_update must be implemented by subclass\")},t.exports=i},3229:(t,e,r)=>{var n=t.exports=function(t){t=t.toLowerCase();var e=n[t];if(!e)throw new Error(t+\" is not supported (we accept pull requests)\");return new e};n.sha=r(3675),n.sha1=r(8980),n.sha224=r(947),n.sha256=r(2826),n.sha384=r(9922),n.sha512=r(6080)},3675:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var p=~~(l/20),d=0|((e=n)<<5|e>>>27)+f(p,i,o,a)+c+r[l]+s[p];c=a,a=o,o=u(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=c},8980:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function f(t){return t<<30|t>>>2}function h(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(c,i),c.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var p=0;p<80;++p){var d=~~(p/20),y=u(n)+h(d,i,o,a)+c+r[p]+s[d]|0;c=a,a=o,o=f(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0},c.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=c},947:(t,e,r)=>{var n=r(5615),i=r(2826),o=r(1229),s=r(5636).Buffer,a=new Array(64);function c(){this.init(),this._w=a,o.call(this,64,56)}n(c,i),c.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},c.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=c},2826:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=new Array(64);function c(){this.init(),this._w=a,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function h(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function l(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(c,i),c.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},c.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,c=0|this._e,d=0|this._f,y=0|this._g,g=0|this._h,b=0;b<16;++b)r[b]=t.readInt32BE(4*b);for(;b<64;++b)r[b]=0|(((e=r[b-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[b-7]+p(r[b-15])+r[b-16];for(var w=0;w<64;++w){var m=g+l(c)+u(c,d,y)+s[w]+r[w]|0,v=h(n)+f(n,i,o)|0;g=y,y=d,d=c,c=a+m|0,a=o,o=i,i=n,n=m+v|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=c+this._e|0,this._f=d+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},c.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=c},9922:(t,e,r)=>{var n=r(5615),i=r(6080),o=r(1229),s=r(5636).Buffer,a=new Array(160);function c(){this.init(),this._w=a,o.call(this,128,112)}n(c,i),c.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},c.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=c},6080:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function c(){this.init(),this._w=a,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function h(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function l(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0>>0?1:0}n(c,i),c.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},c.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,c=0|this._fh,w=0|this._gh,m=0|this._hh,v=0|this._al,E=0|this._bl,_=0|this._cl,S=0|this._dl,A=0|this._el,I=0|this._fl,T=0|this._gl,x=0|this._hl,O=0;O<32;O+=2)e[O]=t.readInt32BE(4*O),e[O+1]=t.readInt32BE(4*O+4);for(;O<160;O+=2){var k=e[O-30],P=e[O-30+1],R=p(k,P),B=d(P,k),C=y(k=e[O-4],P=e[O-4+1]),N=g(P,k),L=e[O-14],U=e[O-14+1],j=e[O-32],M=e[O-32+1],H=B+U|0,F=R+L+b(H,B)|0;F=(F=F+C+b(H=H+N|0,N)|0)+j+b(H=H+M|0,M)|0,e[O]=F,e[O+1]=H}for(var D=0;D<160;D+=2){F=e[D],H=e[D+1];var $=f(r,n,i),K=f(v,E,_),V=h(r,v),G=h(v,r),q=l(a,A),W=l(A,a),X=s[D],z=s[D+1],J=u(a,c,w),Y=u(A,I,T),Z=x+W|0,Q=m+q+b(Z,x)|0;Q=(Q=(Q=Q+J+b(Z=Z+Y|0,Y)|0)+X+b(Z=Z+z|0,z)|0)+F+b(Z=Z+H|0,H)|0;var tt=G+K|0,et=V+$+b(tt,G)|0;m=w,x=T,w=c,T=I,c=a,I=A,a=o+Q+b(A=S+Z|0,S)|0,o=i,S=_,i=n,_=E,n=r,E=v,r=Q+et+b(v=Z+tt|0,Z)|0}this._al=this._al+v|0,this._bl=this._bl+E|0,this._cl=this._cl+_|0,this._dl=this._dl+S|0,this._el=this._el+A|0,this._fl=this._fl+I|0,this._gl=this._gl+T|0,this._hl=this._hl+x|0,this._ah=this._ah+r+b(this._al,v)|0,this._bh=this._bh+n+b(this._bl,E)|0,this._ch=this._ch+i+b(this._cl,_)|0,this._dh=this._dh+o+b(this._dl,S)|0,this._eh=this._eh+a+b(this._el,A)|0,this._fh=this._fh+c+b(this._fl,I)|0,this._gh=this._gh+w+b(this._gl,T)|0,this._hh=this._hh+m+b(this._hl,x)|0},c.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=c},1983:(t,e,r)=>{t.exports=i;var n=r(46).EventEmitter;function i(){n.call(this)}r(5615)(i,n),i.Readable=r(8199),i.Writable=r(5291),i.Duplex=r(1265),i.Transform=r(9415),i.PassThrough=r(4421),i.finished=r(4869),i.pipeline=r(6815),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on(\"data\",i),t.on(\"drain\",o),t._isStdio||e&&!1===e.end||(r.on(\"end\",a),r.on(\"close\",c));var s=!1;function a(){s||(s=!0,t.end())}function c(){s||(s=!0,\"function\"==typeof t.destroy&&t.destroy())}function u(t){if(f(),0===n.listenerCount(this,\"error\"))throw t}function f(){r.removeListener(\"data\",i),t.removeListener(\"drain\",o),r.removeListener(\"end\",a),r.removeListener(\"close\",c),r.removeListener(\"error\",u),t.removeListener(\"error\",u),r.removeListener(\"end\",f),r.removeListener(\"close\",f),t.removeListener(\"close\",f)}return r.on(\"error\",u),t.on(\"error\",u),r.on(\"end\",f),r.on(\"close\",f),t.on(\"close\",f),t.emit(\"pipe\",r),t}},8888:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=n.isEncoding||function(t){switch((t=\"\"+t)&&t.toLowerCase()){case\"hex\":case\"utf8\":case\"utf-8\":case\"ascii\":case\"binary\":case\"base64\":case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":case\"raw\":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return\"utf8\";for(var e;;)switch(t){case\"utf8\":case\"utf-8\":return\"utf8\";case\"ucs2\":case\"ucs-2\":case\"utf16le\":case\"utf-16le\":return\"utf16le\";case\"latin1\":case\"binary\":return\"latin1\";case\"base64\":case\"ascii\":case\"hex\":return t;default:if(e)return;t=(\"\"+t).toLowerCase(),e=!0}}(t);if(\"string\"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error(\"Unknown encoding: \"+t);return e||t}(t),this.encoding){case\"utf16le\":this.text=c,this.end=u,e=4;break;case\"utf8\":this.fillLast=a,e=4;break;case\"base64\":this.text=f,this.end=h,e=3;break;default:return this.write=l,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,\"�\";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,\"�\";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,\"�\"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function c(t,e){if((t.length-e)%2==0){var r=t.toString(\"utf16le\",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString(\"utf16le\",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):\"\";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString(\"utf16le\",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString(\"base64\",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString(\"base64\",e,t.length-r))}function h(t){var e=t&&t.length?this.write(t):\"\";return this.lastNeed?e+this.lastChar.toString(\"base64\",0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):\"\"}e.I=o,o.prototype.write=function(t){if(0===t.length)return\"\";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return\"\";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString(\"utf8\",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString(\"utf8\",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},8262:t=>{const e=/^[-+]?0x[a-fA-F0-9]+$/,r=/^([\\-\\+])?(0*)(\\.[0-9]+([eE]\\-?[0-9]+)?|[0-9]+(\\.[0-9]+([eE]\\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const n={hex:!0,leadingZeros:!0,decimalPoint:\".\",eNotation:!0};t.exports=function(t,i={}){if(i=Object.assign({},n,i),!t||\"string\"!=typeof t)return t;let o=t.trim();if(void 0!==i.skipLike&&i.skipLike.test(o))return t;if(i.hex&&e.test(o))return Number.parseInt(o,16);{const e=r.exec(o);if(e){const r=e[1],n=e[2];let s=function(t){if(t&&-1!==t.indexOf(\".\"))return\".\"===(t=t.replace(/0+$/,\"\"))?t=\"0\":\".\"===t[0]?t=\"0\"+t:\".\"===t[t.length-1]&&(t=t.substr(0,t.length-1)),t;return t}(e[3]);const a=e[4]||e[6];if(!i.leadingZeros&&n.length>0&&r&&\".\"!==o[2])return t;if(!i.leadingZeros&&n.length>0&&!r&&\".\"!==o[1])return t;{const e=Number(o),c=\"\"+e;return-1!==c.search(/[eE]/)||a?i.eNotation?e:t:-1!==o.indexOf(\".\")?\"0\"===c&&\"\"===s||c===s||r&&c===\"-\"+s?e:t:n?s===c||r+s===c?e:t:o===c||o===r+c?e:t}}return t}}},4322:(t,e,r)=>{var n=r(2890);function i(t){return t.name||t.toString().match(/function (.*?)\\s*\\(/)[1]}function o(t){return n.Nil(t)?\"\":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?\"Array\":t&&n.Object(t)?\"Object\":void 0!==t?t:\"\"}function c(t,e,r){var i=function(t){return n.Function(t)?\"\":n.String(t)?JSON.stringify(t):t&&n.Object(t)?\"\":t}(e);return\"Expected \"+a(t)+\", got\"+(\"\"!==r?\" \"+r:\"\")+(\"\"!==i?\" \"+i:\"\")}function u(t,e,r){r=r||o(e),this.message=c(t,e,r),s(this,u),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='\" of type ';return\"key\"===e&&(o='\" with key type '),c('property \"'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property \"'+e+'\"',s(this,u),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,f.prototype=Object.create(Error.prototype),f.prototype.constructor=u,t.exports={TfTypeError:u,TfPropertyTypeError:f,tfCustomError:function(t,e){return new u(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+\".\"+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof u&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},315:(t,e,r)=>{var n=r(1048).Buffer,i=r(2890),o=r(4322);function s(t){return n.isBuffer(t)}function a(t){return\"string\"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function c(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+\"(Length: \"+e+\")\",r+\"(Length: \"+n.length+\")\")}return n.toJSON=function(){return r},n}var u=c.bind(null,i.Array),f=c.bind(null,s),h=c.bind(null,a),l=c.bind(null,i.String);var p=Math.pow(2,53)-1;var d={ArrayN:u,Buffer:s,BufferN:f,Finite:function(t){return\"number\"==typeof t&&isFinite(t)},Hex:a,HexN:h,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return\"number\"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n>>0===t},UInt53:function(t){return\"number\"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},973:(t,e,r)=>{var n=r(4322),i=r(2890),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,u=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return l(t,e,n)}catch(t){throw c(t,r)}}))))))}return t=h(t),e=e||{},r.toJSON=function(){var r=\"[\"+o(t)+\"]\";return void 0!==e.length?r+=\"{\"+e.length+\"}\":void 0===e.minLength&&void 0===e.maxLength||(r+=\"{\"+(void 0===e.minLength?0:e.minLength)+\",\"+(void 0===e.maxLength?1/0:e.maxLength)+\"}\"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return\"?\"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw c(t,o,\"key\")}try{var s=r[o];l(t,s,n)}catch(t){throw c(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return\"{\"+o(e)+\": \"+o(t)+\"}\"}:function(){return\"{\"+o(t)+\"}\"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw c(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some((function(t){try{return l(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(\"|\")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every((function(t){try{return l(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(\" & \")},e},quacksLike:function(t){function e(e){return t===u(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every((function(t,n){try{return l(t,e[n],r)}catch(t){throw c(t,n)}}))))}return e.toJSON=function(){return\"(\"+t.map(o).join(\", \")+\")\"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return\"?\"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError(\"Expected compile() parameter of type Array of length 1\");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var p in f.oneOf=f.anyOf,i)l[p]=i[p];for(p in f)l[p]=f[p];var d=r(315);for(p in d)l[p]=d[p];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,t.exports=l},2890:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return\"boolean\"==typeof t},Function:function(t){return\"function\"==typeof t},Nil:function(t){return null==t},Number:function(t){return\"number\"==typeof t},Object:function(t){return\"object\"==typeof t},String:function(t){return\"string\"==typeof t},\"\":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},6732:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&\"true\"===String(e).toLowerCase()}t.exports=function(t,e){if(n(\"noDeprecation\"))return t;var r=!1;return function(){if(!r){if(n(\"throwDeprecation\"))throw new Error(e);n(\"traceDeprecation\")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},4596:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),Object.defineProperty(e,\"NIL\",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(e,\"parse\",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(e,\"stringify\",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(e,\"v1\",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,\"v3\",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,\"v4\",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,\"v5\",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,\"validate\",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,\"version\",{enumerable:!0,get:function(){return c.default}});var n=l(r(4603)),i=l(r(9917)),o=l(r(2712)),s=l(r(3423)),a=l(r(5911)),c=l(r(4072)),u=l(r(4564)),f=l(r(6585)),h=l(r(9975));function l(t){return t&&t.__esModule?t:{default:t}}},2668:(t,e)=>{\"use strict\";function r(t){return 14+(t+64>>>9<<4)+1}function n(t,e){const r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function i(t,e,r,i,o,s){return n((a=n(n(e,t),n(i,s)))<<(c=o)|a>>>32-c,r);var a,c}function o(t,e,r,n,o,s,a){return i(e&r|~e&n,t,e,o,s,a)}function s(t,e,r,n,o,s,a){return i(e&n|r&~n,t,e,o,s,a)}function a(t,e,r,n,o,s,a){return i(e^r^n,t,e,o,s,a)}function c(t,e,r,n,o,s,a){return i(r^(e|~n),t,e,o,s,a)}Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var u=function(t){if(\"string\"==typeof t){const e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(let r=0;r>5]>>>i%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(15&r),16);e.push(o)}return e}(function(t,e){t[e>>5]|=128<>5]|=(255&t[r/8])<{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var r={randomUUID:\"undefined\"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};e.default=r},5911:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;e.default=\"00000000-0000-0000-0000-000000000000\"},9975:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};var o=function(t){if(!(0,i.default)(t))throw TypeError(\"Invalid UUID\");let e;const r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=255&e,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=255&e,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=255&e,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=255&e,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=255&e,r};e.default=o},6635:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;e.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i},4089:(t,e)=>{\"use strict\";let r;Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=function(){if(!r&&(r=\"undefined\"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!r))throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");return r(n)};const n=new Uint8Array(16)},4271:(t,e)=>{\"use strict\";function r(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function n(t,e){return t<>>32-e}Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var i=function(t){const e=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520];if(\"string\"==typeof t){const e=unescape(encodeURIComponent(t));t=[];for(let r=0;r>>0;h=f,f=u,u=n(c,30)>>>0,c=s,s=a}i[0]=i[0]+s>>>0,i[1]=i[1]+c>>>0,i[2]=i[2]+u>>>0,i[3]=i[3]+f>>>0,i[4]=i[4]+h>>>0}return[i[0]>>24&255,i[0]>>16&255,i[0]>>8&255,255&i[0],i[1]>>24&255,i[1]>>16&255,i[1]>>8&255,255&i[1],i[2]>>24&255,i[2]>>16&255,i[2]>>8&255,255&i[2],i[3]>>24&255,i[3]>>16&255,i[3]>>8&255,255&i[3],i[4]>>24&255,i[4]>>16&255,i[4]>>8&255,255&i[4]]};e.default=i},6585:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0,e.unsafeStringify=s;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};const o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));function s(t,e=0){return o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+\"-\"+o[t[e+4]]+o[t[e+5]]+\"-\"+o[t[e+6]]+o[t[e+7]]+\"-\"+o[t[e+8]]+o[t[e+9]]+\"-\"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]}var a=function(t,e=0){const r=s(t,e);if(!(0,i.default)(r))throw TypeError(\"Stringified UUID is invalid\");return r};e.default=a},4603:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4089))&&n.__esModule?n:{default:n},o=r(6585);let s,a,c=0,u=0;var f=function(t,e,r){let n=e&&r||0;const f=e||new Array(16);let h=(t=t||{}).node||s,l=void 0!==t.clockseq?t.clockseq:a;if(null==h||null==l){const e=t.random||(t.rng||i.default)();null==h&&(h=s=[1|e[0],e[1],e[2],e[3],e[4],e[5]]),null==l&&(l=a=16383&(e[6]<<8|e[7]))}let p=void 0!==t.msecs?t.msecs:Date.now(),d=void 0!==t.nsecs?t.nsecs:u+1;const y=p-c+(d-u)/1e4;if(y<0&&void 0===t.clockseq&&(l=l+1&16383),(y<0||p>c)&&void 0===t.nsecs&&(d=0),d>=1e4)throw new Error(\"uuid.v1(): Can't create more than 10M uuids/sec\");c=p,u=d,a=l,p+=122192928e5;const g=(1e4*(268435455&p)+d)%4294967296;f[n++]=g>>>24&255,f[n++]=g>>>16&255,f[n++]=g>>>8&255,f[n++]=255&g;const b=p/4294967296*1e4&268435455;f[n++]=b>>>8&255,f[n++]=255&b,f[n++]=b>>>24&15|16,f[n++]=b>>>16&255,f[n++]=l>>>8|128,f[n++]=255&l;for(let t=0;t<6;++t)f[n+t]=h[t];return e||(0,o.unsafeStringify)(f)};e.default=f},9917:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=o(r(4782)),i=o(r(2668));function o(t){return t&&t.__esModule?t:{default:t}}var s=(0,n.default)(\"v3\",48,i.default);e.default=s},4782:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.URL=e.DNS=void 0,e.default=function(t,e,r){function n(t,n,s,a){var c;if(\"string\"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));const e=[];for(let r=0;r{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=s(r(193)),i=s(r(4089)),o=r(6585);function s(t){return t&&t.__esModule?t:{default:t}}var a=function(t,e,r){if(n.default.randomUUID&&!e&&!t)return n.default.randomUUID();const s=(t=t||{}).random||(t.rng||i.default)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e){r=r||0;for(let t=0;t<16;++t)e[r+t]=s[t];return e}return(0,o.unsafeStringify)(s)};e.default=a},3423:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n=o(r(4782)),i=o(r(4271));function o(t){return t&&t.__esModule?t:{default:t}}var s=(0,n.default)(\"v5\",80,i.default);e.default=s},4564:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(6635))&&n.__esModule?n:{default:n};var o=function(t){return\"string\"==typeof t&&i.default.test(t)};e.default=o},4072:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.default=void 0;var n,i=(n=r(4564))&&n.__esModule?n:{default:n};var o=function(t){if(!(0,i.default)(t))throw TypeError(\"Invalid UUID\");return parseInt(t.slice(14,15),16)};e.default=o},7820:(t,e,r)=>{\"use strict\";var n=r(5636).Buffer,i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError(\"value out of range\")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError(\"buffer must be a Buffer instance\");return i||(i=0),e<253?(r.writeUInt8(e,i),t.bytes=1):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),t.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),t.bytes=9),r},decode:function t(e,r){if(!n.isBuffer(e))throw new TypeError(\"buffer must be a Buffer instance\");r||(r=0);var i=e.readUInt8(r);if(i<253)return t.bytes=1,i;if(253===i)return t.bytes=3,e.readUInt16LE(r+1);if(254===i)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var s=e.readUInt32LE(r+1),a=4294967296*e.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},6952:(t,e,r)=>{var n=r(1048).Buffer,i=r(9848);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error(\"Invalid network version\");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error(\"Invalid WIF length\");if(1!==t[33])throw new Error(\"Invalid compression flag\");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function s(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return\"number\"==typeof t?i.encode(s(t,e,r)):i.encode(s(t.version,t.privateKey,t.compressed))},encodeRaw:s}},7047:t=>{\"use strict\";t.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},222:(t,e,r)=>{\"use strict\";function n(t){var e=this;if(e instanceof n||(e=new n),e.tail=null,e.head=null,e.length=0,t&&\"function\"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,i=arguments.length;r1)r=e;else{if(!this.head)throw new TypeError(\"Reduce of empty list with no initial value\");n=this.head.next,r=this.head.value}for(var i=0;null!==n;i++)r=t(r,n.value,i),n=n.next;return r},n.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError(\"Reduce of empty list with no initial value\");n=this.tail.prev,r=this.tail.value}for(var i=this.length-1;null!==n;i--)r=t(r,n.value,i),n=n.prev;return r},n.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},n.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},n.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new n;if(ethis.length&&(e=this.length);for(var i=0,o=this.head;null!==o&&ithis.length&&(e=this.length);for(var i=this.length,o=this.tail;null!==o&&i>e;i--)o=o.prev;for(;null!==o&&i>t;i--,o=o.prev)r.push(o.value);return r},n.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var n=0,o=this.head;null!==o&&n{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.JsonRpcRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(4520);e.JsonRpcRequestStruct=(0,o.object)({jsonrpc:(0,i.literal)(\"2.0\"),id:(0,i.union)([(0,i.string)(),(0,i.number)(),(0,i.literal)(null)]),method:(0,i.string)(),params:(0,o.exactOptional)((0,i.union)([(0,i.array)(n.JsonStruct),(0,i.record)((0,i.string)(),n.JsonStruct)]))})},1236:function(t,e,r){\"use strict\";var n,i,o,s=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if(\"m\"===n)throw new TypeError(\"Private method is not writable\");if(\"a\"===n&&!i)throw new TypeError(\"Private accessor was defined without a setter\");if(\"function\"==typeof e?t!==e||!i:!e.has(t))throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");return\"a\"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},a=this&&this.__classPrivateFieldGet||function(t,e,r,n){if(\"a\"===r&&!n)throw new TypeError(\"Private accessor was defined without a getter\");if(\"function\"==typeof e?t!==e||!n:!e.has(t))throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");return\"m\"===r?n:\"a\"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringClient=void 0;const c=r(7251),u=r(4596),f=r(2582),h=r(1925),l=r(4520);e.KeyringClient=class{constructor(t){n.add(this),i.set(this,void 0),s(this,i,t,\"f\")}async listAccounts(){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ListAccounts}),f.ListAccountsResponseStruct)}async getAccount(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetAccount,params:{id:t}}),f.GetAccountResponseStruct)}async getAccountBalances(t,e){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetAccountBalances,params:{id:t,assets:e}}),f.GetAccountBalancesResponseStruct)}async createAccount(t={}){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.CreateAccount,params:{options:t}}),f.CreateAccountResponseStruct)}async filterAccountChains(t,e){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.FilterAccountChains,params:{id:t,chains:e}}),f.FilterAccountChainsResponseStruct)}async updateAccount(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.UpdateAccount,params:{account:t}}),f.UpdateAccountResponseStruct)}async deleteAccount(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.DeleteAccount,params:{id:t}}),f.DeleteAccountResponseStruct)}async exportAccount(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ExportAccount,params:{id:t}}),f.ExportAccountResponseStruct)}async listRequests(){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ListRequests}),f.ListRequestsResponseStruct)}async getRequest(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.GetRequest,params:{id:t}}),f.GetRequestResponseStruct)}async submitRequest(t){return(0,l.strictMask)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.SubmitRequest,params:t}),f.SubmitRequestResponseStruct)}async approveRequest(t,e={}){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.ApproveRequest,params:{id:t,data:e}}),f.ApproveRequestResponseStruct)}async rejectRequest(t){(0,c.assert)(await a(this,n,\"m\",o).call(this,{method:h.KeyringRpcMethod.RejectRequest,params:{id:t}}),f.RejectRequestResponseStruct)}},i=new WeakMap,n=new WeakSet,o=async function(t){return a(this,i,\"f\").send({jsonrpc:\"2.0\",id:(0,u.v4)(),...t})}},4071:function(t,e,r){\"use strict\";var n,i,o=this&&this.__classPrivateFieldSet||function(t,e,r,n,i){if(\"m\"===n)throw new TypeError(\"Private method is not writable\");if(\"a\"===n&&!i)throw new TypeError(\"Private accessor was defined without a setter\");if(\"function\"==typeof e?t!==e||!i:!e.has(t))throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");return\"a\"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},s=this&&this.__classPrivateFieldGet||function(t,e,r,n){if(\"a\"===r&&!n)throw new TypeError(\"Private accessor was defined without a getter\");if(\"function\"==typeof e?t!==e||!n:!e.has(t))throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");return\"m\"===r?n:\"a\"===r?n.call(t):n?n.value:e.get(t)};Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringSnapRpcClient=e.SnapRpcSender=void 0;const a=r(1236);class c{constructor(t,e){n.set(this,void 0),i.set(this,void 0),o(this,n,t,\"f\"),o(this,i,e,\"f\")}async send(t){return s(this,i,\"f\").request({method:\"wallet_invokeKeyring\",params:{snapId:s(this,n,\"f\"),request:t}})}}e.SnapRpcSender=c,n=new WeakMap,i=new WeakMap;class u extends a.KeyringClient{constructor(t,e){super(new c(t,e))}}e.KeyringSnapRpcClient=u},1950:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringAccountStruct=e.BtcAccountType=e.EthAccountType=void 0;const n=r(2049),i=r(7251),o=r(4520),s=r(6580);var a,c;!function(t){t.Eoa=\"eip155:eoa\",t.Erc4337=\"eip155:erc4337\"}(a=e.EthAccountType||(e.EthAccountType={})),function(t){t.P2wpkh=\"bip122:p2wpkh\"}(c=e.BtcAccountType||(e.BtcAccountType={})),e.KeyringAccountStruct=(0,o.object)({id:s.UuidStruct,type:(0,i.enums)([`${a.Eoa}`,`${a.Erc4337}`,`${c.P2wpkh}`]),address:(0,i.string)(),options:(0,i.record)((0,i.string)(),n.JsonStruct),methods:(0,i.array)((0,i.string)())})},3433:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.BalanceStruct=void 0;const n=r(7251),i=r(4520),o=r(6580);e.BalanceStruct=(0,i.object)({amount:o.StringNumberStruct,unit:(0,n.string)()})},8588:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.isCaipAssetId=e.isCaipAssetType=e.CaipAssetIdStruct=e.CaipAssetTypeStruct=void 0;const n=r(7251),i=r(4520);e.CaipAssetTypeStruct=(0,i.definePattern)(\"CaipAssetType\",/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})$/u),e.CaipAssetIdStruct=(0,i.definePattern)(\"CaipAssetId\",/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})\\/(?[-.%a-zA-Z0-9]{1,78})$/u),e.isCaipAssetType=function(t){return(0,n.is)(t,e.CaipAssetTypeStruct)},e.isCaipAssetId=function(t){return(0,n.is)(t,e.CaipAssetIdStruct)}},4015:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringAccountDataStruct=void 0;const n=r(2049),i=r(7251);e.KeyringAccountDataStruct=(0,i.record)((0,i.string)(),n.JsonStruct)},5417:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(1950),e),i(r(3433),e),i(r(8588),e),i(r(4015),e),i(r(5444),e),i(r(7884),e),i(r(6142),e)},5444:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},7884:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(4520),s=r(6580);e.KeyringRequestStruct=(0,o.object)({id:s.UuidStruct,scope:(0,i.string)(),account:s.UuidStruct,request:(0,o.object)({method:(0,i.string)(),params:(0,o.exactOptional)((0,i.union)([(0,i.array)(n.JsonStruct),(0,i.record)((0,i.string)(),n.JsonStruct)]))})})},6142:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringResponseStruct=void 0;const n=r(2049),i=r(7251),o=r(4520);e.KeyringResponseStruct=(0,i.union)([(0,o.object)({pending:(0,i.literal)(!0),redirect:(0,o.exactOptional)((0,o.object)({message:(0,o.exactOptional)((0,i.string)()),url:(0,o.exactOptional)((0,i.string)())}))}),(0,o.object)({pending:(0,i.literal)(!1),result:n.JsonStruct})])},5238:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(5787),e)},5787:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.BtcP2wpkhAccountStruct=e.BtcMethod=e.BtcP2wpkhAddressStruct=void 0;const n=r(6586),i=r(7251),o=r(5417),s=r(4520);var a;e.BtcP2wpkhAddressStruct=(0,i.refine)((0,i.string)(),\"BtcP2wpkhAddressStruct\",(t=>{try{n.bech32.decode(t)}catch(t){return new Error(`Could not decode P2WPKH address: ${t.message}`)}return!0})),function(t){t.SendMany=\"btc_sendmany\"}(a=e.BtcMethod||(e.BtcMethod={})),e.BtcP2wpkhAccountStruct=(0,s.object)({...o.KeyringAccountStruct.schema,address:e.BtcP2wpkhAddressStruct,type:(0,i.literal)(`${o.BtcAccountType.P2wpkh}`),methods:(0,i.array)((0,i.enums)([`${a.SendMany}`]))})},1360:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},322:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(4943),e)},4943:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.EthUserOperationPatchStruct=e.EthBaseUserOperationStruct=e.EthBaseTransactionStruct=e.EthUserOperationStruct=void 0;const n=r(4520),i=r(6580),o=r(6879);e.EthUserOperationStruct=(0,n.object)({sender:o.EthAddressStruct,nonce:o.EthUint256Struct,initCode:o.EthBytesStruct,callData:o.EthBytesStruct,callGasLimit:o.EthUint256Struct,verificationGasLimit:o.EthUint256Struct,preVerificationGas:o.EthUint256Struct,maxFeePerGas:o.EthUint256Struct,maxPriorityFeePerGas:o.EthUint256Struct,paymasterAndData:o.EthBytesStruct,signature:o.EthBytesStruct}),e.EthBaseTransactionStruct=(0,n.object)({to:o.EthAddressStruct,value:o.EthUint256Struct,data:o.EthBytesStruct}),e.EthBaseUserOperationStruct=(0,n.object)({nonce:o.EthUint256Struct,initCode:o.EthBytesStruct,callData:o.EthBytesStruct,gasLimits:(0,n.exactOptional)((0,n.object)({callGasLimit:o.EthUint256Struct,verificationGasLimit:o.EthUint256Struct,preVerificationGas:o.EthUint256Struct})),dummyPaymasterAndData:o.EthBytesStruct,dummySignature:o.EthBytesStruct,bundlerUrl:i.UrlStruct}),e.EthUserOperationPatchStruct=(0,n.object)({paymasterAndData:o.EthBytesStruct,callGasLimit:(0,n.exactOptional)(o.EthUint256Struct),verificationGasLimit:(0,n.exactOptional)(o.EthUint256Struct),preVerificationGas:(0,n.exactOptional)(o.EthUint256Struct)})},6034:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(322),e),i(r(6879),e),i(r(1267),e)},6879:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.EthErc4337AccountStruct=e.EthEoaAccountStruct=e.EthMethod=e.EthUint256Struct=e.EthAddressStruct=e.EthBytesStruct=void 0;const n=r(7251),i=r(5417),o=r(4520);var s;e.EthBytesStruct=(0,o.definePattern)(\"EthBytes\",/^0x[0-9a-f]*$/iu),e.EthAddressStruct=(0,o.definePattern)(\"EthAddress\",/^0x[0-9a-f]{40}$/iu),e.EthUint256Struct=(0,o.definePattern)(\"EthUint256\",/^0x([1-9a-f][0-9a-f]*|0)$/iu),function(t){t.PersonalSign=\"personal_sign\",t.Sign=\"eth_sign\",t.SignTransaction=\"eth_signTransaction\",t.SignTypedDataV1=\"eth_signTypedData_v1\",t.SignTypedDataV3=\"eth_signTypedData_v3\",t.SignTypedDataV4=\"eth_signTypedData_v4\",t.PrepareUserOperation=\"eth_prepareUserOperation\",t.PatchUserOperation=\"eth_patchUserOperation\",t.SignUserOperation=\"eth_signUserOperation\"}(s=e.EthMethod||(e.EthMethod={})),e.EthEoaAccountStruct=(0,o.object)({...i.KeyringAccountStruct.schema,address:e.EthAddressStruct,type:(0,n.literal)(`${i.EthAccountType.Eoa}`),methods:(0,n.array)((0,n.enums)([`${s.PersonalSign}`,`${s.Sign}`,`${s.SignTransaction}`,`${s.SignTypedDataV1}`,`${s.SignTypedDataV3}`,`${s.SignTypedDataV4}`]))}),e.EthErc4337AccountStruct=(0,o.object)({...i.KeyringAccountStruct.schema,address:e.EthAddressStruct,type:(0,n.literal)(`${i.EthAccountType.Erc4337}`),methods:(0,n.array)((0,n.enums)([`${s.PersonalSign}`,`${s.Sign}`,`${s.SignTypedDataV1}`,`${s.SignTypedDataV3}`,`${s.SignTypedDataV4}`,`${s.PrepareUserOperation}`,`${s.PatchUserOperation}`,`${s.SignUserOperation}`]))})},1267:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.isEvmAccountType=void 0;const n=r(5417);e.isEvmAccountType=function(t){return t===n.EthAccountType.Eoa||t===n.EthAccountType.Erc4337}},4433:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.KeyringEvent=void 0,function(t){t.AccountCreated=\"notify:accountCreated\",t.AccountUpdated=\"notify:accountUpdated\",t.AccountDeleted=\"notify:accountDeleted\",t.RequestApproved=\"notify:requestApproved\",t.RequestRejected=\"notify:requestRejected\"}(e.KeyringEvent||(e.KeyringEvent={}))},7962:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(5417),e),i(r(5238),e),i(r(1360),e),i(r(6034),e),i(r(4433),e),i(r(7470),e),i(r(1236),e),i(r(4071),e),i(r(3060),e),i(r(5524),e),i(r(4520),e)},2582:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.RejectRequestResponseStruct=e.RejectRequestRequestStruct=e.ApproveRequestResponseStruct=e.ApproveRequestRequestStruct=e.SubmitRequestResponseStruct=e.SubmitRequestRequestStruct=e.GetRequestResponseStruct=e.GetRequestRequestStruct=e.ListRequestsResponseStruct=e.ListRequestsRequestStruct=e.ExportAccountResponseStruct=e.ExportAccountRequestStruct=e.DeleteAccountResponseStruct=e.DeleteAccountRequestStruct=e.UpdateAccountResponseStruct=e.UpdateAccountRequestStruct=e.FilterAccountChainsResponseStruct=e.FilterAccountChainsStruct=e.GetAccountBalancesResponseStruct=e.GetAccountBalancesRequestStruct=e.CreateAccountResponseStruct=e.CreateAccountRequestStruct=e.GetAccountResponseStruct=e.GetAccountRequestStruct=e.ListAccountsResponseStruct=e.ListAccountsRequestStruct=void 0;const n=r(2049),i=r(7251),o=r(5417),s=r(4520),a=r(6580),c=r(1925),u={jsonrpc:(0,i.literal)(\"2.0\"),id:(0,i.union)([(0,i.string)(),(0,i.number)(),(0,i.literal)(null)])};e.ListAccountsRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_listAccounts\")}),e.ListAccountsResponseStruct=(0,i.array)(o.KeyringAccountStruct),e.GetAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_getAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.GetAccountResponseStruct=o.KeyringAccountStruct,e.CreateAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_createAccount\"),params:(0,s.object)({options:(0,i.record)((0,i.string)(),n.JsonStruct)})}),e.CreateAccountResponseStruct=o.KeyringAccountStruct,e.GetAccountBalancesRequestStruct=(0,s.object)({...u,method:(0,i.literal)(`${c.KeyringRpcMethod.GetAccountBalances}`),params:(0,s.object)({id:a.UuidStruct,assets:(0,i.array)(o.CaipAssetTypeStruct)})}),e.GetAccountBalancesResponseStruct=(0,i.record)(o.CaipAssetTypeStruct,o.BalanceStruct),e.FilterAccountChainsStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_filterAccountChains\"),params:(0,s.object)({id:a.UuidStruct,chains:(0,i.array)((0,i.string)())})}),e.FilterAccountChainsResponseStruct=(0,i.array)((0,i.string)()),e.UpdateAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_updateAccount\"),params:(0,s.object)({account:o.KeyringAccountStruct})}),e.UpdateAccountResponseStruct=(0,i.literal)(null),e.DeleteAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_deleteAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.DeleteAccountResponseStruct=(0,i.literal)(null),e.ExportAccountRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_exportAccount\"),params:(0,s.object)({id:a.UuidStruct})}),e.ExportAccountResponseStruct=o.KeyringAccountDataStruct,e.ListRequestsRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_listRequests\")}),e.ListRequestsResponseStruct=(0,i.array)(o.KeyringRequestStruct),e.GetRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_getRequest\"),params:(0,s.object)({id:a.UuidStruct})}),e.GetRequestResponseStruct=o.KeyringRequestStruct,e.SubmitRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_submitRequest\"),params:o.KeyringRequestStruct}),e.SubmitRequestResponseStruct=o.KeyringResponseStruct,e.ApproveRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_approveRequest\"),params:(0,s.object)({id:a.UuidStruct,data:(0,i.record)((0,i.string)(),n.JsonStruct)})}),e.ApproveRequestResponseStruct=(0,i.literal)(null),e.RejectRequestRequestStruct=(0,s.object)({...u,method:(0,i.literal)(\"keyring_rejectRequest\"),params:(0,s.object)({id:a.UuidStruct})}),e.RejectRequestResponseStruct=(0,i.literal)(null)},6796:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0})},7841:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(6796),e)},3005:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.RequestRejectedEventStruct=e.RequestApprovedEventStruct=e.AccountDeletedEventStruct=e.AccountUpdatedEventStruct=e.AccountCreatedEventStruct=void 0;const n=r(2049),i=r(7251),o=r(5417),s=r(4433),a=r(4520),c=r(6580);e.AccountCreatedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountCreated}`),params:(0,a.object)({account:o.KeyringAccountStruct,accountNameSuggestion:(0,a.exactOptional)((0,i.string)()),displayConfirmation:(0,a.exactOptional)((0,i.boolean)())})}),e.AccountUpdatedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountUpdated}`),params:(0,a.object)({account:o.KeyringAccountStruct})}),e.AccountDeletedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.AccountDeleted}`),params:(0,a.object)({id:c.UuidStruct})}),e.RequestApprovedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.RequestApproved}`),params:(0,a.object)({id:c.UuidStruct,result:n.JsonStruct})}),e.RequestRejectedEventStruct=(0,a.object)({method:(0,i.literal)(`${s.KeyringEvent.RequestRejected}`),params:(0,a.object)({id:c.UuidStruct})})},7470:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(2582),e),i(r(7841),e),i(r(3005),e),i(r(1925),e),i(r(3699),e)},1925:(t,e)=>{\"use strict\";var r;Object.defineProperty(e,\"__esModule\",{value:!0}),e.isKeyringRpcMethod=e.KeyringRpcMethod=void 0,function(t){t.ListAccounts=\"keyring_listAccounts\",t.GetAccount=\"keyring_getAccount\",t.CreateAccount=\"keyring_createAccount\",t.GetAccountBalances=\"keyring_getAccountBalances\",t.FilterAccountChains=\"keyring_filterAccountChains\",t.UpdateAccount=\"keyring_updateAccount\",t.DeleteAccount=\"keyring_deleteAccount\",t.ExportAccount=\"keyring_exportAccount\",t.ListRequests=\"keyring_listRequests\",t.GetRequest=\"keyring_getRequest\",t.SubmitRequest=\"keyring_submitRequest\",t.ApproveRequest=\"keyring_approveRequest\",t.RejectRequest=\"keyring_rejectRequest\"}(r=e.KeyringRpcMethod||(e.KeyringRpcMethod={})),e.isKeyringRpcMethod=function(t){return Object.values(r).includes(t)}},3699:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.InternalAccountStruct=e.InternalAccountStructs=e.InternalBtcP2wpkhAccountStruct=e.InternalEthErc4337AccountStruct=e.InternalEthEoaAccountStruct=e.InternalAccountMetadataStruct=void 0;const n=r(7251),i=r(5417),o=r(5787),s=r(6879),a=r(4520);function c(t){return(0,a.object)({...t.schema,...e.InternalAccountMetadataStruct.schema})}e.InternalAccountMetadataStruct=(0,a.object)({metadata:(0,a.object)({name:(0,n.string)(),snap:(0,a.exactOptional)((0,a.object)({id:(0,n.string)(),enabled:(0,n.boolean)(),name:(0,n.string)()})),lastSelected:(0,a.exactOptional)((0,n.number)()),importTime:(0,n.number)(),keyring:(0,a.object)({type:(0,n.string)()})})}),e.InternalEthEoaAccountStruct=c(s.EthEoaAccountStruct),e.InternalEthErc4337AccountStruct=c(s.EthErc4337AccountStruct),e.InternalBtcP2wpkhAccountStruct=c(o.BtcP2wpkhAccountStruct),e.InternalAccountStructs={[`${i.EthAccountType.Eoa}`]:e.InternalEthEoaAccountStruct,[`${i.EthAccountType.Erc4337}`]:e.InternalEthErc4337AccountStruct,[`${i.BtcAccountType.P2wpkh}`]:e.InternalBtcP2wpkhAccountStruct},e.InternalAccountStruct=(0,a.object)({...i.KeyringAccountStruct.schema,...e.InternalAccountMetadataStruct.schema})},3060:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.handleKeyringRequest=e.MethodNotSupportedError=void 0;const n=r(7251),i=r(2582),o=r(1925),s=r(5978);class a extends Error{constructor(t){super(`Method not supported: ${t}`)}}e.MethodNotSupportedError=a,e.handleKeyringRequest=async function(t,e){try{return await async function(t,e){switch((0,n.assert)(e,s.JsonRpcRequestStruct),e.method){case o.KeyringRpcMethod.ListAccounts:return(0,n.assert)(e,i.ListAccountsRequestStruct),t.listAccounts();case o.KeyringRpcMethod.GetAccount:return(0,n.assert)(e,i.GetAccountRequestStruct),t.getAccount(e.params.id);case o.KeyringRpcMethod.CreateAccount:return(0,n.assert)(e,i.CreateAccountRequestStruct),t.createAccount(e.params.options);case o.KeyringRpcMethod.GetAccountBalances:if(void 0===t.getAccountBalances)throw new a(e.method);return(0,n.assert)(e,i.GetAccountBalancesRequestStruct),t.getAccountBalances(e.params.id,e.params.assets);case o.KeyringRpcMethod.FilterAccountChains:return(0,n.assert)(e,i.FilterAccountChainsStruct),t.filterAccountChains(e.params.id,e.params.chains);case o.KeyringRpcMethod.UpdateAccount:return(0,n.assert)(e,i.UpdateAccountRequestStruct),t.updateAccount(e.params.account);case o.KeyringRpcMethod.DeleteAccount:return(0,n.assert)(e,i.DeleteAccountRequestStruct),t.deleteAccount(e.params.id);case o.KeyringRpcMethod.ExportAccount:if(void 0===t.exportAccount)throw new a(e.method);return(0,n.assert)(e,i.ExportAccountRequestStruct),t.exportAccount(e.params.id);case o.KeyringRpcMethod.ListRequests:if(void 0===t.listRequests)throw new a(e.method);return(0,n.assert)(e,i.ListRequestsRequestStruct),t.listRequests();case o.KeyringRpcMethod.GetRequest:if(void 0===t.getRequest)throw new a(e.method);return(0,n.assert)(e,i.GetRequestRequestStruct),t.getRequest(e.params.id);case o.KeyringRpcMethod.SubmitRequest:return(0,n.assert)(e,i.SubmitRequestRequestStruct),t.submitRequest(e.params);case o.KeyringRpcMethod.ApproveRequest:if(void 0===t.approveRequest)throw new a(e.method);return(0,n.assert)(e,i.ApproveRequestRequestStruct),t.approveRequest(e.params.id,e.params.data);case o.KeyringRpcMethod.RejectRequest:if(void 0===t.rejectRequest)throw new a(e.method);return(0,n.assert)(e,i.RejectRequestRequestStruct),t.rejectRequest(e.params.id);default:throw new a(e.method)}}(t,e)}catch(t){const e=t instanceof Error&&\"string\"==typeof t.message?t.message:\"An unknown error occurred while handling the keyring request\";throw new Error(e)}}},5524:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.emitSnapKeyringEvent=void 0,e.emitSnapKeyringEvent=async function(t,e,r){await t.request({method:\"snap_manageAccounts\",params:{method:e,params:{...r}}})}},4520:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.strictMask=e.definePattern=e.exactOptional=e.object=void 0;const n=r(7251);function i(t){return t.path[t.path.length-1]in t.branch[t.branch.length-2]}e.object=function(t){return(0,n.object)(t)},e.exactOptional=function(t){return new n.Struct({...t,validator:(e,r)=>!i(r)||t.validator(e,r),refiner:(e,r)=>!i(r)||t.refiner(e,r)})},e.definePattern=function(t,e){return(0,n.define)(t,(t=>\"string\"==typeof t&&e.test(t)))},e.strictMask=function(t,e,r){return(0,n.assert)(t,e,r),t}},6580:function(t,e,r){\"use strict\";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!(\"get\"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)\"default\"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,\"__esModule\",{value:!0}),i(r(8401),e),i(r(7765),e)},8401:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.StringNumberStruct=e.UrlStruct=e.UuidStruct=void 0;const n=r(7251),i=r(4520);e.UuidStruct=(0,i.definePattern)(\"UuidV4\",/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu),e.UrlStruct=(0,n.define)(\"Url\",(t=>{try{const e=new URL(t);return\"http:\"===e.protocol||\"https:\"===e.protocol}catch(t){return!1}})),e.StringNumberStruct=(0,i.definePattern)(\"StringNumber\",/^\\d+(\\.\\d+)?$/u)},7765:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.expectTrue=void 0,e.expectTrue=function(){}},1275:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n,i=r(124),o=((n=i)&&n.__esModule?n:{default:n}).default.call(void 0,\"metamask\");e.createProjectLogger=function(t){return o.extend(t)},e.createModuleLogger=function(t,e){return t.extend(e)}},5244:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r=(t,e,r)=>{if(!e.has(t))throw TypeError(\"Cannot \"+r)};e.__privateGet=(t,e,n)=>(r(t,e,\"read from private field\"),n?n.call(t):e.get(t)),e.__privateAdd=(t,e,r)=>{if(e.has(t))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(t):e.set(t,r)},e.__privateSet=(t,e,n,i)=>(r(t,e,\"write to private field\"),i?i.call(t,n):e.set(t,n),n)},3631:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(932),i=r(2722),o=r(7251),s=o.refine.call(void 0,o.string.call(void 0),\"Version\",(t=>null!==i.valid.call(void 0,t)||`Expected SemVer version, got \"${t}\"`)),a=o.refine.call(void 0,o.string.call(void 0),\"Version range\",(t=>null!==i.validRange.call(void 0,t)||`Expected SemVer range, got \"${t}\"`));e.VersionStruct=s,e.VersionRangeStruct=a,e.isValidSemVerVersion=function(t){return o.is.call(void 0,t,s)},e.isValidSemVerRange=function(t){return o.is.call(void 0,t,a)},e.assertIsSemVerVersion=function(t){n.assertStruct.call(void 0,t,s)},e.assertIsSemVerRange=function(t){n.assertStruct.call(void 0,t,a)},e.gtVersion=function(t,e){return i.gt.call(void 0,t,e)},e.gtRange=function(t,e){return i.gtr.call(void 0,t,e)},e.satisfiesVersionRange=function(t,e){return i.satisfies.call(void 0,t,e,{includePrerelease:!0})}},9116:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r,n=((r=n||{})[r.Millisecond=1]=\"Millisecond\",r[r.Second=1e3]=\"Second\",r[r.Minute=6e4]=\"Minute\",r[r.Hour=36e5]=\"Hour\",r[r.Day=864e5]=\"Day\",r[r.Week=6048e5]=\"Week\",r[r.Year=31536e6]=\"Year\",r),i=(t,e)=>{if(!(t=>Number.isInteger(t)&&t>=0)(t))throw new Error(`\"${e}\" must be a non-negative integer. Received: \"${t}\".`)};e.Duration=n,e.inMilliseconds=function(t,e){return i(t,\"count\"),t*e},e.timeSince=function(t){return i(t,\"timestamp\"),Date.now()-t}},7982:()=>{},1848:(t,e,r)=>{\"use strict\";function n(t,e){return null!=t?t:e()}Object.defineProperty(e,\"__esModule\",{value:!0});var i=r(932),o=r(7251);e.base64=(t,e={})=>{const r=n(e.paddingRequired,(()=>!1)),s=n(e.characterSet,(()=>\"base64\"));let a,c;return\"base64\"===s?a=String.raw`[A-Za-z0-9+\\/]`:(i.assert.call(void 0,\"base64url\"===s),a=String.raw`[-_A-Za-z0-9]`),c=r?new RegExp(`^(?:${a}{4})*(?:${a}{3}=|${a}{2}==)?$`,\"u\"):new RegExp(`^(?:${a}{4})*(?:${a}{2,3}|${a}{3}=|${a}{2}==)?$`,\"u\"),o.pattern.call(void 0,t,c)}},932:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(1486),i=r(7251);function o(t,e){return Boolean(\"string\"==typeof function(t){let e,r=t[0],n=1;for(;nr.call(e,...t))),e=void 0)}return r}([t,\"optionalAccess\",t=>t.prototype,\"optionalAccess\",t=>t.constructor,\"optionalAccess\",t=>t.name]))?new t({message:e}):t({message:e})}var s=class extends Error{constructor(t){super(t.message),this.code=\"ERR_ASSERTION\"}};e.AssertionError=s,e.assert=function(t,e=\"Assertion failed.\",r=s){if(!t){if(e instanceof Error)throw e;throw o(r,e)}},e.assertStruct=function(t,e,r=\"Assertion failed\",a=s){try{i.assert.call(void 0,t,e)}catch(t){throw o(a,`${r}: ${function(t){return n.getErrorMessage.call(void 0,t).replace(/\\.$/u,\"\")}(t)}.`)}},e.assertExhaustive=function(t){throw new Error(\"Invalid branch reached. Should be detected during compilation.\")}},9705:(t,e)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),e.createDeferredPromise=function({suppressUnhandledRejection:t=!1}={}){let e,r;const n=new Promise(((t,n)=>{e=t,r=n}));return t&&n.catch((t=>{})),{promise:n,resolve:e,reject:r}}},1203:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(5363),i=r(932),o=r(7251),s=o.union.call(void 0,[o.number.call(void 0),o.bigint.call(void 0),o.string.call(void 0),n.StrictHexStruct]),a=o.coerce.call(void 0,o.number.call(void 0),s,Number),c=o.coerce.call(void 0,o.bigint.call(void 0),s,BigInt),u=(o.union.call(void 0,[n.StrictHexStruct,o.instance.call(void 0,Uint8Array)]),o.coerce.call(void 0,o.instance.call(void 0,Uint8Array),o.union.call(void 0,[n.StrictHexStruct]),n.hexToBytes)),f=o.coerce.call(void 0,n.StrictHexStruct,o.instance.call(void 0,Uint8Array),n.bytesToHex);e.createNumber=function(t){try{const e=o.create.call(void 0,t,a);return i.assert.call(void 0,Number.isFinite(e),`Expected a number-like value, got \"${t}\".`),e}catch(e){if(e instanceof o.StructError)throw new Error(`Expected a number-like value, got \"${t}\".`);throw e}},e.createBigInt=function(t){try{return o.create.call(void 0,t,c)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a number-like value, got \"${String(t.value)}\".`);throw t}},e.createBytes=function(t){if(\"string\"==typeof t&&\"0x\"===t.toLowerCase())return new Uint8Array;try{return o.create.call(void 0,t,u)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a bytes-like value, got \"${String(t.value)}\".`);throw t}},e.createHex=function(t){if(t instanceof Uint8Array&&0===t.length||\"string\"==typeof t&&\"0x\"===t.toLowerCase())return\"0x\";try{return o.create.call(void 0,t,f)}catch(t){if(t instanceof o.StructError)throw new Error(`Expected a bytes-like value, got \"${String(t.value)}\".`);throw t}}},1508:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(1848),i=r(7251),o=i.size.call(void 0,n.base64.call(void 0,i.string.call(void 0),{paddingRequired:!0}),44,44);e.ChecksumStruct=o},1423:()=>{},1486:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(6526),i=r(9756);function o(t){return\"object\"==typeof t&&null!==t&&\"code\"in t}function s(t){return\"object\"==typeof t&&null!==t&&\"message\"in t}e.isErrorWithCode=o,e.isErrorWithMessage=s,e.isErrorWithStack=function(t){return\"object\"==typeof t&&null!==t&&\"stack\"in t},e.getErrorMessage=function(t){return s(t)&&\"string\"==typeof t.message?t.message:n.isNullOrUndefined.call(void 0,t)?\"\":String(t)},e.wrapError=function(t,e){if((r=t)instanceof Error||n.isObject.call(void 0,r)&&\"Error\"===r.constructor.name){let r;return r=2===Error.length?new Error(e,{cause:t}):new(0,i.ErrorWithCause)(e,{cause:t}),o(t)&&(r.code=t.code),r}var r;return e.length>0?new Error(`${String(t)}: ${e}`):new Error(String(t))}},8383:()=>{},7427:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(932),i=r(6526),o=r(7251),s=t=>o.object.call(void 0,t);function a({path:t,branch:e}){const r=t[t.length-1];return i.hasProperty.call(void 0,e[e.length-2],r)}function c(t){return new(0,o.Struct)({...t,type:`optional ${t.type}`,validator:(e,r)=>!a(r)||t.validator(e,r),refiner:(e,r)=>!a(r)||t.refiner(e,r)})}var u=o.union.call(void 0,[o.literal.call(void 0,null),o.boolean.call(void 0),o.define.call(void 0,\"finite number\",(t=>o.is.call(void 0,t,o.number.call(void 0))&&Number.isFinite(t))),o.string.call(void 0),o.array.call(void 0,o.lazy.call(void 0,(()=>u))),o.record.call(void 0,o.string.call(void 0),o.lazy.call(void 0,(()=>u)))]),f=o.coerce.call(void 0,u,o.any.call(void 0),(t=>(n.assertStruct.call(void 0,t,u),JSON.parse(JSON.stringify(t,((t,e)=>{if(\"__proto__\"!==t&&\"constructor\"!==t)return e}))))));function h(t){return o.create.call(void 0,t,f)}var l=o.literal.call(void 0,\"2.0\"),p=o.nullable.call(void 0,o.union.call(void 0,[o.number.call(void 0),o.string.call(void 0)])),d=s({code:o.integer.call(void 0),message:o.string.call(void 0),data:c(f),stack:c(o.string.call(void 0))}),y=o.union.call(void 0,[o.record.call(void 0,o.string.call(void 0),f),o.array.call(void 0,f)]),g=s({id:p,jsonrpc:l,method:o.string.call(void 0),params:c(y)}),b=s({jsonrpc:l,method:o.string.call(void 0),params:c(y)});var w=o.object.call(void 0,{id:p,jsonrpc:l,result:o.optional.call(void 0,o.unknown.call(void 0)),error:o.optional.call(void 0,d)}),m=s({id:p,jsonrpc:l,result:f}),v=s({id:p,jsonrpc:l,error:d}),E=o.union.call(void 0,[m,v]);e.object=s,e.exactOptional=c,e.UnsafeJsonStruct=u,e.JsonStruct=f,e.isValidJson=function(t){try{return h(t),!0}catch(t){return!1}},e.getSafeJson=h,e.getJsonSize=function(t){n.assertStruct.call(void 0,t,f,\"Invalid JSON value\");const e=JSON.stringify(t);return(new TextEncoder).encode(e).byteLength},e.jsonrpc2=\"2.0\",e.JsonRpcVersionStruct=l,e.JsonRpcIdStruct=p,e.JsonRpcErrorStruct=d,e.JsonRpcParamsStruct=y,e.JsonRpcRequestStruct=g,e.JsonRpcNotificationStruct=b,e.isJsonRpcNotification=function(t){return o.is.call(void 0,t,b)},e.assertIsJsonRpcNotification=function(t,e){n.assertStruct.call(void 0,t,b,\"Invalid JSON-RPC notification\",e)},e.isJsonRpcRequest=function(t){return o.is.call(void 0,t,g)},e.assertIsJsonRpcRequest=function(t,e){n.assertStruct.call(void 0,t,g,\"Invalid JSON-RPC request\",e)},e.PendingJsonRpcResponseStruct=w,e.JsonRpcSuccessStruct=m,e.JsonRpcFailureStruct=v,e.JsonRpcResponseStruct=E,e.isPendingJsonRpcResponse=function(t){return o.is.call(void 0,t,w)},e.assertIsPendingJsonRpcResponse=function(t,e){n.assertStruct.call(void 0,t,w,\"Invalid pending JSON-RPC response\",e)},e.isJsonRpcResponse=function(t){return o.is.call(void 0,t,E)},e.assertIsJsonRpcResponse=function(t,e){n.assertStruct.call(void 0,t,E,\"Invalid JSON-RPC response\",e)},e.isJsonRpcSuccess=function(t){return o.is.call(void 0,t,m)},e.assertIsJsonRpcSuccess=function(t,e){n.assertStruct.call(void 0,t,m,\"Invalid JSON-RPC success response\",e)},e.isJsonRpcFailure=function(t){return o.is.call(void 0,t,v)},e.assertIsJsonRpcFailure=function(t,e){n.assertStruct.call(void 0,t,v,\"Invalid JSON-RPC failure response\",e)},e.isJsonRpcError=function(t){return o.is.call(void 0,t,d)},e.assertIsJsonRpcError=function(t,e){n.assertStruct.call(void 0,t,d,\"Invalid JSON-RPC error\",e)},e.getJsonRpcIdValidator=function(t){const{permitEmptyString:e,permitFractions:r,permitNull:n}={permitEmptyString:!0,permitFractions:!1,permitNull:!0,...t};return t=>Boolean(\"number\"==typeof t&&(r||Number.isInteger(t))||\"string\"==typeof t&&(e||t.length>0)||n&&null===t)}},5363:(t,e,r)=>{\"use strict\";var n=r(1048).Buffer;Object.defineProperty(e,\"__esModule\",{value:!0});var i=r(932),o=r(448),s=r(7251),a=r(6710),c=48,u=58,f=87;var h=function(){const t=[];return()=>{if(0===t.length)for(let e=0;e<256;e++)t.push(e.toString(16).padStart(2,\"0\"));return t}}();function l(t){return t instanceof Uint8Array}function p(t){i.assert.call(void 0,l(t),\"Value must be a Uint8Array.\")}function d(t){if(p(t),0===t.length)return\"0x\";const e=h(),r=new Array(t.length);for(let n=0;nr.call(e,...t))),e=void 0)}return r}([t,\"optionalAccess\",t=>t.toLowerCase,\"optionalCall\",t=>t()]))return new Uint8Array;x(t);const e=R(t).toLowerCase(),r=e.length%2==0?e:`0${e}`,n=new Uint8Array(r.length/2);for(let t=0;t=BigInt(0),\"Value must be a non-negative bigint.\");return g(t.toString(16))}function w(t){i.assert.call(void 0,\"number\"==typeof t,\"Value must be a number.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative number.\"),i.assert.call(void 0,Number.isSafeInteger(t),\"Value is not a safe integer. Use `bigIntToBytes` instead.\");return g(t.toString(16))}function m(t){return i.assert.call(void 0,\"string\"==typeof t,\"Value must be a string.\"),(new TextEncoder).encode(t)}function v(t){if(\"bigint\"==typeof t)return b(t);if(\"number\"==typeof t)return w(t);if(\"string\"==typeof t)return t.startsWith(\"0x\")?g(t):m(t);if(l(t))return t;throw new TypeError(`Unsupported value type: \"${typeof t}\".`)}var E=s.pattern.call(void 0,s.string.call(void 0),/^(?:0x)?[0-9a-f]+$/iu),_=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-f]+$/iu),S=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-f]{40}$/u),A=s.pattern.call(void 0,s.string.call(void 0),/^0x[0-9a-fA-F]{40}$/u);function I(t){return s.is.call(void 0,t,E)}function T(t){return s.is.call(void 0,t,_)}function x(t){i.assert.call(void 0,I(t),\"Value must be a hexadecimal string.\")}function O(t){i.assert.call(void 0,s.is.call(void 0,t,A),\"Invalid hex address.\");const e=R(t.toLowerCase()),r=R(d(o.keccak_256.call(void 0,e)));return`0x${e.split(\"\").map(((t,e)=>{const n=r[e];return i.assert.call(void 0,s.is.call(void 0,n,s.string.call(void 0)),\"Hash shorter than address.\"),parseInt(n,16)>7?t.toUpperCase():t})).join(\"\")}`}function k(t){return!!s.is.call(void 0,t,A)&&O(t)===t}function P(t){return t.startsWith(\"0x\")?t:t.startsWith(\"0X\")?`0x${t.substring(2)}`:`0x${t}`}function R(t){return t.startsWith(\"0x\")||t.startsWith(\"0X\")?t.substring(2):t}e.HexStruct=E,e.StrictHexStruct=_,e.HexAddressStruct=S,e.HexChecksumAddressStruct=A,e.isHexString=I,e.isStrictHexString=T,e.assertIsHexString=x,e.assertIsStrictHexString=function(t){i.assert.call(void 0,T(t),'Value must be a hexadecimal string, starting with \"0x\".')},e.isValidHexAddress=function(t){return s.is.call(void 0,t,S)||k(t)},e.getChecksumAddress=O,e.isValidChecksumAddress=k,e.add0x=P,e.remove0x=R,e.isBytes=l,e.assertIsBytes=p,e.bytesToHex=d,e.bytesToBigInt=y,e.bytesToSignedBigInt=function(t){p(t);let e=BigInt(0);for(const r of t)e=(e<0,\"Byte length must be greater than 0.\"),i.assert.call(void 0,function(t,e){i.assert.call(void 0,e>0);const r=t>>BigInt(31);return!((~t&r)+(t&~r)>>BigInt(8*e-1))}(t,e),\"Byte length is too small to represent the given value.\");let r=t;const n=new Uint8Array(e);for(let t=0;t>=BigInt(8);return n.reverse()},e.numberToBytes=w,e.stringToBytes=m,e.base64ToBytes=function(t){return i.assert.call(void 0,\"string\"==typeof t,\"Value must be a string.\"),a.base64.decode(t)},e.valueToBytes=v,e.concatBytes=function(t){const e=new Array(t.length);let r=0;for(let n=0;n{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var r,n=((r=n||{})[r.Null=4]=\"Null\",r[r.Comma=1]=\"Comma\",r[r.Wrapper=1]=\"Wrapper\",r[r.True=4]=\"True\",r[r.False=5]=\"False\",r[r.Quote=1]=\"Quote\",r[r.Colon=1]=\"Colon\",r[r.Date=24]=\"Date\",r),i=/\"|\\\\|\\n|\\r|\\t/gu;function o(t){return t.charCodeAt(0)<=127}e.isNonEmptyArray=function(t){return Array.isArray(t)&&t.length>0},e.isNullOrUndefined=function(t){return null==t},e.isObject=function(t){return Boolean(t)&&\"object\"==typeof t&&!Array.isArray(t)},e.hasProperty=(t,e)=>Object.hasOwnProperty.call(t,e),e.getKnownPropertyNames=function(t){return Object.getOwnPropertyNames(t)},e.JsonSize=n,e.ESCAPE_CHARACTERS_REGEXP=i,e.isPlainObject=function(t){if(\"object\"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}},e.isASCII=o,e.calculateStringSize=function(t){return t.split(\"\").reduce(((t,e)=>o(e)?t+1:t+2),0)+(e=t.match(i),r=()=>[],null!=e?e:r()).length;var e,r},e.calculateNumberSize=function(t){return t.toString().length}},1305:()=>{},3207:()=>{},1535:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n=r(5363),i=r(932);e.numberToHex=t=>(i.assert.call(void 0,\"number\"==typeof t,\"Value must be a number.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative number.\"),i.assert.call(void 0,Number.isSafeInteger(t),\"Value is not a safe integer. Use `bigIntToHex` instead.\"),n.add0x.call(void 0,t.toString(16))),e.bigIntToHex=t=>(i.assert.call(void 0,\"bigint\"==typeof t,\"Value must be a bigint.\"),i.assert.call(void 0,t>=0,\"Value must be a non-negative bigint.\"),n.add0x.call(void 0,t.toString(16))),e.hexToNumber=t=>{n.assertIsHexString.call(void 0,t);const e=parseInt(t,16);return i.assert.call(void 0,Number.isSafeInteger(e),\"Value is not a safe integer. Use `hexToBigInt` instead.\"),e},e.hexToBigInt=t=>(n.assertIsHexString.call(void 0,t),BigInt(n.add0x.call(void 0,t)))},2489:(t,e,r)=>{\"use strict\";function n(t){let e,r=t[0],n=1;for(;nr.call(e,...t))),e=void 0)}return r}Object.defineProperty(e,\"__esModule\",{value:!0});var i,o=r(7251),s=/^(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})$/u,a=/^[-a-z0-9]{3,8}$/u,c=/^[-_a-zA-Z0-9]{1,32}$/u,u=/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})):(?[-.%a-zA-Z0-9]{1,128})$/u,f=/^[-.%a-zA-Z0-9]{1,128}$/u,h=o.pattern.call(void 0,o.string.call(void 0),s),l=o.pattern.call(void 0,o.string.call(void 0),a),p=o.pattern.call(void 0,o.string.call(void 0),c),d=o.pattern.call(void 0,o.string.call(void 0),u),y=o.pattern.call(void 0,o.string.call(void 0),f),g=((i=g||{}).Eip155=\"eip155\",i);function b(t){return o.is.call(void 0,t,l)}function w(t){return o.is.call(void 0,t,p)}e.CAIP_CHAIN_ID_REGEX=s,e.CAIP_NAMESPACE_REGEX=a,e.CAIP_REFERENCE_REGEX=c,e.CAIP_ACCOUNT_ID_REGEX=u,e.CAIP_ACCOUNT_ADDRESS_REGEX=f,e.CaipChainIdStruct=h,e.CaipNamespaceStruct=l,e.CaipReferenceStruct=p,e.CaipAccountIdStruct=d,e.CaipAccountAddressStruct=y,e.KnownCaipNamespace=g,e.isCaipChainId=function(t){return o.is.call(void 0,t,h)},e.isCaipNamespace=b,e.isCaipReference=w,e.isCaipAccountId=function(t){return o.is.call(void 0,t,d)},e.isCaipAccountAddress=function(t){return o.is.call(void 0,t,y)},e.parseCaipChainId=function(t){const e=s.exec(t);if(!n([e,\"optionalAccess\",t=>t.groups]))throw new Error(\"Invalid CAIP chain ID.\");return{namespace:e.groups.namespace,reference:e.groups.reference}},e.parseCaipAccountId=function(t){const e=u.exec(t);if(!n([e,\"optionalAccess\",t=>t.groups]))throw new Error(\"Invalid CAIP account ID.\");return{address:e.groups.accountAddress,chainId:e.groups.chainId,chain:{namespace:e.groups.namespace,reference:e.groups.reference}}},e.toCaipChainId=function(t,e){if(!b(t))throw new Error(`Invalid \"namespace\", must match: ${a.toString()}`);if(!w(e))throw new Error(`Invalid \"reference\", must match: ${c.toString()}`);return`${t}:${e}`}},1584:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0});var n,i,o=r(5244),s=class{constructor(t){o.__privateAdd.call(void 0,this,n,void 0),o.__privateSet.call(void 0,this,n,new Map(t)),Object.freeze(this)}get size(){return o.__privateGet.call(void 0,this,n).size}[Symbol.iterator](){return o.__privateGet.call(void 0,this,n)[Symbol.iterator]()}entries(){return o.__privateGet.call(void 0,this,n).entries()}forEach(t,e){return o.__privateGet.call(void 0,this,n).forEach(((r,n,i)=>t.call(e,r,n,this)))}get(t){return o.__privateGet.call(void 0,this,n).get(t)}has(t){return o.__privateGet.call(void 0,this,n).has(t)}keys(){return o.__privateGet.call(void 0,this,n).keys()}values(){return o.__privateGet.call(void 0,this,n).values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map((([t,e])=>`${String(t)} => ${String(e)}`)).join(\", \")} `:\"\"}}`}};n=new WeakMap;var a=class{constructor(t){o.__privateAdd.call(void 0,this,i,void 0),o.__privateSet.call(void 0,this,i,new Set(t)),Object.freeze(this)}get size(){return o.__privateGet.call(void 0,this,i).size}[Symbol.iterator](){return o.__privateGet.call(void 0,this,i)[Symbol.iterator]()}entries(){return o.__privateGet.call(void 0,this,i).entries()}forEach(t,e){return o.__privateGet.call(void 0,this,i).forEach(((r,n,i)=>t.call(e,r,n,this)))}has(t){return o.__privateGet.call(void 0,this,i).has(t)}keys(){return o.__privateGet.call(void 0,this,i).keys()}values(){return o.__privateGet.call(void 0,this,i).values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map((t=>String(t))).join(\", \")} `:\"\"}}`}};i=new WeakMap,Object.freeze(s),Object.freeze(s.prototype),Object.freeze(a),Object.freeze(a.prototype),e.FrozenMap=s,e.FrozenSet=a},2049:(t,e,r)=>{\"use strict\";Object.defineProperty(e,\"__esModule\",{value:!0}),r(7982);var n=r(1535);r(8383);var i=r(9705),o=r(9116);r(3207);var s=r(3631),a=r(7427);r(1305);var c=r(1275),u=r(2489),f=r(1508),h=r(1848),l=r(1203),p=r(5363),d=r(932),y=r(1486),g=r(6526),b=r(1584);r(5244),r(1423),e.AssertionError=d.AssertionError,e.CAIP_ACCOUNT_ADDRESS_REGEX=u.CAIP_ACCOUNT_ADDRESS_REGEX,e.CAIP_ACCOUNT_ID_REGEX=u.CAIP_ACCOUNT_ID_REGEX,e.CAIP_CHAIN_ID_REGEX=u.CAIP_CHAIN_ID_REGEX,e.CAIP_NAMESPACE_REGEX=u.CAIP_NAMESPACE_REGEX,e.CAIP_REFERENCE_REGEX=u.CAIP_REFERENCE_REGEX,e.CaipAccountAddressStruct=u.CaipAccountAddressStruct,e.CaipAccountIdStruct=u.CaipAccountIdStruct,e.CaipChainIdStruct=u.CaipChainIdStruct,e.CaipNamespaceStruct=u.CaipNamespaceStruct,e.CaipReferenceStruct=u.CaipReferenceStruct,e.ChecksumStruct=f.ChecksumStruct,e.Duration=o.Duration,e.ESCAPE_CHARACTERS_REGEXP=g.ESCAPE_CHARACTERS_REGEXP,e.FrozenMap=b.FrozenMap,e.FrozenSet=b.FrozenSet,e.HexAddressStruct=p.HexAddressStruct,e.HexChecksumAddressStruct=p.HexChecksumAddressStruct,e.HexStruct=p.HexStruct,e.JsonRpcErrorStruct=a.JsonRpcErrorStruct,e.JsonRpcFailureStruct=a.JsonRpcFailureStruct,e.JsonRpcIdStruct=a.JsonRpcIdStruct,e.JsonRpcNotificationStruct=a.JsonRpcNotificationStruct,e.JsonRpcParamsStruct=a.JsonRpcParamsStruct,e.JsonRpcRequestStruct=a.JsonRpcRequestStruct,e.JsonRpcResponseStruct=a.JsonRpcResponseStruct,e.JsonRpcSuccessStruct=a.JsonRpcSuccessStruct,e.JsonRpcVersionStruct=a.JsonRpcVersionStruct,e.JsonSize=g.JsonSize,e.JsonStruct=a.JsonStruct,e.KnownCaipNamespace=u.KnownCaipNamespace,e.PendingJsonRpcResponseStruct=a.PendingJsonRpcResponseStruct,e.StrictHexStruct=p.StrictHexStruct,e.UnsafeJsonStruct=a.UnsafeJsonStruct,e.VersionRangeStruct=s.VersionRangeStruct,e.VersionStruct=s.VersionStruct,e.add0x=p.add0x,e.assert=d.assert,e.assertExhaustive=d.assertExhaustive,e.assertIsBytes=p.assertIsBytes,e.assertIsHexString=p.assertIsHexString,e.assertIsJsonRpcError=a.assertIsJsonRpcError,e.assertIsJsonRpcFailure=a.assertIsJsonRpcFailure,e.assertIsJsonRpcNotification=a.assertIsJsonRpcNotification,e.assertIsJsonRpcRequest=a.assertIsJsonRpcRequest,e.assertIsJsonRpcResponse=a.assertIsJsonRpcResponse,e.assertIsJsonRpcSuccess=a.assertIsJsonRpcSuccess,e.assertIsPendingJsonRpcResponse=a.assertIsPendingJsonRpcResponse,e.assertIsSemVerRange=s.assertIsSemVerRange,e.assertIsSemVerVersion=s.assertIsSemVerVersion,e.assertIsStrictHexString=p.assertIsStrictHexString,e.assertStruct=d.assertStruct,e.base64=h.base64,e.base64ToBytes=p.base64ToBytes,e.bigIntToBytes=p.bigIntToBytes,e.bigIntToHex=n.bigIntToHex,e.bytesToBase64=p.bytesToBase64,e.bytesToBigInt=p.bytesToBigInt,e.bytesToHex=p.bytesToHex,e.bytesToNumber=p.bytesToNumber,e.bytesToSignedBigInt=p.bytesToSignedBigInt,e.bytesToString=p.bytesToString,e.calculateNumberSize=g.calculateNumberSize,e.calculateStringSize=g.calculateStringSize,e.concatBytes=p.concatBytes,e.createBigInt=l.createBigInt,e.createBytes=l.createBytes,e.createDataView=p.createDataView,e.createDeferredPromise=i.createDeferredPromise,e.createHex=l.createHex,e.createModuleLogger=c.createModuleLogger,e.createNumber=l.createNumber,e.createProjectLogger=c.createProjectLogger,e.exactOptional=a.exactOptional,e.getChecksumAddress=p.getChecksumAddress,e.getErrorMessage=y.getErrorMessage,e.getJsonRpcIdValidator=a.getJsonRpcIdValidator,e.getJsonSize=a.getJsonSize,e.getKnownPropertyNames=g.getKnownPropertyNames,e.getSafeJson=a.getSafeJson,e.gtRange=s.gtRange,e.gtVersion=s.gtVersion,e.hasProperty=g.hasProperty,e.hexToBigInt=n.hexToBigInt,e.hexToBytes=p.hexToBytes,e.hexToNumber=n.hexToNumber,e.inMilliseconds=o.inMilliseconds,e.isASCII=g.isASCII,e.isBytes=p.isBytes,e.isCaipAccountAddress=u.isCaipAccountAddress,e.isCaipAccountId=u.isCaipAccountId,e.isCaipChainId=u.isCaipChainId,e.isCaipNamespace=u.isCaipNamespace,e.isCaipReference=u.isCaipReference,e.isErrorWithCode=y.isErrorWithCode,e.isErrorWithMessage=y.isErrorWithMessage,e.isErrorWithStack=y.isErrorWithStack,e.isHexString=p.isHexString,e.isJsonRpcError=a.isJsonRpcError,e.isJsonRpcFailure=a.isJsonRpcFailure,e.isJsonRpcNotification=a.isJsonRpcNotification,e.isJsonRpcRequest=a.isJsonRpcRequest,e.isJsonRpcResponse=a.isJsonRpcResponse,e.isJsonRpcSuccess=a.isJsonRpcSuccess,e.isNonEmptyArray=g.isNonEmptyArray,e.isNullOrUndefined=g.isNullOrUndefined,e.isObject=g.isObject,e.isPendingJsonRpcResponse=a.isPendingJsonRpcResponse,e.isPlainObject=g.isPlainObject,e.isStrictHexString=p.isStrictHexString,e.isValidChecksumAddress=p.isValidChecksumAddress,e.isValidHexAddress=p.isValidHexAddress,e.isValidJson=a.isValidJson,e.isValidSemVerRange=s.isValidSemVerRange,e.isValidSemVerVersion=s.isValidSemVerVersion,e.jsonrpc2=a.jsonrpc2,e.numberToBytes=p.numberToBytes,e.numberToHex=n.numberToHex,e.object=a.object,e.parseCaipAccountId=u.parseCaipAccountId,e.parseCaipChainId=u.parseCaipChainId,e.remove0x=p.remove0x,e.satisfiesVersionRange=s.satisfiesVersionRange,e.signedBigIntToBytes=p.signedBigIntToBytes,e.stringToBytes=p.stringToBytes,e.timeSince=o.timeSince,e.toCaipChainId=u.toCaipChainId,e.valueToBytes=p.valueToBytes,e.wrapError=y.wrapError},2028:()=>{},3011:()=>{},3951:()=>{},7251:(t,e,r)=>{\"use strict\";r.r(e),r.d(e,{Struct:()=>f,StructError:()=>n,any:()=>I,array:()=>T,assert:()=>h,assign:()=>g,bigint:()=>x,boolean:()=>O,coerce:()=>J,create:()=>l,date:()=>k,defaulted:()=>Y,define:()=>b,deprecated:()=>w,dynamic:()=>m,empty:()=>Q,enums:()=>P,func:()=>R,instance:()=>B,integer:()=>C,intersection:()=>N,is:()=>d,lazy:()=>v,literal:()=>L,map:()=>U,mask:()=>p,max:()=>et,min:()=>rt,never:()=>j,nonempty:()=>nt,nullable:()=>M,number:()=>H,object:()=>F,omit:()=>E,optional:()=>D,partial:()=>_,pattern:()=>it,pick:()=>S,record:()=>$,refine:()=>st,regexp:()=>K,set:()=>V,size:()=>ot,string:()=>G,struct:()=>A,trimmed:()=>Z,tuple:()=>q,type:()=>W,union:()=>X,unknown:()=>z,validate:()=>y});class n extends TypeError{constructor(t,e){let r;const{message:n,explanation:i,...o}=t,{path:s}=t,a=0===s.length?n:`At path: ${s.join(\".\")} -- ${n}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[t,...e()])}}function i(t){return\"object\"==typeof t&&null!=t}function o(t){if(\"[object Object]\"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function s(t){return\"symbol\"==typeof t?t.toString():\"string\"==typeof t?JSON.stringify(t):`${t}`}function a(t,e,r,n){if(!0===t)return;!1===t?t={}:\"string\"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:a}=r,{refinement:c,message:u=`Expected a value of type \\`${a}\\`${c?` with refinement \\`${c}\\``:\"\"}, but received: \\`${s(n)}\\``}=t;return{value:n,type:a,refinement:c,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*c(t,e,r,n){var o;i(o=t)&&\"function\"==typeof o[Symbol.iterator]||(t=[t]);for(const i of t){const t=a(i,e,r,n);t&&(yield t)}}function*u(t,e,r={}){const{path:n=[],branch:o=[t],coerce:s=!1,mask:a=!1}=r,c={path:n,branch:o};if(s&&(t=e.coercer(t,c),a&&\"type\"!==e.type&&i(e.schema)&&i(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let f=\"valid\";for(const n of e.validator(t,c))n.explanation=r.message,f=\"not_valid\",yield[n,void 0];for(let[h,l,p]of e.entries(t,c)){const e=u(l,p,{path:void 0===h?n:[...n,h],branch:void 0===h?o:[...o,l],coerce:s,mask:a,message:r.message});for(const r of e)r[0]?(f=null!=r[0].refinement?\"not_refined\":\"not_valid\",yield[r[0],void 0]):s&&(l=r[1],void 0===h?t=l:t instanceof Map?t.set(h,l):t instanceof Set?t.add(l):i(t)&&(void 0!==l||h in t)&&(t[h]=l))}if(\"not_valid\"!==f)for(const n of e.refiner(t,c))n.explanation=r.message,f=\"not_refined\",yield[n,void 0];\"valid\"===f&&(yield[void 0,t])}class f{constructor(t){const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>c(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>c(i(t,e),e,this,t):()=>[]}assert(t,e){return h(t,this,e)}create(t,e){return l(t,this,e)}is(t){return d(t,this)}mask(t,e){return p(t,this,e)}validate(t,e={}){return y(t,this,e)}}function h(t,e,r){const n=y(t,e,{message:r});if(n[0])throw n[0]}function l(t,e,r){const n=y(t,e,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function p(t,e,r){const n=y(t,e,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function d(t,e){return!y(t,e)[0]}function y(t,e,r={}){const i=u(t,e,r),o=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(i);if(o[0]){return[new n(o[0],(function*(){for(const t of i)t[0]&&(yield t[0])})),void 0]}return[void 0,o[1]]}function g(...t){const e=\"type\"===t[0].type,r=t.map((t=>t.schema)),n=Object.assign({},...r);return e?W(n):F(n)}function b(t,e){return new f({type:t,schema:null,validator:e})}function w(t,e){return new f({...t,refiner:(e,r)=>void 0===e||t.refiner(e,r),validator:(r,n)=>void 0===r||(e(r,n),t.validator(r,n))})}function m(t){return new f({type:\"dynamic\",schema:null,*entries(e,r){const n=t(e,r);yield*n.entries(e,r)},validator:(e,r)=>t(e,r).validator(e,r),coercer:(e,r)=>t(e,r).coercer(e,r),refiner:(e,r)=>t(e,r).refiner(e,r)})}function v(t){let e;return new f({type:\"lazy\",schema:null,*entries(r,n){e??(e=t()),yield*e.entries(r,n)},validator:(r,n)=>(e??(e=t()),e.validator(r,n)),coercer:(r,n)=>(e??(e=t()),e.coercer(r,n)),refiner:(r,n)=>(e??(e=t()),e.refiner(r,n))})}function E(t,e){const{schema:r}=t,n={...r};for(const t of e)delete n[t];return\"type\"===t.type?W(n):F(n)}function _(t){const e=t instanceof f?{...t.schema}:{...t};for(const t in e)e[t]=D(e[t]);return F(e)}function S(t,e){const{schema:r}=t,n={};for(const t of e)n[t]=r[t];return F(n)}function A(t,e){return console.warn(\"superstruct@0.11 - The `struct` helper has been renamed to `define`.\"),b(t,e)}function I(){return b(\"any\",(()=>!0))}function T(t){return new f({type:\"array\",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||`Expected an array value, but received: ${s(t)}`})}function x(){return b(\"bigint\",(t=>\"bigint\"==typeof t))}function O(){return b(\"boolean\",(t=>\"boolean\"==typeof t))}function k(){return b(\"date\",(t=>t instanceof Date&&!isNaN(t.getTime())||`Expected a valid \\`Date\\` object, but received: ${s(t)}`))}function P(t){const e={},r=t.map((t=>s(t))).join();for(const r of t)e[r]=r;return new f({type:\"enums\",schema:e,validator:e=>t.includes(e)||`Expected one of \\`${r}\\`, but received: ${s(e)}`})}function R(){return b(\"func\",(t=>\"function\"==typeof t||`Expected a function, but received: ${s(t)}`))}function B(t){return b(\"instance\",(e=>e instanceof t||`Expected a \\`${t.name}\\` instance, but received: ${s(e)}`))}function C(){return b(\"integer\",(t=>\"number\"==typeof t&&!isNaN(t)&&Number.isInteger(t)||`Expected an integer, but received: ${s(t)}`))}function N(t){return new f({type:\"intersection\",schema:null,*entries(e,r){for(const n of t)yield*n.entries(e,r)},*validator(e,r){for(const n of t)yield*n.validator(e,r)},*refiner(e,r){for(const n of t)yield*n.refiner(e,r)}})}function L(t){const e=s(t),r=typeof t;return new f({type:\"literal\",schema:\"string\"===r||\"number\"===r||\"boolean\"===r?t:null,validator:r=>r===t||`Expected the literal \\`${e}\\`, but received: ${s(r)}`})}function U(t,e){return new f({type:\"map\",schema:null,*entries(r){if(t&&e&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,t],yield[n,i,e]},coercer:t=>t instanceof Map?new Map(t):t,validator:t=>t instanceof Map||`Expected a \\`Map\\` object, but received: ${s(t)}`})}function j(){return b(\"never\",(()=>!1))}function M(t){return new f({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function H(){return b(\"number\",(t=>\"number\"==typeof t&&!isNaN(t)||`Expected a number, but received: ${s(t)}`))}function F(t){const e=t?Object.keys(t):[],r=j();return new f({type:\"object\",schema:t||null,*entries(n){if(t&&i(n)){const i=new Set(Object.keys(n));for(const r of e)i.delete(r),yield[r,n[r],t[r]];for(const t of i)yield[t,n[t],r]}},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`,coercer:t=>i(t)?{...t}:t})}function D(t){return new f({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function $(t,e){return new f({type:\"record\",schema:null,*entries(r){if(i(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`})}function K(){return b(\"regexp\",(t=>t instanceof RegExp))}function V(t){return new f({type:\"set\",schema:null,*entries(e){if(t&&e instanceof Set)for(const r of e)yield[r,r,t]},coercer:t=>t instanceof Set?new Set(t):t,validator:t=>t instanceof Set||`Expected a \\`Set\\` object, but received: ${s(t)}`})}function G(){return b(\"string\",(t=>\"string\"==typeof t||`Expected a string, but received: ${s(t)}`))}function q(t){const e=j();return new f({type:\"tuple\",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;iArray.isArray(t)||`Expected an array, but received: ${s(t)}`})}function W(t){const e=Object.keys(t);return new f({type:\"type\",schema:t,*entries(r){if(i(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>i(t)||`Expected an object, but received: ${s(t)}`,coercer:t=>i(t)?{...t}:t})}function X(t){const e=t.map((t=>t.type)).join(\" | \");return new f({type:\"union\",schema:null,coercer(e){for(const r of t){const[t,n]=r.validate(e,{coerce:!0});if(!t)return n}return e},validator(r,n){const i=[];for(const e of t){const[...t]=u(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return[`Expected the value to satisfy a union of \\`${e}\\`, but received: ${s(r)}`,...i]}})}function z(){return b(\"unknown\",(()=>!0))}function J(t,e,r){return new f({...t,coercer:(n,i)=>d(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}function Y(t,e,r={}){return J(t,z(),(t=>{const n=\"function\"==typeof e?e():e;if(void 0===t)return n;if(!r.strict&&o(t)&&o(n)){const e={...t};let r=!1;for(const t in n)void 0===e[t]&&(e[t]=n[t],r=!0);if(r)return e}return t}))}function Z(t){return J(t,G(),(t=>t.trim()))}function Q(t){return st(t,\"empty\",(e=>{const r=tt(e);return 0===r||`Expected an empty ${t.type} but received one with a size of \\`${r}\\``}))}function tt(t){return t instanceof Map||t instanceof Set?t.size:t.length}function et(t,e,r={}){const{exclusive:n}=r;return st(t,\"max\",(r=>n?rn?r>e:r>=e||`Expected a ${t.type} greater than ${n?\"\":\"or equal to \"}${e} but received \\`${r}\\``))}function nt(t){return st(t,\"nonempty\",(e=>tt(e)>0||`Expected a nonempty ${t.type} but received an empty one`))}function it(t,e){return st(t,\"pattern\",(r=>e.test(r)||`Expected a ${t.type} matching \\`/${e.source}/\\` but received \"${r}\"`))}function ot(t,e,r=e){const n=`Expected a ${t.type}`,i=e===r?`of \\`${e}\\``:`between \\`${e}\\` and \\`${r}\\``;return st(t,\"size\",(t=>{if(\"number\"==typeof t||t instanceof Date)return e<=t&&t<=r||`${n} ${i} but received \\`${t}\\``;if(t instanceof Map||t instanceof Set){const{size:o}=t;return e<=o&&o<=r||`${n} with a size ${i} but received one with a size of \\`${o}\\``}{const{length:o}=t;return e<=o&&o<=r||`${n} with a length ${i} but received one with a length of \\`${o}\\``}}))}function st(t,e,r){return new f({...t,*refiner(n,i){yield*t.refiner(n,i);const o=c(r(n,i),i,t,n);for(const t of o)yield{...t,refinement:e}}})}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if(\"object\"==typeof globalThis)return globalThis;try{return this||new Function(\"return this\")()}catch(t){if(\"object\"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})};var n={};(()=>{\"use strict\";r.r(n),r.d(n,{onKeyringRequest:()=>Zn,onRpcRequest:()=>Yn,validateOrigin:()=>Jn});var t=r(7962);function e(t){return Boolean(t)&&\"object\"==typeof t&&!Array.isArray(t)}var i=(t,e)=>Object.hasOwnProperty.call(t,e);var o,s=((o=s||{})[o.Null=4]=\"Null\",o[o.Comma=1]=\"Comma\",o[o.Wrapper=1]=\"Wrapper\",o[o.True=4]=\"True\",o[o.False=5]=\"False\",o[o.Quote=1]=\"Quote\",o[o.Colon=1]=\"Colon\",o[o.Date=24]=\"Date\",o);function a(t){if(\"object\"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}}Error;var c=r(7251);function u(t){return function(t){return function(t){return\"object\"==typeof t&&null!==t&&\"message\"in t}(t)&&\"string\"==typeof t.message?t.message:null==t?\"\":String(t)}(t).replace(/\\.$/u,\"\")}function f(t,e){return r=t,Boolean(\"string\"==typeof r?.prototype?.constructor?.name)?new t({message:e}):t({message:e});var r}var h=class extends Error{constructor(t){super(t.message),this.code=\"ERR_ASSERTION\"}};function l(t,e=\"Assertion failed.\",r=h){if(!t){if(e instanceof Error)throw e;throw f(r,e)}}function p(t,e,r=\"Assertion failed\",n=h){try{(0,c.assert)(t,e)}catch(t){throw f(n,`${r}: ${u(t)}.`)}}var d=t=>(0,c.object)(t);function y({path:t,branch:e}){const r=t[t.length-1];return i(e[e.length-2],r)}function g(t){return new c.Struct({...t,type:`optional ${t.type}`,validator:(e,r)=>!y(r)||t.validator(e,r),refiner:(e,r)=>!y(r)||t.refiner(e,r)})}var b=(0,c.union)([(0,c.literal)(null),(0,c.boolean)(),(0,c.define)(\"finite number\",(t=>(0,c.is)(t,(0,c.number)())&&Number.isFinite(t))),(0,c.string)(),(0,c.array)((0,c.lazy)((()=>b))),(0,c.record)((0,c.string)(),(0,c.lazy)((()=>b)))]),w=(0,c.coerce)(b,(0,c.any)(),(t=>(p(t,b),JSON.parse(JSON.stringify(t,((t,e)=>{if(\"__proto__\"!==t&&\"constructor\"!==t)return e}))))));function m(t){try{return function(t){(0,c.create)(t,w)}(t),!0}catch{return!1}}var v=(0,c.literal)(\"2.0\"),E=(0,c.nullable)((0,c.union)([(0,c.number)(),(0,c.string)()])),_=d({code:(0,c.integer)(),message:(0,c.string)(),data:g(w),stack:g((0,c.string)())}),S=(0,c.union)([(0,c.record)((0,c.string)(),w),(0,c.array)(w)]);d({id:E,jsonrpc:v,method:(0,c.string)(),params:g(S)}),d({jsonrpc:v,method:(0,c.string)(),params:g(S)});(0,c.object)({id:E,jsonrpc:v,result:(0,c.optional)((0,c.unknown)()),error:(0,c.optional)(_)});var A=d({id:E,jsonrpc:v,result:w}),I=d({id:E,jsonrpc:v,error:_});(0,c.union)([A,I]);var T=r(2763),x={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},O={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901},k={\"-32700\":{standard:\"JSON RPC 2.0\",message:\"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.\"},\"-32600\":{standard:\"JSON RPC 2.0\",message:\"The JSON sent is not a valid Request object.\"},\"-32601\":{standard:\"JSON RPC 2.0\",message:\"The method does not exist / is not available.\"},\"-32602\":{standard:\"JSON RPC 2.0\",message:\"Invalid method parameter(s).\"},\"-32603\":{standard:\"JSON RPC 2.0\",message:\"Internal JSON-RPC error.\"},\"-32000\":{standard:\"EIP-1474\",message:\"Invalid input.\"},\"-32001\":{standard:\"EIP-1474\",message:\"Resource not found.\"},\"-32002\":{standard:\"EIP-1474\",message:\"Resource unavailable.\"},\"-32003\":{standard:\"EIP-1474\",message:\"Transaction rejected.\"},\"-32004\":{standard:\"EIP-1474\",message:\"Method not supported.\"},\"-32005\":{standard:\"EIP-1474\",message:\"Request limit exceeded.\"},4001:{standard:\"EIP-1193\",message:\"User rejected the request.\"},4100:{standard:\"EIP-1193\",message:\"The requested account and/or method has not been authorized by the user.\"},4200:{standard:\"EIP-1193\",message:\"The requested method is not supported by this Ethereum provider.\"},4900:{standard:\"EIP-1193\",message:\"The provider is disconnected from all chains.\"},4901:{standard:\"EIP-1193\",message:\"The provider is disconnected from the specified chain.\"}},P=x.internal,R=\"Unspecified error message. This is a bug, please report it.\",B=(C(P),\"Unspecified server error.\");function C(t,e=R){if(function(t){return Number.isInteger(t)}(t)){const e=t.toString();if(i(k,e))return k[e].message;if(function(t){return t>=-32099&&t<=-32e3}(t))return B}return e}function N(t){return Array.isArray(t)?t.map((t=>m(t)?t:e(t)?L(t):null)):e(t)?L(t):m(t)?t:null}function L(t){return Object.getOwnPropertyNames(t).reduce(((e,r)=>{const n=t[r];return m(n)&&(e[r]=n),e}),{})}var U=r(282),j=class extends Error{constructor(t,e,r){if(!Number.isInteger(t))throw new Error('\"code\" must be an integer.');if(!e||\"string\"!=typeof e)throw new Error('\"message\" must be a non-empty string.');super(e),this.code=t,void 0!==r&&(this.data=r)}serialize(){const t={code:this.code,message:this.message};return void 0!==this.data&&(t.data=this.data,a(this.data)&&(t.data.cause=N(this.data.cause))),this.stack&&(t.stack=this.stack),t}toString(){return U(this.serialize(),H,2)}},M=class extends j{constructor(t,e,r){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('\"code\" must be an integer such that: 1000 <= code <= 4999');super(t,e,r)}};function H(t,e){if(\"[Circular]\"!==e)return e}var F=t=>rt(x.parse,t),D=t=>rt(x.invalidRequest,t),$=t=>rt(x.invalidParams,t),K=t=>rt(x.methodNotFound,t),V=t=>rt(x.internal,t),G=t=>rt(x.invalidInput,t),q=t=>rt(x.resourceNotFound,t),W=t=>rt(x.resourceUnavailable,t),X=t=>rt(x.transactionRejected,t),z=t=>rt(x.methodNotSupported,t),J=t=>rt(x.limitExceeded,t),Y=t=>nt(O.userRejectedRequest,t),Z=t=>nt(O.unauthorized,t),Q=t=>nt(O.unsupportedMethod,t),tt=t=>nt(O.disconnected,t),et=t=>nt(O.chainDisconnected,t);function rt(t,e){const[r,n]=it(e);return new j(t,r??C(t),n)}function nt(t,e){const[r,n]=it(e);return new M(t,r??C(t),n)}function it(t){if(t){if(\"string\"==typeof t)return[t];if(\"object\"==typeof t&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&\"string\"!=typeof e)throw new Error(\"Must specify string message.\");return[e??void 0,r]}}return[]}r(1048).Buffer;!function(){const t=[]}();(0,c.pattern)((0,c.string)(),/^(?:0x)?[0-9a-f]+$/iu),(0,c.pattern)((0,c.string)(),/^0x[0-9a-f]+$/iu),(0,c.pattern)((0,c.string)(),/^0x[0-9a-f]{40}$/u);var ot=(0,c.pattern)((0,c.string)(),/^0x[0-9a-fA-F]{40}$/u);var st,at,ct,ut,ft=(t,e,r)=>{if(!e.has(t))throw TypeError(\"Cannot \"+r)},ht=(t,e,r)=>(ft(t,e,\"read from private field\"),r?r.call(t):e.get(t)),lt=(t,e,r)=>{if(e.has(t))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(t):e.set(t,r)},pt=(t,e,r,n)=>(ft(t,e,\"write to private field\"),n?n.call(t,r):e.set(t,r),r),dt=class extends Error{constructor(t,r={}){const n=function(t){if(e(t)&&i(t,\"message\")&&\"string\"==typeof t.message)return t.message;return String(t)}(t);super(n),lt(this,st,void 0),lt(this,at,void 0),lt(this,ct,void 0),lt(this,ut,void 0),pt(this,at,n),pt(this,st,function(t){if(e(t)&&i(t,\"code\")&&\"number\"==typeof t.code&&Number.isInteger(t.code))return t.code;return-32603}(t));const o={...wt(t),...r};Object.keys(o).length>0&&pt(this,ct,o),pt(this,ut,super.stack)}get name(){return\"SnapError\"}get code(){return ht(this,st)}get message(){return ht(this,at)}get data(){return ht(this,ct)}get stack(){return ht(this,ut)}toJSON(){return{code:gt,message:bt,data:{cause:{code:this.code,message:this.message,stack:this.stack,...this.data?{data:this.data}:{}}}}}serialize(){return this.toJSON()}};function yt(t){return class extends dt{constructor(e,r){if(\"object\"==typeof e){const r=t();return void super({code:r.code,message:r.message,data:e})}const n=t(e);super({code:n.code,message:n.message,data:r})}}}st=new WeakMap,at=new WeakMap,ct=new WeakMap,ut=new WeakMap;var gt=-31002,bt=\"Snap Error\";function wt(t){return e(t)&&i(t,\"data\")&&\"object\"==typeof t.data&&null!==t.data&&m(t.data)&&!Array.isArray(t.data)?t.data:{}}function mt(t){return(0,c.define)(JSON.stringify(t),(0,c.literal)(t).validator)}function vt(t){return mt(t)}function Et(t){return function([t,...e]){const r=(0,c.union)([t,...e]);return new c.Struct({...r,schema:[t,...e]})}(t)}function _t(t){try{return function(t){try{const r=t.trim();l(r.length>0);const n=new T.XMLParser({ignoreAttributes:!1,parseAttributeValue:!0}).parse(r,!0);return l(i(n,\"svg\")),e(n.svg)?n.svg:{}}catch{throw new Error(\"Snap icon must be a valid SVG.\")}}(t),!0}catch{return!1}}var St=yt(V),At=yt(G),It=yt($),Tt=yt(D),xt=yt(J),Ot=yt(K),kt=yt(z),Pt=yt(F),Rt=yt(q),Bt=yt(W),Ct=yt(X),Nt=yt(et),Lt=yt(tt),Ut=yt(Z),jt=yt(Q),Mt=yt(Y);function Ht(t,e,r=[]){return(...n)=>{if(1===n.length&&a(n[0])){const r={...n[0],type:t};return p(r,e,`Invalid ${t} component`),r}const i=r.reduce(((t,e,r)=>void 0!==n[r]?{...t,[e]:n[r]}:t),{type:t});return p(i,e,`Invalid ${t} component`),i}}var Ft,Dt=((Ft=Dt||{}).Copyable=\"copyable\",Ft.Divider=\"divider\",Ft.Heading=\"heading\",Ft.Panel=\"panel\",Ft.Spinner=\"spinner\",Ft.Text=\"text\",Ft.Image=\"image\",Ft.Row=\"row\",Ft.Address=\"address\",Ft.Button=\"button\",Ft.Input=\"input\",Ft.Form=\"form\",Ft),$t=(0,c.object)({type:(0,c.string)()}),Kt=(0,c.assign)($t,(0,c.object)({value:(0,c.unknown)()})),Vt=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"address\"),value:ot})),Gt=(Ht(\"address\",Vt,[\"value\"]),(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"copyable\"),value:(0,c.string)(),sensitive:(0,c.optional)((0,c.boolean)())}))),qt=(Ht(\"copyable\",Gt,[\"value\",\"sensitive\"]),(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"divider\")}))),Wt=Ht(\"divider\",qt),Xt=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"heading\"),value:(0,c.string)()})),zt=Ht(\"heading\",Xt,[\"value\"]);var Jt,Yt,Zt,Qt,te=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"image\"),value:(0,c.refine)((0,c.string)(),\"SVG\",(t=>!!_t(t)||\"Value is not a valid SVG.\"))})),ee=(Ht(\"image\",te,[\"value\"]),(Jt=ee||{}).Primary=\"primary\",Jt.Secondary=\"secondary\",Jt),re=((Yt=re||{}).Button=\"button\",Yt.Submit=\"submit\",Yt),ne=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"button\"),value:(0,c.string)(),variant:(0,c.optional)((0,c.union)([vt(\"primary\"),vt(\"secondary\")])),buttonType:(0,c.optional)((0,c.union)([vt(\"button\"),vt(\"submit\")])),name:(0,c.optional)((0,c.string)())})),ie=(Ht(\"button\",ne,[\"value\",\"buttonType\",\"name\",\"variant\"]),(Zt=ie||{}).Text=\"text\",Zt.Number=\"number\",Zt.Password=\"password\",Zt),oe=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"input\"),value:(0,c.optional)((0,c.string)()),name:(0,c.string)(),inputType:(0,c.optional)((0,c.union)([vt(\"text\"),vt(\"password\"),vt(\"number\")])),placeholder:(0,c.optional)((0,c.string)()),label:(0,c.optional)((0,c.string)()),error:(0,c.optional)((0,c.string)())})),se=(Ht(\"input\",oe,[\"name\",\"inputType\",\"placeholder\",\"value\",\"label\"]),(0,c.union)([oe,ne])),ae=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"form\"),children:(0,c.array)(se),name:(0,c.string)()})),ce=(Ht(\"form\",ae,[\"name\",\"children\"]),(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"text\"),value:(0,c.string)(),markdown:(0,c.optional)((0,c.boolean)())}))),ue=Ht(\"text\",ce,[\"value\",\"markdown\"]),fe=((Qt=fe||{}).Default=\"default\",Qt.Critical=\"critical\",Qt.Warning=\"warning\",Qt),he=(0,c.union)([te,ce,Vt]),le=(0,c.assign)(Kt,(0,c.object)({type:(0,c.literal)(\"row\"),variant:(0,c.optional)((0,c.union)([vt(\"default\"),vt(\"critical\"),vt(\"warning\")])),label:(0,c.string)(),value:he})),pe=Ht(\"row\",le,[\"label\",\"value\",\"variant\"]),de=(0,c.assign)($t,(0,c.object)({type:(0,c.literal)(\"spinner\")})),ye=(Ht(\"spinner\",de),(0,c.assign)($t,(0,c.object)({children:(0,c.array)((0,c.lazy)((()=>we)))}))),ge=(0,c.assign)(ye,(0,c.object)({type:(0,c.literal)(\"panel\")})),be=Ht(\"panel\",ge,[\"children\"]),we=(0,c.union)([Gt,qt,Xt,te,ge,de,ce,le,Vt,oe,ae,ne]);var me,ve,Ee,_e,Se,Ae,Ie=((me=Ie||{}).Critical=\"critical\",me),Te=((ve=Te||{}).ButtonClickEvent=\"ButtonClickEvent\",ve.FormSubmitEvent=\"FormSubmitEvent\",ve.InputChangeEvent=\"InputChangeEvent\",ve),xe=(0,c.object)({type:(0,c.string)(),name:(0,c.optional)((0,c.string)())}),Oe=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"ButtonClickEvent\"),name:(0,c.optional)((0,c.string)())})),ke=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"FormSubmitEvent\"),value:(0,c.record)((0,c.string)(),(0,c.nullable)((0,c.string)())),name:(0,c.string)()})),Pe=(0,c.assign)(xe,(0,c.object)({type:(0,c.literal)(\"InputChangeEvent\"),name:(0,c.string)(),value:(0,c.string)()})),Re=((0,c.union)([Oe,ke,Pe]),(Ee=Re||{}).Alert=\"alert\",Ee.Confirmation=\"confirmation\",Ee.Prompt=\"prompt\",Ee),Be=((_e=Be||{}).Base64=\"base64\",_e.Hex=\"hex\",_e.Utf8=\"utf8\",_e),Ce=((Se=Ce||{}).ClearState=\"clear\",Se.GetState=\"get\",Se.UpdateState=\"update\",Se),Ne=((Ae=Ne||{}).InApp=\"inApp\",Ae.Native=\"native\",Ae),Le=Et([(0,c.string)(),(0,c.number)()]),Ue=je((0,c.string)());(0,c.object)({type:(0,c.string)(),props:(0,c.record)((0,c.string)(),w),key:(0,c.nullable)(Le)});function je(t){return Et([t,(0,c.array)(t)])}function Me(t,e={}){return(0,c.object)({type:mt(t),props:(0,c.object)(e),key:(0,c.nullable)(Le)})}var He,Fe,De=Me(\"Button\",{children:Ue,name:(0,c.optional)((0,c.string)()),type:(0,c.optional)(Et([mt(\"button\"),mt(\"submit\")])),variant:(0,c.optional)(Et([mt(\"primary\"),mt(\"destructive\")])),disabled:(0,c.optional)((0,c.boolean)())}),$e=Me(\"Input\",{name:(0,c.string)(),type:(0,c.optional)(Et([mt(\"text\"),mt(\"password\"),mt(\"number\")])),value:(0,c.optional)((0,c.string)()),placeholder:(0,c.optional)((0,c.string)())}),Ke=Me(\"Option\",{value:(0,c.string)(),children:(0,c.string)()}),Ve=Me(\"Dropdown\",{name:(0,c.string)(),value:(0,c.optional)((0,c.string)()),children:je(Ke)}),Ge=Me(\"Field\",{label:(0,c.optional)((0,c.string)()),error:(0,c.optional)((0,c.string)()),children:Et([(0,c.tuple)([$e,De]),$e,Ve])}),qe=Me(\"Form\",{children:je(Et([Ge,De])),name:(0,c.string)()}),We=Me(\"Bold\",{children:je((0,c.nullable)(Et([(0,c.string)(),(0,c.lazy)((()=>Xe))])))}),Xe=Me(\"Italic\",{children:je((0,c.nullable)(Et([(0,c.string)(),(0,c.lazy)((()=>We))])))}),ze=Et([We,Xe]),Je=Me(\"Address\",{address:ot}),Ye=Me(\"Box\",{children:je((0,c.nullable)((0,c.lazy)((()=>ar)))),direction:(0,c.optional)(Et([mt(\"horizontal\"),mt(\"vertical\")])),alignment:(0,c.optional)(Et([mt(\"start\"),mt(\"center\"),mt(\"end\"),mt(\"space-between\"),mt(\"space-around\")]))}),Ze=Me(\"Copyable\",{value:(0,c.string)(),sensitive:(0,c.optional)((0,c.boolean)())}),Qe=Me(\"Divider\"),tr=Me(\"Value\",{value:(0,c.string)(),extra:(0,c.string)()}),er=Me(\"Heading\",{children:Ue}),rr=Me(\"Image\",{src:(0,c.string)(),alt:(0,c.optional)((0,c.string)())}),nr=Me(\"Link\",{href:(0,c.string)(),children:je((0,c.nullable)(Et([ze,(0,c.string)()])))}),ir=Me(\"Text\",{children:je((0,c.nullable)(Et([(0,c.string)(),We,Xe,nr])))}),or=Me(\"Row\",{label:(0,c.string)(),children:Et([Je,rr,ir,tr]),variant:(0,c.optional)(Et([mt(\"default\"),mt(\"warning\"),mt(\"error\")]))}),sr=Me(\"Spinner\"),ar=Et([De,$e,qe,We,Xe,Je,Ye,Ze,Qe,er,rr,nr,or,sr,ir,Ve]),cr=ar,ur=(Et([De,$e,Ge,qe,We,Xe,Je,Ye,Ze,Qe,er,rr,nr,or,sr,ir,Ve,Ke,tr]),(0,c.record)((0,c.string)(),(0,c.nullable)((0,c.string)())));(0,c.record)((0,c.string)(),(0,c.union)([ur,(0,c.nullable)((0,c.string)())])),(0,c.union)([we,cr]),(0,c.record)((0,c.string)(),w);!function(t){t.Mainnet=\"bip122:000000000019d6689c085ae165831e93\",t.Testnet=\"bip122:000000000933ea01ad0ee984209779ba\"}(He||(He={})),function(t){t.Btc=\"bip122:000000000019d6689c085ae165831e93/slip44:0\",t.TBtc=\"bip122:000000000933ea01ad0ee984209779ba/slip44:0\"}(Fe||(Fe={}));const fr={onChainService:{dataClient:{options:{apiKey:\"A___agdRpkDchYPuxqWhXfFidteuWj4m\"}}},wallet:{defaultAccountIndex:0,defaultAccountType:\"bip122:p2wpkh\"},avaliableNetworks:Object.values(He),avaliableAssets:Object.values(Fe),unit:\"BTC\",explorer:{[He.Mainnet]:\"https://blockstream.info/address/${address}\",[He.Testnet]:\"https://blockstream.info/testnet/address/${address}\"},logLevel:\"6\"},hr={randomUUID:\"undefined\"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let lr;const pr=new Uint8Array(16);function dr(){if(!lr&&(lr=\"undefined\"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!lr))throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");return lr(pr)}const yr=[];for(let t=0;t<256;++t)yr.push((t+256).toString(16).slice(1));function gr(t,e=0){return yr[t[e+0]]+yr[t[e+1]]+yr[t[e+2]]+yr[t[e+3]]+\"-\"+yr[t[e+4]]+yr[t[e+5]]+\"-\"+yr[t[e+6]]+yr[t[e+7]]+\"-\"+yr[t[e+8]]+yr[t[e+9]]+\"-\"+yr[t[e+10]]+yr[t[e+11]]+yr[t[e+12]]+yr[t[e+13]]+yr[t[e+14]]+yr[t[e+15]]}const br=function(t,e,r){if(hr.randomUUID&&!e&&!t)return hr.randomUUID();const n=(t=t||{}).random||(t.rng||dr)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(let t=0;t<16;++t)e[r+t]=n[t];return e}return gr(n)};class wr extends Error{name;constructor(t){super(t),Object.defineProperty(this,\"name\",{value:new.target.name,enumerable:!1,configurable:!0}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace(this,this.constructor)}}function mr(t,e){return t instanceof e?t:new e(t.message)}function vr(t){return[dt,Ot,Mt,kt,Ot,Pt,Rt,Bt,Ct,Nt,Lt,Ut,jt,St,At,It,Tt,xt].some((e=>t instanceof e))}var Er=r(1048);function _r(t,e=!0){try{return Er.Buffer.from(e?function(t){return t.startsWith(\"0x\")?t.substring(2):t}(t):t,\"hex\")}catch(t){throw new Error(\"Unable to convert hex string to buffer\")}}function Sr(t,e){try{return t.toString(e)}catch(t){throw new Error(\"Unable to convert buffer to string\")}}const Ar=(0,c.enums)(fr.avaliableAssets),Ir=(0,c.enums)(fr.avaliableNetworks),Tr=(0,c.pattern)((0,c.string)(),/^(?!0\\d)(\\d+(\\.\\d+)?)$/u),xr=(new Error(\"timeout while waiting for mutex to become available\"),new Error(\"mutex already locked\"),new Error(\"request for lock canceled\"));var Or=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};class kr{constructor(t,e=xr){if(this._maxConcurrency=t,this._cancelError=e,this._queue=[],this._waiters=[],t<=0)throw new Error(\"semaphore must be initialized to a positive value\");this._value=t}acquire(){const t=this.isLocked(),e=new Promise(((t,e)=>this._queue.push({resolve:t,reject:e})));return t||this._dispatch(),e}runExclusive(t){return Or(this,void 0,void 0,(function*(){const[e,r]=yield this.acquire();try{return yield t(e)}finally{r()}}))}waitForUnlock(){return Or(this,void 0,void 0,(function*(){if(!this.isLocked())return Promise.resolve();return new Promise((t=>this._waiters.push({resolve:t})))}))}isLocked(){return this._value<=0}release(){if(this._maxConcurrency>1)throw new Error(\"this method is unavailable on semaphores with concurrency > 1; use the scoped release returned by acquire instead\");if(this._currentReleaser){const t=this._currentReleaser;this._currentReleaser=void 0,t()}}cancel(){this._queue.forEach((t=>t.reject(this._cancelError))),this._queue=[]}_dispatch(){const t=this._queue.shift();if(!t)return;let e=!1;this._currentReleaser=()=>{e||(e=!0,this._value++,this._resolveWaiters(),this._dispatch())},t.resolve([this._value--,this._currentReleaser])}_resolveWaiters(){this._waiters.forEach((t=>t.resolve())),this._waiters=[]}}var Pr=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))};class Rr{constructor(t){this._semaphore=new kr(1,t)}acquire(){return Pr(this,void 0,void 0,(function*(){const[,t]=yield this._semaphore.acquire();return t}))}runExclusive(t){return this._semaphore.runExclusive((()=>t()))}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Br=new Rr;var Cr;!function(t){t[t.ERROR=1]=\"ERROR\",t[t.WARN=2]=\"WARN\",t[t.INFO=3]=\"INFO\",t[t.DEBUG=4]=\"DEBUG\",t[t.TRACE=5]=\"TRACE\",t[t.ALL=6]=\"ALL\",t[t.OFF=0]=\"OFF\"}(Cr||(Cr={}));const Nr=(t,...e)=>{};const Lr=new class{log;warn;error;debug;info;trace;#t=Cr.OFF;set logLevel(t){this.#t=t,this.init()}get logLevel(){return this.#t}init(){this.error=console.error.bind(console),this.warn=console.warn.bind(console),this.info=console.info.bind(console),this.debug=console.debug.bind(console),this.trace=console.trace.bind(console),this.log=console.log.bind(console),this.#t{const e=await this.get();await t(e),await this.set(e)}))}async withTransaction(t){await this.mtx.runExclusive((async()=>{if(await this.#n(),!this.#e.current||!this.#e.orgState||!this.#e.id)throw new Error(\"Failed to begin transaction\");Lr.info(`SnapStateManager.withTransaction [${this.#r}]: begin transaction`);try{await t(this.#e.current),await this.set(this.#e.current)}catch(t){throw Lr.info(`SnapStateManager.withTransaction [${this.#r}]: error : ${JSON.stringify(t.message)}`),await this.#i(),t}finally{this.#o()}}))}async commit(){if(!this.#e.current||!this.#e.orgState)throw new Error(\"Failed to commit transaction\");this.#e.hasCommited=!0,await this.set(this.#e.current)}async#n(){this.#e={id:br(),orgState:await this.get(),current:await this.get(),isRollingBack:!1,hasCommited:!1}}async#i(){try{this.#e.hasCommited&&!this.#e.isRollingBack&&this.#e.orgState&&(Lr.info(`SnapStateManager.rollback [${this.#r}]: attemp to rollback state`),this.#e.isRollingBack=!0,await this.set(this.#e.orgState))}catch(t){throw Lr.info(`SnapStateManager.rollback [${this.#r}]: error : ${JSON.stringify(t)}`),new Error(\"Failed to rollback state\")}}#o(){this.#e.orgState=void 0,this.#e.current=void 0,this.#e.id=void 0,this.#e.isRollingBack=!1,this.#e.hasCommited=!1}get#r(){return this.#e.id??\"\"}}function jr(t,e){try{(0,c.assert)(t,e)}catch(t){throw new It(t.message)}}function Mr(t,e){try{(0,c.assert)(t,e)}catch(t){throw new dt(\"Invalid Response\")}}var Hr=1e6,Fr=1e6,Dr=\"[big.js] \",$r=Dr+\"Invalid \",Kr=$r+\"decimal places\",Vr=$r+\"rounding mode\",Gr=Dr+\"Division by zero\",qr={},Wr=void 0,Xr=/^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i;function zr(t,e,r,n){var i=t.c;if(r===Wr&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(Vr);if(e<1)n=3===r&&(n||!!i[0])||0===e&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(n||i[1]!==Wr))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e=5||2===r&&(i[e]>5||5===i[e]&&(n||i[e+1]!==Wr||1&i[e-1]))||3===r&&(n||!!i[0]),i.length=e,n)for(;++i[--e]>9;)if(i[e]=0,0===e){++t.e,i.unshift(1);break}for(e=i.length;!i[--e];)i.pop()}return t}function Jr(t,e,r){var n=t.e,i=t.c.join(\"\"),o=i.length;if(e)i=i.charAt(0)+(o>1?\".\"+i.slice(1):\"\")+(n<0?\"e\":\"e+\")+n;else if(n<0){for(;++n;)i=\"0\"+i;i=\"0.\"+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+=\"0\";else n1&&(i=i.charAt(0)+\".\"+i.slice(1));return t.s<0&&r?\"-\"+i:i}qr.abs=function(){var t=new this.constructor(this);return t.s=1,t},qr.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,s=t.s,a=r.e,c=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(e=o<0,a!=c)return a>c^e?1:-1;for(s=(a=n.length)<(c=i.length)?a:c,o=-1;++oi[o]^e?1:-1;return a==c?0:a>c^e?1:-1},qr.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,o=e.s==t.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>Hr)throw Error(Kr);if(!i[0])throw Error(Gr);if(!n[0])return t.s=o,t.c=[t.e=0],t;var a,c,u,f,h,l=i.slice(),p=a=i.length,d=n.length,y=n.slice(0,a),g=y.length,b=t,w=b.c=[],m=0,v=s+(b.e=e.e-t.e)+1;for(b.s=o,o=v<0?0:v,l.unshift(0);g++g?1:-1;else for(h=-1,f=0;++hy[h]?1:-1;break}if(!(f<0))break;for(c=g==a?i:l;g;){if(y[--g]v&&zr(b,v,r.RM,y[0]!==Wr),b},qr.eq=function(t){return 0===this.cmp(t)},qr.gt=function(t){return this.cmp(t)>0},qr.gte=function(t){return this.cmp(t)>-1},qr.lt=function(t){return this.cmp(t)<0},qr.lte=function(t){return this.cmp(t)<1},qr.minus=qr.sub=function(t){var e,r,n,i,o=this,s=o.constructor,a=o.s,c=(t=new s(t)).s;if(a!=c)return t.s=-c,o.plus(t);var u=o.c.slice(),f=o.e,h=t.c,l=t.e;if(!u[0]||!h[0])return h[0]?t.s=-c:u[0]?t=new s(o):t.s=1,t;if(a=f-l){for((i=a<0)?(a=-a,n=u):(l=f,n=h),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(r=((i=u.length0)for(;c--;)u[e++]=0;for(c=e;r>a;){if(u[--r]0?(c=s,n=u):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-u.length<0&&(n=u,u=a,a=n),e=u.length,r=0;e;a[e]%=10)r=(a[--e]=a[e]+u[e]+r)/10|0;for(r&&(a.unshift(r),++c),e=a.length;0===a[--e];)a.pop();return t.c=a,t.e=c,t},qr.pow=function(t){var e=this,r=new e.constructor(\"1\"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>Fr)throw Error($r+\"exponent\");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},qr.prec=function(t,e){if(t!==~~t||t<1||t>Hr)throw Error($r+\"precision\");return zr(new this.constructor(this),t,e)},qr.round=function(t,e){if(t===Wr)t=0;else if(t!==~~t||t<-Hr||t>Hr)throw Error(Kr);return zr(new this.constructor(this),t+this.e+1,e)},qr.sqrt=function(){var t,e,r,n=this,i=n.constructor,o=n.s,s=n.e,a=new i(\"0.5\");if(!n.c[0])return new i(n);if(o<0)throw Error(Dr+\"No square root\");0===(o=Math.sqrt(n+\"\"))||o===1/0?((e=n.c.join(\"\")).length+s&1||(e+=\"0\"),s=((s+1)/2|0)-(s<0||1&s),t=new i(((o=Math.sqrt(e))==1/0?\"5e\":(o=o.toExponential()).slice(0,o.indexOf(\"e\")+1))+s)):t=new i(o+\"\"),s=t.e+(i.DP+=4);do{r=t,t=a.times(r.plus(n.div(r)))}while(r.c.slice(0,s).join(\"\")!==t.c.slice(0,s).join(\"\"));return zr(t,(i.DP-=4)+t.e+1,i.RM)},qr.times=qr.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,s=i.length,a=o.length,c=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=c+u,sc;)a=e[u]+o[c]*i[u-c-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},qr.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==Wr){if(t!==~~t||t<0||t>Hr)throw Error(Kr);for(r=zr(new r.constructor(r),++t,e);r.c.lengthHr)throw Error(Kr);for(t=t+(r=zr(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length=e.PE,!!t.c[0])},qr.toNumber=function(){var t=Number(Jr(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(Dr+\"Imprecise conversion\");return t},qr.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==Wr){if(t!==~~t||t<1||t>Hr)throw Error($r+\"precision\");for(r=zr(new n(r),t,e);r.c.length=n.PE,!!i)},qr.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(Dr+\"valueOf disallowed\");return Jr(t,t.e<=e.NE||t.e>=e.PE,!0)};var Yr=function t(){function e(r){var n=this;if(!(n instanceof e))return r===Wr?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if(\"string\"!=typeof r){if(!0===e.strict&&\"bigint\"!=typeof r)throw TypeError($r+\"value\");r=0===r&&1/r<0?\"-0\":String(r)}!function(t,e){var r,n,i;if(!Xr.test(e))throw Error($r+\"number\");t.s=\"-\"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf(\".\"))>-1&&(e=e.replace(\".\",\"\"));(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length);for(i=e.length,n=0;n0&&\"0\"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=qr,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();const Zr=Yr,Qr=21e14;function tn(t,e=!1){if(\"number\"==typeof t&&!Number.isInteger(t))throw new Error(\"satsToBtc must be called on an integer number\");const r=new Zr(t).div(1e8).toFixed(8);return e?`${r} ${fr.unit}`:r}function en(t){const e=t.split(\".\");if(e.length>1&&e[1].length>8)throw new Error(\"BTC amount is out of range\");const r=new Zr(t).times(1e8);if(r.lt(0)||r.gt(Qr))throw new Error(\"BTC amount is out of range\");return BigInt(r.toFixed(0))}class rn extends wr{}class nn extends wr{}var on,sn,an,cn=r(7612);class un{_dataClient;_options;constructor(t,e){this._dataClient=t,this._options=e}get network(){return this._options.network}async getBalances(t,e){try{if(e.length>1)throw new nn(\"Only one asset is supported\");if(!new Set(Object.values(Fe)).has(e[0])||this.network===cn.o8.testnet&&e[0]!==Fe.TBtc||this.network===cn.o8.bitcoin&&e[0]!==Fe.Btc)throw new nn(\"Invalid asset\");const r=await this._dataClient.getBalances(t);return t.reduce(((t,n)=>(t.balances[n]={[e[0]]:{amount:BigInt(r[n])}},t)),{balances:{}})}catch(t){throw mr(t,nn)}}async getFeeRates(){try{const t=await this._dataClient.getFeeRates();return{fees:Object.entries(t).map((([t,e])=>({type:t,rate:BigInt(e)})))}}catch(t){throw mr(t,nn)}}async getTransactionStatus(t){try{return await this._dataClient.getTransactionStatus(t)}catch(t){throw new nn(t)}}async getDataForTransaction(t){try{return{data:{utxos:await this._dataClient.getUtxos(t)}}}catch(t){throw mr(t,nn)}}async broadcastTransaction(t){try{return{transactionId:await this._dataClient.sendTransaction(t)}}catch(t){throw mr(t,nn)}}listTransactions(){throw new Error(\"Method not implemented.\")}}!function(t){t.Fast=\"fast\",t.Medium=\"medium\",t.Slow=\"slow\"}(on||(on={})),function(t){t.Confirmed=\"confirmed\",t.Pending=\"pending\",t.Failed=\"failed\"}(sn||(sn={}));class fn{_options;constructor(t){this._options=t}get baseUrl(){switch(this._options.network){case cn.o8.bitcoin:return\"https://api.blockchair.com/bitcoin\";case cn.o8.testnet:return\"https://api.blockchair.com/bitcoin/testnet\";default:throw new Error(\"Invalid network\")}}getApiUrl(t){const e=new URL(`${this.baseUrl}${t}`);return this._options.apiKey&&e.searchParams.append(\"key\",this._options.apiKey),e.toString()}async get(t){const e=await fetch(this.getApiUrl(t),{method:\"GET\"});if(!e.ok)throw new Error(`Failed to fetch data from blockchair: ${e.statusText}`);return e.json()}async post(t,e){const r=await fetch(this.getApiUrl(t),{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(e)});if(400==r.status){const t=await r.json();throw new Error(`Failed to post data from blockchair: ${t.context.error}`)}if(!r.ok)throw new Error(`Failed to post data from blockchair: ${r.statusText}`);return r.json()}async getTxDashboardData(t){try{Lr.info(\"[BlockChairClient.getTxDashboardData] start:\");const e=await this.get(`/dashboards/transaction/${t}`);return Lr.info(`[BlockChairClient.getTxDashboardData] response: ${JSON.stringify(e)}`),e}catch(t){throw Lr.info(`[BlockChairClient.getTxDashboardData] error: ${t.message}`),mr(t,rn)}}async getBalances(t){try{Lr.info(`[BlockChairClient.getBalance] start: { addresses : ${JSON.stringify(t)} }`);const e=await this.get(`/addresses/balances?addresses=${t.join(\",\")}`);return Lr.info(`[BlockChairClient.getBalance] response: ${JSON.stringify(e)}`),t.reduce(((t,r)=>(t[r]=e.data[r]??0,t)),{})}catch(t){throw Lr.info(`[BlockChairClient.getBalance] error: ${t.message}`),mr(t,rn)}}async getUtxos(t,e){try{let r=!0,n=0;const i=1e3,o=[];for(;r;){let s=`/dashboards/address/${t}?limit=0,${i}&offset=0,${n}`;e||(s+=\"&state=latest\");const a=await this.get(s);if(Lr.info(`[BlockChairClient.getUtxos] response: ${JSON.stringify(a)}`),!Object.prototype.hasOwnProperty.call(a.data,t))throw new Error(\"Data not avaiable\");a.data[t].utxo.forEach((t=>{o.push({block:t.block_id,txHash:t.transaction_hash,index:t.index,value:t.value})})),n+=1,a.data[t].utxo.lengththis.validateInputs(t,e,r))))throw new dn(\"Invalid signature to sign the PSBT's inputs\")}catch(t){throw mr(t,dn)}}finalize(){try{this._psbt.finalizeAllInputs();const t=this._psbt.extractTransaction().toHex();if(this._psbt.extractTransaction().weight()>4e5)throw new dn(\"Transaction is too large\");return t}catch(t){throw mr(t,dn)}}validateInputs(t,e,r){return xn.fromPublicKey(t).verify(e,r)}}class kn{publicKey;fingerprint;_node;constructor(t,e){this._node=t,this.publicKey=this._node.publicKey,this.fingerprint=e??this._node.fingerprint}derivePath(t){try{let e=t.split(\"/\");\"m\"===e[0]&&(e=e.slice(1));const r=e.reduce(((t,e)=>{let r;return e.endsWith(\"'\")?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this._node);return new kn(r,this.fingerprint)}catch(t){throw new Error(\"Unable to derive path\")}}async sign(t){return this._node.sign(t)}verify(t,e){return this._node.verify(t,e)}}class Pn{sender;_change;_recipients;_outputTotal;_txFee;_feeRate;constructor(t,e){this.feeRate=e,this.txFee=0,this.sender=t,this._recipients=[],this._outputTotal=BigInt(0)}addRecipients(t){for(const e of t)this.addRecipient(e)}addRecipient(t){this._outputTotal+=t.bigIntValue,this._recipients.push({address:t.address,value:t.bigIntValue})}addChange(t){this._change={address:t.address,value:t.bigIntValue}}set txFee(t){this._txFee=\"number\"==typeof t?BigInt(t):t}get txFee(){return this._txFee}set feeRate(t){this._feeRate=\"number\"==typeof t?BigInt(t):t}get feeRate(){return this._feeRate}get total(){return this._outputTotal+(this.change?BigInt(this.change.value):BigInt(0))+this.txFee}get recipients(){return this._recipients}get change(){return this._change}}class Rn{_value;script;txHash;index;block;constructor(t,e){this.script=e,this._value=BigInt(t.value),this.index=t.index,this.txHash=t.txHash,this.block=t.block}get value(){return Number(this._value)}get bigIntValue(){return this._value}}class Bn{_value;script;address;constructor(t,e,r){this.value=t,this.address=e,this.script=r}get value(){return Number(this._value)}set value(t){this._value=\"number\"==typeof t?BigInt(t):t}get bigIntValue(){return this._value}}class Cn{_deriver;_network;constructor(t,e){this._deriver=t,this._network=e}async unlock(t,e){try{const r=this.getAccountCtor(e??an.P2wpkh),n=await this._deriver.getRoot(r.path),i=await this._deriver.getChild(n,t),o=[\"m\",\"0'\",\"0\",`${t}`].join(\"/\");return new r(Sr(n.fingerprint,\"hex\"),t,o,Sr(i.publicKey,\"hex\"),this._network,r.scriptType,`bip122:${r.scriptType.toLowerCase()}`,this.getHdSigner(n))}catch(t){throw mr(t,ln)}}async createTransaction(t,e,r){const n=t.script,{scriptType:i}=t,o=r.utxos.map((t=>new Rn(t,n))),s=e.map((t=>{if(bn(t.value,i))throw new pn(\"Transaction amount too small\");const e=function(t,e){try{return cn.hl.toOutputScript(t,e)}catch(t){throw new Error(\"Destination address has no matching Script\")}}(t.address,this._network);return new Bn(t.value,t.address,e)})),a=Math.max(1,r.fee),c=new Tn(a),u=new Bn(0,t.address,n),f=c.selectCoins(o,s,u),h=new On(this._network);h.addInputs(f.inputs,r.replaceable,t.hdPath,_r(t.pubkey,!1),_r(t.mfp,!1));const l=new Pn(t.address,a);for(const t of f.outputs)h.addOutput(t),l.addRecipient(t);f.change&&(bn(u.value,i)?Lr.warn(\"[BtcWallet.createTransaction] Change is too small, adding to fees\"):(h.addOutput(f.change),l.addChange(f.change)));const p=await h.signDummy(t.signer);return l.txFee=p.getFee(),{tx:h.toBase64(),txInfo:l}}async signTransaction(t,e){const r=On.fromBase64(this._network,e);return await r.signNVerify(t),r.finalize()}getHdSigner(t){return new kn(t,t.fingerprint)}getAccountCtor(t){let e=t;switch(t.includes(\"bip122:\")&&(e=t.split(\":\")[1]),e.toLowerCase()){case an.P2wpkh.toLowerCase():return mn;case an.P2shP2wkh.toLowerCase():return vn;default:throw new ln(\"Invalid script type\")}}}class Nn{static createOnChainServiceProvider(t){var e,r;const n=gn(t),i=new fn({network:n,apiKey:null===(r=fr.onChainService.dataClient.options)||void 0===r||null===(e=r.apiKey)||void 0===e?void 0:e.toString()});return new un(i,{network:n})}static createWallet(t){const e=gn(t);return new Cn(new Sn(e),e)}}class Ln extends Ur{async get(){return super.get().then((t=>(t||(t={walletIds:[],wallets:{}}),t.walletIds||(t.walletIds=[]),t.wallets||(t.wallets={}),t)))}async listAccounts(){try{const t=await this.get();return t.walletIds.map((e=>t.wallets[e].account))}catch(t){throw mr(t,Error)}}async addWallet(t){try{await this.update((async e=>{const{id:r,address:n}=t.account;if(this.isAccountExist(e,r)||this.getAccountByAddress(e,n))throw new Error(`Account address ${n} already exists`);e.wallets[r]=t,e.walletIds.push(r)}))}catch(t){throw mr(t,Error)}}async updateAccount(t){try{await this.update((async e=>{if(!this.isAccountExist(e,t.id))throw new Error(`Account id ${t.id} does not exist`);const r=e.wallets[t.id].account;if(r.address.toLowerCase()!==t.address.toLowerCase()||r.type!==t.type)throw new Error(\"Account address or type is immutable\");e.wallets[t.id].account=t}))}catch(t){throw mr(t,Error)}}async removeAccounts(t){try{await this.update((async e=>{const r=new Set;for(const n of t){if(!this.isAccountExist(e,n))throw new Error(`Account id ${n} does not exist`);r.add(n)}r.forEach((t=>delete e.wallets[t])),e.walletIds=e.walletIds.filter((t=>!r.has(t)))}))}catch(t){throw mr(t,Error)}}async getAccount(t){try{var e;return(null===(e=(await this.get()).wallets[t])||void 0===e?void 0:e.account)??null}catch(t){throw mr(t,Error)}}async getWallet(t){try{return(await this.get()).wallets[t]??null}catch(t){throw mr(t,Error)}}getAccountByAddress(t,e){var r;return(null===(r=Object.values(t.wallets).find((t=>t.account.address.toString()===e.toLowerCase())))||void 0===r?void 0:r.account)??null}isAccountExist(t,e){return Object.prototype.hasOwnProperty.call(t.wallets,e)}}(0,c.object)({scope:Ir});const Un=(0,c.object)({assets:(0,c.array)(Ar),scope:Ir});(0,c.object)({assets:(0,c.record)(Ar,(0,c.object)({amount:Tr,unit:(0,c.enums)([fr.unit])}))});const jn=(0,c.object)({transactionId:(0,c.string)(),scope:Ir}),Mn=(0,c.object)({status:(0,c.enums)(Object.values(sn))});const Hn=(0,c.refine)((0,c.record)(t.BtcP2wpkhAddressStruct,(0,c.string)()),\"TransactionAmountStuct\",(t=>{if(0===Object.entries(t).length)return\"Transaction must have at least one recipient\";for(const e of Object.values(t)){const t=parseFloat(e);if(Number.isNaN(t)||t<=0||!Number.isFinite(t))return\"Invalid amount for send\";try{en(e)}catch(t){return\"Invalid amount for send\"}}return!0})),Fn=(0,c.object)({amounts:Hn,comment:(0,c.string)(),subtractFeeFrom:(0,c.array)(t.BtcP2wpkhAddressStruct),replaceable:(0,c.boolean)(),dryrun:(0,c.optional)((0,c.boolean)()),scope:Ir}),Dn=(0,c.object)({txId:(0,c.nonempty)((0,c.string)()),txHash:(0,c.optional)((0,c.string)())});async function $n(t,e){try{jr(e,Fn);const{dryrun:r,scope:n}=e,i=Nn.createOnChainServiceProvider(n),o=Nn.createWallet(n),s=await i.getFeeRates();if(0===s.fees.length)throw new Error(\"No fee rates available\");const a=Math.max(Number(s.fees[s.fees.length-1].rate),1),c=Object.entries(e.amounts).map((([t,e])=>({address:t,value:en(e)}))),u=await i.getDataForTransaction(t.address),{tx:f,txInfo:h}=await o.createTransaction(t,c,{utxos:u.data.utxos,fee:a,subtractFeeFrom:e.subtractFeeFrom,replaceable:e.replaceable});if(!await async function(t,e,r){const n=\"Send Request\",i=\"Review the request before proceeding. Once the transaction is made, it's irreversible.\",o=\"Recipient\",s=\"Amount\",a=\"Comment\",c=\"Network fee\",u=\"Total\",f=\"Requested by\",h=[be([zt(n),ue(i),pe(f,ue(\"[portfolio.metamask.io](https://portfolio.metamask.io/)\"))]),Wt()],l=t.recipients.length+(t.change?1:0)>1;let p=0;const d=t=>{const e=[];e.push(pe(l?`${o} ${p+1}`:o,ue(`[${function(t){return function(t,e,r,n=\"...\"){return t?`${t.substring(0,e)}${n}${t.substring(t.length-r)}`:t}(t,5,3)}(t.address)}](${function(t,e){switch(e){case He.Mainnet:return fr.explorer[He.Mainnet].replace(\"${address}\",t);case He.Testnet:return fr.explorer[He.Testnet].replace(\"${address}\",t);default:throw new Error(\"Invalid Chain ID\")}}(t.address,r)})`))),e.push(pe(s,ue(tn(t.value,!0),!1))),p+=1,h.push(be(e)),h.push(Wt())};t.recipients.forEach(d),t.change&&[t.change].forEach(d);const y=[];e.trim().length>0&&y.push(pe(a,ue(e.trim(),!1)));return y.push(pe(c,ue(`${tn(t.txFee,!0)}`,!1))),y.push(pe(u,ue(`${tn(t.total,!0)}`,!1))),h.push(be(y)),await async function(t){return snap.request({method:\"snap_dialog\",params:{type:\"confirmation\",content:be(t)}})}(h)}(h,e.comment,n))throw new Mt;const l=await o.signTransaction(t.signer,f);if(r)return{txId:\"\",txHash:l};const p={txId:(await i.broadcastTransaction(l)).transactionId};return Mr(p,Dn),p}catch(t){if(Lr.error(\"Failed to send the transaction\",t),vr(t))throw t;if(t instanceof pn)throw t;throw new Error(\"Failed to send the transaction\")}}const Kn=(0,c.object)({scope:Ir});class Vn{_stateMgr;_options;_methods=[\"btc_sendmany\"];constructor(t,e){this._stateMgr=t,this._options=e}async listAccounts(){try{return await this._stateMgr.listAccounts()}catch(t){throw new Error(t)}}async getAccount(t){try{return await this._stateMgr.getAccount(t)??void 0}catch(t){throw new Error(t)}}async createAccount(e){try{(0,c.assert)(e,Kn);const r=this.getBtcWallet(e.scope),n=this._options.defaultIndex,i=fr.wallet.defaultAccountType,o=await this.discoverAccount(r,n,i);Lr.info(`[BtcKeyring.createAccount] Account unlocked: ${o.address}`);const s=this.newKeyringAccount(o,{scope:e.scope,index:n});return Lr.info(`[BtcKeyring.createAccount] Keyring account data: ${JSON.stringify(s)}`),await this._stateMgr.withTransaction((async()=>{await this._stateMgr.addWallet({account:s,hdPath:o.hdPath,index:o.index,scope:e.scope}),await this.#c(t.KeyringEvent.AccountCreated,{account:s})})),s}catch(t){if(Lr.info(`[BtcKeyring.createAccount] Error: ${t.message}`),t instanceof c.StructError)throw new Error(\"Invalid params to create an account\");throw new Error(t)}}async filterAccountChains(t,e){throw new Error(\"Method not implemented.\")}async updateAccount(e){try{await this._stateMgr.withTransaction((async()=>{await this._stateMgr.updateAccount(e),await this.#c(t.KeyringEvent.AccountUpdated,{account:e})}))}catch(t){throw Lr.info(`[BtcKeyring.updateAccount] Error: ${t.message}`),new Error(t)}}async deleteAccount(e){try{await this._stateMgr.withTransaction((async()=>{await this._stateMgr.removeAccounts([e]),await this.#c(t.KeyringEvent.AccountDeleted,{id:e})}))}catch(t){throw Lr.info(`[BtcKeyring.deleteAccount] Error: ${t.message}`),new Error(t)}}async submitRequest(t){return{pending:!1,result:await this.handleSubmitRequest(t)}}async handleSubmitRequest(t){const{scope:e,account:r}=t,{method:n,params:i}=t.request,o=await this.getWalletData(r);if(o.scope!==e)throw new Error(\"Account's scope does not match with the request's scope\");const s=this.getBtcWallet(o.scope),a=await this.discoverAccount(s,o.index,o.account.type);if(this.verifyIfAccountValid(a,o.account),\"btc_sendmany\"===n)return await $n(a,{...i,scope:o.scope});throw new Ot(n)}async#c(e,r){this._options.emitEvents&&await(0,t.emitSnapKeyringEvent)(snap,e,r)}async getAccountBalances(t,e){try{const r=await this.getWalletData(t),n=this.getBtcWallet(r.scope),i=await this.discoverAccount(n,r.index,r.account.type);return this.verifyIfAccountValid(i,r.account),await async function(t,e){try{jr(e,Un),(0,c.assert)(e,Un);const{assets:r,scope:n}=e,i=Nn.createOnChainServiceProvider(n),o=[t.address],s=new Set(o),a=new Set(r),u=await i.getBalances(o,r),f=Object.entries(u.balances),h=new Map;for(const[t,e]of f)if(s.has(t))for(const t in e){if(!a.has(t))continue;const{amount:r}=e[t];let n=h.get(t);n&&(n+=r),h.set(t,n??r)}const l=Object.fromEntries([...h.entries()].map((([t,e])=>[t,{amount:tn(e),unit:fr.unit}])));return Mr(e,Un),l}catch(t){if(Lr.error(\"Failed to get balances\",t),vr(t))throw t;throw new Error(\"Fail to get the balances\")}}(i,{assets:e,scope:r.scope})}catch(t){throw Lr.info(`[BtcKeyring.getAccountBalances] Error: ${t.message}`),new Error(t)}}async getWalletData(t){const e=await this._stateMgr.getWallet(t);if(!e)throw new Error(\"Account not found\");return e}getBtcWallet(t){return Nn.createWallet(t)}async discoverAccount(t,e,r){return await t.unlock(e,r)}verifyIfAccountValid(t,e){if(!t||t.address!==e.address)throw new Error(\"Account not found\")}newKeyringAccount(t,e){return{type:t.type,id:br(),address:t.address,options:{...e},methods:this._methods}}}var Gn;!function(t){t.GetTransactionStatus=\"chain_getTransactionStatus\",t.CreateAccount=\"chain_createAccount\"}(Gn||(Gn={}));const qn=new Set([t.KeyringRpcMethod.ListAccounts,t.KeyringRpcMethod.GetAccount,t.KeyringRpcMethod.CreateAccount,t.KeyringRpcMethod.FilterAccountChains,t.KeyringRpcMethod.ListRequests,t.KeyringRpcMethod.GetRequest,t.KeyringRpcMethod.ApproveRequest,t.KeyringRpcMethod.RejectRequest,t.KeyringRpcMethod.SubmitRequest,t.KeyringRpcMethod.GetAccountBalances,Gn.GetTransactionStatus]),Wn=new Set([t.KeyringRpcMethod.ListAccounts,t.KeyringRpcMethod.GetAccount,t.KeyringRpcMethod.CreateAccount,t.KeyringRpcMethod.FilterAccountChains,t.KeyringRpcMethod.UpdateAccount,t.KeyringRpcMethod.DeleteAccount,t.KeyringRpcMethod.ListRequests,t.KeyringRpcMethod.GetRequest,t.KeyringRpcMethod.ApproveRequest,t.KeyringRpcMethod.RejectRequest,t.KeyringRpcMethod.SubmitRequest,t.KeyringRpcMethod.GetAccountBalances,Gn.GetTransactionStatus]),Xn=[\"https://portfolio.metamask.io\",\"https://portfolio-builds.metafi-dev.codefi.network\",\"https://dev.portfolio.metamask.io\",\"https://ramps-dev.portfolio.metamask.io\"],zn=new Map([]);for(const t of Xn)zn.set(t,qn);zn.set(\"metamask\",Wn),zn.set(\"http://localhost:3000\",new Set([...qn,Gn.CreateAccount]));const Jn=(t,e)=>{var r;if(!t)throw new Ut(\"Origin not found\");if(!(null===(r=zn.get(t))||void 0===r?void 0:r.has(e)))throw new Ut(\"Permission denied\")},Yn=async({origin:t,request:e})=>{Lr.logLevel=parseInt(fr.logLevel,10);try{const{method:r}=e;switch(Jn(t,r),r){case Gn.CreateAccount:return await async function(t){const e=new Vn(new Ln,{defaultIndex:fr.wallet.defaultAccountIndex,emitEvents:!1});return await e.createAccount({scope:t.scope})}(e.params);case Gn.GetTransactionStatus:return await async function(t){try{jr(t,jn);const{scope:e,transactionId:r}=t,n=Nn.createOnChainServiceProvider(e),i={status:(await n.getTransactionStatus(r)).status};return Mr(i,Mn),i}catch(t){if(Lr.error(\"Failed to get transaction status\",t),vr(t))throw t;throw new Error(\"Fail to get the transaction status\")}}(e.params);default:throw new Ot(r)}}catch(t){let e=t;throw vr(t)||(e=new dt(t)),Lr.error(`onRpcRequest error: ${JSON.stringify(e.toJSON(),null,2)}`),e}},Zn=async({origin:e,request:r})=>{Lr.logLevel=parseInt(fr.logLevel,10);try{Jn(e,r.method);const n=new Vn(new Ln,{defaultIndex:fr.wallet.defaultAccountIndex,emitEvents:!0});return await(0,t.handleKeyringRequest)(n,r)}catch(t){let e=t;throw vr(t)||(e=new dt(t)),Lr.error(`onKeyringRequest error: ${JSON.stringify(e.toJSON(),null,2)}`),e}}})();var i=exports;for(var o in n)i[o]=n[o];n.__esModule&&Object.defineProperty(i,\"__esModule\",{value:!0})})();"}],"removable":false} \ No newline at end of file diff --git a/app/scripts/snaps/preinstalled-snaps.ts b/app/scripts/snaps/preinstalled-snaps.ts index bc3bbab76880..4d94e8a86354 100644 --- a/app/scripts/snaps/preinstalled-snaps.ts +++ b/app/scripts/snaps/preinstalled-snaps.ts @@ -1,7 +1,7 @@ import type { PreinstalledSnap } from '@metamask/snaps-controllers'; import MessageSigningSnap from '@metamask/message-signing-snap/dist/preinstalled-snap.json'; ///: BEGIN:ONLY_INCLUDE_IF(build-flask) -import BitcoinManagerSnap from './bitcoin-manager-snap-0.1.4-rc4-preinstalled-snap.json'; +import BitcoinManagerSnap from '@consensys/bitcoin-manager-snap/dist/preinstalled-snap.json'; ///: END:ONLY_INCLUDE_IF const PREINSTALLED_SNAPS: readonly PreinstalledSnap[] = Object.freeze([ diff --git a/package.json b/package.json index 1975c42e7a21..dcc729b13b20 100644 --- a/package.json +++ b/package.json @@ -260,6 +260,7 @@ "dependencies": { "@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", "@blockaid/ppom_release": "^1.4.9", + "@consensys/bitcoin-manager-snap": "0.1.4-rc5", "@contentful/rich-text-html-renderer": "^16.3.5", "@ensdomains/content-hash": "^2.5.7", "@ethereumjs/tx": "^4.1.1", diff --git a/yarn.lock b/yarn.lock index 220048bc3e48..92c87ed149d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1758,6 +1758,13 @@ __metadata: languageName: node linkType: hard +"@consensys/bitcoin-manager-snap@npm:0.1.4-rc5": + version: 0.1.4-rc5 + resolution: "@consensys/bitcoin-manager-snap@npm:0.1.4-rc5" + checksum: 10/fce2354db7f75f48655d7e2a1f02b05385b0dcbfd704d366890afdd8eee7432ab550bf8963e0e6dfb64ce9c565f4e6c697e8940af1798f75a8069891a476ee37 + languageName: node + linkType: hard + "@contentful/rich-text-html-renderer@npm:^16.3.5": version: 16.3.5 resolution: "@contentful/rich-text-html-renderer@npm:16.3.5" @@ -25150,6 +25157,7 @@ __metadata: "@babel/register": "npm:^7.22.15" "@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch" "@blockaid/ppom_release": "npm:^1.4.9" + "@consensys/bitcoin-manager-snap": "npm:0.1.4-rc5" "@contentful/rich-text-html-renderer": "npm:^16.3.5" "@ensdomains/content-hash": "npm:^2.5.7" "@ethereumjs/tx": "npm:^4.1.1" From b6a36272917bcbe5dd42d56195326bf698491576 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:02:29 -0400 Subject: [PATCH 20/75] refactor: update experiment-tab component to TS --- ...nent.js => experimental-tab.component.tsx} | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) rename ui/pages/settings/experimental-tab/{experimental-tab.component.js => experimental-tab.component.tsx} (86%) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.js b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx similarity index 86% rename from ui/pages/settings/experimental-tab/experimental-tab.component.js rename to ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 01a7dc56c73b..3a1cabf7cfa5 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -29,29 +29,29 @@ import { ///: END:ONLY_INCLUDE_IF } from '../../../helpers/constants/design-system'; -export default class ExperimentalTab extends PureComponent { +interface ExperimentalTabProps { + bitcoinSupportEnabled: boolean; + setBitcoinSupportEnabled: (value: boolean) => void; + ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) + addSnapAccountEnabled: boolean; + setAddSnapAccountEnabled: (value: boolean) => void; + ///: END:ONLY_INCLUDE_IF + useRequestQueue: boolean; + setUseRequestQueue: (value: boolean) => void; + petnamesEnabled: boolean; + setPetnamesEnabled: (value: boolean) => void; + featureNotificationsEnabled: boolean; + setFeatureNotificationsEnabled: (value: boolean) => void; + redesignedConfirmationsEnabled: boolean; + setRedesignedConfirmationsEnabled: (value: boolean) => void; +} + +export default class ExperimentalTab extends PureComponent { static contextTypes = { t: PropTypes.func, trackEvent: PropTypes.func, }; - static propTypes = { - bitcoinSupportEnabled: PropTypes.bool, - setBitcoinSupportEnabled: PropTypes.func, - ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) - addSnapAccountEnabled: PropTypes.bool, - setAddSnapAccountEnabled: PropTypes.func, - ///: END:ONLY_INCLUDE_IF - useRequestQueue: PropTypes.bool, - setUseRequestQueue: PropTypes.func, - petnamesEnabled: PropTypes.bool.isRequired, - setPetnamesEnabled: PropTypes.func.isRequired, - featureNotificationsEnabled: PropTypes.bool, - setFeatureNotificationsEnabled: PropTypes.func, - redesignedConfirmationsEnabled: PropTypes.bool.isRequired, - setRedesignedConfirmationsEnabled: PropTypes.func.isRequired, - }; - settingsRefs = Array( getNumberOfSettingRoutesInTab( this.context.t, @@ -60,7 +60,7 @@ export default class ExperimentalTab extends PureComponent { ) .fill(undefined) .map(() => { - return React.createRef(); + return React.createRef(); }); componentDidUpdate() { @@ -81,6 +81,15 @@ export default class ExperimentalTab extends PureComponent { toggleDataTestId, toggleOffLabel, toggleOnLabel, + }: { + title: string; + description: string; + toggleValue: boolean; + toggleCallback: (value: boolean) => void; + toggleDataTestId: string; + toggleOffLabel: string; + toggleOnLabel: string; + }) { return ( Date: Thu, 4 Jul 2024 11:08:42 -0400 Subject: [PATCH 21/75] refactor: update experiment-tab container to TS --- ...ainer.js => experimental-tab.container.ts} | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) rename ui/pages/settings/experimental-tab/{experimental-tab.container.js => experimental-tab.container.ts} (73%) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.container.js b/ui/pages/settings/experimental-tab/experimental-tab.container.ts similarity index 73% rename from ui/pages/settings/experimental-tab/experimental-tab.container.js rename to ui/pages/settings/experimental-tab/experimental-tab.container.ts index 229e908dbc2d..d7285a957eb3 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.container.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.container.ts @@ -23,7 +23,10 @@ import { } from '../../../selectors'; import ExperimentalTab from './experimental-tab.component'; -const mapStateToProps = (state) => { +import type { MetaMaskReduxDispatch, MetaMaskReduxState } from '../../../store/store'; + + +const mapStateToProps = (state: MetaMaskReduxState) => { const petnamesEnabled = getPetnamesEnabled(state); const featureNotificationsEnabled = getFeatureNotificationsEnabled(state); return { @@ -38,20 +41,20 @@ const mapStateToProps = (state) => { }; }; -const mapDispatchToProps = (dispatch) => { +const mapDispatchToProps = (dispatch: MetaMaskReduxDispatch) => { return { - setBitcoinSupportEnabled: (val) => setBitcoinSupportEnabled(val), + setBitcoinSupportEnabled: (value: boolean) => setBitcoinSupportEnabled(value), ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) - setAddSnapAccountEnabled: (val) => setAddSnapAccountEnabled(val), + setAddSnapAccountEnabled: (value: boolean) => setAddSnapAccountEnabled(value), ///: END:ONLY_INCLUDE_IF - setUseRequestQueue: (val) => setUseRequestQueue(val), - setPetnamesEnabled: (value) => { + setUseRequestQueue: (value: boolean) => setUseRequestQueue(value), + setPetnamesEnabled: (value: boolean) => { return dispatch(setPetnamesEnabled(value)); }, - setFeatureNotificationsEnabled: (value) => { + setFeatureNotificationsEnabled: (value: boolean) => { return dispatch(setFeatureNotificationsEnabled(value)); }, - setRedesignedConfirmationsEnabled: (value) => + setRedesignedConfirmationsEnabled: (value: boolean) => dispatch(setRedesignedConfirmationsEnabled(value)), }; }; From 261e55c8c7842c40cc6ca04af1fbd453ce4d1102 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:44:21 -0400 Subject: [PATCH 22/75] chore: update messages file --- app/_locales/en/messages.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index f92a3e08eb9d..571c8613a0f6 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -300,17 +300,17 @@ }, "experimentalBitcoinSectionTitle": { "message": "Bitcoin" - }, - "experimentalBitcoinFeatureToggleTitle": { + }, + "experimentalBitcoinToggleTitle": { "message": "Enable \"Add Bitcoin Account (Beta)\"" - }, - "experimentalBitcoinFeatureToggleDescription": { + }, + "experimentalBitcoinToggleDescription": { "message": "Turning on this feature will give you the option to add a Bitcoin Account to your MetaMask Extension derived from your existing Secret Recovery Phrase. This is an experimental Beta feature, so you should use it at your own risk. To give us feedback on this new Bitcoin experience, please fill out this $1.", "description": "$1 is the link to a product feedback form" - }, - "form": { + }, + "form": { "message": "form" - }, + }, "addSuggestedNFTs": { "message": "Add suggested NFTs" }, From 8fcde18e42d840faf946bcb4b7d7d18551216b7b Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:08:24 -0400 Subject: [PATCH 23/75] fix: prettier --- app/_locales/en/messages.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 571c8613a0f6..54058799134d 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -298,19 +298,6 @@ "addSnapAccountsDescription": { "message": "Turning on this feature will give you the option to add the new Beta account Snaps right from your account list. If you install an account Snap, remember that it is a third-party service." }, - "experimentalBitcoinSectionTitle": { - "message": "Bitcoin" - }, - "experimentalBitcoinToggleTitle": { - "message": "Enable \"Add Bitcoin Account (Beta)\"" - }, - "experimentalBitcoinToggleDescription": { - "message": "Turning on this feature will give you the option to add a Bitcoin Account to your MetaMask Extension derived from your existing Secret Recovery Phrase. This is an experimental Beta feature, so you should use it at your own risk. To give us feedback on this new Bitcoin experience, please fill out this $1.", - "description": "$1 is the link to a product feedback form" - }, - "form": { - "message": "form" - }, "addSuggestedNFTs": { "message": "Add suggested NFTs" }, @@ -1894,6 +1881,16 @@ "experimental": { "message": "Experimental" }, + "experimentalBitcoinSectionTitle": { + "message": "Bitcoin" + }, + "experimentalBitcoinToggleDescription": { + "message": "Turning on this feature will give you the option to add a Bitcoin Account to your MetaMask Extension derived from your existing Secret Recovery Phrase. This is an experimental Beta feature, so you should use it at your own risk. To give us feedback on this new Bitcoin experience, please fill out this $1.", + "description": "$1 is the link to a product feedback form" + }, + "experimentalBitcoinToggleTitle": { + "message": "Enable \"Add Bitcoin Account (Beta)\"" + }, "extendWalletWithSnaps": { "message": "Explore community-built Snaps to customize your web3 experience", "description": "Banner description displayed on Snaps list page in Settings when less than 6 Snaps is installed." @@ -1981,6 +1978,9 @@ "forgotPassword": { "message": "Forgot password?" }, + "form": { + "message": "form" + }, "from": { "message": "From" }, From a114e6fdb27087b3ede78da1916202b6b37ed7bc Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:36:31 -0400 Subject: [PATCH 24/75] chore: update to use code fence --- .../experimental-tab.component.tsx | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 3a1cabf7cfa5..8b7e7b229139 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -254,23 +254,30 @@ export default class ExperimentalTab extends PureComponent { ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) this.renderKeyringSnapsToggle() + + } + { + ///: BEGIN:ONLY_INCLUDE_IF(build-flask,build-beta) + // We're only setting the code fences here since + // we should remove it for the feature release + + /* Section: Bitcoin Accounts */ + } + <> + + {t('experimentalBitcoinSectionTitle')} + + {this.renderBitcoinSupport()} + + { ///: END:ONLY_INCLUDE_IF } - {/* Section: Bitcoin Accounts */} - {process.env.BTC_BETA_SUPPORT && ( - <> - - {t('experimentalBitcoinSectionTitle')} - - {this.renderBitcoinSupport()} - - )} ); } From 9c7e0a3740ac25af7bfce3f997bf75fb219b91ad Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:42:28 -0400 Subject: [PATCH 25/75] fix: lint errors --- .../experimental-tab.component.tsx | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 8b7e7b229139..45c7d91d9629 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -29,7 +29,7 @@ import { ///: END:ONLY_INCLUDE_IF } from '../../../helpers/constants/design-system'; -interface ExperimentalTabProps { +type ExperimentalTabProps = { bitcoinSupportEnabled: boolean; setBitcoinSupportEnabled: (value: boolean) => void; ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) @@ -44,7 +44,7 @@ interface ExperimentalTabProps { setFeatureNotificationsEnabled: (value: boolean) => void; redesignedConfirmationsEnabled: boolean; setRedesignedConfirmationsEnabled: (value: boolean) => void; -} +}; export default class ExperimentalTab extends PureComponent { static contextTypes = { @@ -89,7 +89,6 @@ export default class ExperimentalTab extends PureComponent toggleDataTestId: string; toggleOffLabel: string; toggleOnLabel: string; - }) { return ( { ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) this.renderKeyringSnapsToggle() - + ///: END:ONLY_INCLUDE_IF } { ///: BEGIN:ONLY_INCLUDE_IF(build-flask,build-beta) @@ -262,20 +261,18 @@ export default class ExperimentalTab extends PureComponent // we should remove it for the feature release /* Section: Bitcoin Accounts */ - } - <> - - {t('experimentalBitcoinSectionTitle')} - - {this.renderBitcoinSupport()} - - { + <> + + {t('experimentalBitcoinSectionTitle')} + + {this.renderBitcoinSupport()} + ///: END:ONLY_INCLUDE_IF } From 1a5b73116a81ab3277a11266cd6fbaff49d5a6a7 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:42:49 -0400 Subject: [PATCH 26/75] refactor: update data types --- .../experimental-tab/experimental-tab.container.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.container.ts b/ui/pages/settings/experimental-tab/experimental-tab.container.ts index d7285a957eb3..7137d1665692 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.container.ts +++ b/ui/pages/settings/experimental-tab/experimental-tab.container.ts @@ -21,11 +21,12 @@ import { getFeatureNotificationsEnabled, getRedesignedConfirmationsEnabled, } from '../../../selectors'; +import type { + MetaMaskReduxDispatch, + MetaMaskReduxState, +} from '../../../store/store'; import ExperimentalTab from './experimental-tab.component'; -import type { MetaMaskReduxDispatch, MetaMaskReduxState } from '../../../store/store'; - - const mapStateToProps = (state: MetaMaskReduxState) => { const petnamesEnabled = getPetnamesEnabled(state); const featureNotificationsEnabled = getFeatureNotificationsEnabled(state); @@ -43,9 +44,11 @@ const mapStateToProps = (state: MetaMaskReduxState) => { const mapDispatchToProps = (dispatch: MetaMaskReduxDispatch) => { return { - setBitcoinSupportEnabled: (value: boolean) => setBitcoinSupportEnabled(value), + setBitcoinSupportEnabled: (value: boolean) => + setBitcoinSupportEnabled(value), ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) - setAddSnapAccountEnabled: (value: boolean) => setAddSnapAccountEnabled(value), + setAddSnapAccountEnabled: (value: boolean) => + setAddSnapAccountEnabled(value), ///: END:ONLY_INCLUDE_IF setUseRequestQueue: (value: boolean) => setUseRequestQueue(value), setPetnamesEnabled: (value: boolean) => { From bfbe6aa5e3185f39e15947f559e364998c86215c Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:08:59 -0400 Subject: [PATCH 27/75] test: add tests and update mocks --- test/data/mock-state.json | 1 + .../errors-after-init-opt-in-ui-state.json | 1 + .../experimental-tab/experimental-tab.test.js | 20 ++++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/test/data/mock-state.json b/test/data/mock-state.json index 9e595ad8f0e0..fce21cd8030d 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -1879,6 +1879,7 @@ } ], "addSnapAccountEnabled": false, + "bitcoinSupportEnabled": false, "pendingApprovals": { "testApprovalId": { "id": "testApprovalId", diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json index 401f92d138a0..5f9666cb6702 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -122,6 +122,7 @@ "openSeaEnabled": false, "securityAlertsEnabled": "boolean", "addSnapAccountEnabled": "boolean", + "bitcoinSupportEnabled": "boolean", "advancedGasFee": {}, "incomingTransactionsPreferences": {}, "identities": "object", diff --git a/ui/pages/settings/experimental-tab/experimental-tab.test.js b/ui/pages/settings/experimental-tab/experimental-tab.test.js index b5cf5520c6fe..c7272baffb60 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.test.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.test.js @@ -30,7 +30,7 @@ describe('ExperimentalTab', () => { const { getAllByRole } = render(); const toggle = getAllByRole('checkbox'); - expect(toggle).toHaveLength(4); + expect(toggle).toHaveLength(5); }); it('should enable add account snap', async () => { @@ -90,4 +90,22 @@ describe('ExperimentalTab', () => { expect(setRedesignedConfirmationsEnabled).toHaveBeenCalledWith(true); }); }); + + it('enables and disables the experimental bitcoin account feature', async () => { + const setBitcoinSupportEnabled = jest.fn(); + const { getByTestId } = render( + {}, + { + setBitcoinSupportEnabled, + bitcoinSupportEnabled: false, + }, + ); + const toggle = getByTestId('bitcoin-accounts-toggle'); + + // Should turn the BTC experimental toggle ON + fireEvent.click(toggle); + await waitFor(() => { + expect(setBitcoinSupportEnabled).toHaveBeenNthCalledWith(1, true); + }); + }); }); From ad1d0f52616e4f4db412af54a7b725c2c9f21d9d Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 10:43:22 -0400 Subject: [PATCH 28/75] chore: solve CI issues --- .../experimental-tab/experimental-tab.component.tsx | 12 ++++++++++++ .../experimental-tab/experimental-tab.test.js | 10 +++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 45c7d91d9629..54f5adbd9181 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -164,6 +164,18 @@ export default class ExperimentalTab extends PureComponent > {t('snaps')} +
+ {t('snapAccounts')} +
+ + {t('snapAccountsDescription')} + +
+
{this.renderToggleSection({ title: t('addSnapAccountToggle'), description: t('addSnapAccountsDescription'), diff --git a/ui/pages/settings/experimental-tab/experimental-tab.test.js b/ui/pages/settings/experimental-tab/experimental-tab.test.js index c7272baffb60..069c4ec802f5 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.test.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.test.js @@ -26,14 +26,14 @@ describe('ExperimentalTab', () => { }).not.toThrow(); }); - it('should render multiple toggle options', () => { + it('renders multiple toggle options', () => { const { getAllByRole } = render(); const toggle = getAllByRole('checkbox'); expect(toggle).toHaveLength(5); }); - it('should enable add account snap', async () => { + it('enables add account snap', async () => { const setAddSnapAccountEnabled = jest.fn(); const setPetnamesEnabled = jest.fn(); const { getByTestId } = render( @@ -53,7 +53,7 @@ describe('ExperimentalTab', () => { }); }); - it('should disable petnames', async () => { + it('disables petnames', async () => { const setAddSnapAccountEnabled = jest.fn(); const setPetnamesEnabled = jest.fn(); const { getByTestId } = render( @@ -73,7 +73,7 @@ describe('ExperimentalTab', () => { }); }); - it('should enable redesigned confirmations', async () => { + it('enables redesigned confirmations', async () => { const setRedesignedConfirmationsEnabled = jest.fn(); const { getByTestId } = render( {}, @@ -91,7 +91,7 @@ describe('ExperimentalTab', () => { }); }); - it('enables and disables the experimental bitcoin account feature', async () => { + it('enables the experimental bitcoin account feature', async () => { const setBitcoinSupportEnabled = jest.fn(); const { getByTestId } = render( {}, From 2e37b0be2496c3a869e8125d2cbd7a1750dffb84 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:16:00 -0400 Subject: [PATCH 29/75] fix: code fenced logic --- .../experimental-tab.component.tsx | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 54f5adbd9181..595abf8ca5a5 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -229,32 +229,48 @@ export default class ExperimentalTab extends PureComponent }); } + ///: BEGIN:ONLY_INCLUDE_IF(build-flask,build-beta) + // We're only setting the code fences here since + // we should remove it for the feature release renderBitcoinSupport() { const { t } = this.context; const { bitcoinSupportEnabled, setBitcoinSupportEnabled } = this.props; - return this.renderToggleSection({ - title: t('experimentalBitcoinToggleTitle'), - description: t('experimentalBitcoinToggleDescription', [ - + - {t('form')} - , - ]), - toggleValue: bitcoinSupportEnabled, - toggleCallback: (value) => setBitcoinSupportEnabled(!value), - toggleDataTestId: 'bitcoin-accounts-toggle', - toggleOffLabel: t('off'), - toggleOnLabel: t('on'), - }); + {t('experimentalBitcoinSectionTitle')} + + {this.renderToggleSection({ + title: t('experimentalBitcoinToggleTitle'), + description: t('experimentalBitcoinToggleDescription', [ + + {t('form')} + , + ]), + toggleValue: bitcoinSupportEnabled, + toggleCallback: (value) => setBitcoinSupportEnabled(!value), + toggleDataTestId: 'bitcoin-accounts-toggle', + toggleOffLabel: t('off'), + toggleOnLabel: t('on'), + })} + + ) } + ///: END:ONLY_INCLUDE_IF render() { - const { t } = this.context; return (
{this.renderTogglePetnames()} @@ -274,15 +290,6 @@ export default class ExperimentalTab extends PureComponent /* Section: Bitcoin Accounts */ <> - - {t('experimentalBitcoinSectionTitle')} - {this.renderBitcoinSupport()} ///: END:ONLY_INCLUDE_IF From 7190ee19c97bdb9882627a4e745833bab5743997 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:34:08 -0400 Subject: [PATCH 30/75] fix: lint issues --- .../experimental-tab/experimental-tab.component.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 595abf8ca5a5..9841ddc998e3 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -266,7 +266,7 @@ export default class ExperimentalTab extends PureComponent toggleOnLabel: t('on'), })} - ) + ); } ///: END:ONLY_INCLUDE_IF @@ -289,9 +289,7 @@ export default class ExperimentalTab extends PureComponent // we should remove it for the feature release /* Section: Bitcoin Accounts */ - <> - {this.renderBitcoinSupport()} - + <>{this.renderBitcoinSupport()} ///: END:ONLY_INCLUDE_IF }
From d3cebc7c557f632a04acb0b6c9a603b3b7623ab2 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 13:16:07 -0400 Subject: [PATCH 31/75] chore: update test ids --- .../experimental-tab/experimental-tab.component.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 9841ddc998e3..2f84f86b4125 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -79,6 +79,7 @@ export default class ExperimentalTab extends PureComponent toggleValue, toggleCallback, toggleDataTestId, + toggleContainerDataTestId, toggleOffLabel, toggleOnLabel, }: { @@ -86,6 +87,7 @@ export default class ExperimentalTab extends PureComponent description: string; toggleValue: boolean; toggleCallback: (value: boolean) => void; + toggleContainerDataTestId?: string; toggleDataTestId: string; toggleOffLabel: string; toggleOnLabel: string; @@ -102,7 +104,10 @@ export default class ExperimentalTab extends PureComponent -
+
}); setAddSnapAccountEnabled(!value); }, + toggleContainerDataTestId: 'add-account-snap-toggle-div', toggleDataTestId: 'add-account-snap-toggle-button', toggleOffLabel: t('off'), toggleOnLabel: t('on'), @@ -207,6 +213,7 @@ export default class ExperimentalTab extends PureComponent description: t('toggleRequestQueueDescription'), toggleValue: useRequestQueue || false, toggleCallback: (value) => setUseRequestQueue(!value), + toggleContainerDataTestId: 'experimental-setting-toggle-request-queue', toggleDataTestId: 'experimental-setting-toggle-request-queue', toggleOffLabel: t('toggleRequestQueueOff'), toggleOnLabel: t('toggleRequestQueueOn'), From 31010e9a366cced60ecc4ab88c1b34a77ce4ed9d Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:40:20 -0400 Subject: [PATCH 32/75] chore: update snapshots --- .../errors-after-init-opt-in-background-state.json | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index 69e4002b7e46..8c438b61c912 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -188,7 +188,6 @@ "useRequestQueue": true, "openSeaEnabled": false, "securityAlertsEnabled": "boolean", - "addSnapAccountEnabled": "boolean", "advancedGasFee": {}, "featureFlags": {}, "incomingTransactionsPreferences": {}, From 8c6306d9709a87f0d5e0becd5363b3c608da021a Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:43:17 -0400 Subject: [PATCH 33/75] test: add unit test to setBitcoinSupportEnabled --- app/scripts/controllers/preferences.js | 1 - app/scripts/controllers/preferences.test.js | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 64f065e99a40..849d41dbfcd4 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -298,7 +298,6 @@ export default class PreferencesController { * enable the "Add Bitcoin account" button. */ setBitcoinSupportEnabled(bitcoinSupportEnabled) { - console.log({ bitcoinSupportEnabled }); this.store.updateState({ bitcoinSupportEnabled, }); diff --git a/app/scripts/controllers/preferences.test.js b/app/scripts/controllers/preferences.test.js index cd8e9d3fe896..e3737f685b7e 100644 --- a/app/scripts/controllers/preferences.test.js +++ b/app/scripts/controllers/preferences.test.js @@ -560,4 +560,24 @@ describe('preferences controller', () => { ).toStrictEqual(false); }); }); + + describe('setBitcoinSupportEnabled', () => { + it('has the default value as false', () => { + expect( + preferencesController.store.getState().bitcoinSupportEnabled, + ).toStrictEqual(false); + }); + + it('sets the bitcoinSupportEnabled property in state to true and then false', () => { + preferencesController.setBitcoinSupportEnabled(true); + expect( + preferencesController.store.getState().bitcoinSupportEnabled, + ).toStrictEqual(true); + + preferencesController.setBitcoinSupportEnabled(false); + expect( + preferencesController.store.getState().bitcoinSupportEnabled, + ).toStrictEqual(false); + }); + }); }); From b4821c7bc38b060f5b82f920eb53e154c7fada77 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:53:50 -0400 Subject: [PATCH 34/75] chore: update snapshots --- .../errors-after-init-opt-in-background-state.json | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index 8c438b61c912..eb815b7727eb 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -60,11 +60,7 @@ }, "AuthenticationController": { "isSignedIn": "boolean" }, "BridgeController": { - "bridgeState": { - "bridgeFeatureFlags": { - "extensionSupport": "boolean" - } - } + "bridgeState": { "bridgeFeatureFlags": { "extensionSupport": "boolean" } } }, "CronjobController": { "jobs": "object" }, "CurrencyController": { @@ -188,6 +184,8 @@ "useRequestQueue": true, "openSeaEnabled": false, "securityAlertsEnabled": "boolean", + "bitcoinSupportEnabled": "boolean", + "addSnapAccountEnabled": "boolean", "advancedGasFee": {}, "featureFlags": {}, "incomingTransactionsPreferences": {}, @@ -220,9 +218,7 @@ "selectedAddress": "string" }, "PushPlatformNotificationsController": { "fcmToken": "string" }, - "QueuedRequestController": { - "queuedRequestCount": 0 - }, + "QueuedRequestController": { "queuedRequestCount": 0 }, "SelectedNetworkController": { "domains": "object" }, "SignatureController": { "unapprovedMsgs": "object", From a0b03bed10ccfa59e7048200d932fd3ef68b8977 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:15:19 -0400 Subject: [PATCH 35/75] fix: e2e test for request queue --- test/e2e/tests/request-queuing/enable-queuing.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/e2e/tests/request-queuing/enable-queuing.spec.js b/test/e2e/tests/request-queuing/enable-queuing.spec.js index 8bff29afa8a6..dadf57708c3f 100644 --- a/test/e2e/tests/request-queuing/enable-queuing.spec.js +++ b/test/e2e/tests/request-queuing/enable-queuing.spec.js @@ -6,7 +6,7 @@ const { const FixtureBuilder = require('../../fixture-builder'); describe('Toggle Request Queuing Setting', function () { - it('should enable the request queuing setting ', async function () { + it('should enable the request queuing setting', async function () { await withFixtures( { dapp: true, @@ -38,7 +38,9 @@ describe('Toggle Request Queuing Setting', function () { await driver.clickElement(securityAndPrivacyTabRawLocator); // Toggle request queue setting - await driver.clickElement('.request-queue-toggle'); + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); }, ); }); From 2ed11b1f17f7e3b54b9cf1a010c1230a0655af09 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:16:12 -0400 Subject: [PATCH 36/75] test: update test name --- test/e2e/tests/request-queuing/enable-queuing.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/tests/request-queuing/enable-queuing.spec.js b/test/e2e/tests/request-queuing/enable-queuing.spec.js index dadf57708c3f..ccc5f7cec2c7 100644 --- a/test/e2e/tests/request-queuing/enable-queuing.spec.js +++ b/test/e2e/tests/request-queuing/enable-queuing.spec.js @@ -6,7 +6,7 @@ const { const FixtureBuilder = require('../../fixture-builder'); describe('Toggle Request Queuing Setting', function () { - it('should enable the request queuing setting', async function () { + it('enables the request queuing experimental setting', async function () { await withFixtures( { dapp: true, From d5fd4b99f9c18b2176782a26ef895a88898b5ebc Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Fri, 5 Jul 2024 18:18:59 -0400 Subject: [PATCH 37/75] fix: e2e test for json-rpc/switchEthereumChain --- test/e2e/json-rpc/switchEthereumChain.spec.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/test/e2e/json-rpc/switchEthereumChain.spec.js b/test/e2e/json-rpc/switchEthereumChain.spec.js index ef195f4b9a2b..f8ccb0116e84 100644 --- a/test/e2e/json-rpc/switchEthereumChain.spec.js +++ b/test/e2e/json-rpc/switchEthereumChain.spec.js @@ -50,7 +50,9 @@ describe('Switch Ethereum Chain for two dapps', function () { await driver.clickElement(experimentalTabRawLocator); // Toggle off request queue setting (on by default now) - await driver.clickElement('.request-queue-toggle'); + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); // open two dapps const dappOne = await openDapp(driver, undefined, DAPP_URL); @@ -99,7 +101,7 @@ describe('Switch Ethereum Chain for two dapps', function () { ); }); - it('should queue switchEthereumChain request from second dapp after send tx request', async function () { + it('queues switchEthereumChain request from second dapp after send tx request', async function () { await withFixtures( { dapp: true, @@ -137,7 +139,9 @@ describe('Switch Ethereum Chain for two dapps', function () { await driver.clickElement(experimentalTabRawLocator); // Toggle off request queue setting (on by default now) - await driver.clickElement('.request-queue-toggle'); + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); // open two dapps const dappOne = await openDapp(driver, undefined, DAPP_URL); @@ -189,7 +193,7 @@ describe('Switch Ethereum Chain for two dapps', function () { ); }); - it('should queue send tx after switchEthereum request with a warning, confirming removes pending tx', async function () { + it('queues send tx after switchEthereum request with a warning, confirming removes pending tx', async function () { await withFixtures( { dapp: true, @@ -227,7 +231,9 @@ describe('Switch Ethereum Chain for two dapps', function () { await driver.clickElement(experimentalTabRawLocator); // Toggle off request queue setting (on by default now) - await driver.clickElement('.request-queue-toggle'); + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); // open two dapps const dappOne = await openDapp(driver, undefined, DAPP_URL); @@ -286,7 +292,7 @@ describe('Switch Ethereum Chain for two dapps', function () { ); }); - it('should queue send tx after switchEthereum request with a warning, if switchEthereum request is cancelled should show pending tx', async function () { + it('queues send tx after switchEthereum request with a warning, if switchEthereum request is cancelled should show pending tx', async function () { await withFixtures( { dapp: true, @@ -324,7 +330,9 @@ describe('Switch Ethereum Chain for two dapps', function () { await driver.clickElement(experimentalTabRawLocator); // Toggle off request queue setting (on by default now) - await driver.clickElement('.request-queue-toggle'); + await driver.clickElement( + '[data-testid="experimental-setting-toggle-request-queue"]', + ); // open two dapps const dappOne = await openDapp(driver, undefined, DAPP_URL); From bb7059ff0125393db83a1665b3362162cd64e01f Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Mon, 8 Jul 2024 21:45:04 -0400 Subject: [PATCH 38/75] chore: add metric event --- shared/constants/metametrics.ts | 1 + .../experimental-tab/experimental-tab.component.tsx | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index 209cc3c7f414..eb22807886ae 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -512,6 +512,7 @@ export enum MetaMetricsEventName { AppLocked = 'App Locked', AppWindowExpanded = 'App Window Expanded', BridgeLinkClicked = 'Bridge Link Clicked', + BtcExperimentalToggled = 'BTC Experimental Toggled', DappViewed = 'Dapp Viewed', DecryptionApproved = 'Decryption Approved', DecryptionRejected = 'Decryption Rejected', diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 2f84f86b4125..ee1147d061c1 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -240,7 +240,7 @@ export default class ExperimentalTab extends PureComponent // We're only setting the code fences here since // we should remove it for the feature release renderBitcoinSupport() { - const { t } = this.context; + const { t, trackEvent } = this.context; const { bitcoinSupportEnabled, setBitcoinSupportEnabled } = this.props; return ( @@ -267,7 +267,16 @@ export default class ExperimentalTab extends PureComponent , ]), toggleValue: bitcoinSupportEnabled, - toggleCallback: (value) => setBitcoinSupportEnabled(!value), + toggleCallback: (value) => { + trackEvent({ + event: MetaMetricsEventName.BtcExperimentalToggled, + category: MetaMetricsEventCategory.Settings, + properties: { + enabled: !value, + }, + }); + setBitcoinSupportEnabled(!value) + }, toggleDataTestId: 'bitcoin-accounts-toggle', toggleOffLabel: t('off'), toggleOnLabel: t('on'), From 2d3a750e75026716bf54bb9977953fa8e2bf491e Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Mon, 8 Jul 2024 23:21:11 -0400 Subject: [PATCH 39/75] fix: lint --- .../settings/experimental-tab/experimental-tab.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index ee1147d061c1..7b165c4ee853 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -275,7 +275,7 @@ export default class ExperimentalTab extends PureComponent enabled: !value, }, }); - setBitcoinSupportEnabled(!value) + setBitcoinSupportEnabled(!value); }, toggleDataTestId: 'bitcoin-accounts-toggle', toggleOffLabel: t('off'), From d1a94e5811253ec30f1b0ecd1b0b8148728ff5eb Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 4 Jul 2024 00:37:05 +0800 Subject: [PATCH 40/75] feat: add account / remove account e2e test --- privacy-snapshot.json | 1 + test/e2e/accounts/common.ts | 12 ++ test/e2e/accounts/create-snap-account.spec.ts | 114 ++++++++++++++++++ 3 files changed, 127 insertions(+) diff --git a/privacy-snapshot.json b/privacy-snapshot.json index fe6579bfab73..12b336c6f27a 100644 --- a/privacy-snapshot.json +++ b/privacy-snapshot.json @@ -1,5 +1,6 @@ [ "acl.execution.metamask.io", + "api.blockchair.com", "api.lens.dev", "api.segment.io", "api.web3modal.com", diff --git a/test/e2e/accounts/common.ts b/test/e2e/accounts/common.ts index f4039d6b6533..7da9fe42e306 100644 --- a/test/e2e/accounts/common.ts +++ b/test/e2e/accounts/common.ts @@ -372,3 +372,15 @@ export async function signData( }); } } + +export async function createBtcAccount(driver: Driver) { + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '[data-testid="multichain-account-menu-popover-action-button"]', + ); + await driver.clickElement({ + text: 'Add a new Bitcoin account', + tag: 'button', + }); + await driver.clickElement({ text: 'Create', tag: 'button' }); +} diff --git a/test/e2e/accounts/create-snap-account.spec.ts b/test/e2e/accounts/create-snap-account.spec.ts index ab34ac0046c0..5c186b06547b 100644 --- a/test/e2e/accounts/create-snap-account.spec.ts +++ b/test/e2e/accounts/create-snap-account.spec.ts @@ -1,4 +1,6 @@ +import { strict as assert } from 'assert'; import { Suite } from 'mocha'; + import FixtureBuilder from '../fixture-builder'; import { WINDOW_TITLES, @@ -9,6 +11,7 @@ import { } from '../helpers'; import { Driver } from '../webdriver/driver'; import { TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL } from '../constants'; +import { createBtcAccount } from './common'; describe('Create Snap Account', function (this: Suite) { it('create Snap account popup contains correct Snap name and snapId', async function () { @@ -259,4 +262,115 @@ describe('Create Snap Account', function (this: Suite) { }, ); }); + + it.only('create BTC account from the menu', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + }, + ); + }); + + it.only('cannot create multiple BTC accounts', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await createBtcAccount(driver); + + // modal will still be here + await driver.clickElement('.mm-box button[aria-label="Close"]'); + + // check the number of accounts. it should only be 2. + await driver.clickElement('[data-testid="account-menu-icon"]'); + const menuItems = await driver.findElements( + '.multichain-account-list-item', + ); + assert.equal(menuItems.length, 2); + }, + ); + }); + + it.only('can cancel the removal of BTC account', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + + // const accountAddress = + + // Remove account + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]', + ); + await driver.clickElement('[data-testid="account-list-menu-remove"]'); + await driver.clickElement({ text: 'Nevermind', tag: 'button' }); + + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + }, + ); + }); + + it.only('can recreate BTC account after deleting it', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + + // const accountAddress = + + // Remove account + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]', + ); + await driver.clickElement('[data-testid="account-list-menu-remove"]'); + await driver.clickElement({ text: 'Remove', tag: 'button' }); + + // Recreate account + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + }, + ); + }); }); From 473efbacfa0fb32c839ceb14cda98deb5bec90bb Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 4 Jul 2024 00:52:11 +0800 Subject: [PATCH 41/75] feat: overview e2e test --- .../accounts/snap-account-overview.spec.ts | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/e2e/accounts/snap-account-overview.spec.ts diff --git a/test/e2e/accounts/snap-account-overview.spec.ts b/test/e2e/accounts/snap-account-overview.spec.ts new file mode 100644 index 000000000000..efc0dfa07136 --- /dev/null +++ b/test/e2e/accounts/snap-account-overview.spec.ts @@ -0,0 +1,55 @@ +import { strict as assert } from 'assert'; +import { Suite } from 'mocha'; +import { withFixtures, defaultGanacheOptions, unlockWallet } from '../helpers'; +import { Driver } from '../webdriver/driver'; +import FixtureBuilder from '../fixture-builder'; +import { createBtcAccount } from './common'; + +describe('Snap Account - Overview', function (this: Suite) { + it('has buy/sell and portfolio button enabled', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + + await driver.waitForSelector({ + text: 'Send', + tag: 'button', + css: '[disabled]', + }); + + await driver.waitForSelector({ + text: 'Swap', + tag: 'button', + css: '[disabled]', + }); + + await driver.waitForSelector({ + text: 'Bridge', + tag: 'button', + css: '[disabled]', + }); + + const buySellButton = await driver.waitForSelector( + '[data-testid="coin-overview-buy"]', + ); + assert.equal(await buySellButton.isEnabled(), true); + + const portfolioButton = await driver.waitForSelector( + '[data-testid="coin-overview-portfolio"]', + ); + + assert.equal(await portfolioButton.isEnabled(), true); + }, + ); + }); +}); From 287c03f5e6968d881fbadf0850f93e6c682f7e21 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 4 Jul 2024 01:11:05 +0800 Subject: [PATCH 42/75] feat: add restore srp test --- test/e2e/accounts/create-snap-account.spec.ts | 81 ++++++++++++++++++- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/test/e2e/accounts/create-snap-account.spec.ts b/test/e2e/accounts/create-snap-account.spec.ts index 5c186b06547b..d8812975e086 100644 --- a/test/e2e/accounts/create-snap-account.spec.ts +++ b/test/e2e/accounts/create-snap-account.spec.ts @@ -3,9 +3,13 @@ import { Suite } from 'mocha'; import FixtureBuilder from '../fixture-builder'; import { + WALLET_PASSWORD, WINDOW_TITLES, + completeSRPRevealQuiz, defaultGanacheOptions, + openSRPRevealQuiz, switchToNotificationWindow, + tapAndHoldToRevealSRP, unlockWallet, withFixtures, } from '../helpers'; @@ -263,7 +267,7 @@ describe('Create Snap Account', function (this: Suite) { ); }); - it.only('create BTC account from the menu', async function () { + it('create BTC account from the menu', async function () { await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -281,7 +285,7 @@ describe('Create Snap Account', function (this: Suite) { ); }); - it.only('cannot create multiple BTC accounts', async function () { + it('cannot create multiple BTC accounts', async function () { await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -306,7 +310,7 @@ describe('Create Snap Account', function (this: Suite) { ); }); - it.only('can cancel the removal of BTC account', async function () { + it('can cancel the removal of BTC account', async function () { await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -339,7 +343,7 @@ describe('Create Snap Account', function (this: Suite) { ); }); - it.only('can recreate BTC account after deleting it', async function () { + it('can recreate BTC account after deleting it', async function () { await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -373,4 +377,73 @@ describe('Create Snap Account', function (this: Suite) { }, ); }); + + it('can recreate BTC account after restoring wallet with srp', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + + // const accountAddress = + + await openSRPRevealQuiz(driver); + await completeSRPRevealQuiz(driver); + await driver.fill('[data-testid="input-password"]', WALLET_PASSWORD); + await driver.press('[data-testid="input-password"]', driver.Key.ENTER); + await tapAndHoldToRevealSRP(driver); + const seedPhrase = await ( + await driver.findElement('[data-testid="srp_text"]') + ).getText(); + + // Reset wallet + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + const lockButton = await driver.findClickableElement( + '[data-testid="global-menu-lock"]', + ); + assert.equal(await lockButton.getText(), 'Lock MetaMask'); + await lockButton.click(); + + await driver.clickElement({ + text: 'Forgot password?', + tag: 'a', + }); + + await driver.pasteIntoField( + '[data-testid="import-srp__srp-word-0"]', + seedPhrase, + ); + + await driver.fill( + '[data-testid="create-vault-password"]', + WALLET_PASSWORD, + ); + await driver.fill( + '[data-testid="create-vault-confirm-password"]', + WALLET_PASSWORD, + ); + + await driver.clickElement({ + text: 'Restore', + tag: 'button', + }); + + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + }, + ); + }); }); From c52b66eed1cc7e050cc0fb54fac37f472f820365 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 4 Jul 2024 01:23:19 +0800 Subject: [PATCH 43/75] fix: address assertion --- test/e2e/accounts/create-snap-account.spec.ts | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/test/e2e/accounts/create-snap-account.spec.ts b/test/e2e/accounts/create-snap-account.spec.ts index d8812975e086..9907da4d95eb 100644 --- a/test/e2e/accounts/create-snap-account.spec.ts +++ b/test/e2e/accounts/create-snap-account.spec.ts @@ -358,7 +358,17 @@ describe('Create Snap Account', function (this: Suite) { text: 'Bitcoin Account', }); - // const accountAddress = + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + + await driver.clickElement('[data-testid="account-list-menu-details"]'); + + const accountAddress = await ( + await driver.findElement('[data-testid="address-copy-button-text"]') + ).getText(); + + await driver.clickElement('.mm-box button[aria-label="Close"]'); // Remove account await driver.clickElement('[data-testid="account-menu-icon"]'); @@ -374,11 +384,25 @@ describe('Create Snap Account', function (this: Suite) { css: '[data-testid="account-menu-icon"]', text: 'Bitcoin Account', }); + + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + + await driver.clickElement('[data-testid="account-list-menu-details"]'); + + const recreatedAccountAddress = await ( + await driver.findElement('[data-testid="address-copy-button-text"]') + ).getText(); + + await driver.clickElement('.mm-box button[aria-label="Close"]'); + + assert(accountAddress === recreatedAccountAddress); }, ); }); - it('can recreate BTC account after restoring wallet with srp', async function () { + it.only('can recreate BTC account after restoring wallet with srp', async function () { await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -393,7 +417,17 @@ describe('Create Snap Account', function (this: Suite) { text: 'Bitcoin Account', }); - // const accountAddress = + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + + await driver.clickElement('[data-testid="account-list-menu-details"]'); + + const accountAddress = await ( + await driver.findElement('[data-testid="address-copy-button-text"]') + ).getText(); + + await driver.clickElement('.mm-box button[aria-label="Close"]'); await openSRPRevealQuiz(driver); await completeSRPRevealQuiz(driver); @@ -443,6 +477,20 @@ describe('Create Snap Account', function (this: Suite) { css: '[data-testid="account-menu-icon"]', text: 'Bitcoin Account', }); + + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + + await driver.clickElement('[data-testid="account-list-menu-details"]'); + + const recreatedAccountAddress = await ( + await driver.findElement('[data-testid="address-copy-button-text"]') + ).getText(); + + await driver.clickElement('.mm-box button[aria-label="Close"]'); + + assert(accountAddress === recreatedAccountAddress); }, ); }); From 564de73014537fd1190dae0632f6f640d1d4b955 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 4 Jul 2024 01:56:21 +0800 Subject: [PATCH 44/75] fix: only test --- test/e2e/accounts/create-snap-account.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/e2e/accounts/create-snap-account.spec.ts b/test/e2e/accounts/create-snap-account.spec.ts index 9907da4d95eb..4d1f8f61780c 100644 --- a/test/e2e/accounts/create-snap-account.spec.ts +++ b/test/e2e/accounts/create-snap-account.spec.ts @@ -325,8 +325,6 @@ describe('Create Snap Account', function (this: Suite) { text: 'Bitcoin Account', }); - // const accountAddress = - // Remove account await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement( @@ -402,7 +400,7 @@ describe('Create Snap Account', function (this: Suite) { ); }); - it.only('can recreate BTC account after restoring wallet with srp', async function () { + it('can recreate BTC account after restoring wallet with srp', async function () { await withFixtures( { fixtures: new FixtureBuilder().build(), From 7823f322140bfb1ccc60c5403300028abe3ec67d Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Tue, 9 Jul 2024 16:49:02 +0800 Subject: [PATCH 45/75] fix: check for flask if its btc test --- test/e2e/accounts/create-snap-account.spec.ts | 21 +++++++++++++++++++ .../accounts/snap-account-overview.spec.ts | 7 ++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/test/e2e/accounts/create-snap-account.spec.ts b/test/e2e/accounts/create-snap-account.spec.ts index 4d1f8f61780c..8357c6106b20 100644 --- a/test/e2e/accounts/create-snap-account.spec.ts +++ b/test/e2e/accounts/create-snap-account.spec.ts @@ -16,6 +16,7 @@ import { import { Driver } from '../webdriver/driver'; import { TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL } from '../constants'; import { createBtcAccount } from './common'; +import { IS_FLASK } from '../../../ui/helpers/utils/util'; describe('Create Snap Account', function (this: Suite) { it('create Snap account popup contains correct Snap name and snapId', async function () { @@ -268,6 +269,10 @@ describe('Create Snap Account', function (this: Suite) { }); it('create BTC account from the menu', async function () { + // Skip test if its not flask + if (!IS_FLASK) { + return; + } await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -286,6 +291,10 @@ describe('Create Snap Account', function (this: Suite) { }); it('cannot create multiple BTC accounts', async function () { + // Skip test if its not flask + if (!IS_FLASK) { + return; + } await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -311,6 +320,10 @@ describe('Create Snap Account', function (this: Suite) { }); it('can cancel the removal of BTC account', async function () { + // Skip test if its not flask + if (!IS_FLASK) { + return; + } await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -342,6 +355,10 @@ describe('Create Snap Account', function (this: Suite) { }); it('can recreate BTC account after deleting it', async function () { + // Skip test if its not flask + if (!IS_FLASK) { + return; + } await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -401,6 +418,10 @@ describe('Create Snap Account', function (this: Suite) { }); it('can recreate BTC account after restoring wallet with srp', async function () { + // Skip test if its not flask + if (!IS_FLASK) { + return; + } await withFixtures( { fixtures: new FixtureBuilder().build(), diff --git a/test/e2e/accounts/snap-account-overview.spec.ts b/test/e2e/accounts/snap-account-overview.spec.ts index efc0dfa07136..d4cde551eb93 100644 --- a/test/e2e/accounts/snap-account-overview.spec.ts +++ b/test/e2e/accounts/snap-account-overview.spec.ts @@ -4,9 +4,14 @@ import { withFixtures, defaultGanacheOptions, unlockWallet } from '../helpers'; import { Driver } from '../webdriver/driver'; import FixtureBuilder from '../fixture-builder'; import { createBtcAccount } from './common'; +import { IS_FLASK } from '../../../ui/helpers/utils/util'; describe('Snap Account - Overview', function (this: Suite) { - it('has buy/sell and portfolio button enabled', async function () { + it('has buy/sell and portfolio button enabled for BTC accounts', async function () { + // Skip test if its not flask + if (!IS_FLASK) { + return; + } await withFixtures( { fixtures: new FixtureBuilder().build(), From 1f35b1d3cd63b2eb2a2626e93e25922005450a04 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Tue, 9 Jul 2024 17:29:07 +0800 Subject: [PATCH 46/75] fix: lint --- test/e2e/accounts/create-snap-account.spec.ts | 2 +- test/e2e/accounts/snap-account-overview.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/accounts/create-snap-account.spec.ts b/test/e2e/accounts/create-snap-account.spec.ts index 8357c6106b20..91fdb6142d7d 100644 --- a/test/e2e/accounts/create-snap-account.spec.ts +++ b/test/e2e/accounts/create-snap-account.spec.ts @@ -15,8 +15,8 @@ import { } from '../helpers'; import { Driver } from '../webdriver/driver'; import { TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL } from '../constants'; -import { createBtcAccount } from './common'; import { IS_FLASK } from '../../../ui/helpers/utils/util'; +import { createBtcAccount } from './common'; describe('Create Snap Account', function (this: Suite) { it('create Snap account popup contains correct Snap name and snapId', async function () { diff --git a/test/e2e/accounts/snap-account-overview.spec.ts b/test/e2e/accounts/snap-account-overview.spec.ts index d4cde551eb93..2134abc2104f 100644 --- a/test/e2e/accounts/snap-account-overview.spec.ts +++ b/test/e2e/accounts/snap-account-overview.spec.ts @@ -3,8 +3,8 @@ import { Suite } from 'mocha'; import { withFixtures, defaultGanacheOptions, unlockWallet } from '../helpers'; import { Driver } from '../webdriver/driver'; import FixtureBuilder from '../fixture-builder'; -import { createBtcAccount } from './common'; import { IS_FLASK } from '../../../ui/helpers/utils/util'; +import { createBtcAccount } from './common'; describe('Snap Account - Overview', function (this: Suite) { it('has buy/sell and portfolio button enabled for BTC accounts', async function () { From 4b4e4523b59ee81a2159e46d7a709992e38c7273 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Tue, 9 Jul 2024 20:50:49 +0800 Subject: [PATCH 47/75] refactor: move btc test to flask --- test/e2e/accounts/create-snap-account.spec.ts | 253 ------------------ test/e2e/fixture-builder.js | 5 + .../btc/btc-account-overview.spec.ts} | 25 +- test/e2e/flask/btc/create-btc-account.spec.ts | 218 +++++++++++++++ test/e2e/helpers.js | 25 ++ .../account-list-menu/account-list-menu.js | 33 ++- .../experimental-tab.component.tsx | 5 +- 7 files changed, 282 insertions(+), 282 deletions(-) rename test/e2e/{accounts/snap-account-overview.spec.ts => flask/btc/btc-account-overview.spec.ts} (73%) create mode 100644 test/e2e/flask/btc/create-btc-account.spec.ts diff --git a/test/e2e/accounts/create-snap-account.spec.ts b/test/e2e/accounts/create-snap-account.spec.ts index 91fdb6142d7d..8dcff978bad9 100644 --- a/test/e2e/accounts/create-snap-account.spec.ts +++ b/test/e2e/accounts/create-snap-account.spec.ts @@ -1,22 +1,15 @@ -import { strict as assert } from 'assert'; import { Suite } from 'mocha'; import FixtureBuilder from '../fixture-builder'; import { - WALLET_PASSWORD, WINDOW_TITLES, - completeSRPRevealQuiz, defaultGanacheOptions, - openSRPRevealQuiz, switchToNotificationWindow, - tapAndHoldToRevealSRP, unlockWallet, withFixtures, } from '../helpers'; import { Driver } from '../webdriver/driver'; import { TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL } from '../constants'; -import { IS_FLASK } from '../../../ui/helpers/utils/util'; -import { createBtcAccount } from './common'; describe('Create Snap Account', function (this: Suite) { it('create Snap account popup contains correct Snap name and snapId', async function () { @@ -267,250 +260,4 @@ describe('Create Snap Account', function (this: Suite) { }, ); }); - - it('create BTC account from the menu', async function () { - // Skip test if its not flask - if (!IS_FLASK) { - return; - } - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await createBtcAccount(driver); - await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: 'Bitcoin Account', - }); - }, - ); - }); - - it('cannot create multiple BTC accounts', async function () { - // Skip test if its not flask - if (!IS_FLASK) { - return; - } - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await createBtcAccount(driver); - await createBtcAccount(driver); - - // modal will still be here - await driver.clickElement('.mm-box button[aria-label="Close"]'); - - // check the number of accounts. it should only be 2. - await driver.clickElement('[data-testid="account-menu-icon"]'); - const menuItems = await driver.findElements( - '.multichain-account-list-item', - ); - assert.equal(menuItems.length, 2); - }, - ); - }); - - it('can cancel the removal of BTC account', async function () { - // Skip test if its not flask - if (!IS_FLASK) { - return; - } - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await createBtcAccount(driver); - await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: 'Bitcoin Account', - }); - - // Remove account - await driver.clickElement('[data-testid="account-menu-icon"]'); - await driver.clickElement( - '.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]', - ); - await driver.clickElement('[data-testid="account-list-menu-remove"]'); - await driver.clickElement({ text: 'Nevermind', tag: 'button' }); - - await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: 'Bitcoin Account', - }); - }, - ); - }); - - it('can recreate BTC account after deleting it', async function () { - // Skip test if its not flask - if (!IS_FLASK) { - return; - } - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await createBtcAccount(driver); - await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: 'Bitcoin Account', - }); - - await driver.clickElement( - '[data-testid="account-options-menu-button"]', - ); - - await driver.clickElement('[data-testid="account-list-menu-details"]'); - - const accountAddress = await ( - await driver.findElement('[data-testid="address-copy-button-text"]') - ).getText(); - - await driver.clickElement('.mm-box button[aria-label="Close"]'); - - // Remove account - await driver.clickElement('[data-testid="account-menu-icon"]'); - await driver.clickElement( - '.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]', - ); - await driver.clickElement('[data-testid="account-list-menu-remove"]'); - await driver.clickElement({ text: 'Remove', tag: 'button' }); - - // Recreate account - await createBtcAccount(driver); - await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: 'Bitcoin Account', - }); - - await driver.clickElement( - '[data-testid="account-options-menu-button"]', - ); - - await driver.clickElement('[data-testid="account-list-menu-details"]'); - - const recreatedAccountAddress = await ( - await driver.findElement('[data-testid="address-copy-button-text"]') - ).getText(); - - await driver.clickElement('.mm-box button[aria-label="Close"]'); - - assert(accountAddress === recreatedAccountAddress); - }, - ); - }); - - it('can recreate BTC account after restoring wallet with srp', async function () { - // Skip test if its not flask - if (!IS_FLASK) { - return; - } - await withFixtures( - { - fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, - title: this.test?.fullTitle(), - }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await createBtcAccount(driver); - await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: 'Bitcoin Account', - }); - - await driver.clickElement( - '[data-testid="account-options-menu-button"]', - ); - - await driver.clickElement('[data-testid="account-list-menu-details"]'); - - const accountAddress = await ( - await driver.findElement('[data-testid="address-copy-button-text"]') - ).getText(); - - await driver.clickElement('.mm-box button[aria-label="Close"]'); - - await openSRPRevealQuiz(driver); - await completeSRPRevealQuiz(driver); - await driver.fill('[data-testid="input-password"]', WALLET_PASSWORD); - await driver.press('[data-testid="input-password"]', driver.Key.ENTER); - await tapAndHoldToRevealSRP(driver); - const seedPhrase = await ( - await driver.findElement('[data-testid="srp_text"]') - ).getText(); - - // Reset wallet - await driver.clickElement( - '[data-testid="account-options-menu-button"]', - ); - const lockButton = await driver.findClickableElement( - '[data-testid="global-menu-lock"]', - ); - assert.equal(await lockButton.getText(), 'Lock MetaMask'); - await lockButton.click(); - - await driver.clickElement({ - text: 'Forgot password?', - tag: 'a', - }); - - await driver.pasteIntoField( - '[data-testid="import-srp__srp-word-0"]', - seedPhrase, - ); - - await driver.fill( - '[data-testid="create-vault-password"]', - WALLET_PASSWORD, - ); - await driver.fill( - '[data-testid="create-vault-confirm-password"]', - WALLET_PASSWORD, - ); - - await driver.clickElement({ - text: 'Restore', - tag: 'button', - }); - - await createBtcAccount(driver); - await driver.findElement({ - css: '[data-testid="account-menu-icon"]', - text: 'Bitcoin Account', - }); - - await driver.clickElement( - '[data-testid="account-options-menu-button"]', - ); - - await driver.clickElement('[data-testid="account-list-menu-details"]'); - - const recreatedAccountAddress = await ( - await driver.findElement('[data-testid="address-copy-button-text"]') - ).getText(); - - await driver.clickElement('.mm-box button[aria-label="Close"]'); - - assert(accountAddress === recreatedAccountAddress); - }, - ); - }); }); diff --git a/test/e2e/fixture-builder.js b/test/e2e/fixture-builder.js index 8a48f29fdef7..1719c7421a46 100644 --- a/test/e2e/fixture-builder.js +++ b/test/e2e/fixture-builder.js @@ -539,6 +539,11 @@ class FixtureBuilder { }); } + withPreferencesControllerAndFeatureFlag(flags) { + merge(this.fixture.data.PreferencesController, flags); + return this; + } + withAccountsController(data) { merge(this.fixture.data.AccountsController, data); return this; diff --git a/test/e2e/accounts/snap-account-overview.spec.ts b/test/e2e/flask/btc/btc-account-overview.spec.ts similarity index 73% rename from test/e2e/accounts/snap-account-overview.spec.ts rename to test/e2e/flask/btc/btc-account-overview.spec.ts index 2134abc2104f..0dc3edf1cbdd 100644 --- a/test/e2e/accounts/snap-account-overview.spec.ts +++ b/test/e2e/flask/btc/btc-account-overview.spec.ts @@ -1,20 +1,23 @@ import { strict as assert } from 'assert'; import { Suite } from 'mocha'; -import { withFixtures, defaultGanacheOptions, unlockWallet } from '../helpers'; -import { Driver } from '../webdriver/driver'; -import FixtureBuilder from '../fixture-builder'; -import { IS_FLASK } from '../../../ui/helpers/utils/util'; -import { createBtcAccount } from './common'; +import { + withFixtures, + defaultGanacheOptions, + unlockWallet, +} from '../../helpers'; +import { Driver } from '../../webdriver/driver'; +import FixtureBuilder from '../../fixture-builder'; +import { createBtcAccount } from '../../accounts/common'; -describe('Snap Account - Overview', function (this: Suite) { +describe('BTC Account - Overview', function (this: Suite) { it('has buy/sell and portfolio button enabled for BTC accounts', async function () { - // Skip test if its not flask - if (!IS_FLASK) { - return; - } await withFixtures( { - fixtures: new FixtureBuilder().build(), + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + bitcoinSupportEnabled: true, + }) + .build(), ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, diff --git a/test/e2e/flask/btc/create-btc-account.spec.ts b/test/e2e/flask/btc/create-btc-account.spec.ts new file mode 100644 index 000000000000..a4cb433e2d6d --- /dev/null +++ b/test/e2e/flask/btc/create-btc-account.spec.ts @@ -0,0 +1,218 @@ +import { strict as assert } from 'assert'; +import { Suite } from 'mocha'; + +import FixtureBuilder from '../../fixture-builder'; +import { + WALLET_PASSWORD, + completeSRPRevealQuiz, + defaultGanacheOptions, + getSelectedAccountAddress, + openSRPRevealQuiz, + removeSelectedAccount, + tapAndHoldToRevealSRP, + unlockWallet, + withFixtures, +} from '../../helpers'; +import { Driver } from '../../webdriver/driver'; +import { createBtcAccount } from '../../accounts/common'; + +describe('Create Snap Account', function (this: Suite) { + it('create BTC account from the menu', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + bitcoinSupportEnabled: true, + }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + }, + ); + }); + + it('cannot create multiple BTC accounts', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + bitcoinSupportEnabled: true, + }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await createBtcAccount(driver); + + // modal will still be here + await driver.clickElement('.mm-box button[aria-label="Close"]'); + + // check the number of accounts. it should only be 2. + await driver.clickElement('[data-testid="account-menu-icon"]'); + const menuItems = await driver.findElements( + '.multichain-account-list-item', + ); + assert.equal(menuItems.length, 2); + }, + ); + }); + + it('can cancel the removal of BTC account', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + bitcoinSupportEnabled: true, + }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]', + ); + await driver.clickElement('[data-testid="account-list-menu-remove"]'); + await driver.clickElement({ text: 'Nevermind', tag: 'button' }); + + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + }, + ); + }); + + it('can recreate BTC account after deleting it', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + bitcoinSupportEnabled: true, + }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + + const accountAddress = await getSelectedAccountAddress(driver); + + await removeSelectedAccount(driver); + + // Recreate account + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + + const recreatedAccountAddress = await getSelectedAccountAddress(driver); + + assert(accountAddress === recreatedAccountAddress); + }, + ); + }); + + it('can recreate BTC account after restoring wallet with srp', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + bitcoinSupportEnabled: true, + }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + + const accountAddress = await getSelectedAccountAddress(driver); + + await openSRPRevealQuiz(driver); + await completeSRPRevealQuiz(driver); + await driver.fill('[data-testid="input-password"]', WALLET_PASSWORD); + await driver.press('[data-testid="input-password"]', driver.Key.ENTER); + await tapAndHoldToRevealSRP(driver); + const seedPhrase = await ( + await driver.findElement('[data-testid="srp_text"]') + ).getText(); + + // Reset wallet + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + const lockButton = await driver.findClickableElement( + '[data-testid="global-menu-lock"]', + ); + assert.equal(await lockButton.getText(), 'Lock MetaMask'); + await lockButton.click(); + + await driver.clickElement({ + text: 'Forgot password?', + tag: 'a', + }); + + await driver.pasteIntoField( + '[data-testid="import-srp__srp-word-0"]', + seedPhrase, + ); + + await driver.fill( + '[data-testid="create-vault-password"]', + WALLET_PASSWORD, + ); + await driver.fill( + '[data-testid="create-vault-confirm-password"]', + WALLET_PASSWORD, + ); + + await driver.clickElement({ + text: 'Restore', + tag: 'button', + }); + + await createBtcAccount(driver); + await driver.findElement({ + css: '[data-testid="account-menu-icon"]', + text: 'Bitcoin Account', + }); + + const recreatedAccountAddress = await getSelectedAccountAddress(driver); + + assert(accountAddress === recreatedAccountAddress); + }, + ); + }); +}); diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 5aa187496412..e358df00db3e 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -1140,6 +1140,29 @@ async function initBundler(bundlerServer, ganacheServer, usePaymaster) { } } +async function removeSelectedAccount(driver) { + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '.multichain-account-list-item--selected [data-testid="account-list-item-menu-button"]', + ); + await driver.clickElement('[data-testid="account-list-menu-remove"]'); + await driver.clickElement({ text: 'Remove', tag: 'button' }); +} + +async function getSelectedAccountAddress(driver) { + await driver.clickElement('[data-testid="account-options-menu-button"]'); + + await driver.clickElement('[data-testid="account-list-menu-details"]'); + + const accountAddress = await ( + await driver.findElement('[data-testid="address-copy-button-text"]') + ).getText(); + + await driver.clickElement('.mm-box button[aria-label="Close"]'); + + return accountAddress; +} + module.exports = { DAPP_HOST_ADDRESS, DAPP_URL, @@ -1207,4 +1230,6 @@ module.exports = { editGasFeeForm, clickNestedButton, defaultGanacheOptionsForType2Transactions, + removeSelectedAccount, + getSelectedAccountAddress, }; diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index 48ff055cdd58..48903ccddd82 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -45,6 +45,7 @@ import { getSelectedInternalAccount, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) getIsAddSnapAccountEnabled, + getIsBitcoinSupportEnabled, ///: END:ONLY_INCLUDE_IF } from '../../../selectors'; import { setSelectedAccount } from '../../../store/actions'; @@ -149,6 +150,8 @@ export const AccountListMenu = ({ const addSnapAccountEnabled = useSelector(getIsAddSnapAccountEnabled); ///: END:ONLY_INCLUDE_IF + const isBtcEnabled = useSelector(getIsBitcoinSupportEnabled); + const [searchQuery, setSearchQuery] = useState(''); const [actionMode, setActionMode] = useState(ACTION_MODES.LIST); @@ -206,23 +209,19 @@ export const AccountListMenu = ({ /> ) : null} - { - ///: BEGIN:ONLY_INCLUDE_IF(build-flask) - actionMode === ACTION_MODES.ADD_BITCOIN ? ( - - { - if (confirmed) { - onClose(); - } else { - setActionMode(ACTION_MODES.LIST); - } - }} - /> - - ) : null - ///: END:ONLY_INCLUDE_IF - } + {isBtcEnabled && actionMode === ACTION_MODES.ADD_BITCOIN ? ( + + { + if (confirmed) { + onClose(); + } else { + setActionMode(ACTION_MODES.LIST); + } + }} + /> + + ) : null} {actionMode === ACTION_MODES.IMPORT ? ( ref={this.settingsRefs[0]} className="settings-page__content-row settings-page__content-row-experimental" > -
+
{title}
{description} From 66f21f4e1041b6d3e218298d46f00bb0fe2cabb0 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Tue, 9 Jul 2024 20:51:06 +0800 Subject: [PATCH 48/75] feat: add connection and experimental settings --- .../e2e/flask/btc/btc-dapp-connection.spec.ts | 47 +++++++++++++++++ .../btc/btc-experimental-settings.spec.ts | 50 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 test/e2e/flask/btc/btc-dapp-connection.spec.ts create mode 100644 test/e2e/flask/btc/btc-experimental-settings.spec.ts diff --git a/test/e2e/flask/btc/btc-dapp-connection.spec.ts b/test/e2e/flask/btc/btc-dapp-connection.spec.ts new file mode 100644 index 000000000000..cbf99bf0fe60 --- /dev/null +++ b/test/e2e/flask/btc/btc-dapp-connection.spec.ts @@ -0,0 +1,47 @@ +import { strict as assert } from 'assert'; +import { Suite } from 'mocha'; +import { + withFixtures, + defaultGanacheOptions, + unlockWallet, + openDapp, + WINDOW_TITLES, +} from '../../helpers'; +import { Driver } from '../../webdriver/driver'; +import FixtureBuilder from '../../fixture-builder'; +import { createBtcAccount } from '../../accounts/common'; + +describe('BTC Account - Dapp Connection', function (this: Suite) { + it('cannot connect to dapps', async function () { + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withPreferencesControllerAndFeatureFlag({ + bitcoinSupportEnabled: true, + }) + .build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await createBtcAccount(driver); + await openDapp(driver); + await driver.clickElement('#connectButton'); + await driver.waitUntilXWindowHandles(3); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + + const account2 = await driver.waitForSelector( + '[data-testid="choose-account-list-1"]', + ); + assert((await account2.getText()).includes('Bitcoin Ac...')); + await account2.click(); + const nextButton = await driver.waitForSelector( + '[data-testid="page-container-footer-next"]', + ); + assert.equal(await nextButton.isEnabled(), false); + }, + ); + }); +}); diff --git a/test/e2e/flask/btc/btc-experimental-settings.spec.ts b/test/e2e/flask/btc/btc-experimental-settings.spec.ts new file mode 100644 index 000000000000..e5b7d6bf4d74 --- /dev/null +++ b/test/e2e/flask/btc/btc-experimental-settings.spec.ts @@ -0,0 +1,50 @@ +import { Suite } from 'mocha'; + +import FixtureBuilder from '../../fixture-builder'; +import { + defaultGanacheOptions, + unlockWallet, + withFixtures, +} from '../../helpers'; +import { Driver } from '../../webdriver/driver'; + +describe('BTC Experimental Settings', function (this: Suite) { + it('will show `Add new BTC account` option when setting is enabled', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder().build(), + ganacheOptions: defaultGanacheOptions, + title: this.test?.fullTitle(), + }, + async ({ driver }: { driver: Driver }) => { + await unlockWallet(driver); + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + await driver.clickElement({ text: 'Settings', tag: 'div' }); + await driver.clickElement({ text: 'Experimental', tag: 'div' }); + + // The option requires tapping the experimental title 5 times before appearing. + for (let i = 0; i < 5; i++) { + await driver.clickElement( + '[data-testid="experimental-container-title"]', + ); + } + await driver.waitForSelector({ + text: 'Enable "Add Bitcoin Account (Beta)"', + tag: 'span', + }); + await driver.clickElement('button[aria-label="Close"]'); + + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '[data-testid="multichain-account-menu-popover-action-button"]', + ); + await driver.waitForSelector({ + text: 'Add a new Bitcoin account', + tag: 'button', + }); + }, + ); + }); +}); From 48c87b5eb65d34abc470b26919f8728649c6b4f7 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Tue, 9 Jul 2024 21:13:09 +0800 Subject: [PATCH 49/75] fix: fence --- .../account-list-menu/account-list-menu.js | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index 48903ccddd82..1e22b3f1bdb4 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -209,19 +209,23 @@ export const AccountListMenu = ({ /> ) : null} - {isBtcEnabled && actionMode === ACTION_MODES.ADD_BITCOIN ? ( - - { - if (confirmed) { - onClose(); - } else { - setActionMode(ACTION_MODES.LIST); - } - }} - /> - - ) : null} + { + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) + isBtcEnabled && actionMode === ACTION_MODES.ADD_BITCOIN ? ( + + { + if (confirmed) { + onClose(); + } else { + setActionMode(ACTION_MODES.LIST); + } + }} + /> + + ) : null + ///: END:ONLY_INCLUDE_IF + } {actionMode === ACTION_MODES.IMPORT ? ( Date: Tue, 9 Jul 2024 21:33:36 +0800 Subject: [PATCH 50/75] fix: add fence for isBtcEnabled --- ui/components/multichain/account-list-menu/account-list-menu.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index 1e22b3f1bdb4..8b0fc57dd27b 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -150,7 +150,9 @@ export const AccountListMenu = ({ const addSnapAccountEnabled = useSelector(getIsAddSnapAccountEnabled); ///: END:ONLY_INCLUDE_IF + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) const isBtcEnabled = useSelector(getIsBitcoinSupportEnabled); + ///: END:ONLY_INCLUDE_IF const [searchQuery, setSearchQuery] = useState(''); const [actionMode, setActionMode] = useState(ACTION_MODES.LIST); From 07d95834cfbbe57697556409e04a5b60df563fc6 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Tue, 9 Jul 2024 22:12:38 +0800 Subject: [PATCH 51/75] fix: lint --- ui/components/multichain/account-list-menu/account-list-menu.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index 8b0fc57dd27b..0c22f199793d 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -45,6 +45,8 @@ import { getSelectedInternalAccount, ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) getIsAddSnapAccountEnabled, + ///: END:ONLY_INCLUDE_IF + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) getIsBitcoinSupportEnabled, ///: END:ONLY_INCLUDE_IF } from '../../../selectors'; From 324b95568b5c1ffe5b505cebfdf4c0e3820a7127 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Tue, 9 Jul 2024 10:53:39 -0400 Subject: [PATCH 52/75] chore: update commentary for setBitcoinSupportEnabled --- app/scripts/controllers/preferences.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 849d41dbfcd4..aa14bc84a1a4 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -295,7 +295,7 @@ export default class PreferencesController { * Setter for the `bitcoinSupportEnabled` property. * * @param {boolean} bitcoinSupportEnabled - Whether or not the user wants to - * enable the "Add Bitcoin account" button. + * enable the "Add a new Bitcoin account" button. */ setBitcoinSupportEnabled(bitcoinSupportEnabled) { this.store.updateState({ From 573a5b5d532697070be241916f117395cb93b0ea Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Tue, 9 Jul 2024 10:54:40 -0400 Subject: [PATCH 53/75] test: update toggle test ID --- .../settings/experimental-tab/experimental-tab.component.tsx | 2 +- ui/pages/settings/experimental-tab/experimental-tab.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 7b165c4ee853..6154a16fa09a 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -277,7 +277,7 @@ export default class ExperimentalTab extends PureComponent }); setBitcoinSupportEnabled(!value); }, - toggleDataTestId: 'bitcoin-accounts-toggle', + toggleDataTestId: 'bitcoin-support-toggle', toggleOffLabel: t('off'), toggleOnLabel: t('on'), })} diff --git a/ui/pages/settings/experimental-tab/experimental-tab.test.js b/ui/pages/settings/experimental-tab/experimental-tab.test.js index 069c4ec802f5..ef519bca6df2 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.test.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.test.js @@ -100,7 +100,7 @@ describe('ExperimentalTab', () => { bitcoinSupportEnabled: false, }, ); - const toggle = getByTestId('bitcoin-accounts-toggle'); + const toggle = getByTestId('bitcoin-support-toggle'); // Should turn the BTC experimental toggle ON fireEvent.click(toggle); From f39d57fe7442c7bf181ad14dcb2acc811cbd6a73 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Tue, 9 Jul 2024 10:55:34 -0400 Subject: [PATCH 54/75] chore: update event variable name --- shared/constants/metametrics.ts | 2 +- .../settings/experimental-tab/experimental-tab.component.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index eb22807886ae..ddbe772e905c 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -512,7 +512,7 @@ export enum MetaMetricsEventName { AppLocked = 'App Locked', AppWindowExpanded = 'App Window Expanded', BridgeLinkClicked = 'Bridge Link Clicked', - BtcExperimentalToggled = 'BTC Experimental Toggled', + BitcoinSupportToggled = 'BTC Experimental Toggled', DappViewed = 'Dapp Viewed', DecryptionApproved = 'Decryption Approved', DecryptionRejected = 'Decryption Rejected', diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 6154a16fa09a..d621691e5457 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -269,7 +269,7 @@ export default class ExperimentalTab extends PureComponent toggleValue: bitcoinSupportEnabled, toggleCallback: (value) => { trackEvent({ - event: MetaMetricsEventName.BtcExperimentalToggled, + event: MetaMetricsEventName.BitcoinSupportToggled, category: MetaMetricsEventCategory.Settings, properties: { enabled: !value, From 20e356b53e25c0ff6f4a6dbc965042e052d92654 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Tue, 9 Jul 2024 10:59:30 -0400 Subject: [PATCH 55/75] chore: update copy variable names --- app/_locales/en/messages.json | 20 +++++++++---------- .../experimental-tab.component.tsx | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 37cf2b87a286..f3ea92c08526 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -756,6 +756,16 @@ "bitcoinActivityNotSupported": { "message": "Bitcoin activity is not supported" }, + "bitcoinSupportSectionTitle": { + "message": "Bitcoin" + }, + "bitcoinSupportToggleDescription": { + "message": "Turning on this feature will give you the option to add a Bitcoin Account to your MetaMask Extension derived from your existing Secret Recovery Phrase. This is an experimental Beta feature, so you should use it at your own risk. To give us feedback on this new Bitcoin experience, please fill out this $1.", + "description": "$1 is the link to a product feedback form" + }, + "bitcoinSupportToggleTitle": { + "message": "Enable \"Add Bitcoin Account (Beta)\"" + }, "blockExplorerAccountAction": { "message": "Account", "description": "This is used with viewOnEtherscan and viewInExplorer e.g View Account in Explorer" @@ -1887,16 +1897,6 @@ "experimental": { "message": "Experimental" }, - "experimentalBitcoinSectionTitle": { - "message": "Bitcoin" - }, - "experimentalBitcoinToggleDescription": { - "message": "Turning on this feature will give you the option to add a Bitcoin Account to your MetaMask Extension derived from your existing Secret Recovery Phrase. This is an experimental Beta feature, so you should use it at your own risk. To give us feedback on this new Bitcoin experience, please fill out this $1.", - "description": "$1 is the link to a product feedback form" - }, - "experimentalBitcoinToggleTitle": { - "message": "Enable \"Add Bitcoin Account (Beta)\"" - }, "extendWalletWithSnaps": { "message": "Explore community-built Snaps to customize your web3 experience", "description": "Banner description displayed on Snaps list page in Settings when less than 6 Snaps is installed." diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index d621691e5457..ab467ac1eba6 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -252,11 +252,11 @@ export default class ExperimentalTab extends PureComponent marginBottom={2} fontWeight={FontWeight.Bold} > - {t('experimentalBitcoinSectionTitle')} + {t('bitcoinSupportSectionTitle')} {this.renderToggleSection({ - title: t('experimentalBitcoinToggleTitle'), - description: t('experimentalBitcoinToggleDescription', [ + title: t('bitcoinSupportToggleTitle'), + description: t('bitcoinSupportToggleDescription', [ Date: Tue, 9 Jul 2024 11:00:37 -0400 Subject: [PATCH 56/75] refactor: remove redundant code --- .../settings/experimental-tab/experimental-tab.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index ab467ac1eba6..c17536462131 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -305,7 +305,7 @@ export default class ExperimentalTab extends PureComponent // we should remove it for the feature release /* Section: Bitcoin Accounts */ - <>{this.renderBitcoinSupport()} + this.renderBitcoinSupport() ///: END:ONLY_INCLUDE_IF }
From 737b269ceb50e31b31833ffbefaf65430f182b10 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:31:47 -0400 Subject: [PATCH 57/75] chore: rename metrics variable --- shared/constants/metametrics.ts | 2 +- .../settings/experimental-tab/experimental-tab.component.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index ddbe772e905c..8011a84f9f12 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -512,7 +512,7 @@ export enum MetaMetricsEventName { AppLocked = 'App Locked', AppWindowExpanded = 'App Window Expanded', BridgeLinkClicked = 'Bridge Link Clicked', - BitcoinSupportToggled = 'BTC Experimental Toggled', + BtcSupportToggled = 'BTC Experimental Toggled', DappViewed = 'Dapp Viewed', DecryptionApproved = 'Decryption Approved', DecryptionRejected = 'Decryption Rejected', diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index c17536462131..ed1ebe6fcad3 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -269,7 +269,7 @@ export default class ExperimentalTab extends PureComponent toggleValue: bitcoinSupportEnabled, toggleCallback: (value) => { trackEvent({ - event: MetaMetricsEventName.BitcoinSupportToggled, + event: MetaMetricsEventName.BtcSupportToggled, category: MetaMetricsEventCategory.Settings, properties: { enabled: !value, From e99ef8301d231265a71911c757654ce3de0f293c Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:37:40 -0400 Subject: [PATCH 58/75] chore: update metrics event Co-authored-by: Charly Chevalier --- shared/constants/metametrics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index 8011a84f9f12..7a83ec4f61e2 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -512,7 +512,7 @@ export enum MetaMetricsEventName { AppLocked = 'App Locked', AppWindowExpanded = 'App Window Expanded', BridgeLinkClicked = 'Bridge Link Clicked', - BtcSupportToggled = 'BTC Experimental Toggled', + BitcoinSupportToggled = 'Bitcoin Support Toggled', DappViewed = 'Dapp Viewed', DecryptionApproved = 'Decryption Approved', DecryptionRejected = 'Decryption Rejected', From f789263a11605c1cb1995780d5b5a4b33c310734 Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:37:48 -0400 Subject: [PATCH 59/75] chore: update metrics event Co-authored-by: Charly Chevalier --- .../settings/experimental-tab/experimental-tab.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index ed1ebe6fcad3..c17536462131 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -269,7 +269,7 @@ export default class ExperimentalTab extends PureComponent toggleValue: bitcoinSupportEnabled, toggleCallback: (value) => { trackEvent({ - event: MetaMetricsEventName.BtcSupportToggled, + event: MetaMetricsEventName.BitcoinSupportToggled, category: MetaMetricsEventCategory.Settings, properties: { enabled: !value, From 163511b0bb6fd92e46c649451ebacc45b6d5fb6e Mon Sep 17 00:00:00 2001 From: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:20:14 -0400 Subject: [PATCH 60/75] chore: update copy Co-authored-by: Charly Chevalier --- app/_locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index f3ea92c08526..0c7f46adad19 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -764,7 +764,7 @@ "description": "$1 is the link to a product feedback form" }, "bitcoinSupportToggleTitle": { - "message": "Enable \"Add Bitcoin Account (Beta)\"" + "message": "Enable \"Add a new Bitcoin account (Beta)\"" }, "blockExplorerAccountAction": { "message": "Account", From a88a3bb2a14f63a0ce55ae822f4630590530bef8 Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:17:48 -0400 Subject: [PATCH 61/75] chore: update copy --- app/_locales/en/messages.json | 7 +++++-- .../experimental-tab/experimental-tab.component.tsx | 11 +---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index f3ea92c08526..3b35a6a1120b 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -759,8 +759,11 @@ "bitcoinSupportSectionTitle": { "message": "Bitcoin" }, - "bitcoinSupportToggleDescription": { - "message": "Turning on this feature will give you the option to add a Bitcoin Account to your MetaMask Extension derived from your existing Secret Recovery Phrase. This is an experimental Beta feature, so you should use it at your own risk. To give us feedback on this new Bitcoin experience, please fill out this $1.", + "bitcoinSupportToggleDescriptionPart1": { + "message": "Turning on this feature will give you the option to add a Bitcoin Account to your MetaMask Extension derived from your existing Secret Recovery Phrase. This is an experimental Beta feature, so you should use it at your own risk." + }, + "bitcoinSupportToggleDescriptionPart2": { + "message": "To give us feedback on this new Bitcoin experience, please fill out this $1.", "description": "$1 is the link to a product feedback form" }, "bitcoinSupportToggleTitle": { diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index ed1ebe6fcad3..fd06bc737319 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -256,16 +256,7 @@ export default class ExperimentalTab extends PureComponent {this.renderToggleSection({ title: t('bitcoinSupportToggleTitle'), - description: t('bitcoinSupportToggleDescription', [ - - {t('form')} - , - ]), + description: t('bitcoinSupportToggleDescriptionPart1'), toggleValue: bitcoinSupportEnabled, toggleCallback: (value) => { trackEvent({ From 58cccfe5d1ba4148f6b54ae3c459e6d5c063674e Mon Sep 17 00:00:00 2001 From: gantunesr <17601467+gantunesr@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:30:18 -0400 Subject: [PATCH 62/75] chore: hide add account behind feature flag --- .../account-list-menu/account-list-menu.js | 46 +++++++------------ .../experimental-tab.component.tsx | 4 +- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index 4dac071db4b9..1eaeb51877de 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -22,9 +22,7 @@ import { CreateEthAccount, ImportAccount, AccountListItemMenuTypes, - ///: BEGIN:ONLY_INCLUDE_IF(build-flask) CreateBtcAccount, - ///: END:ONLY_INCLUDE_IF } from '..'; import { AlignItems, @@ -46,6 +44,7 @@ import { ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) getIsAddSnapAccountEnabled, ///: END:ONLY_INCLUDE_IF + getIsBitcoinSupportEnabled, } from '../../../selectors'; import { setSelectedAccount } from '../../../store/actions'; import { @@ -62,9 +61,7 @@ import { import { getEnvironmentType } from '../../../../app/scripts/lib/util'; import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app'; import { getAccountLabel } from '../../../helpers/utils/accounts'; -///: BEGIN:ONLY_INCLUDE_IF(build-flask) import { hasCreatedBtcMainnetAccount } from '../../../selectors/accounts'; -///: END:ONLY_INCLUDE_IF import { HiddenAccountList } from './hidden-account-list'; const ACTION_MODES = { @@ -74,10 +71,8 @@ const ACTION_MODES = { MENU: 'menu', // Displays the add account form controls ADD: 'add', - ///: BEGIN:ONLY_INCLUDE_IF(build-flask) // Displays the add account form controls (for bitcoin account) ADD_BITCOIN: 'add-bitcoin', - ///: END:ONLY_INCLUDE_IF // Displays the import account form controls IMPORT: 'import', }; @@ -151,11 +146,10 @@ export const AccountListMenu = ({ ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) const addSnapAccountEnabled = useSelector(getIsAddSnapAccountEnabled); ///: END:ONLY_INCLUDE_IF - ///: BEGIN:ONLY_INCLUDE_IF(build-flask) + const bitcoinSupportEnabled = useSelector(getIsBitcoinSupportEnabled); const isBtcMainnetAccountAlreadyCreated = useSelector( hasCreatedBtcMainnetAccount, ); - ///: END:ONLY_INCLUDE_IF const [searchQuery, setSearchQuery] = useState(''); const [actionMode, setActionMode] = useState(ACTION_MODES.LIST); @@ -214,23 +208,19 @@ export const AccountListMenu = ({ /> ) : null} - { - ///: BEGIN:ONLY_INCLUDE_IF(build-flask) - actionMode === ACTION_MODES.ADD_BITCOIN ? ( - - { - if (confirmed) { - onClose(); - } else { - setActionMode(ACTION_MODES.LIST); - } - }} - /> - - ) : null - ///: END:ONLY_INCLUDE_IF - } + {actionMode === ACTION_MODES.ADD_BITCOIN ? ( + + { + if (confirmed) { + onClose(); + } else { + setActionMode(ACTION_MODES.LIST); + } + }} + /> + + ) : null} {actionMode === ACTION_MODES.IMPORT ? ( - { - ///: BEGIN:ONLY_INCLUDE_IF(build-flask) + {bitcoinSupportEnabled ? ( - ///: END:ONLY_INCLUDE_IF - } + ) : null} }); } - ///: BEGIN:ONLY_INCLUDE_IF(build-flask,build-beta) + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) // We're only setting the code fences here since // we should remove it for the feature release renderBitcoinSupport() { @@ -291,7 +291,7 @@ export default class ExperimentalTab extends PureComponent ///: END:ONLY_INCLUDE_IF } { - ///: BEGIN:ONLY_INCLUDE_IF(build-flask,build-beta) + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) // We're only setting the code fences here since // we should remove it for the feature release From 8a97a3718df002ce08701ff32591b9acaecf9c57 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 11 Jul 2024 00:39:17 +0800 Subject: [PATCH 63/75] fix:lint --- .../multichain/account-list-menu/account-list-menu.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index 10d743ec806b..1eaeb51877de 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -151,10 +151,6 @@ export const AccountListMenu = ({ hasCreatedBtcMainnetAccount, ); - ///: BEGIN:ONLY_INCLUDE_IF(build-flask) - const isBtcEnabled = useSelector(getIsBitcoinSupportEnabled); - ///: END:ONLY_INCLUDE_IF - const [searchQuery, setSearchQuery] = useState(''); const [actionMode, setActionMode] = useState(ACTION_MODES.LIST); From 024fc7e089e812f93ccd315ee39fcde9bb92e233 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 11 Jul 2024 00:45:12 +0800 Subject: [PATCH 64/75] fix: remove unused dep --- package.json | 1 - yarn.lock | 8 -------- 2 files changed, 9 deletions(-) diff --git a/package.json b/package.json index fd9726114462..7223d7d1713f 100644 --- a/package.json +++ b/package.json @@ -262,7 +262,6 @@ "dependencies": { "@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", "@blockaid/ppom_release": "^1.4.9", - "@consensys/bitcoin-manager-snap": "0.1.4-rc5", "@contentful/rich-text-html-renderer": "^16.3.5", "@ensdomains/content-hash": "^2.5.7", "@ethereumjs/tx": "^4.1.1", diff --git a/yarn.lock b/yarn.lock index 39d850f4df45..728fafdc45ed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1758,13 +1758,6 @@ __metadata: languageName: node linkType: hard -"@consensys/bitcoin-manager-snap@npm:0.1.4-rc5": - version: 0.1.4-rc5 - resolution: "@consensys/bitcoin-manager-snap@npm:0.1.4-rc5" - checksum: 10/fce2354db7f75f48655d7e2a1f02b05385b0dcbfd704d366890afdd8eee7432ab550bf8963e0e6dfb64ce9c565f4e6c697e8940af1798f75a8069891a476ee37 - languageName: node - linkType: hard - "@contentful/rich-text-html-renderer@npm:^16.3.5": version: 16.3.5 resolution: "@contentful/rich-text-html-renderer@npm:16.3.5" @@ -25164,7 +25157,6 @@ __metadata: "@babel/register": "npm:^7.22.15" "@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch" "@blockaid/ppom_release": "npm:^1.4.9" - "@consensys/bitcoin-manager-snap": "npm:0.1.4-rc5" "@contentful/rich-text-html-renderer": "npm:^16.3.5" "@ensdomains/content-hash": "npm:^2.5.7" "@ethereumjs/tx": "npm:^4.1.1" From 98f07600317010e9616efb4dcfcad86c74308d82 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 11 Jul 2024 07:22:20 +0800 Subject: [PATCH 65/75] fix: remove unneeded changes --- .prettierignore | 1 - .../lib/snap-keyring/bitcoin-manager-snap.ts | 21 ------------------- .../account-list-menu/account-list-menu.js | 7 +++++++ 3 files changed, 7 insertions(+), 22 deletions(-) delete mode 100644 app/scripts/lib/snap-keyring/bitcoin-manager-snap.ts diff --git a/.prettierignore b/.prettierignore index 228f246bc4d0..e70feef786f9 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,7 +4,6 @@ dist/**/* builds/**/* test-*/**/* app/vendor/** -app/scripts/snaps/*.json .nyc_output/**/* test/e2e/send-eth-with-private-key-test/**/* *.scss diff --git a/app/scripts/lib/snap-keyring/bitcoin-manager-snap.ts b/app/scripts/lib/snap-keyring/bitcoin-manager-snap.ts deleted file mode 100644 index 9ce906f4a368..000000000000 --- a/app/scripts/lib/snap-keyring/bitcoin-manager-snap.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { SnapId } from '@metamask/snaps-sdk'; -import { Sender } from '@metamask/keyring-api'; -import { HandlerType } from '@metamask/snaps-utils'; -import { Json, JsonRpcRequest } from '@metamask/utils'; -import { handleSnapRequest } from '../../../../ui/store/actions'; - -export const BITCOIN_MANAGER_SNAP_ID: SnapId = - 'npm:@consensys/bitcoin-manager-snap' as SnapId; -// Local snap: -// 'local:http://localhost:8080' as SnapId; - -export class BitcoinManagerSnapSender implements Sender { - send = async (request: JsonRpcRequest): Promise => { - return (await handleSnapRequest({ - origin: 'metamask', - snapId: BITCOIN_MANAGER_SNAP_ID, - handler: HandlerType.OnKeyringRequest, - request, - })) as Json; - }; -} diff --git a/ui/components/multichain/account-list-menu/account-list-menu.js b/ui/components/multichain/account-list-menu/account-list-menu.js index 8c650a8223de..6e4c7490541c 100644 --- a/ui/components/multichain/account-list-menu/account-list-menu.js +++ b/ui/components/multichain/account-list-menu/account-list-menu.js @@ -22,7 +22,9 @@ import { CreateEthAccount, ImportAccount, AccountListItemMenuTypes, + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) CreateBtcAccount, + ///: END:ONLY_INCLUDE_IF } from '..'; import { AlignItems, @@ -63,7 +65,9 @@ import { import { getEnvironmentType } from '../../../../app/scripts/lib/util'; import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app'; import { getAccountLabel } from '../../../helpers/utils/accounts'; +///: BEGIN:ONLY_INCLUDE_IF(build-flask) import { hasCreatedBtcMainnetAccount } from '../../../selectors/accounts'; +///: END:ONLY_INCLUDE_IF import { HiddenAccountList } from './hidden-account-list'; const ACTION_MODES = { @@ -73,8 +77,10 @@ const ACTION_MODES = { MENU: 'menu', // Displays the add account form controls ADD: 'add', + ///: BEGIN:ONLY_INCLUDE_IF(build-flask) // Displays the add account form controls (for bitcoin account) ADD_BITCOIN: 'add-bitcoin', + ///: END:ONLY_INCLUDE_IF // Displays the import account form controls IMPORT: 'import', }; @@ -153,6 +159,7 @@ export const AccountListMenu = ({ const isBtcMainnetAccountAlreadyCreated = useSelector( hasCreatedBtcMainnetAccount, ); + ///: END:ONLY_INCLUDE_IF const [searchQuery, setSearchQuery] = useState(''); const [actionMode, setActionMode] = useState(ACTION_MODES.LIST); From 16321701e0036b6ac2ad366cc95979a65ffe0a05 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 11 Jul 2024 13:36:08 +0800 Subject: [PATCH 66/75] fix: test --- test/e2e/flask/btc/btc-experimental-settings.spec.ts | 11 ++++------- .../experimental-tab/experimental-tab.component.tsx | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/e2e/flask/btc/btc-experimental-settings.spec.ts b/test/e2e/flask/btc/btc-experimental-settings.spec.ts index e5b7d6bf4d74..d12b67e337b9 100644 --- a/test/e2e/flask/btc/btc-experimental-settings.spec.ts +++ b/test/e2e/flask/btc/btc-experimental-settings.spec.ts @@ -24,16 +24,13 @@ describe('BTC Experimental Settings', function (this: Suite) { await driver.clickElement({ text: 'Settings', tag: 'div' }); await driver.clickElement({ text: 'Experimental', tag: 'div' }); - // The option requires tapping the experimental title 5 times before appearing. - for (let i = 0; i < 5; i++) { - await driver.clickElement( - '[data-testid="experimental-container-title"]', - ); - } await driver.waitForSelector({ - text: 'Enable "Add Bitcoin Account (Beta)"', + text: 'Enable "Add a new Bitcoin account (Beta)"', tag: 'span', }); + + await driver.clickElement('[data-testid="bitcoin-support-toggle-div"]'); + await driver.clickElement('button[aria-label="Close"]'); await driver.clickElement('[data-testid="account-menu-icon"]'); diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx index 04f4de68f608..7e01650cd688 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.tsx +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.tsx @@ -268,6 +268,7 @@ export default class ExperimentalTab extends PureComponent }); setBitcoinSupportEnabled(!value); }, + toggleContainerDataTestId: 'bitcoin-support-toggle-div', toggleDataTestId: 'bitcoin-support-toggle', toggleOffLabel: t('off'), toggleOnLabel: t('on'), From 3d31330e7f196ea3f9a8c6d3314a3cae0f533ae4 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 11 Jul 2024 21:18:47 +0800 Subject: [PATCH 67/75] Update test/e2e/accounts/common.ts Co-authored-by: Charly Chevalier --- test/e2e/accounts/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/accounts/common.ts b/test/e2e/accounts/common.ts index 7da9fe42e306..875d9da2a720 100644 --- a/test/e2e/accounts/common.ts +++ b/test/e2e/accounts/common.ts @@ -379,7 +379,7 @@ export async function createBtcAccount(driver: Driver) { '[data-testid="multichain-account-menu-popover-action-button"]', ); await driver.clickElement({ - text: 'Add a new Bitcoin account', + text: 'Add a new Bitcoin account (Beta)', tag: 'button', }); await driver.clickElement({ text: 'Create', tag: 'button' }); From 590263674813ca2dfe44c714717547b16fc353dd Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 11 Jul 2024 21:29:30 +0800 Subject: [PATCH 68/75] fix: cannot create multiple BTC account test --- test/e2e/flask/btc/create-btc-account.spec.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/e2e/flask/btc/create-btc-account.spec.ts b/test/e2e/flask/btc/create-btc-account.spec.ts index a4cb433e2d6d..57c925ea87ee 100644 --- a/test/e2e/flask/btc/create-btc-account.spec.ts +++ b/test/e2e/flask/btc/create-btc-account.spec.ts @@ -53,7 +53,17 @@ describe('Create Snap Account', function (this: Suite) { async ({ driver }: { driver: Driver }) => { await unlockWallet(driver); await createBtcAccount(driver); - await createBtcAccount(driver); + await driver.delay(500); + await driver.clickElement('[data-testid="account-menu-icon"]'); + await driver.clickElement( + '[data-testid="multichain-account-menu-popover-action-button"]', + ); + const createButton = await driver.findElement({ + text: 'Add a new Bitcoin account (Beta)', + tag: 'button', + }); + + assert.equal(await createButton.isEnabled(), false); // modal will still be here await driver.clickElement('.mm-box button[aria-label="Close"]'); From 89a85b628ac03817a0905688d47c63564851a744 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 11 Jul 2024 21:56:26 +0800 Subject: [PATCH 69/75] fix: empty lines --- test/e2e/helpers.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index e358df00db3e..e492e714b00a 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -1151,13 +1151,10 @@ async function removeSelectedAccount(driver) { async function getSelectedAccountAddress(driver) { await driver.clickElement('[data-testid="account-options-menu-button"]'); - await driver.clickElement('[data-testid="account-list-menu-details"]'); - const accountAddress = await ( await driver.findElement('[data-testid="address-copy-button-text"]') ).getText(); - await driver.clickElement('.mm-box button[aria-label="Close"]'); return accountAddress; From 11451d8ea0a843f0460c83df9a8a835cc018ef31 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Fri, 12 Jul 2024 20:53:24 +0800 Subject: [PATCH 70/75] Apply suggestions from code review Co-authored-by: Charly Chevalier --- test/e2e/flask/btc/btc-experimental-settings.spec.ts | 4 ++-- test/e2e/flask/btc/create-btc-account.spec.ts | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/e2e/flask/btc/btc-experimental-settings.spec.ts b/test/e2e/flask/btc/btc-experimental-settings.spec.ts index d12b67e337b9..06a8f994a62b 100644 --- a/test/e2e/flask/btc/btc-experimental-settings.spec.ts +++ b/test/e2e/flask/btc/btc-experimental-settings.spec.ts @@ -9,7 +9,7 @@ import { import { Driver } from '../../webdriver/driver'; describe('BTC Experimental Settings', function (this: Suite) { - it('will show `Add new BTC account` option when setting is enabled', async function () { + it('will show `Add a new Bitcoin account (Beta)` option when setting is enabled', async function () { await withFixtures( { fixtures: new FixtureBuilder().build(), @@ -38,7 +38,7 @@ describe('BTC Experimental Settings', function (this: Suite) { '[data-testid="multichain-account-menu-popover-action-button"]', ); await driver.waitForSelector({ - text: 'Add a new Bitcoin account', + text: 'Add a new Bitcoin account (Beta)', tag: 'button', }); }, diff --git a/test/e2e/flask/btc/create-btc-account.spec.ts b/test/e2e/flask/btc/create-btc-account.spec.ts index 57c925ea87ee..5815bd057f2c 100644 --- a/test/e2e/flask/btc/create-btc-account.spec.ts +++ b/test/e2e/flask/btc/create-btc-account.spec.ts @@ -16,7 +16,7 @@ import { import { Driver } from '../../webdriver/driver'; import { createBtcAccount } from '../../accounts/common'; -describe('Create Snap Account', function (this: Suite) { +describe('Create BTC Account', function (this: Suite) { it('create BTC account from the menu', async function () { await withFixtures( { @@ -58,11 +58,11 @@ describe('Create Snap Account', function (this: Suite) { await driver.clickElement( '[data-testid="multichain-account-menu-popover-action-button"]', ); + const createButton = await driver.findElement({ text: 'Add a new Bitcoin account (Beta)', tag: 'button', }); - assert.equal(await createButton.isEnabled(), false); // modal will still be here @@ -143,13 +143,12 @@ describe('Create Snap Account', function (this: Suite) { }); const recreatedAccountAddress = await getSelectedAccountAddress(driver); - assert(accountAddress === recreatedAccountAddress); }, ); }); - it('can recreate BTC account after restoring wallet with srp', async function () { + it('can recreate BTC account after restoring wallet with SRP', async function () { await withFixtures( { fixtures: new FixtureBuilder() @@ -220,7 +219,6 @@ describe('Create Snap Account', function (this: Suite) { }); const recreatedAccountAddress = await getSelectedAccountAddress(driver); - assert(accountAddress === recreatedAccountAddress); }, ); From 1998540eac2489bc8b2d24e5609efc36fa09b66e Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Fri, 12 Jul 2024 20:54:31 +0800 Subject: [PATCH 71/75] Update test/e2e/flask/btc/create-btc-account.spec.ts Co-authored-by: Charly Chevalier --- test/e2e/flask/btc/create-btc-account.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/flask/btc/create-btc-account.spec.ts b/test/e2e/flask/btc/create-btc-account.spec.ts index 5815bd057f2c..2d634288f034 100644 --- a/test/e2e/flask/btc/create-btc-account.spec.ts +++ b/test/e2e/flask/btc/create-btc-account.spec.ts @@ -132,7 +132,6 @@ describe('Create BTC Account', function (this: Suite) { }); const accountAddress = await getSelectedAccountAddress(driver); - await removeSelectedAccount(driver); // Recreate account From eb37113f705c2631ea1e732e38fa89b132790f93 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Fri, 12 Jul 2024 23:03:17 +0800 Subject: [PATCH 72/75] fix: test --- test/e2e/flask/btc/btc-account-overview.spec.ts | 3 ++- test/e2e/flask/btc/btc-experimental-settings.spec.ts | 5 +++-- test/e2e/flask/btc/create-btc-account.spec.ts | 12 ++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/test/e2e/flask/btc/btc-account-overview.spec.ts b/test/e2e/flask/btc/btc-account-overview.spec.ts index 0dc3edf1cbdd..f7ff8e21de0c 100644 --- a/test/e2e/flask/btc/btc-account-overview.spec.ts +++ b/test/e2e/flask/btc/btc-account-overview.spec.ts @@ -50,7 +50,8 @@ describe('BTC Account - Overview', function (this: Suite) { const buySellButton = await driver.waitForSelector( '[data-testid="coin-overview-buy"]', ); - assert.equal(await buySellButton.isEnabled(), true); + // feature flag is disabled + assert.equal(await buySellButton.isEnabled(), false); const portfolioButton = await driver.waitForSelector( '[data-testid="coin-overview-portfolio"]', diff --git a/test/e2e/flask/btc/btc-experimental-settings.spec.ts b/test/e2e/flask/btc/btc-experimental-settings.spec.ts index 06a8f994a62b..45bc7d0d1701 100644 --- a/test/e2e/flask/btc/btc-experimental-settings.spec.ts +++ b/test/e2e/flask/btc/btc-experimental-settings.spec.ts @@ -1,5 +1,6 @@ import { Suite } from 'mocha'; +import messages from '../../../../app/_locales/en/messages.json'; import FixtureBuilder from '../../fixture-builder'; import { defaultGanacheOptions, @@ -25,7 +26,7 @@ describe('BTC Experimental Settings', function (this: Suite) { await driver.clickElement({ text: 'Experimental', tag: 'div' }); await driver.waitForSelector({ - text: 'Enable "Add a new Bitcoin account (Beta)"', + text: messages.bitcoinSupportToggleTitle.message, tag: 'span', }); @@ -38,7 +39,7 @@ describe('BTC Experimental Settings', function (this: Suite) { '[data-testid="multichain-account-menu-popover-action-button"]', ); await driver.waitForSelector({ - text: 'Add a new Bitcoin account (Beta)', + text: messages.addNewBitcoinAccount.message, tag: 'button', }); }, diff --git a/test/e2e/flask/btc/create-btc-account.spec.ts b/test/e2e/flask/btc/create-btc-account.spec.ts index 2d634288f034..5f989bf53260 100644 --- a/test/e2e/flask/btc/create-btc-account.spec.ts +++ b/test/e2e/flask/btc/create-btc-account.spec.ts @@ -1,5 +1,6 @@ import { strict as assert } from 'assert'; import { Suite } from 'mocha'; +import messages from '../../../../app/_locales/en/messages.json'; import FixtureBuilder from '../../fixture-builder'; import { @@ -58,9 +59,9 @@ describe('Create BTC Account', function (this: Suite) { await driver.clickElement( '[data-testid="multichain-account-menu-popover-action-button"]', ); - + const createButton = await driver.findElement({ - text: 'Add a new Bitcoin account (Beta)', + text: messages.addNewBitcoinAccount.message, tag: 'button', }); assert.equal(await createButton.isEnabled(), false); @@ -108,6 +109,13 @@ describe('Create BTC Account', function (this: Suite) { css: '[data-testid="account-menu-icon"]', text: 'Bitcoin Account', }); + + // check the number of accounts. it should only be 2. + await driver.clickElement('[data-testid="account-menu-icon"]'); + const menuItems = await driver.findElements( + '.multichain-account-list-item', + ); + assert.equal(menuItems.length, 2); }, ); }); From 4d81c474f9fe6d68ed1377e438a0c9132b467ec8 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Mon, 15 Jul 2024 21:33:31 +0800 Subject: [PATCH 73/75] Apply suggestions from code review Co-authored-by: Charly Chevalier --- test/e2e/accounts/common.ts | 2 +- test/e2e/flask/btc/btc-account-overview.spec.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/accounts/common.ts b/test/e2e/accounts/common.ts index 875d9da2a720..03ab2d1fcdf8 100644 --- a/test/e2e/accounts/common.ts +++ b/test/e2e/accounts/common.ts @@ -379,7 +379,7 @@ export async function createBtcAccount(driver: Driver) { '[data-testid="multichain-account-menu-popover-action-button"]', ); await driver.clickElement({ - text: 'Add a new Bitcoin account (Beta)', + text: messages.addNewBitcoinAccount.message, tag: 'button', }); await driver.clickElement({ text: 'Create', tag: 'button' }); diff --git a/test/e2e/flask/btc/btc-account-overview.spec.ts b/test/e2e/flask/btc/btc-account-overview.spec.ts index f7ff8e21de0c..2f9e0a3ff9da 100644 --- a/test/e2e/flask/btc/btc-account-overview.spec.ts +++ b/test/e2e/flask/btc/btc-account-overview.spec.ts @@ -10,7 +10,7 @@ import FixtureBuilder from '../../fixture-builder'; import { createBtcAccount } from '../../accounts/common'; describe('BTC Account - Overview', function (this: Suite) { - it('has buy/sell and portfolio button enabled for BTC accounts', async function () { + it('has portfolio button enabled for BTC accounts', async function () { await withFixtures( { fixtures: new FixtureBuilder() @@ -50,13 +50,13 @@ describe('BTC Account - Overview', function (this: Suite) { const buySellButton = await driver.waitForSelector( '[data-testid="coin-overview-buy"]', ); - // feature flag is disabled + // Ramps now support buyable chains dynamically (https://github.com/MetaMask/metamask-extension/pull/24041), for now it's + // disabled for Bitcoin assert.equal(await buySellButton.isEnabled(), false); const portfolioButton = await driver.waitForSelector( '[data-testid="coin-overview-portfolio"]', ); - assert.equal(await portfolioButton.isEnabled(), true); }, ); From fb351b2809f276ef59ff71b4fad6a14578a12bc6 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Mon, 15 Jul 2024 22:08:22 +0800 Subject: [PATCH 74/75] fix: lint --- test/e2e/accounts/common.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/accounts/common.ts b/test/e2e/accounts/common.ts index 03ab2d1fcdf8..f0e13c5c20bc 100644 --- a/test/e2e/accounts/common.ts +++ b/test/e2e/accounts/common.ts @@ -1,4 +1,5 @@ import { privateToAddress } from 'ethereumjs-util'; +import messages from '../../../../app/_locales/en/messages.json'; import FixtureBuilder from '../fixture-builder'; import { PRIVATE_KEY, From 4a97a6ff3012c69d6e7c1e7927879ecb1fd828aa Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Mon, 15 Jul 2024 22:34:27 +0800 Subject: [PATCH 75/75] fix: import path --- test/e2e/accounts/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/accounts/common.ts b/test/e2e/accounts/common.ts index f0e13c5c20bc..eb297116ac31 100644 --- a/test/e2e/accounts/common.ts +++ b/test/e2e/accounts/common.ts @@ -1,5 +1,5 @@ import { privateToAddress } from 'ethereumjs-util'; -import messages from '../../../../app/_locales/en/messages.json'; +import messages from '../../../app/_locales/en/messages.json'; import FixtureBuilder from '../fixture-builder'; import { PRIVATE_KEY,