@stakekit/widget 0.0.290 → 0.0.291
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/{assets-DvEv_w-P.js → assets-H3qs-BfM.js} +1 -1
- package/dist/bundle/{cardano-connector-Cqj1z0wD.js → cardano-connector-C1YrKgp8.js} +2 -2
- package/dist/bundle/{configured-chains-Nn1qeOjm.js → configured-chains-CljV1eCV.js} +1 -1
- package/dist/bundle/{cosmos-connector-meta-BMa49Bqn.js → cosmos-connector-meta-CogU-5R3.js} +1 -1
- package/dist/bundle/index.bundle.js +17718 -17703
- package/dist/bundle/{ledger-connector-cdqjHR7O.js → ledger-connector-PwjsEMH_.js} +16 -16
- package/dist/bundle/{network-BvWfFLMi.js → network-rRxrzik9.js} +1 -1
- package/dist/bundle/{solana-connector-t7ro7CGZ.js → solana-connector-mwCnoTC6.js} +3 -3
- package/dist/bundle/{stellar-connector-CGTk18nF.js → stellar-connector-CIkU0qDy.js} +2 -2
- package/dist/bundle/{substrate-connector-Blu0Fmlx.js → substrate-connector-BtpGbum5.js} +1 -1
- package/dist/bundle/{ton-connector-D_6F9QzE.js → ton-connector-B9Rb8DpG.js} +3 -3
- package/dist/bundle/{transaction-nCW9pp-W.js → transaction-BU8gNx_-.js} +3 -3
- package/dist/bundle/{transaction-DFK_HUua.js → transaction-C5Rdik4M.js} +22 -22
- package/dist/bundle/transaction-C6SgGYH0.js +23 -0
- package/dist/bundle/{transaction-Dd1bxz-u.js → transaction-D8vYa3xG.js} +9 -9
- package/dist/bundle/{tron-connector-CNS7QrN7.js → tron-connector-feSoCE1Z.js} +13 -13
- package/dist/bundle/{utils-B2hhTK5t.js → utils-B5UkNjd3.js} +1 -1
- package/dist/bundle/{wallet-manager-xXCqWo2v.js → wallet-manager-iwdzlSwY.js} +34 -34
- package/dist/package/{assets-CCANldg9.js → assets-DLmJ26y-.js} +1 -1
- package/dist/package/{cardano-connector-DiiSoILv.js → cardano-connector-CIrXiVTi.js} +2 -2
- package/dist/package/{configured-chains-CqS9GQgO.js → configured-chains-Ddwhz0AO.js} +1 -1
- package/dist/package/{cosmos-connector-meta-D2OXd_8A.js → cosmos-connector-meta-gXG2LZJw.js} +1 -1
- package/dist/package/index.package.js +69 -34
- package/dist/package/{ledger-connector-CoflrvIY.js → ledger-connector-DA2MGFO1.js} +5 -5
- package/dist/package/{network-DzIq3Eb-.js → network-DRWqFyX1.js} +1 -1
- package/dist/package/{solana-connector-BGL_7RtS.js → solana-connector-zdXBpO69.js} +3 -3
- package/dist/package/{stellar-connector-KA4sbBsT.js → stellar-connector-Bwd8_6fg.js} +2 -2
- package/dist/package/{substrate-connector-C47hmu7O.js → substrate-connector-DWxNzj24.js} +1 -1
- package/dist/package/{ton-connector-Os8-LilP.js → ton-connector-Bwc9mQfl.js} +3 -3
- package/dist/package/{transaction-BUvzBUD1.js → transaction-C10sHjOp.js} +1 -1
- package/dist/package/{transaction-BhlMhMmN.js → transaction-CRtu-oMo.js} +1 -1
- package/dist/package/{transaction-GC-w6eas.js → transaction-CYsojERR.js} +1 -1
- package/dist/package/{transaction-9ZjMuyda.js → transaction-cowIxlQK.js} +1 -1
- package/dist/package/{tron-connector-73EkJLaC.js → tron-connector-DQ9QzTbX.js} +3 -3
- package/dist/package/{wallet-manager-fjTGOCl1.js → wallet-manager-CV7OgeRF.js} +2 -2
- package/dist/types/domain/network/contract.d.ts +1 -1
- package/dist/types/domain/network/network-name.d.ts +7 -0
- package/dist/types/domain/wallet/contract.d.ts +0 -1
- package/dist/types/domain/wallet/wallet-policy.d.ts +9 -0
- package/dist/types/generated/api/legacy-networks.d.ts +1 -0
- package/dist/types/generated/api/yield-networks.d.ts +1 -0
- package/dist/types/index.bundle.d.ts +1 -1
- package/dist/types/index.package.d.ts +1 -1
- package/dist/types/public-api/react-types.d.ts +8 -0
- package/dist/types/public-api/types.d.ts +73 -23
- package/dist/website/assets/{assets-Cv_Ib61e.js → assets-h8USQKgq.js} +1 -1
- package/dist/website/assets/{cardano-connector-BQ5eYUAn.js → cardano-connector-C0Sq11R4.js} +1 -1
- package/dist/website/assets/{configured-chains-BHW1HK8Y.js → configured-chains-CIWlanAA.js} +1 -1
- package/dist/website/assets/{cosmos-connector-meta-PXOxxoiN.js → cosmos-connector-meta-rno_UNzC.js} +1 -1
- package/dist/website/assets/index-5Aa-rcFh.js +540 -0
- package/dist/website/assets/{ledger-connector-CfdYVk_B.js → ledger-connector-Dd5qrF8_.js} +2 -2
- package/dist/website/assets/{network-CpiZy7GL.js → network-BGx8nCzY.js} +1 -1
- package/dist/website/assets/{solana-connector-Dko0nLRl.js → solana-connector-B7Md4VDG.js} +1 -1
- package/dist/website/assets/{stellar-connector-CzEQ-GiL.js → stellar-connector-BwE5re5j.js} +1 -1
- package/dist/website/assets/{substrate-connector-BySKIZSU.js → substrate-connector-Bc3A8Ngf.js} +1 -1
- package/dist/website/assets/{ton-connector-DfHih6IL.js → ton-connector-1XbtGnNe.js} +1 -1
- package/dist/website/assets/{transaction-BgxiRDr6.js → transaction-BN_PDuuD.js} +1 -1
- package/dist/website/assets/{transaction-Z0G1srG_.js → transaction-BTjp5Yv_.js} +2 -2
- package/dist/website/assets/{transaction-qQ73FnRV.js → transaction-CRGTe3Dx.js} +2 -2
- package/dist/website/assets/transaction-DhoVCNGK.js +1 -0
- package/dist/website/assets/{tron-connector-BkQWCtpI.js → tron-connector-BPQRviGm.js} +2 -2
- package/dist/website/assets/{utils-BnE0E9wY.js → utils-Bi0bPCX2.js} +1 -1
- package/dist/website/assets/{wallet-manager-Bnoaodi-.js → wallet-manager-Dysx00HR.js} +3 -3
- package/dist/website/index.html +9 -9
- package/package.json +2 -2
- package/dist/bundle/transaction-B_6wJk3a.js +0 -23
- package/dist/types/domain/network/intersection.d.ts +0 -2
- package/dist/types/domain/network/network.d.ts +0 -3
- package/dist/types/domain/wallet/network.d.ts +0 -575
- package/dist/types/generated/api/legacy-schema.d.ts +0 -1017
- package/dist/types/generated/api/yield-schema.d.ts +0 -4328
- package/dist/website/assets/index-DPaiXt13.js +0 -540
- package/dist/website/assets/transaction-XbbbllS0.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,B as t,D as n,j as r,k as i,l as a,o,p as s,yt as c}from"./assets-h8USQKgq.js";var l=e({raw_data:e({contract:o(n(i,t)),ref_block_bytes:i,ref_block_hash:i,expiration:s,timestamp:s,data:c(t),fee_limit:c(t)}),raw_data_hex:i,txID:i,visible:a}),u=[n(i,t)],d=r(e({...l.fields,raw_data:r(l.fields.raw_data,u),signature:o(i),contract_address:c(i)}),u);export{l as n,d as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,s as t,t as n}from"./rolldown-runtime-BcKkbAw3.js";import{n as r,t as i}from"./dist-Cuadm9-o.js";import{zt as a}from"./Result-Bvvef0v1.js";import{A as o,
|
|
1
|
+
import{r as e,s as t,t as n}from"./rolldown-runtime-BcKkbAw3.js";import{n as r,t as i}from"./dist-Cuadm9-o.js";import{zt as a}from"./Result-Bvvef0v1.js";import{A as o,Dt as s,X as c,_ as l,at as u,n as d,r as f,t as p,z as m}from"./assets-h8USQKgq.js";import{J as h,Qt as g,_n as _,c as v,cr as y,n as b,nn as x,s as S,t as C,wn as ee}from"./wagmi-connect-result-B59F3NGW.js";import{n as te,t as ne}from"./dist-D6L6gF64.js";import{n as re,r as w,t as T}from"./dist-CELdgNh9.js";import{t as ie}from"./eventemitter3-DqfHna5i.js";import{t as E}from"./events-D2w4OsQJ.js";import{o as ae}from"./configured-chains-CIWlanAA.js";import{t as oe}from"./transaction-DhoVCNGK.js";import{t as se}from"./tron-connector-meta-8UgQa4LI.js";import{a as ce,c as le,i as ue,l as de,n as fe,o as pe,s as me,t as he}from"./sha256-BQ-kmMHy.js";import{t as ge}from"./axios-Dl6BaS8Y.js";import{n as _e,t as D}from"./bignumber-CziKLYjt.js";import{t as ve}from"./wagmi-connector-events-uWDzb_Wq.js";w();var ye=t(E()),be={},xe={},Se=(e,t)=>{xe[e]=t},O=e=>{class t extends Error{cause;constructor(n,r,i){if(super(n||e,i),Object.setPrototypeOf(this,t.prototype),this.name=e,r)for(let e in r)this[e]=r[e];if(i&&Ce(i)&&`cause`in i&&!this.cause){let e=i.cause;this.cause=e,`stack`in e&&(this.stack=this.stack+`
|
|
2
2
|
CAUSE: `+e.stack)}}}return be[e]=t,t};function Ce(e){return typeof e==`object`}O(`AccountNameRequired`),O(`AccountNotSupported`),O(`AccountAwaitingSendPendingOperations`),O(`AmountRequired`),O(`BluetoothRequired`),O(`BtcUnmatchedApp`),O(`CantOpenDevice`),O(`CashAddrNotSupported`),O(`ClaimRewardsFeesWarning`),O(`CurrencyNotSupported`),O(`DeviceAppVerifyNotSupported`),O(`DeviceGenuineSocketEarlyClose`),O(`DeviceNotGenuine`),O(`DeviceOnDashboardExpected`),O(`DeviceOnDashboardUnexpected`),O(`DeviceInOSUExpected`),O(`DeviceHalted`),O(`DeviceNameInvalid`),O(`DeviceSocketFail`),O(`DeviceSocketNoBulkStatus`),O(`DeviceSocketNoBulkStatus`),O(`UnresponsiveDeviceError`),O(`DisconnectedDevice`),O(`DisconnectedDeviceDuringOperation`),O(`DeviceExtractOnboardingStateError`),O(`DeviceOnboardingStatePollingError`),O(`EnpointConfig`),O(`EthAppPleaseEnableContractData`),O(`SolAppPleaseEnableContractData`),O(`CeloAppPleaseEnableContractData`),O(`FeeEstimationFailed`),O(`FirmwareNotRecognized`),O(`HardResetFail`),O(`InvalidXRPTag`),O(`InvalidAddress`),O(`InvalidTransactionError`),O(`InvalidNonce`),O(`InvalidAddressBecauseDestinationIsAlsoSource`),O(`LatestMCUInstalledError`),O(`LatestFirmwareVersionRequired`),O(`UnsupportedFeatureError`),O(`NanoSNotSupported`),O(`UnknownMCU`),O(`LedgerAPIError`),O(`LedgerAPIErrorWithMessage`),O(`LedgerAPINotAvailable`),O(`ManagerAppAlreadyInstalled`),O(`ManagerAppRelyOnBTC`),O(`ManagerAppDepInstallRequired`),O(`ManagerAppDepUninstallRequired`),O(`ManagerDeviceLocked`),O(`ManagerFirmwareNotEnoughSpace`),O(`ManagerNotEnoughSpace`),O(`ManagerUninstallBTCDep`),O(`NetworkDown`),O(`NetworkError`),O(`NoAddressesFound`),O(`NotEnoughBalance`),O(`NotEnoughBalanceFees`),O(`NotEnoughBalanceSwap`),O(`NotEnoughBalanceToDelegate`),O(`UnstakeNotEnoughStakedBalanceLeft`),O(`RestakeNotEnoughStakedBalanceLeft`),O(`NotEnoughToRestake`),O(`NotEnoughToUnstake`),O(`NotEnoughBalanceInParentAccount`),O(`NotEnoughSpendableBalance`),O(`NotEnoughBalanceBecauseDestinationNotCreated`),O(`NotEnoughToStake`),O(`NoAccessToCamera`),O(`NotEnoughGas`),O(`NotEnoughGasSwap`),O(`TronEmptyAccount`),O(`MaybeKeepTronAccountAlive`),O(`NotSupportedLegacyAddress`),O(`GasLessThanEstimate`),O(`PriorityFeeTooLow`),O(`PriorityFeeTooHigh`),O(`PriorityFeeHigherThanMaxFee`),O(`MaxFeeTooLow`),O(`PasswordsDontMatch`),O(`PasswordIncorrect`),O(`RecommendSubAccountsToEmpty`),O(`RecommendUndelegation`),O(`TimeoutTagged`),O(`UnexpectedBootloader`),O(`MCUNotGenuineToDashboard`),O(`RecipientRequired`),O(`UnavailableTezosOriginatedAccountReceive`),O(`UnavailableTezosOriginatedAccountSend`),O(`UpdateFetchFileFail`),O(`UpdateIncorrectHash`),O(`UpdateIncorrectSig`),O(`UpdateYourApp`),O(`UserRefusedDeviceNameChange`),O(`UserRefusedAddress`),O(`UserRefusedFirmwareUpdate`),O(`UserRefusedAllowManager`),O(`UserRefusedOnDevice`),O(`PinNotSet`),O(`ExpertModeRequired`),O(`TransportOpenUserCancelled`),O(`TransportInterfaceNotAvailable`);var we=O(`TransportRaceCondition`);O(`TransportWebUSBGestureRequired`),O(`TransactionHasBeenValidatedError`),O(`TransportExchangeTimeoutError`),O(`DeviceShouldStayInApp`),O(`WebsocketConnectionError`),O(`WebsocketConnectionFailed`),O(`WrongDeviceForAccount`),O(`WrongDeviceForAccountPayout`),O(`MissingSwapPayloadParamaters`),O(`WrongDeviceForAccountRefund`),O(`WrongAppForCurrency`),O(`ETHAddressNonEIP`),O(`CantScanQRCode`),O(`FeeNotLoaded`),O(`FeeNotLoadedSwap`),O(`FeeRequired`),O(`FeeTooHigh`),O(`ValAddressRequired`),O(`RedelegateDstValAddressRequired`),O(`PendingOperation`),O(`SyncError`),O(`PairingFailed`),O(`PeerRemovedPairing`),O(`GenuineCheckFailed`),O(`LedgerAPI4xx`),O(`LedgerAPI5xx`),O(`FirmwareOrAppUpdateRequired`),O(`ReplacementTransactionUnderpriced`),O(`OpReturnSizeLimit`),O(`DustLimit`),O(`ConcordiumInsufficientFunds`),O(`ConcordiumMemoTooLong`),O(`ConcordiumPairingExpiredError`),O(`ConcordiumSessionExpiredError`),O(`ConcordiumTrustedMetadataServiceError`),O(`ConcordiumAddressVerificationFailedError`),O(`ConcordiumInvalidMaxFeeError`),O(`LanguageNotFound`),O(`NoDBPathGiven`),O(`DBWrongPassword`),O(`DBNotReset`),O(`SequenceNumberError`),O(`DisabledTransactionBroadcastError`),O(`InvalidParameterError`);var Te;(function(e){e.Unknown=`Unknown`,e.LocationServicesDisabled=`LocationServicesDisabled`,e.LocationServicesUnauthorized=`LocationServicesUnauthorized`,e.BluetoothScanStartFailed=`BluetoothScanStartFailed`})(Te||={});var Ee=class extends Error{id;constructor(e,t){let n=`TransportError`;super(e||n),this.name=n,this.message=e,this.stack=Error(e).stack,this.id=t}};Se(`TransportError`,e=>new Ee(e.message,e.id));var De={ACCESS_CONDITION_NOT_FULFILLED:38916,ALGORITHM_NOT_SUPPORTED:38020,CLA_NOT_SUPPORTED:28160,CLA_NOT_SUPPORTED_BOOTLOADER:28161,CODE_BLOCKED:38976,CODE_NOT_INITIALIZED:38914,COMMAND_INCOMPATIBLE_FILE_STRUCTURE:27009,CONDITIONS_OF_USE_NOT_SATISFIED:27013,CONTRADICTION_INVALIDATION:38928,CONTRADICTION_SECRET_CODE_STATUS:38920,DEVICE_IN_RECOVERY_MODE:26159,CUSTOM_IMAGE_EMPTY:26158,FILE_ALREADY_EXISTS:27273,FILE_NOT_FOUND:37892,GP_AUTH_FAILED:25344,HALTED:28586,INCONSISTENT_FILE:37896,INCORRECT_DATA:27264,INCORRECT_LENGTH:26368,INCORRECT_P1_P2:27392,INS_NOT_SUPPORTED:27904,DEVICE_NOT_ONBOARDED:27911,DEVICE_NOT_ONBOARDED_2:26129,INVALID_KCV:38021,INVALID_OFFSET:37890,LICENSING:28482,LOCKED_DEVICE:21781,MAX_VALUE_REACHED:38992,MEMORY_PROBLEM:37440,MISSING_CRITICAL_PARAMETER:26624,NO_EF_SELECTED:37888,NOT_ENOUGH_MEMORY_SPACE:27268,OK:36864,PIN_REMAINING_ATTEMPTS:25536,REFERENCED_DATA_NOT_FOUND:27272,SECURITY_STATUS_NOT_SATISFIED:27010,TECHNICAL_PROBLEM:28416,UNKNOWN_APDU:27906,USER_REFUSED_ON_DEVICE:21761,NOT_ENOUGH_SPACE:20738,APP_NOT_FOUND_OR_INVALID_CONTEXT:20771,INVALID_APP_NAME_LENGTH:26378,GEN_AES_KEY_FAILED:21529,INTERNAL_CRYPTO_OPERATION_FAILED:21530,INTERNAL_COMPUTE_AES_CMAC_FAILED:21531,ENCRYPT_APP_STORAGE_FAILED:21532,INVALID_BACKUP_STATE:26178,PIN_NOT_SET:21762,INVALID_BACKUP_LENGTH:26419,INVALID_RESTORE_STATE:26179,INVALID_CHUNK_LENGTH:26420,INVALID_BACKUP_HEADER:26698,SW_BAD_STATE:45063};function Oe(e){switch(e){case 26368:return`Incorrect length`;case 26624:return`Missing critical parameter`;case 27010:return`Security not satisfied (dongle locked or have invalid access rights)`;case 27013:return`Condition of use not satisfied (denied by the user?)`;case 27264:return`Invalid data received`;case 27392:return`Invalid parameter received`;case 21781:return`Locked device`;case 45063:return`Unexpected state on the device`}if(28416<=e&&e<=28671)return`Internal error, please report`}var ke=class e extends Error{statusCode;statusText;constructor(t,{canBeMappedToChildError:n=!0}={}){let r=Object.keys(De).find(e=>De[e]===t)||`UNKNOWN_ERROR`,i=`Ledger device: ${Oe(t)||r} (0x${t.toString(16)})`;if(super(i),this.name=`TransportStatusError`,this.statusCode=t,this.statusText=r,Object.setPrototypeOf(this,e.prototype),n&&t===De.LOCKED_DEVICE)return new Ae(i)}},Ae=class e extends ke{constructor(t){super(De.LOCKED_DEVICE,{canBeMappedToChildError:!1}),t&&(this.message=t),this.name=`LockedDeviceError`,Object.setPrototypeOf(this,e.prototype)}};Se(`TransportStatusError`,e=>new ke(e.statusCode));var je=0,Me=[],Ne=(e,t,n)=>{let r={type:e,id:String(++je),date:new Date};t&&(r.message=t),n&&(r.data=n),Le(r)},Pe=({type:e,message:t,data:n,context:r})=>{let i={type:e,id:String(++je),date:new Date};t&&(i.message=t),n&&(i.data=n),r&&(i.context=r),Le(i)},Fe=class e{type;context;constructor(e,t){this.type=e,this.context=t}trace(e,t){Pe({type:this.type,message:e,data:t,context:this.context})}getContext(){return this.context}setContext(e){this.context=e}updateContext(e){this.context={...this.context,...e}}getType(){return this.type}setType(e){this.type=e}withType(t){return new e(t,this.context)}withContext(t){return new e(this.type,t)}withUpdatedContext(t){return new e(this.type,{...this.context,...t})}},Ie=e=>(Me.push(e),()=>{let t=Me.indexOf(e);t!==-1&&(Me[t]=Me[Me.length-1],Me.pop())});function Le(e){for(let t=0;t<Me.length;t++)try{Me[t](e)}catch{}}typeof window<`u`&&(window.__ledgerLogsListen=Ie);var Re=`transport`,ze=class{exchangeTimeout=3e4;unresponsiveTimeout=15e3;deviceModel=null;tracer;constructor({context:e,logType:t}={}){this.tracer=new Fe(t??Re,e)}static isSupported;static list;static listen;static open;exchange(e,{abortTimeoutMs:t}={}){throw Error(`exchange not implemented`)}exchangeBulk(e,t){let n=!1;return(async()=>{if(!n)for(let r of e){let e=await this.exchange(r);if(n)return;let i=e.readUInt16BE(e.length-2);if(i!==De.OK)throw new ke(i);t.next(e)}})().then(()=>!n&&t.complete(),e=>!n&&t.error(e)),{unsubscribe:()=>{n=!0}}}setScrambleKey(e){}close(){return Promise.resolve()}_events=new ye.default;on(e,t){this._events.on(e,t)}off(e,t){this._events.removeListener(e,t)}emit(e,...t){this._events.emit(e,...t)}setDebugMode(){}setExchangeTimeout(e){this.exchangeTimeout=e}setExchangeUnresponsiveTimeout(e){this.unresponsiveTimeout=e}send=async(e,t,n,r,i=T.alloc(0),a=[De.OK],{abortTimeoutMs:o}={})=>{let s=this.tracer.withUpdatedContext({function:`send`});if(i.length>=256)throw s.trace(`data.length exceeded 256 bytes limit`,{dataLength:i.length}),new Ee(`data.length exceed 256 bytes limit. Got: `+i.length,`DataLengthTooBig`);let c=await this.exchange(T.concat([T.from([e,t,n,r]),T.from([i.length]),i]),{abortTimeoutMs:o}),l=c.readUInt16BE(c.length-2);if(!a.some(e=>e===l))throw new ke(l);return c};static create(e=3e3,t){return new Promise((n,r)=>{let i=!1,a=this.listen({next:t=>{i=!0,a&&a.unsubscribe(),o&&clearTimeout(o),this.open(t.descriptor,e).then(n,r)},error:e=>{o&&clearTimeout(o),r(e)},complete:()=>{o&&clearTimeout(o),i||r(new Ee(this.ErrorMessage_NoDeviceFound,`NoDeviceFound`))}}),o=t?setTimeout(()=>{a.unsubscribe(),r(new Ee(this.ErrorMessage_ListenTimeout,`ListenTimeout`))},t):null})}exchangeBusyPromise;async exchangeAtomicImpl(e){let t=this.tracer.withUpdatedContext({function:`exchangeAtomicImpl`,unresponsiveTimeout:this.unresponsiveTimeout});if(this.exchangeBusyPromise)throw t.trace(`Atomic exchange is already busy`),new we(`An action was already pending on the Ledger device. Please deny or reconnect.`);let n,r=new Promise(e=>{n=e});this.exchangeBusyPromise=r;let i=!1,a=setTimeout(()=>{t.trace(`Timeout reached, emitting Transport event "unresponsive"`,{unresponsiveTimeout:this.unresponsiveTimeout}),i=!0,this.emit(`unresponsive`)},this.unresponsiveTimeout);try{let n=await e();return i&&(t.trace(`Device was unresponsive, emitting responsive`),this.emit(`responsive`)),n}finally{t.trace(`Finalize, clearing busy guard`),clearTimeout(a),n&&n(),this.exchangeBusyPromise=null}}decorateAppAPIMethods(e,t,n){for(let r of t)e[r]=this.decorateAppAPIMethod(r,e[r],e,n)}_appAPIlock=null;decorateAppAPIMethod(e,t,n,r){return async(...i)=>{let{_appAPIlock:a}=this;if(a)return Promise.reject(new Ee(`Ledger Device is busy (lock `+a+`)`,`TransportLocked`));try{return this._appAPIlock=e,this.setScrambleKey(r),await t.apply(n,i)}finally{this._appAPIlock=null}}}setTraceContext(e){this.tracer=this.tracer.withContext(e)}updateTraceContext(e){this.tracer.updateContext(e)}getTraceContext(){return this.tracer.getContext()}static ErrorMessage_ListenTimeout=`No Ledger device found (timeout)`;static ErrorMessage_NoDeviceFound=`No Ledger device found`},k={},Be={},Ve=(e,t)=>{Be[e]=t},A=e=>{class t extends Error{cause;constructor(n,r,i){if(super(n||e,i),Object.setPrototypeOf(this,t.prototype),this.name=e,r)for(let e in r)this[e]=r[e];if(i&&He(i)&&`cause`in i&&!this.cause){let e=i.cause;this.cause=e,`stack`in e&&(this.stack=this.stack+`
|
|
3
3
|
CAUSE: `+e.stack)}}}return k[e]=t,t};function He(e){return typeof e==`object`}A(`AccountNameRequired`),A(`AccountNotSupported`),A(`AccountAwaitingSendPendingOperations`),A(`AmountRequired`),A(`BluetoothRequired`),A(`BtcUnmatchedApp`),A(`CantOpenDevice`),A(`CashAddrNotSupported`),A(`ClaimRewardsFeesWarning`),A(`CurrencyNotSupported`),A(`DeviceAppVerifyNotSupported`),A(`DeviceGenuineSocketEarlyClose`),A(`DeviceNotGenuine`),A(`DeviceOnDashboardExpected`),A(`DeviceOnDashboardUnexpected`),A(`DeviceInOSUExpected`),A(`DeviceHalted`),A(`DeviceNameInvalid`),A(`DeviceSocketFail`),A(`DeviceSocketNoBulkStatus`),A(`DeviceSocketNoBulkStatus`),A(`UnresponsiveDeviceError`);var Ue=A(`DisconnectedDevice`),We=A(`DisconnectedDeviceDuringOperation`);A(`DeviceExtractOnboardingStateError`),A(`DeviceOnboardingStatePollingError`),A(`EnpointConfig`),A(`EthAppPleaseEnableContractData`),A(`SolAppPleaseEnableContractData`),A(`CeloAppPleaseEnableContractData`),A(`FeeEstimationFailed`),A(`FirmwareNotRecognized`),A(`HardResetFail`),A(`InvalidXRPTag`),A(`InvalidAddress`),A(`InvalidTransactionError`),A(`InvalidNonce`),A(`InvalidAddressBecauseDestinationIsAlsoSource`),A(`LatestMCUInstalledError`),A(`LatestFirmwareVersionRequired`),A(`UnsupportedFeatureError`),A(`NanoSNotSupported`),A(`UnknownMCU`),A(`LedgerAPIError`),A(`LedgerAPIErrorWithMessage`),A(`LedgerAPINotAvailable`),A(`ManagerAppAlreadyInstalled`),A(`ManagerAppRelyOnBTC`),A(`ManagerAppDepInstallRequired`),A(`ManagerAppDepUninstallRequired`),A(`ManagerDeviceLocked`),A(`ManagerFirmwareNotEnoughSpace`),A(`ManagerNotEnoughSpace`),A(`ManagerUninstallBTCDep`),A(`NetworkDown`),A(`NetworkError`),A(`NoAddressesFound`),A(`NotEnoughBalance`),A(`NotEnoughBalanceFees`),A(`NotEnoughBalanceSwap`),A(`NotEnoughBalanceToDelegate`),A(`UnstakeNotEnoughStakedBalanceLeft`),A(`RestakeNotEnoughStakedBalanceLeft`),A(`NotEnoughToRestake`),A(`NotEnoughToUnstake`),A(`NotEnoughBalanceInParentAccount`),A(`NotEnoughSpendableBalance`),A(`NotEnoughBalanceBecauseDestinationNotCreated`),A(`NotEnoughToStake`),A(`NoAccessToCamera`),A(`NotEnoughGas`),A(`NotEnoughGasSwap`),A(`TronEmptyAccount`),A(`MaybeKeepTronAccountAlive`),A(`NotSupportedLegacyAddress`),A(`GasLessThanEstimate`),A(`PriorityFeeTooLow`),A(`PriorityFeeTooHigh`),A(`PriorityFeeHigherThanMaxFee`),A(`MaxFeeTooLow`),A(`PasswordsDontMatch`),A(`PasswordIncorrect`),A(`RecommendSubAccountsToEmpty`),A(`RecommendUndelegation`),A(`TimeoutTagged`),A(`UnexpectedBootloader`),A(`MCUNotGenuineToDashboard`),A(`RecipientRequired`),A(`UnavailableTezosOriginatedAccountReceive`),A(`UnavailableTezosOriginatedAccountSend`),A(`UpdateFetchFileFail`),A(`UpdateIncorrectHash`),A(`UpdateIncorrectSig`),A(`UpdateYourApp`),A(`UserRefusedDeviceNameChange`),A(`UserRefusedAddress`),A(`UserRefusedFirmwareUpdate`),A(`UserRefusedAllowManager`),A(`UserRefusedOnDevice`),A(`PinNotSet`),A(`ExpertModeRequired`);var Ge=A(`TransportOpenUserCancelled`);A(`TransportInterfaceNotAvailable`),A(`TransportRaceCondition`),A(`TransportWebUSBGestureRequired`),A(`TransactionHasBeenValidatedError`),A(`TransportExchangeTimeoutError`),A(`DeviceShouldStayInApp`),A(`WebsocketConnectionError`),A(`WebsocketConnectionFailed`),A(`WrongDeviceForAccount`),A(`WrongDeviceForAccountPayout`),A(`MissingSwapPayloadParamaters`),A(`WrongDeviceForAccountRefund`),A(`WrongAppForCurrency`),A(`ETHAddressNonEIP`),A(`CantScanQRCode`),A(`FeeNotLoaded`),A(`FeeNotLoadedSwap`),A(`FeeRequired`),A(`FeeTooHigh`),A(`ValAddressRequired`),A(`RedelegateDstValAddressRequired`),A(`PendingOperation`),A(`SyncError`),A(`PairingFailed`),A(`PeerRemovedPairing`),A(`GenuineCheckFailed`),A(`LedgerAPI4xx`),A(`LedgerAPI5xx`),A(`FirmwareOrAppUpdateRequired`),A(`ReplacementTransactionUnderpriced`),A(`OpReturnSizeLimit`),A(`DustLimit`),A(`ConcordiumInsufficientFunds`),A(`ConcordiumMemoTooLong`),A(`ConcordiumPairingExpiredError`),A(`ConcordiumSessionExpiredError`),A(`ConcordiumTrustedMetadataServiceError`),A(`ConcordiumAddressVerificationFailedError`),A(`ConcordiumInvalidMaxFeeError`),A(`LanguageNotFound`),A(`NoDBPathGiven`),A(`DBWrongPassword`),A(`DBNotReset`),A(`SequenceNumberError`),A(`DisabledTransactionBroadcastError`),A(`InvalidParameterError`);var Ke;(function(e){e.Unknown=`Unknown`,e.LocationServicesDisabled=`LocationServicesDisabled`,e.LocationServicesUnauthorized=`LocationServicesUnauthorized`,e.BluetoothScanStartFailed=`BluetoothScanStartFailed`})(Ke||={});var j=class extends Error{id;constructor(e,t){let n=`TransportError`;super(e||n),this.name=n,this.message=e,this.stack=Error(e).stack,this.id=t}};Ve(`TransportError`,e=>new j(e.message,e.id));var qe={ACCESS_CONDITION_NOT_FULFILLED:38916,ALGORITHM_NOT_SUPPORTED:38020,CLA_NOT_SUPPORTED:28160,CLA_NOT_SUPPORTED_BOOTLOADER:28161,CODE_BLOCKED:38976,CODE_NOT_INITIALIZED:38914,COMMAND_INCOMPATIBLE_FILE_STRUCTURE:27009,CONDITIONS_OF_USE_NOT_SATISFIED:27013,CONTRADICTION_INVALIDATION:38928,CONTRADICTION_SECRET_CODE_STATUS:38920,DEVICE_IN_RECOVERY_MODE:26159,CUSTOM_IMAGE_EMPTY:26158,FILE_ALREADY_EXISTS:27273,FILE_NOT_FOUND:37892,GP_AUTH_FAILED:25344,HALTED:28586,INCONSISTENT_FILE:37896,INCORRECT_DATA:27264,INCORRECT_LENGTH:26368,INCORRECT_P1_P2:27392,INS_NOT_SUPPORTED:27904,DEVICE_NOT_ONBOARDED:27911,DEVICE_NOT_ONBOARDED_2:26129,INVALID_KCV:38021,INVALID_OFFSET:37890,LICENSING:28482,LOCKED_DEVICE:21781,MAX_VALUE_REACHED:38992,MEMORY_PROBLEM:37440,MISSING_CRITICAL_PARAMETER:26624,NO_EF_SELECTED:37888,NOT_ENOUGH_MEMORY_SPACE:27268,OK:36864,PIN_REMAINING_ATTEMPTS:25536,REFERENCED_DATA_NOT_FOUND:27272,SECURITY_STATUS_NOT_SATISFIED:27010,TECHNICAL_PROBLEM:28416,UNKNOWN_APDU:27906,USER_REFUSED_ON_DEVICE:21761,NOT_ENOUGH_SPACE:20738,APP_NOT_FOUND_OR_INVALID_CONTEXT:20771,INVALID_APP_NAME_LENGTH:26378,GEN_AES_KEY_FAILED:21529,INTERNAL_CRYPTO_OPERATION_FAILED:21530,INTERNAL_COMPUTE_AES_CMAC_FAILED:21531,ENCRYPT_APP_STORAGE_FAILED:21532,INVALID_BACKUP_STATE:26178,PIN_NOT_SET:21762,INVALID_BACKUP_LENGTH:26419,INVALID_RESTORE_STATE:26179,INVALID_CHUNK_LENGTH:26420,INVALID_BACKUP_HEADER:26698,SW_BAD_STATE:45063};function Je(e){switch(e){case 26368:return`Incorrect length`;case 26624:return`Missing critical parameter`;case 27010:return`Security not satisfied (dongle locked or have invalid access rights)`;case 27013:return`Condition of use not satisfied (denied by the user?)`;case 27264:return`Invalid data received`;case 27392:return`Invalid parameter received`;case 21781:return`Locked device`;case 45063:return`Unexpected state on the device`}if(28416<=e&&e<=28671)return`Internal error, please report`}var Ye=class e extends Error{statusCode;statusText;constructor(t,{canBeMappedToChildError:n=!0}={}){let r=Object.keys(qe).find(e=>qe[e]===t)||`UNKNOWN_ERROR`,i=`Ledger device: ${Je(t)||r} (0x${t.toString(16)})`;if(super(i),this.name=`TransportStatusError`,this.statusCode=t,this.statusText=r,Object.setPrototypeOf(this,e.prototype),n&&t===qe.LOCKED_DEVICE)return new Xe(i)}},Xe=class e extends Ye{constructor(t){super(qe.LOCKED_DEVICE,{canBeMappedToChildError:!1}),t&&(this.message=t),this.name=`LockedDeviceError`,Object.setPrototypeOf(this,e.prototype)}};Ve(`TransportStatusError`,e=>new Ye(e.statusCode));var Ze=class extends fe{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,de(e);let n=pe(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return le(this),this.iHash.update(e),this}digestInto(e){le(this),me(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Qe=(e,t,n)=>new Ze(e,t).update(n).digest();Qe.create=(e,t)=>new Ze(e,t);var $e=e({abytes:()=>it,bitGet:()=>vt,bitLen:()=>F,bitMask:()=>bt,bitSet:()=>yt,bytesToHex:()=>ot,bytesToNumberBE:()=>ft,bytesToNumberLE:()=>pt,concatBytes:()=>gt,createHmacDrbg:()=>St,ensureBytes:()=>ht,equalBytes:()=>_t,hexToBytes:()=>dt,hexToNumber:()=>ct,isBytes:()=>rt,numberToBytesBE:()=>mt,numberToBytesLE:()=>M,numberToHexUnpadded:()=>st,numberToVarBytesBE:()=>N,utf8ToBytes:()=>P,validateObject:()=>wt}),et=BigInt(0),tt=BigInt(1),nt=BigInt(2);function rt(e){return e instanceof Uint8Array||typeof e==`object`&&!!e&&e.constructor.name===`Uint8Array`}function it(e){if(!rt(e))throw Error(`Uint8Array expected`)}var at=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function ot(e){it(e);let t=``;for(let n=0;n<e.length;n++)t+=at[e[n]];return t}function st(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function ct(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return BigInt(e===``?`0`:`0x${e}`)}var lt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ut(e){if(e>=lt._0&&e<=lt._9)return e-lt._0;if(e>=lt._A&&e<=lt._F)return e-(lt._A-10);if(e>=lt._a&&e<=lt._f)return e-(lt._a-10)}function dt(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=e.length,n=t/2;if(t%2)throw Error(`padded hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=ut(e.charCodeAt(i)),a=ut(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function ft(e){return ct(ot(e))}function pt(e){return it(e),ct(ot(Uint8Array.from(e).reverse()))}function mt(e,t){return dt(e.toString(16).padStart(t*2,`0`))}function M(e,t){return mt(e,t).reverse()}function N(e){return dt(st(e))}function ht(e,t,n){let r;if(typeof t==`string`)try{r=dt(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else if(rt(t))r=Uint8Array.from(t);else throw Error(`${e} must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(`${e} expected ${n} bytes, got ${i}`);return r}function gt(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];it(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function _t(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function P(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function F(e){let t=0;for(;e>et;e>>=tt,t+=1);return t}function vt(e,t){return e>>BigInt(t)&tt}function yt(e,t,n){return e|(n?tt:et)<<BigInt(t)}var bt=e=>(nt<<BigInt(e-1))-tt,I=e=>new Uint8Array(e),xt=e=>Uint8Array.from(e);function St(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=I(e),i=I(e),a=0,o=()=>{r.fill(1),i.fill(0),a=0},s=(...e)=>n(i,r,...e),c=(e=I())=>{i=s(xt([0]),e),r=s(),e.length!==0&&(i=s(xt([1]),e),r=s())},l=()=>{if(a++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){r=s();let t=r.slice();n.push(t),e+=r.length}return gt(...n)};return(e,t)=>{o(),c(e);let n;for(;!(n=t(l()));)c();return o(),n}}var Ct={bigint:e=>typeof e==`bigint`,function:e=>typeof e==`function`,boolean:e=>typeof e==`boolean`,string:e=>typeof e==`string`,stringOrUint8Array:e=>typeof e==`string`||rt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==`function`&&Number.isSafeInteger(e.outputLen)};function wt(e,t,n={}){let r=(t,n,r)=>{let i=Ct[n];if(typeof i!=`function`)throw Error(`Invalid validator "${n}", expected function`);let a=e[t];if(!(r&&a===void 0)&&!i(a,e))throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`)};for(let[e,n]of Object.entries(t))r(e,n,!1);for(let[e,t]of Object.entries(n))r(e,t,!0);return e}var Tt=BigInt(0),Et=BigInt(1),Dt=BigInt(2),Ot=BigInt(3),kt=BigInt(4),At=BigInt(5),jt=BigInt(8),Mt=BigInt(16);function Nt(e,t){let n=e%t;return n>=Tt?n:t+n}function Pt(e,t,n){if(n<=Tt||t<Tt)throw Error(`Expected power/modulo > 0`);if(n===Et)return Tt;let r=Et;for(;t>Tt;)t&Et&&(r=r*e%n),e=e*e%n,t>>=Et;return r}function Ft(e,t,n){let r=e;for(;t-->Tt;)r*=r,r%=n;return r}function It(e,t){if(e===Tt||t<=Tt)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Nt(e,t),r=t,i=Tt,a=Et,o=Et,s=Tt;for(;n!==Tt;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==Et)throw Error(`invert: does not exist`);return Nt(i,t)}function Lt(e){let t=(e-Et)/Dt,n,r,i;for(n=e-Et,r=0;n%Dt===Tt;n/=Dt,r++);for(i=Dt;i<e&&Pt(i,t,e)!==e-Et;i++);if(r===1){let t=(e+Et)/kt;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}let a=(n+Et)/Dt;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw Error(`Cannot find square root`);let s=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(o,a),u=e.pow(o,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<s&&!e.eql(n,e.ONE);t++)n=e.sqr(n);let n=e.pow(c,Et<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),u=e.mul(u,c),s=t}return l}}function Rt(e){if(e%kt===Ot){let t=(e+Et)/kt;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}if(e%jt===At){let t=(e-At)/jt;return function(e,n){let r=e.mul(n,Dt),i=e.pow(r,t),a=e.mul(n,i),o=e.mul(e.mul(a,Dt),i),s=e.mul(a,e.sub(o,e.ONE));if(!e.eql(e.sqr(s),n))throw Error(`Cannot find square root`);return s}}return e%Mt,Lt(e)}var zt=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Bt(e){return wt(e,zt.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`isSafeInteger`,BITS:`isSafeInteger`}))}function Vt(e,t,n){if(n<Tt)throw Error(`Expected power > 0`);if(n===Tt)return e.ONE;if(n===Et)return t;let r=e.ONE,i=t;for(;n>Tt;)n&Et&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Et;return r}function Ht(e,t){let n=Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}function Ut(e,t){let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Wt(e,t,n=!1,r={}){if(e<=Tt)throw Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:a}=Ut(e,t);if(a>2048)throw Error(`Field lengths over 2048 bytes are not supported`);let o=Rt(e),s=Object.freeze({ORDER:e,BITS:i,BYTES:a,MASK:bt(i),ZERO:Tt,ONE:Et,create:t=>Nt(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`Invalid field element: expected bigint, got ${typeof t}`);return Tt<=t&&t<e},is0:e=>e===Tt,isOdd:e=>(e&Et)===Et,neg:t=>Nt(-t,e),eql:(e,t)=>e===t,sqr:t=>Nt(t*t,e),add:(t,n)=>Nt(t+n,e),sub:(t,n)=>Nt(t-n,e),mul:(t,n)=>Nt(t*n,e),pow:(e,t)=>Vt(s,e,t),div:(t,n)=>Nt(t*It(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>It(t,e),sqrt:r.sqrt||(e=>o(s,e)),invertBatch:e=>Ht(s,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?M(e,a):mt(e,a),fromBytes:e=>{if(e.length!==a)throw Error(`Fp.fromBytes: expected ${a}, got ${e.length}`);return n?pt(e):ft(e)}});return Object.freeze(s)}function Gt(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function Kt(e){let t=Gt(e);return t+Math.ceil(t/2)}function qt(e,t,n=!1){let r=e.length,i=Gt(t),a=Kt(t);if(r<16||r<a||r>1024)throw Error(`expected ${a}-1024 bytes of input, got ${r}`);let o=Nt(n?ft(e):pt(e),t-Et)+Et;return n?M(o,i):mt(o,i)}var Jt=BigInt(0),Yt=BigInt(1);function Xt(e,t){let n=(e,t)=>{let n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>Jt;)n&Yt&&(r=r.add(i)),i=i.double(),n>>=Yt;return r},precomputeWindow(e,t){let{windows:n,windowSize:i}=r(t),a=[],o=e,s=o;for(let e=0;e<n;e++){s=o,a.push(s);for(let e=1;e<i;e++)s=s.add(o),a.push(s);o=s.double()}return a},wNAF(t,i,a){let{windows:o,windowSize:s}=r(t),c=e.ZERO,l=e.BASE,u=BigInt(2**t-1),d=2**t,f=BigInt(t);for(let e=0;e<o;e++){let t=e*s,r=Number(a&u);a>>=f,r>s&&(r-=d,a+=Yt);let o=t,p=t+Math.abs(r)-1,m=e%2!=0,h=r<0;r===0?l=l.add(n(m,i[o])):c=c.add(n(h,i[p]))}return{p:c,f:l}},wNAFCached(e,t,n,r){let i=e._WINDOW_SIZE||1,a=t.get(e);return a||(a=this.precomputeWindow(e,i),i!==1&&t.set(e,r(a))),this.wNAF(i,a,n)}}}function Zt(e){return Bt(e.Fp),wt(e,{n:`bigint`,h:`bigint`,Gx:`field`,Gy:`field`},{nBitLength:`isSafeInteger`,nByteLength:`isSafeInteger`}),Object.freeze({...Ut(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function Qt(e){let t=Zt(e);wt(t,{a:`field`,b:`field`},{allowedPrivateKeyLengths:`array`,wrapPrivateKey:`boolean`,isTorsionFree:`function`,clearCofactor:`function`,allowInfinityPoint:`boolean`,fromBytes:`function`,toBytes:`function`});let{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.ZERO))throw Error(`Endomorphism can only be defined for Koblitz curves that have a=0`);if(typeof n!=`object`||typeof n.beta!=`bigint`||typeof n.splitScalar!=`function`)throw Error(`Expected endomorphism with beta: bigint and splitScalar: function`)}return Object.freeze({...t})}var{bytesToNumberBE:$t,hexToBytes:en}=$e,tn={Err:class extends Error{constructor(e=``){super(e)}},_parseInt(e){let{Err:t}=tn;if(e.length<2||e[0]!==2)throw new t(`Invalid signature integer tag`);let n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t(`Invalid signature integer: wrong length`);if(r[0]&128)throw new t(`Invalid signature integer: negative`);if(r[0]===0&&!(r[1]&128))throw new t(`Invalid signature integer: unnecessary leading zero`);return{d:$t(r),l:e.subarray(n+2)}},toSig(e){let{Err:t}=tn,n=typeof e==`string`?en(e):e;it(n);let r=n.length;if(r<2||n[0]!=48)throw new t(`Invalid signature tag`);if(n[1]!==r-2)throw new t(`Invalid signature: incorrect length`);let{d:i,l:a}=tn._parseInt(n.subarray(2)),{d:o,l:s}=tn._parseInt(a);if(s.length)throw new t(`Invalid signature: left bytes after parsing`);return{r:i,s:o}},hexFromSig(e){let t=e=>Number.parseInt(e[0],16)&8?`00`+e:e,n=e=>{let t=e.toString(16);return t.length&1?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),a=r.length/2,o=i.length/2,s=n(a),c=n(o);return`30${n(o+a+4)}02${c}${i}02${s}${r}`}},nn=BigInt(0),rn=BigInt(1),an=BigInt(3);function on(e){let t=Qt(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{let i=t.toAffine();return gt(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=t.fromBytes||(e=>{let t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){let{a:r,b:i}=t,a=n.sqr(e),o=n.mul(a,e);return n.add(n.add(o,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),a(t.Gx)))throw Error(`bad generator point: equation left != right`);function o(e){return typeof e==`bigint`&&nn<e&&e<t.n}function s(e){if(!o(e))throw Error(`Expected valid bigint: 0 < bigint < curve.n`)}function c(e){let{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:a}=t;if(n&&typeof e!=`bigint`){if(rt(e)&&(e=ot(e)),typeof e!=`string`||!n.includes(e.length))throw Error(`Invalid key`);e=e.padStart(r*2,`0`)}let o;try{o=typeof e==`bigint`?e:ft(ht(`private key`,e,r))}catch{throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=Nt(o,a)),s(o),o}let l=new Map;function u(e){if(!(e instanceof d))throw Error(`ProjectivePoint expected`)}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,e==null||!n.isValid(e))throw Error(`x required`);if(t==null||!n.isValid(t))throw Error(`y required`);if(r==null||!n.isValid(r))throw Error(`z required`)}static fromAffine(e){let{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error(`invalid affine point`);if(e instanceof d)throw Error(`projective point not allowed`);let i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){let t=d.fromAffine(i(ht(`pointHex`,e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw Error(`bad point: ZERO`)}let{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw Error(`bad point: x or y not FE`);let i=n.sqr(r),o=a(e);if(!n.eql(i,o))throw Error(`bad point: equation left != right`);if(!this.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw Error(`Field doesn't support isOdd`)}equals(e){u(e);let{px:t,py:r,pz:i}=this,{px:a,py:o,pz:s}=e,c=n.eql(n.mul(t,s),n.mul(a,i)),l=n.eql(n.mul(r,s),n.mul(o,i));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){let{a:e,b:r}=t,i=n.mul(r,an),{px:a,py:o,pz:s}=this,c=n.ZERO,l=n.ZERO,u=n.ZERO,f=n.mul(a,a),p=n.mul(o,o),m=n.mul(s,s),h=n.mul(a,o);return h=n.add(h,h),u=n.mul(a,s),u=n.add(u,u),c=n.mul(e,u),l=n.mul(i,m),l=n.add(c,l),c=n.sub(p,l),l=n.add(p,l),l=n.mul(c,l),c=n.mul(h,c),u=n.mul(i,u),m=n.mul(e,m),h=n.sub(f,m),h=n.mul(e,h),h=n.add(h,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,m),f=n.mul(f,h),l=n.add(l,f),m=n.mul(o,s),m=n.add(m,m),f=n.mul(m,h),c=n.sub(c,f),u=n.mul(m,p),u=n.add(u,u),u=n.add(u,u),new d(c,l,u)}add(e){u(e);let{px:r,py:i,pz:a}=this,{px:o,py:s,pz:c}=e,l=n.ZERO,f=n.ZERO,p=n.ZERO,m=t.a,h=n.mul(t.b,an),g=n.mul(r,o),_=n.mul(i,s),v=n.mul(a,c),y=n.add(r,i),b=n.add(o,s);y=n.mul(y,b),b=n.add(g,_),y=n.sub(y,b),b=n.add(r,a);let x=n.add(o,c);return b=n.mul(b,x),x=n.add(g,v),b=n.sub(b,x),x=n.add(i,a),l=n.add(s,c),x=n.mul(x,l),l=n.add(_,v),x=n.sub(x,l),p=n.mul(m,b),l=n.mul(h,v),p=n.add(l,p),l=n.sub(_,p),p=n.add(_,p),f=n.mul(l,p),_=n.add(g,g),_=n.add(_,g),v=n.mul(m,v),b=n.mul(h,b),_=n.add(_,v),v=n.sub(g,v),v=n.mul(m,v),b=n.add(b,v),g=n.mul(_,b),f=n.add(f,g),g=n.mul(x,b),l=n.mul(y,l),l=n.sub(l,g),g=n.mul(y,_),p=n.mul(x,p),p=n.add(p,g),new d(l,f,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.wNAFCached(this,l,e,e=>{let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){let r=d.ZERO;if(e===nn)return r;if(s(e),e===rn)return this;let{endo:i}=t;if(!i)return p.unsafeLadder(this,e);let{k1neg:a,k1:o,k2neg:c,k2:l}=i.splitScalar(e),u=r,f=r,m=this;for(;o>nn||l>nn;)o&rn&&(u=u.add(m)),l&rn&&(f=f.add(m)),m=m.double(),o>>=rn,l>>=rn;return a&&(u=u.negate()),c&&(f=f.negate()),f=new d(n.mul(f.px,i.beta),f.py,f.pz),u.add(f)}multiply(e){s(e);let r=e,i,a,{endo:o}=t;if(o){let{k1neg:e,k1:t,k2neg:s,k2:c}=o.splitScalar(r),{p:l,f:u}=this.wNAF(t),{p:f,f:m}=this.wNAF(c);l=p.constTimeNegate(e,l),f=p.constTimeNegate(s,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=l.add(f),a=u.add(m)}else{let{p:e,f:t}=this.wNAF(r);i=e,a=t}return d.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){let r=d.BASE,i=(e,t)=>t===nn||t===rn||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),a=i(this,t).add(i(e,n));return a.is0()?void 0:a}toAffine(e){let{px:t,py:r,pz:i}=this,a=this.is0();e??=a?n.ONE:n.inv(i);let o=n.mul(t,e),s=n.mul(r,e),c=n.mul(i,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw Error(`invZ was invalid`);return{x:o,y:s}}isTorsionFree(){let{h:e,isTorsionFree:n}=t;if(e===rn)return!0;if(n)return n(d,this);throw Error(`isTorsionFree() has not been declared for the elliptic curve`)}clearCofactor(){let{h:e,clearCofactor:n}=t;return e===rn?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return ot(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);let f=t.nBitLength,p=Xt(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function sn(e){let t=Zt(e);return wt(t,{hash:`hash`,hmac:`function`,randomBytes:`function`},{bits2int:`function`,bits2int_modN:`function`,lowS:`boolean`}),Object.freeze({lowS:!0,...t})}function cn(e){let t=sn(e),{Fp:n,n:r}=t,i=n.BYTES+1,a=2*n.BYTES+1;function o(e){return nn<e&&e<n.ORDER}function s(e){return Nt(e,r)}function c(e){return It(e,r)}let{ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=on({...t,toBytes(e,t,r){let i=t.toAffine(),a=n.toBytes(i.x),o=gt;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),a):o(Uint8Array.from([4]),a,n.toBytes(i.y))},fromBytes(e){let t=e.length,r=e[0],s=e.subarray(1);if(t===i&&(r===2||r===3)){let e=ft(s);if(!o(e))throw Error(`Point is not on curve`);let t=d(e),i;try{i=n.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`Point is not on curve`+t)}let a=(i&rn)===rn;return(r&1)==1!==a&&(i=n.neg(i)),{x:e,y:i}}if(t===a&&r===4)return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))};throw Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${a} uncompressed bytes`)}}),p=e=>ot(mt(e,t.nByteLength));function m(e){return e>r>>rn}function h(e){return m(e)?s(-e):e}let g=(e,t,n)=>ft(e.slice(t,n));class _{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){let n=t.nByteLength;return e=ht(`compactSignature`,e,n*2),new _(g(e,0,n),g(e,n,2*n))}static fromDER(e){let{r:t,s:n}=tn.toSig(ht(`DER`,e));return new _(t,n)}assertValidity(){if(!f(this.r))throw Error(`r must be 0 < r < CURVE.n`);if(!f(this.s))throw Error(`s must be 0 < s < CURVE.n`)}addRecoveryBit(e){return new _(this.r,this.s,e)}recoverPublicKey(e){let{r,s:i,recovery:a}=this,o=C(ht(`msgHash`,e));if(a==null||![0,1,2,3].includes(a))throw Error(`recovery id invalid`);let u=a===2||a===3?r+t.n:r;if(u>=n.ORDER)throw Error(`recovery id 2 or 3 invalid`);let d=a&1?`03`:`02`,f=l.fromHex(d+p(u)),m=c(u),h=s(-o*m),g=s(i*m),_=l.BASE.multiplyAndAddUnsafe(f,h,g);if(!_)throw Error(`point at infinify`);return _.assertValidity(),_}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new _(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return dt(this.toDERHex())}toDERHex(){return tn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return dt(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let v={isValidPrivateKey(e){try{return u(e),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let e=Kt(t.n);return qt(t.randomBytes(e),t.n)},precompute(e=8,t=l.BASE){return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function y(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)}function b(e){let t=rt(e),n=typeof e==`string`,r=(t||n)&&e.length;return t?r===i||r===a:n?r===2*i||r===2*a:e instanceof l}function x(e,t,n=!0){if(b(e))throw Error(`first arg must be private key`);if(!b(t))throw Error(`second arg must be public key`);return l.fromHex(t).multiply(u(e)).toRawBytes(n)}let S=t.bits2int||function(e){let n=ft(e),r=e.length*8-t.nBitLength;return r>0?n>>BigInt(r):n},C=t.bits2int_modN||function(e){return s(S(e))},ee=bt(t.nBitLength);function te(e){if(typeof e!=`bigint`)throw Error(`bigint expected`);if(!(nn<=e&&e<ee))throw Error(`bigint expected < 2^${t.nBitLength}`);return mt(e,t.nByteLength)}function ne(e,r,i=re){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{hash:a,randomBytes:o}=t,{lowS:d,prehash:p,extraEntropy:g}=i;d??=!0,e=ht(`msgHash`,e),p&&(e=ht(`prehashed msgHash`,a(e)));let v=C(e),y=u(r),b=[te(y),te(v)];if(g!=null&&g!==!1){let e=g===!0?o(n.BYTES):g;b.push(ht(`extraEntropy`,e))}let x=gt(...b),ee=v;function ne(e){let t=S(e);if(!f(t))return;let n=c(t),r=l.BASE.multiply(t).toAffine(),i=s(r.x);if(i===nn)return;let a=s(n*s(ee+i*y));if(a===nn)return;let o=(r.x===i?0:2)|Number(r.y&rn),u=a;return d&&m(a)&&(u=h(a),o^=1),new _(i,u,o)}return{seed:x,k2sig:ne}}let re={lowS:t.lowS,prehash:!1},w={lowS:t.lowS,prehash:!1};function T(e,n,r=re){let{seed:i,k2sig:a}=ne(e,n,r),o=t;return St(o.hash.outputLen,o.nByteLength,o.hmac)(i,a)}l.BASE._setWindowSize(8);function ie(e,n,r,i=w){let a=e;if(n=ht(`msgHash`,n),r=ht(`publicKey`,r),`strict`in i)throw Error(`options.strict was renamed to lowS`);let{lowS:o,prehash:u}=i,d,f;try{if(typeof a==`string`||rt(a))try{d=_.fromDER(a)}catch(e){if(!(e instanceof tn.Err))throw e;d=_.fromCompact(a)}else if(typeof a==`object`&&typeof a.r==`bigint`&&typeof a.s==`bigint`){let{r:e,s:t}=a;d=new _(e,t)}else throw Error(`PARSE`);f=l.fromHex(r)}catch(e){if(e.message===`PARSE`)throw Error(`signature must be Signature instance, Uint8Array or hex string`);return!1}if(o&&d.hasHighS())return!1;u&&(n=t.hash(n));let{r:p,s:m}=d,h=C(n),g=c(m),v=s(h*g),y=s(p*g),b=l.BASE.multiplyAndAddUnsafe(f,v,y)?.toAffine();return b?s(b.x)===p:!1}return{CURVE:t,getPublicKey:y,getSharedSecret:x,sign:T,verify:ie,ProjectivePoint:l,Signature:_,utils:v}}function ln(e){return{hash:e,hmac:(t,...n)=>Qe(e,t,ue(...n)),randomBytes:ce}}function un(e,t){let n=t=>cn({...e,...ln(t)});return Object.freeze({...n(t),create:n})}var dn=BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),fn=BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),pn=BigInt(1),mn=BigInt(2),hn=(e,t)=>(e+t/mn)/t;function gn(e){let t=dn,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=Ft(Ft(Ft(u,n,t)*u%t,n,t)*u%t,mn,t)*l%t,f=Ft(d,i,t)*d%t,p=Ft(f,a,t)*f%t,m=Ft(p,s,t)*p%t,h=Ft(Ft(Ft(Ft(Ft(Ft(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,mn,t);if(!_n.eql(_n.sqr(h),e))throw Error(`Cannot find square root`);return h}var _n=Wt(dn,void 0,void 0,{sqrt:gn}),vn=un({a:BigInt(0),b:BigInt(7),Fp:_n,n:fn,Gx:BigInt(`55066263022277343669578718895168534326250603453777594175500187360389116729240`),Gy:BigInt(`32670510020758816978083085130507043184471273380659243275938904335757337482424`),h:BigInt(1),lowS:!0,endo:{beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),splitScalar:e=>{let t=fn,n=BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),r=-pn*BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`),i=BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),a=n,o=BigInt(`0x100000000000000000000000000000000`),s=hn(a*e,t),c=hn(-r*e,t),l=Nt(e-s*n-c*i,t),u=Nt(-s*r-c*a,t),d=l>o,f=u>o;if(d&&(l=t-l),f&&(u=t-u),l>o||u>o)throw Error(`splitScalar: Endomorphism failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}}},he);vn.ProjectivePoint;var yn=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),bn=class extends Error{constructor(e,t){super(e),this.error=t}},xn=class extends bn{constructor(e,t){super(e||`The wallet is not found.`,t),this.name=`WalletNotFoundError`}},Sn=class extends bn{constructor(){super(...arguments),this.name=`WalletDisconnectedError`,this.message=`The wallet is disconnected. Please connect first.`}},Cn=class extends bn{constructor(){super(...arguments),this.name=`WalletConnectionError`}},wn=class extends bn{constructor(){super(...arguments),this.name=`WalletSignMessageError`}},Tn=class extends bn{constructor(){super(...arguments),this.name=`WalletSignTransactionError`}},En=class extends bn{constructor(){super(...arguments),this.name=`WalletSwitchChainError`}},Dn=class extends bn{constructor(){super(...arguments),this.name=`WalletGetNetworkError`}},On=class extends bn{constructor(){super(...arguments),this.name=`WalletSignTypedDataError`}};function kn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var An=/^[0-9]+$/,jn=/^0[xX][0-9a-fA-F]+$/;function Mn(e){if(typeof e==`string`){let t=e.trim();if(!An.test(t)&&!jn.test(t))throw new On(`Invalid domain.chainId: ${e}. Expected a non-negative decimal or 0x-prefixed hex integer.`)}let t=Number(e);if(!Number.isInteger(t)||t<0)throw new On(`Invalid domain.chainId: ${e}. Expected a non-negative integer.`);if(!Number.isSafeInteger(t))throw new On(`domain.chainId ${e} exceeds Number.MAX_SAFE_INTEGER (${2**53-1}) and cannot be represented as a number without losing precision.`);return t}function Nn(e){if(!kn(e))throw new On(`typedData must be an object.`);if(!kn(e.domain))throw new On(`typedData.domain must be an object.`);if(!kn(e.types))throw new On(`typedData.types must be an object.`);if(!kn(e.message))throw new On(`typedData.message must be an object.`);let{chainId:t}=e.domain;if(typeof t==`string`||typeof t==`number`||typeof t==`bigint`){let n=Mn(t);return n===t?e:Object.assign(Object.assign({},e),{domain:Object.assign(Object.assign({},e.domain),{chainId:n})})}return e}var Pn;(function(e){e.Loading=`Loading`,e.NotFound=`NotFound`,e.Found=`Found`})(Pn||={});var L;(function(e){e.Loading=`Loading`,e.NotFound=`NotFound`,e.Disconnect=`Disconnected`,e.Connected=`Connected`})(L||={});var Fn;(function(e){e.Mainnet=`Mainnet`,e.Shasta=`Shasta`,e.Nile=`Nile`,e.Unknown=`Unknown`})(Fn||={});var In;(function(e){e.Mainnet=`Mainnet`,e.Shasta=`Shasta`,e.Nile=`Nile`})(In||={});var Ln=`TIP6963:announceProvider`,Rn=`TIP6963:requestProvider`,zn=t(yn(),1),Bn=class extends zn.default{get connected(){return this.state===L.Connected}disconnect(){return Promise.resolve()}multiSign(e,t={}){return Promise.reject(`The current wallet doesn't support multiSign.`)}signTypedData(e){let t;try{t=Nn(e)}catch(e){return Promise.reject(e)}return this._signTypedData(t)}_signTypedData(e){return Promise.reject(`The current wallet doesn't support signTypedData.`)}switchChain(e){return Promise.reject(`The current wallet doesn't support switch chain.`)}},Vn=6e5;function Hn(e,t=`[WalletAdapter]`){if(typeof e!=`number`)throw Error(`${t} config.checkTimeout should be a number`);if(!Number.isFinite(e)||e<0||e>6e5)throw Error(`${t} config.checkTimeout should be a finite number between 0 and ${Vn}, but got ${e}`)}function Un(e){return Object.fromEntries(Object.entries(e??{}).filter(([,e])=>e!==void 0))}function Wn(e){if(!e)throw new Cn(`Request connect error.`);return e}function Gn(){return typeof window<`u`&&typeof document<`u`&&typeof navigator<`u`}function Kn(){return typeof navigator<`u`&&navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i)}var qn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Jn={onRiskDetected:e=>qn(void 0,void 0,void 0,function*(){}),configUrls:[],enabled:!1,timeout:2e3,retries:0,cacheTTL:6e5},Yn=6e4,Xn=10;function Zn(e,t,n,r){if(typeof e!=`number`||!Number.isFinite(e)||e<n||e>r)throw Error(`[WalletAdapter] config.securityOptions.${t} should be a finite number between ${n} and ${r}, but got ${String(e)}`)}function Qn(e){try{return new URL(e)}catch{return null}}function $n(e){if(!Array.isArray(e))throw Error(`[WalletAdapter] config.securityOptions.configUrls should be an array of URLs, but got ${typeof e}`);for(let t of e){if(typeof t!=`string`||t.trim()===``)throw Error(`[WalletAdapter] config.securityOptions.configUrls should only contain non-empty URL strings, but got ${String(t)}`);let e=Qn(t);if(e&&e.protocol!==`http:`&&e.protocol!==`https:`)throw Error(`[WalletAdapter] config.securityOptions.configUrls only supports http(s) URLs, but got ${t}`)}}function er(e){let{enabled:t,configUrls:n,timeout:r,retries:i,cacheTTL:a,onRiskDetected:o,onConfigFallback:s}=e;if(t!==void 0&&typeof t!=`boolean`)throw Error(`[WalletAdapter] config.securityOptions.enabled should be a boolean, but got ${typeof t}`);if(n!==void 0&&$n(n),t&&(!n||n.length===0))throw Error(`[WalletAdapter] config.securityOptions.configUrls is required when securityOptions.enabled is true`);if(r!==void 0&&Zn(r,`timeout`,1,Yn),a!==void 0&&Zn(a,`cacheTTL`,0,2**53-1),i!==void 0&&(!Number.isInteger(i)||i<0||i>Xn))throw Error(`[WalletAdapter] config.securityOptions.retries should be an integer between 0 and ${Xn}, but got ${String(i)}`);if(o!==void 0&&typeof o!=`function`)throw Error(`[WalletAdapter] config.securityOptions.onRiskDetected should be a function, but got ${typeof o}`);if(s!==void 0&&typeof s!=`function`)throw Error(`[WalletAdapter] config.securityOptions.onConfigFallback should be a function, but got ${typeof s}`)}function tr(e){return!!e&&typeof e==`object`&&typeof e.title==`string`&&e.title.length>0&&(e.noticeType===1||e.noticeType===2||e.noticeType===3)}function nr(e){let t={title:e.title,noticeType:e.noticeType};return typeof e.ext==`string`&&(t.ext=e.ext),typeof e.ios==`string`&&(t.ios=e.ios),typeof e.and==`string`&&(t.and=e.and),t}function rr(e){let t=e&&typeof e==`object`?e:{},n={};if(t.wallets&&typeof t.wallets==`object`)for(let[e,r]of Object.entries(t.wallets)){if(!Array.isArray(r))continue;let t=[];for(let e of r)tr(e)&&t.push(nr(e));t.length>0&&(n[e]=t)}return{v:typeof t.v==`string`?t.v:``,ts:typeof t.ts==`number`?t.ts:0,wallets:n}}var ir={};function ar(e){return qn(this,void 0,void 0,function*(){let{configUrls:t=Jn.configUrls,timeout:n=Jn.timeout,retries:r=Jn.retries,onConfigFallback:i,cacheTTL:a=Jn.cacheTTL}=e,o=Date.now();function s(e){return qn(this,void 0,void 0,function*(){let t=ir[e];if(t&&o-t.timestamp<a)return t.data;function i(){return qn(this,void 0,void 0,function*(){return new Promise((t,r)=>{let i=new AbortController,a=setTimeout(()=>i.abort(),n);fetch(e,{signal:i.signal}).then(e=>{clearTimeout(a),e.ok?e.json().then(e=>t(rr(e)),r):r(Error(`Fetch failed with code: `+e.status))}).catch(e=>{clearTimeout(a),r(e)})})})}for(let t=0;t<=r;t++)try{let t=yield i();return ir[e]={data:t,timestamp:Date.now()},t}catch{}return null})}let c=(yield Promise.all(t.map(s))).filter(e=>e!==null);return c.length>0?c.reduce((e,t)=>{t.ts>e.ts&&(e.v=t.v,e.ts=t.ts);for(let[n,r]of Object.entries(t.wallets))e.wallets[n]=[...e.wallets[n]??[],...r];return e},{v:``,ts:0,wallets:{}}):i?rr(yield i()):{v:``,ts:0,wallets:{}}})}var or=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},sr=class e extends Bn{constructor(e){super(),this.commonConfig={checkTimeout:2e3,openAppWithDeeplink:!0,openUrlWhenWalletNotFound:!0,securityOptions:Jn},this._connectPromise=null,this._securityCheckCache=null,this.commonConfig=Object.assign(Object.assign({},this.commonConfig),Un(e)),Hn(this.commonConfig.checkTimeout),er(this.commonConfig.securityOptions)}updateSecurityOptions(e){let t=Object.assign(Object.assign({},this.commonConfig.securityOptions),e);er(t),this.commonConfig.securityOptions=t,this._securityCheckCache=null}connect(e){if(this._connectPromise)return this._connectPromise;let t=or(this,void 0,void 0,function*(){return this._connect(e)}).finally(()=>{this._connectPromise===t&&(this._connectPromise=null)});return this._connectPromise=t,t}_beforeConnect(){return or(this,void 0,void 0,function*(){if(this.connected||this.connecting)return!1;if(yield this._checkWallet(),this.readyState===Pn.NotFound)throw Gn()&&!this._openAppByDeepLinkIfNeed()&&this.commonConfig.openUrlWhenWalletNotFound!==!1&&window.open(this.url,`_blank`),new xn;return yield this.checkSecurity(),!0})}checkSecurity(){return or(this,void 0,void 0,function*(){if(!this.commonConfig.securityOptions.enabled)return;let t=this._securityCheckCache;if(t&&(t.settledAt===null||Date.now()-t.settledAt<e.SECURITY_CHECK_CACHE_TTL))return t.promise;let n=or(this,void 0,void 0,function*(){let e=(yield ar(this.commonConfig.securityOptions)).wallets[this.name];e&&e.length>0&&(yield(this.commonConfig.securityOptions.onRiskDetected||Jn.onRiskDetected)({risks:e}))}),r={promise:n,settledAt:null};return this._securityCheckCache=r,n.finally(()=>{this._securityCheckCache===r&&(r.settledAt=Date.now())}).catch(()=>{}),n})}};sr.SECURITY_CHECK_CACHE_TTL=5e3;var cr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function lr(){return Gn()&&!!(window.tron&&window.tron.isTronLink)}function ur(){return Gn()&&!!(lr()||window.tronLink||window.tronWeb)}function dr(){return Gn()&&window.iTron!==void 0}function fr({dappIcon:e,dappName:t}={dappIcon:``,dappName:``}){if(!ur()&&Kn()&&!dr()){let n=``,r=``;try{n=document.title;let e=document.querySelector(`link[rel*="icon"]`);e&&(r=new URL(e.getAttribute(`href`)||``,location.href).toString())}catch{}let{origin:i,pathname:a,search:o,hash:s}=window.location,c=i+a+o+(s.includes(`?`)?s:`${s}?_=1`),l={action:`open`,actionId:Date.now()+``,callbackUrl:`http://someurl.com`,dappIcon:e||r,dappName:t||n,url:c,protocol:`TronLink`,version:`1.0`,chainId:`0x2b6653dc`};return window.location.href=`tronlinkoutside://pull.activity?param=${encodeURIComponent(JSON.stringify(l))}`,!0}return!1}function pr(e){return cr(this,void 0,void 0,function*(){return new Promise((t,n)=>{let r=setInterval(()=>{e.tronWeb&&(clearInterval(r),clearTimeout(i),t())},50),i=setTimeout(()=>{clearInterval(r),n("`window.tron.tronweb` is not ready.")},2e3)})})}var mr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},hr={"0x2b6653dc":Fn.Mainnet,"0x94a9059e":Fn.Shasta,"0xcd8690dc":Fn.Nile};function gr(e){return mr(this,void 0,void 0,function*(){let{blockID:t=``}=yield e.trx.getBlockByNumber(0),n=`0x${t.slice(-8)}`;return{networkType:hr[n]||Fn.Unknown,chainId:n,fullNode:e.fullNode?.host||``,solidityNode:e.solidityNode?.host||``,eventServer:e.eventServer?.host||``}})}var _r=`TronLink`,vr=class extends sr{constructor(e={}){super(e),this.name=_r,this.url=`https://www.tronlink.org/`,this.icon=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF0AAABdCAYAAADHcWrDAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAUGVYSWZNTQAqAAAACAACARIAAwAAAAEAAQAAh2kABAAAAAEAAAAmAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAABdoAMABAAAAAEAAABdAAAAAMkTBfIAAAFZaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIj4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Chle4QcAABZhSURBVHgB7V0JlB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eu65sqmTkjok4K+AvNnyZH0Xsb+eO/wWrg46Do/7gYAAAAABJRU5ErkJggg==`,this._readyState=Gn()?Pn.Loading:Pn.NotFound,this._state=Gn()?L.Loading:L.NotFound,this._supportNewTronProtocol=!1,this._onChainChanged=e=>{this.emit(`chainChanged`,e)},this._onAccountsChanged=()=>{let e=this.address||``,t=this._wallet?.tronWeb&&this._wallet?.tronWeb.defaultAddress?.base58||``;this.setAddress(t||null),this.setState(this.address?L.Connected:L.Disconnect),this.emit(`accountsChanged`,this.address||``,e),!e&&this.address?this.emit(`connect`,this.address):e&&!this.address&&this.emit(`disconnect`)},this._checkPromise=null,this._updateWallet=()=>mr(this,void 0,void 0,function*(){this._supportNewTronProtocol=!1;let e,t;if(Kn()){if(this._wallet=window.tronLink?window.tronLink:{ready:!!window.tronWeb?.defaultAddress,tronWeb:window.tronWeb,request:()=>Promise.resolve(!0)},t=this._wallet.tronWeb?.defaultAddress?.base58||null,t){try{yield this.checkSecurity()}catch{this.setAddress(null),this.setState(L.Disconnect);return}e=L.Connected}else e=L.Disconnect}else if(this.isLegacyTronLinkProvider(window.tron)){this._supportNewTronProtocol=!0,this._wallet=window.tron,this._listenTronEvent();try{t=this._wallet?.tronWeb&&this._wallet.tronWeb?.defaultAddress?.base58||null,e=t?L.Connected:L.Disconnect}catch{this._readyState=Pn.NotFound,this.emit(`readyStateChanged`,this.readyState);return}}else window.tronLink?(this._wallet=window.tronLink,t=this._wallet.tronWeb?.defaultAddress?.base58||null,e=this._wallet.ready?L.Connected:L.Disconnect):(this._wallet=null,t=null,e=L.NotFound);Kn()&&e===L.Disconnect&&this.checkForWalletReadyForApp(),this.setAddress(t),this.setState(e)}),this.checkReadyInterval=null;let{checkTimeout:t=5e3,dappIcon:n=``,dappName:r=``,openUrlWhenWalletNotFound:i=!0,openTronLinkAppOnMobile:a=!0,openAppWithDeeplink:o=!0}=e;if(typeof t!=`number`)throw Error(`[TronLinkAdapter] config.checkTimeout should be a number`);if(this.config=Object.assign(Object.assign({},this.commonConfig),{checkTimeout:t,openTronLinkAppOnMobile:a,openAppWithDeeplink:o,openUrlWhenWalletNotFound:i,dappIcon:n,dappName:r}),this._connecting=!1,this._wallet=null,this._address=null,!Gn()){this._readyState=Pn.NotFound,this.setState(L.NotFound);return}Kn()&&(lr()||Kn()&&(window.tronLink||window.tronWeb))?(this._readyState=Pn.Found,this._updateWallet().then(()=>{this.connected&&this.emit(`connect`,this.address||``)})):this._checkWallet().then(()=>{this.connected&&this.emit(`connect`,this.address||``)})}get address(){return this._address}get state(){return this._state}get readyState(){return this._readyState}get connecting(){return this._connecting}network(){return mr(this,void 0,void 0,function*(){try{if(yield this._checkWallet(),this.state!==L.Connected)throw new Sn;let e=this._wallet?.tronWeb||window.tronWeb;if(!e)throw new Sn;try{return yield gr(e)}catch(e){throw new Dn(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}})}_connect(){return mr(this,void 0,void 0,function*(){try{if(!(yield this._beforeConnect())||!this._wallet)return;if(this._connecting=!0,this._supportNewTronProtocol){let e=this._wallet;try{let t=Wn((yield e.request({method:`eth_requestAccounts`}))?.[0]);this.setAddress(t),this.setState(L.Connected),this._listenTronEvent(),this._wallet.tronWeb||(yield pr(this._wallet))}catch(e){let t=e?.message||e||`Connect TronLink wallet failed.`;throw e.code===-32002&&(t=`The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed.`),e.code===4001&&(t=`The user rejected connection.`),new Cn(t,e)}}else if(window.tronLink){let e=this._wallet,t=yield e.request({method:`tron_requestAccounts`});if(!t)throw new Cn(`TronLink wallet is locked or no wallet account is avaliable.`);if(t.code===4e3)throw new Cn(`The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed.`);if(t.code===4001)throw new Cn(`The user rejected connection.`);let n=Wn(e.tronWeb.defaultAddress?.base58);this.setAddress(n),this.setState(L.Connected)}else if(window.tronWeb){let e=this._wallet,t=Wn(e.tronWeb.defaultAddress?.base58);this.setAddress(t),this.setState(L.Connected)}else throw new Cn(`Cannot connect wallet.`);this.connected&&this.emit(`connect`,this.address||``)}catch(e){let t=e instanceof bn?e:new Cn(e?.message,e);throw this.emit(`error`,t),t}finally{this._connecting=!1}})}disconnect(){return mr(this,void 0,void 0,function*(){this._supportNewTronProtocol&&this._stopListenTronEvent(),this.state===L.Connected&&(this.setAddress(null),this.setState(L.Disconnect),this.emit(`disconnect`))})}_checkAndSign(e,t){return mr(this,void 0,void 0,function*(){try{let n=yield this.checkAndGetWallet();try{return yield e(n)}catch(e){throw e instanceof Error||typeof e==`object`&&e.message?new t(e.message,e):typeof e==`string`?new t(e,Error(e)):new t(`Unknown error`,e)}}catch(e){throw this.emit(`error`,e),e}})}signTransaction(e){return mr(this,void 0,void 0,function*(){return this._checkAndSign(t=>t.tronWeb.trx.sign(e),Tn)})}multiSign(e){return mr(this,arguments,void 0,function*(e,t={}){return this._checkAndSign(n=>n.tronWeb.trx.multiSign(e,void 0,t.permissionId),Tn)})}signMessage(e){return mr(this,void 0,void 0,function*(){return this._checkAndSign(t=>mr(this,void 0,void 0,function*(){return t.tronWeb.trx.signMessageV2(e)}),wn)})}_signTypedData(e){return mr(this,void 0,void 0,function*(){return this._checkAndSign(t=>mr(this,void 0,void 0,function*(){return t.tronWeb.trx._signTypedData(e.domain,e.types,e.message)}),On)})}switchChain(e){return mr(this,void 0,void 0,function*(){try{if(yield this._checkWallet(),this.state===L.NotFound)throw this.config.openUrlWhenWalletNotFound!==!1&&Gn()&&window.open(this.url,`_blank`),new xn;if(!this._supportNewTronProtocol)throw new En(`Current version of TronLink doesn't support switch chain operation.`);let t=this._wallet;try{yield t.request({method:`wallet_switchEthereumChain`,params:[{chainId:e}]})}catch(e){throw new En(e?.message||e,e instanceof Error?e:Error(e))}}catch(e){throw this.emit(`error`,e),e}})}checkAndGetWallet(){return mr(this,void 0,void 0,function*(){if(this._openAppByDeepLinkIfNeed())throw new xn;if(yield this._checkWallet(),this.state!==L.Connected)throw new Sn;let e=this._wallet;if(!e||!e.tronWeb)throw new Sn;return e})}_openAppByDeepLinkIfNeed(){if(this.config.openAppWithDeeplink===!1||this.config.openTronLinkAppOnMobile===!1)return!1;let{dappName:e=``,dappIcon:t=``}=this.config;return fr({dappIcon:t,dappName:e})}_listenTronEvent(){var e,t;this._stopListenTronEvent();let n=this._wallet;(e=n.on)==null||e.call(n,`chainChanged`,this._onChainChanged),(t=n.on)==null||t.call(n,`accountsChanged`,this._onAccountsChanged)}_stopListenTronEvent(){var e,t;let n=this._wallet;(e=n.removeListener)==null||e.call(n,`chainChanged`,this._onChainChanged),(t=n.removeListener)==null||t.call(n,`accountsChanged`,this._onAccountsChanged)}isLegacyTronLinkProvider(e){return!!e?.isTronLink}hasDesktopLegacyTronLinkProvider(){return this.isLegacyTronLinkProvider(window.tron)||!!window.tronLink}_checkWallet(){if(this.readyState===Pn.Found)return Promise.resolve(!0);if(this._checkPromise)return this._checkPromise;if(Gn()&&!Kn()){let e=new Promise(e=>{let t=!1,n=null,r=null,i=null,a=()=>{r&&=(clearInterval(r),null),n&&=(clearTimeout(n),null),typeof window<`u`&&i&&window.removeEventListener(Ln,i)};n=setTimeout(()=>{if(t)return;if(t=!0,a(),typeof window>`u`){e(!1);return}this._updateWallet();let n=this.state!==L.NotFound;this._readyState=n?Pn.Found:Pn.NotFound,this.emit(`readyStateChanged`,this._readyState),e(n)},this.config.checkTimeout),i=n=>mr(this,void 0,void 0,function*(){if(t)return;let{info:r,provider:i}=n.detail;if(r.name===`TronLink`){t=!0,this._supportNewTronProtocol=!0,this._wallet=i;try{yield this.checkSecurity()}catch{this.setAddress(null),this.setState(L.Disconnect),this._readyState=Pn.Found,this.emit(`readyStateChanged`,this.readyState),e(!0);return}this._listenTronEvent(),this._readyState=Pn.Found;let n=this._wallet?.tronWeb&&this._wallet.tronWeb.defaultAddress?.base58||null,r=n?L.Connected:L.Disconnect;this.setAddress(n),this.setState(r),this.emit(`readyStateChanged`,this.readyState),a(),e(!0)}}),window.addEventListener(Ln,i),window.dispatchEvent(new Event(Rn))});return this._checkPromise=e,e.then(t=>{!t&&this._checkPromise===e&&(this._checkPromise=null)}),e}let e=Math.floor(this.config.checkTimeout/100),t=0,n,r=new Promise(r=>{let i=()=>{t++,this._updateWallet();let i=!!(Kn()&&(window.tronLink||window.tronWeb));(i||t>e)&&(n&&clearInterval(n),this._readyState=i?Pn.Found:Pn.NotFound,this.emit(`readyStateChanged`,this.readyState),r(i))};n=setInterval(i,100),i()});return this._checkPromise=r,r.then(e=>{!e&&this._checkPromise===r&&(this._checkPromise=null)}),r}checkForWalletReadyForApp(){if(this.checkReadyInterval)return;let e=0,t=Math.floor(this.config.checkTimeout/200),n=()=>{(window.tronLink?window.tronLink.tronWeb?.defaultAddress:window.tronWeb?.defaultAddress)?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null,this._updateWallet(),this.emit(`connect`,this.address||``)):e>t?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null):e++};this.checkReadyInterval=setInterval(n,200)}setAddress(e){this._address=e}setState(e){e!==this.state&&(this._state=e,this.emit(`stateChanged`,e))}};function yr(){return!!window.tronLink&&window.isBitKeep}function br(){if(Kn()&&!yr()){let{origin:e,pathname:t,search:n,hash:r}=window.location,i=e+t+n+r;return location.href=`https://bkcode.vip?action=dapp&url=${encodeURIComponent(i)}`,!0}return!1}var xr=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Sr=`Bitget Wallet`,Cr=class extends sr{constructor(e={}){if(super(e),this.name=Sr,this.url=`https://web3.bitget.com`,this.icon=`data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiIgdmlld0JveD0iMCAwIDUxMiA1MTIiIGZpbGw9Im5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state=L.Loading,this.checkReadyInterval=null,this._checkPromise=null,this._hasRunInitialDetection=!1,this._updateWallet=()=>xr(this,void 0,void 0,function*(){let e,t;if(yr()){if(Kn()){let e=window.bitkeep?.tronLink;this._wallet={tron:e,tronWeb:e?.tronWeb}}else{let e=window.bitkeep?.tronWeb;this._wallet={tron:window.bitkeep.tronLink,tronWeb:e}}let n=this._wallet.tron?.ready;if(t=n?this._wallet.tronWeb.defaultAddress?.base58||null:``,n){try{yield this.checkSecurity()}catch{this.setAddress(null),this.setState(L.Disconnect);return}e=L.Connected}else e=L.Disconnect,this.checkForWalletReady()}else this._wallet=null,t=null,e=L.NotFound;this.setAddress(t),this.setState(e)}),this.config=Object.assign({},this.commonConfig),this._connecting=!1,this._wallet=null,this._address=null,!Gn()){this._readyState=Pn.NotFound,this.setState(L.NotFound);return}yr()?(this._readyState=Pn.Found,this._updateWallet().then(()=>{this.connected&&this.emit(`connect`,this.address||``)})):this._checkWallet().then(()=>{this.connected&&this.emit(`connect`,this.address||``)})}get address(){return this._address}get state(){return this._state}get readyState(){return this._readyState}get connecting(){return this._connecting}network(){return xr(this,void 0,void 0,function*(){try{if(yield this._checkWallet(),this.state!==L.Connected)throw new Sn;let e=this._wallet;if(!e||!e.tronWeb)throw new Sn;try{return yield gr(e.tronWeb)}catch(e){throw new Dn(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}})}_connect(){return xr(this,void 0,void 0,function*(){try{if(!(yield this._beforeConnect()))return;let e=this._wallet;if(!e)return;if(!Kn()){this._connecting=!0;let t=yield e.tron.request({method:`tron_requestAccounts`});if(t?.code!==200)throw new Cn(t?.code===40001?`The connection request is canceled by user.`:t?.message)}let t=Wn(e?.tronWeb.defaultAddress?.base58||window.bitkeep?.tronWeb?.defaultAddress?.base58);this.setAddress(t),this.setState(L.Connected),this.emit(`connect`,this.address||``)}catch(e){let t=e instanceof bn?e:new Cn(e?.message,e);throw this.emit(`error`,t),t}finally{this._connecting=!1}})}disconnect(){return xr(this,void 0,void 0,function*(){this.state===L.Connected&&(this.setAddress(null),this.setState(L.Disconnect),this.emit(`disconnect`))})}signTransaction(e){return xr(this,void 0,void 0,function*(){try{let t=yield this.checkAndGetWallet();try{return yield t.tronWeb.trx.sign(e)}catch(e){throw e instanceof Error?new Tn(e.message,e):new Tn(e,Error(e))}}catch(e){throw this.emit(`error`,e),e}})}multiSign(e){return xr(this,arguments,void 0,function*(e,t={}){try{let n=yield this.checkAndGetWallet();try{return yield n.tronWeb.trx.multiSign(e,void 0,t.permissionId)}catch(e){throw e instanceof Error?new Tn(e.message,e):new Tn(e,Error(e))}}catch(e){throw this.emit(`error`,e),e}})}signMessage(e){return xr(this,void 0,void 0,function*(){try{let t=yield this.checkAndGetWallet();try{return yield t.tronWeb.trx.signMessageV2(e)}catch(e){throw e instanceof Error?new wn(e.message,e):new wn(e,Error(e))}}catch(e){throw this.emit(`error`,e),e}})}checkAndGetWallet(){return xr(this,void 0,void 0,function*(){if(this.checkIfOpenApp(),yield this._checkWallet(),!this.connected)throw new Sn;let e=this._wallet;if(!e||!e.tronWeb)throw new Sn;return e})}checkForWalletReady(){if(this.checkReadyInterval)return;let e=0,t=Math.floor(this.config.checkTimeout/200),n=()=>xr(this,void 0,void 0,function*(){this._wallet&&this._wallet?.tron.ready?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null,yield this._updateWallet(),this.emit(`connect`,this.address||``)):e>t?(this.checkReadyInterval&&clearInterval(this.checkReadyInterval),this.checkReadyInterval=null):e++});this.checkReadyInterval=setInterval(n,200)}_checkWallet(){if(this.readyState===Pn.Found)return Promise.resolve(!0);if(this._checkPromise)return this._checkPromise;let e=this._hasRunInitialDetection?0:Math.floor(this.config.checkTimeout/100);this._hasRunInitialDetection=!0;let t=0,n,r=new Promise(r=>{let i=()=>xr(this,void 0,void 0,function*(){t++;let i=yr();(i||t>e)&&(n&&clearInterval(n),this._readyState=i?Pn.Found:Pn.NotFound,yield this._updateWallet(),this.emit(`readyStateChanged`,this.readyState),r(i))});n=setInterval(i,100),i()});return this._checkPromise=r,r.then(e=>{!e&&this._checkPromise===r&&(this._checkPromise=null)}),r}checkIfOpenApp(){if(this.config.openAppWithDeeplink!==!1&&br())throw new xn}setAddress(e){this._address=e}setState(e){e!==this.state&&(this._state=e,this.emit(`stateChanged`,e))}_openAppByDeepLinkIfNeed(){return this.config.openAppWithDeeplink!==!1&&br()}};w(),typeof window<`u`&&window.Buffer===void 0&&(window.Buffer=re);var wr=class extends Error{constructor(e,t){super(e),this.error=t}},Tr=class extends wr{constructor(e,t){super(e||`The wallet is not found.`,t),this.name=`WalletNotFoundError`}},Er=class extends wr{constructor(){super(...arguments),this.name=`WalletDisconnectedError`,this.message=`The wallet is disconnected. Please connect first.`}},Dr=class extends wr{constructor(){super(...arguments),this.name=`WalletConnectionError`}},Or=class extends wr{constructor(){super(...arguments),this.name=`WalletDisconnectionError`}},kr=class extends wr{constructor(){super(...arguments),this.name=`WalletSignMessageError`}},Ar=class extends wr{constructor(){super(...arguments),this.name=`WalletSignTransactionError`}},jr=class extends wr{constructor(){super(...arguments),this.name=`WalletSignTypedDataError`}};function Mr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Nr(e){if(!Mr(e))throw new jr(`typedData must be an object.`);if(!Mr(e.domain))throw new jr(`typedData.domain must be an object.`);if(!Mr(e.types))throw new jr(`typedData.types must be an object.`);if(!Mr(e.message))throw new jr(`typedData.message must be an object.`);let{chainId:t}=e.domain;if(typeof t==`string`){let n=Number(t);if(!Number.isFinite(n))throw new jr(`Invalid domain.chainId: ${t}.`);return Object.assign(Object.assign({},e),{domain:Object.assign(Object.assign({},e.domain),{chainId:n})})}return e}var Pr;(function(e){e.Loading=`Loading`,e.NotFound=`NotFound`,e.Found=`Found`})(Pr||={});var Fr;(function(e){e.Loading=`Loading`,e.NotFound=`NotFound`,e.Disconnect=`Disconnected`,e.Connected=`Connected`})(Fr||={});var Ir;(function(e){e.Mainnet=`Mainnet`,e.Shasta=`Shasta`,e.Nile=`Nile`,e.Unknown=`Unknown`})(Ir||={});var Lr;(function(e){e.Mainnet=`Mainnet`,e.Shasta=`Shasta`,e.Nile=`Nile`})(Lr||={});var Rr=class extends zn.default{get connected(){return this.state===Fr.Connected}disconnect(){return Promise.resolve()}multiSign(e,t={}){return Promise.reject(`The current wallet doesn't support multiSign.`)}signTypedData(e){let t;try{t=Nr(e)}catch(e){return Promise.reject(e)}return this._signTypedData(t)}_signTypedData(e){return Promise.reject(`The current wallet doesn't support signTypedData.`)}switchChain(e){return Promise.reject(`The current wallet doesn't support switch chain.`)}};function zr(){return typeof window<`u`&&typeof document<`u`&&typeof navigator<`u`}var Br=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Vr=class{encode(e){let t=``,n,r,i,a,o,s,c,l=0;for(;l<e.length;)n=e.charCodeAt(l++),r=e.charCodeAt(l++),i=e.charCodeAt(l++),a=n>>2,o=(n&3)<<4|r>>4,s=(r&15)<<2|i>>6,c=i&63,isNaN(r)?s=c=64:isNaN(i)&&(c=64),t=t+Br.charAt(a)+Br.charAt(o)+Br.charAt(s)+Br.charAt(c);return t}encodeIgnoreUtf8(e){let t=``,n,r,i,a,o,s,c,l=0;for(;l<e.length;)n=e[l++],r=e[l++],i=e[l++],a=n>>2,o=(n&3)<<4|r>>4,s=(r&15)<<2|i>>6,c=i&63,isNaN(r)?s=c=64:isNaN(i)&&(c=64),t=t+Br.charAt(a)+Br.charAt(o)+Br.charAt(s)+Br.charAt(c);return t}decode(e){let t=``,n,r,i,a,o,s,c,l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,``);l<e.length;)a=Br.indexOf(e.charAt(l++)),o=Br.indexOf(e.charAt(l++)),s=Br.indexOf(e.charAt(l++)),c=Br.indexOf(e.charAt(l++)),n=a<<2|o>>4,r=(o&15)<<4|s>>2,i=(s&3)<<6|c,t+=String.fromCharCode(n),s!=64&&(t+=String.fromCharCode(r)),c!=64&&(t+=String.fromCharCode(i));return this._utf8_decode(t)}decodeToByteArray(e){let t=``,n,r,i,a,o,s,c,l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,``);l<e.length;)a=Br.indexOf(e.charAt(l++)),o=Br.indexOf(e.charAt(l++)),s=Br.indexOf(e.charAt(l++)),c=Br.indexOf(e.charAt(l++)),n=a<<2|o>>4,r=(o&15)<<4|s>>2,i=(s&3)<<6|c,t+=String.fromCharCode(n),s!=64&&(t+=String.fromCharCode(r)),c!=64&&(t+=String.fromCharCode(i));return this._out2ByteArray(t)}_out2ByteArray(e){let t=Array(e.length),n=0,r=0;for(;n<e.length;)r=e.charCodeAt(n),t[n]=r,n++;return t}_utf8_encode(e){e=e.replace(/\r\n/g,`
|
|
4
4
|
`);let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(r&63|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(r&63|128))}return t}_utf8_decode(e){let t=``,n=0,r=0,i=0,a=0;for(;n<e.length;)r=e.charCodeAt(n),r<128?(t+=String.fromCharCode(r),n++):r>191&&r<224?(i=e.charCodeAt(n+1),t+=String.fromCharCode((r&31)<<6|i&63),n+=2):(i=e.charCodeAt(n+1),a=e.charCodeAt(n+2),t+=String.fromCharCode((r&15)<<12|(i&63)<<6|a&63),n+=3);return t}},Hr=e({base64DecodeFromString:()=>Kr,base64EncodeToString:()=>qr,byte2hexStr:()=>Ur,byteArray2hexStr:()=>R,bytesToString:()=>Wr,hextoString:()=>Gr});function Ur(e){if(e<0||e>255)throw Error(`Input must be a byte`);let t=`0123456789ABCDEF`,n=``;return n+=t.charAt(e>>4),n+=t.charAt(e&15),n}function Wr(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n].toString(2),i=r.match(/^1+?(?=0)/);if(i&&r.length===8){let r=i[0].length,a=e[n].toString(2).slice(7-r);for(let t=1;t<r;t++)a+=e[t+n].toString(2).slice(2);t+=String.fromCharCode(parseInt(a,2)),n+=r-1}else t+=String.fromCharCode(e[n])}return t}function Gr(e){let t=e.replace(/^0x/,``).split(``),n=``;for(let e=0;e<t.length/2;e++){let r=`0x${t[e*2]}${t[e*2+1]}`;n+=String.fromCharCode(parseInt(r))}return n}function R(e){let t=``;for(let n=0;n<e.length;n++)t+=Ur(e[n]);return t}function Kr(e){return new Vr().decodeToByteArray(e)}function qr(e){return new Vr().encodeIgnoreUtf8(e)}var Jr=e({ADDRESS_PREFIX:()=>`41`,ADDRESS_PREFIX_BYTE:()=>65,ADDRESS_PREFIX_REGEX:()=>Yr,ADDRESS_SIZE:()=>34,TRON_BIP39_PATH_INDEX_0:()=>Zr,TRON_BIP39_PATH_PREFIX:()=>Xr}),Yr=/^(41)/,Xr=`m/44'/195'`,Zr=`m/44'/195'/0'/0/0`,Qr=e({arrayEquals:()=>ei,base64DecodeFromString:()=>Kr,base64EncodeToString:()=>qr,bin2String:()=>$r,byte2hexStr:()=>Ur,byteArray2hexStr:()=>R,bytesToString:()=>Wr,getStringType:()=>si,hexChar2byte:()=>ni,hexStr2byteArray:()=>ii,hextoString:()=>Gr,isHexChar:()=>ri,isNumber:()=>oi,strToDate:()=>ai,stringToBytes:()=>ti});function $r(e){return Wr(e)}function ei(e,t,n=!1){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(n){if(e[r]!=t[r])return!1}else if(JSON.stringify(e[r])!=JSON.stringify(t[r]))return!1;return!0}function ti(e){let t=[],n=e.length,r;for(let i=0;i<n;i++)r=e.charCodeAt(i),r>=65536&&r<=1114111?(t.push(r>>18&7|240),t.push(r>>12&63|128),t.push(r>>6&63|128),t.push(r&63|128)):r>=2048&&r<=65535?(t.push(r>>12&15|224),t.push(r>>6&63|128),t.push(r&63|128)):r>=128&&r<=2047?(t.push(r>>6&31|192),t.push(r&63|128)):t.push(r&255);return t}function ni(e){let t;if(e>=`A`&&e<=`F`?t=e.charCodeAt(0)-65+10:e>=`a`&&e<=`f`?t=e.charCodeAt(0)-97+10:e>=`0`&&e<=`9`&&(t=e.charCodeAt(0)-48),typeof t==`number`)return t;throw Error(`The passed hex char is not a valid hex char`)}function ri(e){return+(e>=`A`&&e<=`F`||e>=`a`&&e<=`f`||e>=`0`&&e<=`9`)}function ii(e,t=!1){let n=e.length;t&&n%2&&(e=`0${e}`,n++);let r=[],i=0,a=0,o=0;for(let t=0;t<n;t++){let n=e.charAt(t);if(ri(n))i<<=4,i+=ni(n),a++,a%2==0&&(r[o++]=i,i=0);else throw Error(`The passed hex char is not a valid hex string`)}return r}function ai(e){if(!/^\d{4}-\d{2}-\d{2}( \d{2}-\d{2}-\d{2}|)/.test(e))throw Error(`The passed date string is not valid`);let t=e.split(` `),n=t[0].split(`-`),r=parseInt(n[0],10),i=parseInt(n[1],10)-1,a=parseInt(n[2],10);if(t.length>1){let e=t[1].split(`-`),n=parseInt(e[0],10),o=parseInt(e[1],10),s=parseInt(e[2],10);return new Date(r,i,a,n,o,s)}return new Date(r,i,a)}function oi(e){return+(e>=`0`&&e<=`9`)}function si(e){if(e==null||e.length==0||e==``)return-1;let t=0;if(e.length==40)for(;t<40&&ri(e.charAt(t));t++);if(t==40)return 1;for(t=0;t<e.length&&oi(e.charAt(t));t++);if(t==e.length)return 2;for(t=0;t<e.length;t++)if(e.charAt(t)>` `)return 3;return-1}var ci=e({decode58:()=>pi,encode58:()=>fi}),li=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,ui={};for(let e=0;e<58;e++)ui[li.charAt(e)]=e;var di=58;function fi(e){if(e.length===0)return``;let t,n,r=[0];for(t=0;t<e.length;t++){for(n=0;n<r.length;n++)r[n]<<=8;r[0]+=e[t];let i=0;for(n=0;n<r.length;++n)r[n]+=i,i=r[n]/di|0,r[n]%=di;for(;i;)r.push(i%di),i=i/di|0}for(t=0;e[t]===0&&t<e.length-1;t++)r.push(0);return r.reverse().map(e=>li[e]).join(``)}function pi(e){if(e.length===0)return[];let t,n,r=[0];for(t=0;t<e.length;t++){let i=e[t];if(!(i in ui))throw Error(`Non-base58 character`);for(n=0;n<r.length;n++)r[n]*=di;r[0]+=ui[i];let a=0;for(n=0;n<r.length;++n)r[n]+=a,a=r[n]>>8,r[n]&=255;for(;a;)r.push(a&255),a>>=8}for(t=0;e[t]===`1`&&t<e.length-1;t++)r.push(0);return r.reverse()}var mi=`6.13.5`;function hi(e,t,n){let r=t.split(`|`).map(e=>e.trim());for(let n=0;n<r.length;n++)switch(t){case`any`:return;case`bigint`:case`boolean`:case`number`:case`string`:if(typeof e===t)return}let i=Error(`invalid value for type ${t}`);throw i.code=`INVALID_ARGUMENT`,i.argument=`value.${n}`,i.value=e,i}async function gi(e){let t=Object.keys(e);return(await Promise.all(t.map(t=>Promise.resolve(e[t])))).reduce((e,n,r)=>(e[t[r]]=n,e),{})}function z(e,t,n){for(let r in t){let i=t[r],a=n?n[r]:null;a&&hi(i,a,r),Object.defineProperty(e,r,{enumerable:!0,value:i,writable:!1})}}function _i(e){if(e==null)return`null`;if(Array.isArray(e))return`[ `+e.map(_i).join(`, `)+` ]`;if(e instanceof Uint8Array){let t=`0123456789abcdef`,n=`0x`;for(let r=0;r<e.length;r++)n+=t[e[r]>>4],n+=t[e[r]&15];return n}if(typeof e==`object`&&typeof e.toJSON==`function`)return _i(e.toJSON());switch(typeof e){case`boolean`:case`symbol`:return e.toString();case`bigint`:return BigInt(e).toString();case`number`:return e.toString();case`string`:return JSON.stringify(e);case`object`:{let t=Object.keys(e);return t.sort(),`{ `+t.map(t=>`${_i(t)}: ${_i(e[t])}`).join(`, `)+` }`}}return`[ COULD NOT SERIALIZE ]`}function vi(e,t){return e&&e.code===t}function yi(e,t,n){let r=e;{let r=[];if(n){if(`message`in n||`code`in n||`name`in n)throw Error(`value will overwrite populated values: ${_i(n)}`);for(let e in n){if(e===`shortMessage`)continue;let t=n[e];r.push(e+`=`+_i(t))}}r.push(`code=${t}`),r.push(`version=${mi}`),r.length&&(e+=` (`+r.join(`, `)+`)`)}let i;switch(t){case`INVALID_ARGUMENT`:i=TypeError(e);break;case`NUMERIC_FAULT`:case`BUFFER_OVERRUN`:i=RangeError(e);break;default:i=Error(e)}return z(i,{code:t}),n&&Object.assign(i,n),i.shortMessage??z(i,{shortMessage:r}),i}function B(e,t,n,r){if(!e)throw yi(t,n,r)}function V(e,t,n,r){B(e,t,`INVALID_ARGUMENT`,{argument:n,value:r})}function bi(e,t,n){n??=``,n&&=`: `+n,B(e>=t,`missing argument`+n,`MISSING_ARGUMENT`,{count:e,expectedCount:t}),B(e<=t,`too many arguments`+n,`UNEXPECTED_ARGUMENT`,{count:e,expectedCount:t})}var xi=[`NFD`,`NFC`,`NFKD`,`NFKC`].reduce((e,t)=>{try{if(`test`.normalize(t)!==`test`)throw Error(`bad`);if(t===`NFD`&&`é`.normalize(`NFD`)!==`é`)throw Error(`broken`);e.push(t)}catch{}return e},[]);function Si(e){B(xi.indexOf(e)>=0,`platform missing String.prototype.normalize`,`UNSUPPORTED_OPERATION`,{operation:`String.prototype.normalize`,info:{form:e}})}function Ci(e,t,n){if(n??=``,e!==t){let e=n,t=`new`;n&&(e+=`.`,t+=` `+n),B(!1,`private constructor; use ${e}from* methods`,`UNSUPPORTED_OPERATION`,{operation:t})}}function wi(e,t,n){if(e instanceof Uint8Array)return n?new Uint8Array(e):e;if(typeof e==`string`&&e.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){let t=new Uint8Array((e.length-2)/2),n=2;for(let r=0;r<t.length;r++)t[r]=parseInt(e.substring(n,n+2),16),n+=2;return t}V(!1,`invalid BytesLike value`,t||`value`,e)}function H(e,t){return wi(e,t,!1)}function Ti(e,t){return wi(e,t,!0)}function Ei(e,t){return!(typeof e!=`string`||!e.match(/^0x[0-9A-Fa-f]*$/)||typeof t==`number`&&e.length!==2+2*t||t===!0&&e.length%2!=0)}function Di(e){return Ei(e,!0)||e instanceof Uint8Array}var Oi=`0123456789abcdef`;function U(e){let t=H(e),n=`0x`;for(let e=0;e<t.length;e++){let r=t[e];n+=Oi[(r&240)>>4]+Oi[r&15]}return n}function ki(e){return`0x`+e.map(e=>U(e).substring(2)).join(``)}function Ai(e){return Ei(e,!0)?(e.length-2)/2:H(e).length}function ji(e,t,n){let r=H(e);return n!=null&&n>r.length&&B(!1,`cannot slice beyond data bounds`,`BUFFER_OVERRUN`,{buffer:r,length:r.length,offset:n}),U(r.slice(t??0,n??r.length))}function Mi(e,t,n){let r=H(e);B(t>=r.length,`padding exceeds data length`,`BUFFER_OVERRUN`,{buffer:new Uint8Array(r),length:t,offset:t+1});let i=new Uint8Array(t);return i.fill(0),n?i.set(r,t-r.length):i.set(r,0),U(i)}function Ni(e,t){return Mi(e,t,!0)}var Pi=BigInt(0),Fi=BigInt(1),Ii=9007199254740991;function Li(e,t){let n=Vi(e,`value`),r=BigInt(Wi(t,`width`));if(B(n>>r===Pi,`overflow`,`NUMERIC_FAULT`,{operation:`fromTwos`,fault:`overflow`,value:e}),n>>r-Fi){let e=(Fi<<r)-Fi;return-((~n&e)+Fi)}return n}function Ri(e,t){let n=Bi(e,`value`),r=BigInt(Wi(t,`width`)),i=Fi<<r-Fi;if(n<Pi){n=-n,B(n<=i,`too low`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e});let t=(Fi<<r)-Fi;return(~n&t)+Fi}return B(n<i,`too high`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e}),n}function zi(e,t){return Vi(e,`value`)&(Fi<<BigInt(Wi(t,`bits`)))-Fi}function Bi(e,t){switch(typeof e){case`bigint`:return e;case`number`:return V(Number.isInteger(e),`underflow`,t||`value`,e),V(e>=-9007199254740991&&e<=Ii,`overflow`,t||`value`,e),BigInt(e);case`string`:try{if(e===``)throw Error(`empty string`);return e[0]===`-`&&e[1]!==`-`?-BigInt(e.substring(1)):BigInt(e)}catch(n){V(!1,`invalid BigNumberish string: ${n.message}`,t||`value`,e)}}V(!1,`invalid BigNumberish value`,t||`value`,e)}function Vi(e,t){let n=Bi(e,t);return B(n>=Pi,`unsigned value cannot be negative`,`NUMERIC_FAULT`,{fault:`overflow`,operation:`getUint`,value:e}),n}var Hi=`0123456789abcdef`;function Ui(e){if(e instanceof Uint8Array){let t=`0x0`;for(let n of e)t+=Hi[n>>4],t+=Hi[n&15];return BigInt(t)}return Bi(e)}function Wi(e,t){switch(typeof e){case`bigint`:return V(e>=-9007199254740991&&e<=Ii,`overflow`,t||`value`,e),Number(e);case`number`:return V(Number.isInteger(e),`underflow`,t||`value`,e),V(e>=-9007199254740991&&e<=Ii,`overflow`,t||`value`,e),e;case`string`:try{if(e===``)throw Error(`empty string`);return Wi(BigInt(e),t)}catch(n){V(!1,`invalid numeric string: ${n.message}`,t||`value`,e)}}V(!1,`invalid numeric value`,t||`value`,e)}function Gi(e){return Wi(Ui(e))}function Ki(e,t){let n=Vi(e,`value`).toString(16);if(t==null)n.length%2&&(n=`0`+n);else{let r=Wi(t,`width`);for(B(r*2>=n.length,`value exceeds width (${r} bytes)`,`NUMERIC_FAULT`,{operation:`toBeHex`,fault:`overflow`,value:e});n.length<r*2;)n=`0`+n}return`0x`+n}function qi(e){let t=Vi(e,`value`);if(t===Pi)return new Uint8Array([]);let n=t.toString(16);n.length%2&&(n=`0`+n);let r=new Uint8Array(n.length/2);for(let e=0;e<r.length;e++){let t=e*2;r[e]=parseInt(n.substring(t,t+2),16)}return r}function Ji(e){let t=U(Di(e)?e:qi(e)).substring(2);for(;t.startsWith(`0`);)t=t.substring(1);return t===``&&(t=`0`),`0x`+t}var Yi=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,Xi=null;function Zi(e){if(Xi==null){Xi={};for(let e=0;e<58;e++)Xi[Yi[e]]=BigInt(e)}let t=Xi[e];return V(t!=null,`invalid base58 value`,`letter`,e),t}var Qi=BigInt(0),$i=BigInt(58);function ea(e){let t=H(e),n=Ui(t),r=``;for(;n;)r=Yi[Number(n%$i)]+r,n/=$i;for(let e=0;e<t.length&&!t[e];e++)r=Yi[0]+r;return r}function ta(e){let t=Qi;for(let n=0;n<e.length;n++)t*=$i,t+=Zi(e[n]);return t}function na(e,t,n,r,i){V(!1,`invalid codepoint at offset ${t}; ${e}`,`bytes`,n)}function ra(e,t,n,r,i){if(e===`BAD_PREFIX`||e===`UNEXPECTED_CONTINUE`){let e=0;for(let r=t+1;r<n.length&&n[r]>>6==2;r++)e++;return e}return e===`OVERRUN`?n.length-t-1:0}function ia(e,t,n,r,i){return e===`OVERLONG`?(V(typeof i==`number`,`invalid bad code point for replacement`,`badCodepoint`,i),r.push(i),0):(r.push(65533),ra(e,t,n,r,i))}var aa=Object.freeze({error:na,ignore:ra,replace:ia});function oa(e,t){t??=aa.error;let n=H(e,`bytes`),r=[],i=0;for(;i<n.length;){let e=n[i++];if(!(e>>7)){r.push(e);continue}let a=null,o=null;if((e&224)==192)a=1,o=127;else if((e&240)==224)a=2,o=2047;else if((e&248)==240)a=3,o=65535;else{(e&192)==128?i+=t(`UNEXPECTED_CONTINUE`,i-1,n,r):i+=t(`BAD_PREFIX`,i-1,n,r);continue}if(i-1+a>=n.length){i+=t(`OVERRUN`,i-1,n,r);continue}let s=e&(1<<8-a-1)-1;for(let e=0;e<a;e++){let e=n[i];if((e&192)!=128){i+=t(`MISSING_CONTINUE`,i,n,r),s=null;break}s=s<<6|e&63,i++}if(s!==null){if(s>1114111){i+=t(`OUT_OF_RANGE`,i-1-a,n,r,s);continue}if(s>=55296&&s<=57343){i+=t(`UTF16_SURROGATE`,i-1-a,n,r,s);continue}if(s<=o){i+=t(`OVERLONG`,i-1-a,n,r,s);continue}r.push(s)}}return r}function sa(e,t){V(typeof e==`string`,`invalid string value`,`str`,e),t!=null&&(Si(t),e=e.normalize(t));let n=[];for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r<128)n.push(r);else if(r<2048)n.push(r>>6|192),n.push(r&63|128);else if((r&64512)==55296){t++;let i=e.charCodeAt(t);V(t<e.length&&(i&64512)==56320,`invalid surrogate pair`,`str`,e);let a=65536+((r&1023)<<10)+(i&1023);n.push(a>>18|240),n.push(a>>12&63|128),n.push(a>>6&63|128),n.push(a&63|128)}else n.push(r>>12|224),n.push(r>>6&63|128),n.push(r&63|128)}return new Uint8Array(n)}function ca(e){return e.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join(``)}function la(e,t){return ca(oa(e,t))}function ua(e){let t=e.toString(16);for(;t.length<2;)t=`0`+t;return`0x`+t}function da(e,t,n){let r=0;for(let i=0;i<n;i++)r=r*256+e[t+i];return r}function fa(e,t,n,r){let i=[];for(;n<t+1+r;){let a=pa(e,n);i.push(a.result),n+=a.consumed,B(n<=t+1+r,`child data too short`,`BUFFER_OVERRUN`,{buffer:e,length:r,offset:t})}return{consumed:1+r,result:i}}function pa(e,t){B(e.length!==0,`data too short`,`BUFFER_OVERRUN`,{buffer:e,length:0,offset:1});let n=t=>{B(t<=e.length,`data short segment too short`,`BUFFER_OVERRUN`,{buffer:e,length:e.length,offset:t})};if(e[t]>=248){let r=e[t]-247;n(t+1+r);let i=da(e,t+1,r);return n(t+1+r+i),fa(e,t,t+1+r,r+i)}if(e[t]>=192){let r=e[t]-192;return n(t+1+r),fa(e,t,t+1,r)}if(e[t]>=184){let r=e[t]-183;n(t+1+r);let i=da(e,t+1,r);n(t+1+r+i);let a=U(e.slice(t+1+r,t+1+r+i));return{consumed:1+r+i,result:a}}if(e[t]>=128){let r=e[t]-128;n(t+1+r);let i=U(e.slice(t+1,t+1+r));return{consumed:1+r,result:i}}return{consumed:1,result:ua(e[t])}}function ma(e){let t=H(e,`data`),n=pa(t,0);return V(n.consumed===t.length,`unexpected junk after rlp payload`,`data`,e),n.result}function ha(e){let t=[];for(;e;)t.unshift(e&255),e>>=8;return t}function ga(e){if(Array.isArray(e)){let t=[];if(e.forEach(function(e){t=t.concat(ga(e))}),t.length<=55)return t.unshift(192+t.length),t;let n=ha(t.length);return n.unshift(247+n.length),n.concat(t)}let t=Array.prototype.slice.call(H(e,`object`));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;let n=ha(t.length);return n.unshift(183+n.length),n.concat(t)}var _a=`0123456789abcdef`;function va(e){let t=`0x`;for(let n of ga(e))t+=_a[n>>4],t+=_a[n&15];return t}function ya(e){let t=H(e,`randomBytes`);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=U(t);return[n.substring(2,10),n.substring(10,14),n.substring(14,18),n.substring(18,22),n.substring(22,34)].join(`-`)}var ba=new Uint8Array(32),xa=[`then`],Sa={},Ca=new WeakMap;function wa(e){return Ca.get(e)}function Ta(e,t){Ca.set(e,t)}function Ea(e,t){let n=Error(`deferred error during ABI decoding triggered accessing ${e}`);throw n.error=t,n}function Da(e,t,n){return e.indexOf(null)>=0?t.map((e,t)=>e instanceof Oa?Da(wa(e),e,n):e):e.reduce((e,r,i)=>{let a=t.getValue(r);return r in e||(n&&a instanceof Oa&&(a=Da(wa(a),a,n)),e[r]=a),e},{})}var Oa=class e extends Array{#e;constructor(...e){let t=e[0],n=e[1],r=(e[2]||[]).slice(),i=!0;t!==Sa&&(n=e,r=[],i=!1),super(n.length),n.forEach((e,t)=>{this[t]=e});let a=r.reduce((e,t)=>(typeof t==`string`&&e.set(t,(e.get(t)||0)+1),e),new Map);if(Ta(this,Object.freeze(n.map((e,t)=>{let n=r[t];return n!=null&&a.get(n)===1?n:null}))),this.#e=[],this.#e??this.#e,!i)return;Object.freeze(this);let o=new Proxy(this,{get:(e,t,n)=>{if(typeof t==`string`){if(t.match(/^[0-9]+$/)){let n=Wi(t,`%index`);if(n<0||n>=this.length)throw RangeError(`out of result range`);let r=e[n];return r instanceof Error&&Ea(`index ${n}`,r),r}if(xa.indexOf(t)>=0)return Reflect.get(e,t,n);let r=e[t];if(r instanceof Function)return function(...t){return r.apply(this===n?e:this,t)};if(!(t in e))return e.getValue.apply(this===n?e:this,[t])}return Reflect.get(e,t,n)}});return Ta(o,wa(this)),o}toArray(t){let n=[];return this.forEach((r,i)=>{r instanceof Error&&Ea(`index ${i}`,r),t&&r instanceof e&&(r=r.toArray(t)),n.push(r)}),n}toObject(e){let t=wa(this);return t.reduce((n,r,i)=>(B(r!=null,`value at index ${i} unnamed`,`UNSUPPORTED_OPERATION`,{operation:`toObject()`}),Da(t,this,e)),{})}slice(t,n){t??=0,t<0&&(t+=this.length,t<0&&(t=0)),n??=this.length,n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);let r=wa(this),i=[],a=[];for(let e=t;e<n;e++)i.push(this[e]),a.push(r[e]);return new e(Sa,i,a)}filter(t,n){let r=wa(this),i=[],a=[];for(let e=0;e<this.length;e++){let o=this[e];o instanceof Error&&Ea(`index ${e}`,o),t.call(n,o,e,this)&&(i.push(o),a.push(r[e]))}return new e(Sa,i,a)}map(e,t){let n=[];for(let r=0;r<this.length;r++){let i=this[r];i instanceof Error&&Ea(`index ${r}`,i),n.push(e.call(t,i,r,this))}return n}getValue(e){let t=wa(this).indexOf(e);if(t===-1)return;let n=this[t];return n instanceof Error&&Ea(`property ${JSON.stringify(e)}`,n.error),n}static fromItems(t,n){return new e(Sa,t,n)}};function ka(e){let t=qi(e);return B(t.length<=32,`value out-of-bounds`,`BUFFER_OVERRUN`,{buffer:t,length:32,offset:t.length}),t.length!==32&&(t=Ti(ki([ba.slice(t.length%32),t]))),t}var Aa=class{name;type;localName;dynamic;constructor(e,t,n,r){z(this,{name:e,type:t,localName:n,dynamic:r},{name:`string`,type:`string`,localName:`string`,dynamic:`boolean`})}_throwError(e,t){V(!1,e,this.localName,t)}},ja=class{#e;#t;constructor(){this.#e=[],this.#t=0}get data(){return ki(this.#e)}get length(){return this.#t}#n(e){return this.#e.push(e),this.#t+=e.length,e.length}appendWriter(e){return this.#n(Ti(e.data))}writeBytes(e){let t=Ti(e),n=t.length%32;return n&&(t=Ti(ki([t,ba.slice(n)]))),this.#n(t)}writeValue(e){return this.#n(ka(e))}writeUpdatableValue(){let e=this.#e.length;return this.#e.push(ba),this.#t+=32,t=>{this.#e[e]=ka(t)}}},Ma=class e{allowLoose;#e;#t;#n;#r;#i;constructor(e,t,n){z(this,{allowLoose:!!t}),this.#e=Ti(e),this.#n=0,this.#r=null,this.#i=n??1024,this.#t=0}get data(){return U(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#t}get bytes(){return new Uint8Array(this.#e)}#a(e){if(this.#r)return this.#r.#a(e);this.#n+=e,B(this.#i<1||this.#n<=this.#i*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#i} ( see: https:/\/github.com/ethers-io/ethers.js/issues/4537 )`,`BUFFER_OVERRUN`,{buffer:Ti(this.#e),offset:this.#t,length:e,info:{bytesRead:this.#n,dataLength:this.dataLength}})}#o(e,t,n){let r=Math.ceil(t/32)*32;return this.#t+r>this.#e.length&&(this.allowLoose&&n&&this.#t+t<=this.#e.length?r=t:B(!1,`data out-of-bounds`,`BUFFER_OVERRUN`,{buffer:Ti(this.#e),length:this.#e.length,offset:this.#t+r})),this.#e.slice(this.#t,this.#t+r)}subReader(t){let n=new e(this.#e.slice(this.#t+t),this.allowLoose,this.#i);return n.#r=this,n}readBytes(e,t){let n=this.#o(0,e,!!t);return this.#a(e),this.#t+=n.length,n.slice(0,e)}readValue(){return Ui(this.readBytes(32))}readIndex(){return Gi(this.readBytes(32))}};function Na(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`Wrong positive integer: ${e}`)}function Pa(e,...t){if(!(e instanceof Uint8Array))throw Error(`Expected Uint8Array`);if(t.length>0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Fa(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.wrapConstructor`);Na(e.outputLen),Na(e.blockLen)}function Ia(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function La(e,t){Pa(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least ${n}`)}var Ra=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0,za=e=>e instanceof Uint8Array,Ba=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Va=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Ha=(e,t)=>e<<32-t|e>>>t;if(new Uint8Array(new Uint32Array([287454020]).buffer)[0]!==68)throw Error(`Non little-endian hardware is not supported`);var Ua=async()=>{};async function Wa(e,t,n){let r=Date.now();for(let i=0;i<e;i++){n(i);let e=Date.now()-r;e>=0&&e<t||(await Ua(),r+=e)}}function Ga(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Ka(e){if(typeof e==`string`&&(e=Ga(e)),!za(e))throw Error(`expected Uint8Array, got ${typeof e}`);return e}function qa(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!za(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}var Ja=class{clone(){return this._cloneInto()}},Ya={}.toString;function Xa(e,t){if(t!==void 0&&Ya.call(t)!==`[object Object]`)throw Error(`Options should be object or undefined`);return Object.assign(e,t)}function Za(e){let t=t=>e().update(Ka(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Qa(e=32){if(Ra&&typeof Ra.getRandomValues==`function`)return Ra.getRandomValues(new Uint8Array(e));throw Error(`crypto.getRandomValues must be defined`)}var $a=class extends Ja{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Fa(e);let n=Ka(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return Ia(this),this.iHash.update(e),this}digestInto(e){Ia(this),Pa(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},eo=(e,t,n)=>new $a(e,t).update(n).digest();eo.create=(e,t)=>new $a(e,t);function to(e,t,n,r){Fa(e);let{c:i,dkLen:a,asyncTick:o}=Xa({dkLen:32,asyncTick:10},r);if(Na(i),Na(a),Na(o),i<1)throw Error(`PBKDF2: iterations (c) should be >= 1`);let s=Ka(t),c=Ka(n),l=new Uint8Array(a),u=eo.create(e,s);return{c:i,dkLen:a,asyncTick:o,DK:l,PRF:u,PRFSalt:u._cloneInto().update(c)}}function no(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),i.fill(0),n}function ro(e,t,n,r){let{c:i,dkLen:a,DK:o,PRF:s,PRFSalt:c}=to(e,t,n,r),l,u=new Uint8Array(4),d=Va(u),f=new Uint8Array(s.outputLen);for(let e=1,t=0;t<a;e++,t+=s.outputLen){let n=o.subarray(t,t+s.outputLen);d.setInt32(0,e,!1),(l=c._cloneInto(l)).update(u).digestInto(f),n.set(f.subarray(0,n.length));for(let e=1;e<i;e++){s._cloneInto(l).update(f).digestInto(f);for(let e=0;e<n.length;e++)n[e]^=f[e]}}return no(s,c,o,l,f)}function io(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}var ao=class extends Ja{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Va(this.buffer)}update(e){Ia(this);let{view:t,buffer:n,blockLen:r}=this;e=Ka(e);let i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Va(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ia(this),La(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;io(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=Va(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=a,r%t&&e.buffer.set(n),e}},oo=(e,t,n)=>e&t^~e&n,so=(e,t,n)=>e&t^e&n^t&n,co=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]),lo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),uo=new Uint32Array(64),fo=class extends ao{constructor(){super(64,32,8,!1),this.A=lo[0]|0,this.B=lo[1]|0,this.C=lo[2]|0,this.D=lo[3]|0,this.E=lo[4]|0,this.F=lo[5]|0,this.G=lo[6]|0,this.H=lo[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)uo[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=uo[e-15],n=uo[e-2],r=Ha(t,7)^Ha(t,18)^t>>>3,i=Ha(n,17)^Ha(n,19)^n>>>10;uo[e]=i+uo[e-7]+r+uo[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Ha(o,6)^Ha(o,11)^Ha(o,25),u=l+t+oo(o,s,c)+co[e]+uo[e]|0,d=(Ha(n,2)^Ha(n,13)^Ha(n,22))+so(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){uo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},po=Za(()=>new fo),mo=BigInt(2**32-1),ho=BigInt(32);function go(e,t=!1){return t?{h:Number(e&mo),l:Number(e>>ho&mo)}:{h:Number(e>>ho&mo)|0,l:Number(e&mo)|0}}function _o(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:a,l:o}=go(e[i],t);[n[i],r[i]]=[a,o]}return[n,r]}var vo=(e,t)=>BigInt(e>>>0)<<ho|BigInt(t>>>0),yo=(e,t,n)=>e>>>n,bo=(e,t,n)=>e<<32-n|t>>>n,xo=(e,t,n)=>e>>>n|t<<32-n,So=(e,t,n)=>e<<32-n|t>>>n,Co=(e,t,n)=>e<<64-n|t>>>n-32,wo=(e,t,n)=>e>>>n-32|t<<64-n,To=(e,t)=>t,Eo=(e,t)=>e,Do=(e,t,n)=>e<<n|t>>>32-n,Oo=(e,t,n)=>t<<n|e>>>32-n,ko=(e,t,n)=>t<<n-32|e>>>64-n,Ao=(e,t,n)=>e<<n-32|t>>>64-n;function jo(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var W={fromBig:go,split:_o,toBig:vo,shrSH:yo,shrSL:bo,rotrSH:xo,rotrSL:So,rotrBH:Co,rotrBL:wo,rotr32H:To,rotr32L:Eo,rotlSH:Do,rotlSL:Oo,rotlBH:ko,rotlBL:Ao,add:jo,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,add5H:(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,add5L:(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0)},[Mo,No]=W.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`.split(`.`).map(e=>BigInt(e))),Po=new Uint32Array(80),Fo=new Uint32Array(80),Io=class extends ao{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(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Po[n]=e.getUint32(t),Fo[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Po[e-15]|0,n=Fo[e-15]|0,r=W.rotrSH(t,n,1)^W.rotrSH(t,n,8)^W.shrSH(t,n,7),i=W.rotrSL(t,n,1)^W.rotrSL(t,n,8)^W.shrSL(t,n,7),a=Po[e-2]|0,o=Fo[e-2]|0,s=W.rotrSH(a,o,19)^W.rotrBH(a,o,61)^W.shrSH(a,o,6),c=W.rotrSL(a,o,19)^W.rotrBL(a,o,61)^W.shrSL(a,o,6),l=W.add4L(i,c,Fo[e-7],Fo[e-16]),u=W.add4H(l,r,s,Po[e-7],Po[e-16]);Po[e]=u|0,Fo[e]=l|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=W.rotrSH(u,d,14)^W.rotrSH(u,d,18)^W.rotrBH(u,d,41),v=W.rotrSL(u,d,14)^W.rotrSL(u,d,18)^W.rotrBL(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=W.add5L(_,v,b,No[e],Fo[e]),S=W.add5H(x,g,t,y,Mo[e],Po[e]),C=x|0,ee=W.rotrSH(n,r,28)^W.rotrBH(n,r,34)^W.rotrBH(n,r,39),te=W.rotrSL(n,r,28)^W.rotrBL(n,r,34)^W.rotrBL(n,r,39),ne=n&i^n&o^i&o,re=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=W.add(c|0,l|0,S|0,C|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let w=W.add3L(C,te,re);n=W.add3H(w,S,ee,ne),r=w|0}({h:n,l:r}=W.add(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=W.add(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=W.add(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=W.add(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=W.add(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=W.add(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=W.add(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=W.add(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){Po.fill(0),Fo.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)}},Lo=Za(()=>new Io);te();function Ro(){if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(ne!==void 0)return ne;throw Error(`unable to locate global object`)}var zo=Ro(),Bo=zo.crypto||zo.msCrypto;function Vo(e){switch(e){case`sha256`:return po.create();case`sha512`:return Lo.create()}V(!1,`invalid hashing algorithm name`,`algorithm`,e)}function Ho(e,t){let n={sha256:po,sha512:Lo}[e];return V(n!=null,`invalid hmac algorithm`,`algorithm`,e),eo.create(n,t)}function Uo(e,t,n,r,i){let a={sha256:po,sha512:Lo}[i];return V(a!=null,`invalid pbkdf2 algorithm`,`algorithm`,i),ro(a,e,t,{c:n,dkLen:r})}function Wo(e){B(Bo!=null,`platform does not support secure random numbers`,`UNSUPPORTED_OPERATION`,{operation:`randomBytes`}),V(Number.isInteger(e)&&e>0&&e<=1024,`invalid length`,`length`,e);let t=new Uint8Array(e);return Bo.getRandomValues(t),t}var Go=!1,Ko=function(e,t,n){return Ho(e,t).update(n).digest()},qo=Ko;function Jo(e,t,n){let r=H(t,`key`),i=H(n,`data`);return U(qo(e,r,i))}Jo._=Ko,Jo.lock=function(){Go=!0},Jo.register=function(e){if(Go)throw Error(`computeHmac is locked`);qo=e},Object.freeze(Jo);var[Yo,Xo,Zo]=[[],[],[]],Qo=BigInt(0),$o=BigInt(1),es=BigInt(2),ts=BigInt(7),ns=BigInt(256),rs=BigInt(113);for(let e=0,t=$o,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Yo.push(2*(5*r+n)),Xo.push((e+1)*(e+2)/2%64);let i=Qo;for(let e=0;e<7;e++)t=(t<<$o^(t>>ts)*rs)%ns,t&es&&(i^=$o<<($o<<BigInt(e))-$o);Zo.push(i)}var[is,as]=_o(Zo,!0),os=(e,t,n)=>n>32?ko(e,t,n):Do(e,t,n),ss=(e,t,n)=>n>32?Ao(e,t,n):Oo(e,t,n);function cs(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=os(a,o,1)^n[r],c=ss(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=Xo[n],a=os(t,i,r),o=ss(t,i,r),s=Yo[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=is[r],e[1]^=as[r]}n.fill(0)}var ls=class e extends Ja{constructor(e,t,n,r=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Na(n),0>=this.blockLen||this.blockLen>=200)throw Error(`Sha3 supports only keccak-f1600 function`);this.state=new Uint8Array(200),this.state32=Ba(this.state)}keccak(){cs(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Ia(this);let{blockLen:t,state:n}=this;e=Ka(e);let r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Ia(this,!1),Pa(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return Na(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(La(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},us=((e,t,n)=>Za(()=>new ls(t,e,n)))(1,136,32),ds=!1,fs=function(e){return us(e)},ps=fs;function G(e){let t=H(e,`data`);return U(ps(t))}G._=fs,G.lock=function(){ds=!0},G.register=function(e){if(ds)throw TypeError(`keccak256 is locked`);ps=e},Object.freeze(G);var ms=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),hs=Uint8Array.from({length:16},(e,t)=>t),gs=hs.map(e=>(9*e+5)%16),_s=[hs],vs=[gs];for(let e=0;e<4;e++)for(let t of[_s,vs])t.push(t[e].map(e=>ms[e]));var ys=[[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(e=>new Uint8Array(e)),bs=_s.map((e,t)=>e.map(e=>ys[t][e])),xs=vs.map((e,t)=>e.map(e=>ys[t][e])),Ss=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Cs=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),ws=(e,t)=>e<<t|e>>>32-t;function Ts(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}var Es=new Uint32Array(16),Ds=class extends ao{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){let{h0:e,h1:t,h2:n,h3:r,h4:i}=this;return[e,t,n,r,i]}set(e,t,n,r,i){this.h0=e|0,this.h1=t|0,this.h2=n|0,this.h3=r|0,this.h4=i|0}process(e,t){for(let n=0;n<16;n++,t+=4)Es[n]=e.getUint32(t,!0);let n=this.h0|0,r=n,i=this.h1|0,a=i,o=this.h2|0,s=o,c=this.h3|0,l=c,u=this.h4|0,d=u;for(let e=0;e<5;e++){let t=4-e,f=Ss[e],p=Cs[e],m=_s[e],h=vs[e],g=bs[e],_=xs[e];for(let t=0;t<16;t++){let r=ws(n+Ts(e,i,o,c)+Es[m[t]]+f,g[t])+u|0;n=u,u=c,c=ws(o,10)|0,o=i,i=r}for(let e=0;e<16;e++){let n=ws(r+Ts(t,a,s,l)+Es[h[e]]+p,_[e])+d|0;r=d,d=l,l=ws(s,10)|0,s=a,a=n}}this.set(this.h1+o+l|0,this.h2+c+d|0,this.h3+u+r|0,this.h4+n+a|0,this.h0+i+s|0)}roundClean(){Es.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}},Os=Za(()=>new Ds),ks=!1,As=function(e){return Os(e)},js=As;function Ms(e){let t=H(e,`data`);return U(js(t))}Ms._=As,Ms.lock=function(){ks=!0},Ms.register=function(e){if(ks)throw TypeError(`ripemd160 is locked`);js=e},Object.freeze(Ms);var Ns=!1,Ps=function(e,t,n,r,i){return Uo(e,t,n,r,i)},Fs=Ps;function Is(e,t,n,r,i){let a=H(e,`password`),o=H(t,`salt`);return U(Fs(a,o,n,r,i))}Is._=Ps,Is.lock=function(){Ns=!0},Is.register=function(e){if(Ns)throw Error(`pbkdf2 is locked`);Fs=e},Object.freeze(Is);var Ls=!1,Rs=function(e){return new Uint8Array(Wo(e))},zs=Rs;function Bs(e){return zs(e)}Bs._=Rs,Bs.lock=function(){Ls=!0},Bs.register=function(e){if(Ls)throw Error(`randomBytes is locked`);zs=e},Object.freeze(Bs);var Vs=(e,t)=>e<<t|e>>>32-t;function Hs(e,t,n,r,i,a){let o=e[t++]^n[r++],s=e[t++]^n[r++],c=e[t++]^n[r++],l=e[t++]^n[r++],u=e[t++]^n[r++],d=e[t++]^n[r++],f=e[t++]^n[r++],p=e[t++]^n[r++],m=e[t++]^n[r++],h=e[t++]^n[r++],g=e[t++]^n[r++],_=e[t++]^n[r++],v=e[t++]^n[r++],y=e[t++]^n[r++],b=e[t++]^n[r++],x=e[t++]^n[r++],S=o,C=s,ee=c,te=l,ne=u,re=d,w=f,T=p,ie=m,E=h,ae=g,oe=_,se=v,ce=y,le=b,ue=x;for(let e=0;e<8;e+=2)ne^=Vs(S+se|0,7),ie^=Vs(ne+S|0,9),se^=Vs(ie+ne|0,13),S^=Vs(se+ie|0,18),E^=Vs(re+C|0,7),ce^=Vs(E+re|0,9),C^=Vs(ce+E|0,13),re^=Vs(C+ce|0,18),le^=Vs(ae+w|0,7),ee^=Vs(le+ae|0,9),w^=Vs(ee+le|0,13),ae^=Vs(w+ee|0,18),te^=Vs(ue+oe|0,7),T^=Vs(te+ue|0,9),oe^=Vs(T+te|0,13),ue^=Vs(oe+T|0,18),C^=Vs(S+te|0,7),ee^=Vs(C+S|0,9),te^=Vs(ee+C|0,13),S^=Vs(te+ee|0,18),w^=Vs(re+ne|0,7),T^=Vs(w+re|0,9),ne^=Vs(T+w|0,13),re^=Vs(ne+T|0,18),oe^=Vs(ae+E|0,7),ie^=Vs(oe+ae|0,9),E^=Vs(ie+oe|0,13),ae^=Vs(E+ie|0,18),se^=Vs(ue+le|0,7),ce^=Vs(se+ue|0,9),le^=Vs(ce+se|0,13),ue^=Vs(le+ce|0,18);i[a++]=o+S|0,i[a++]=s+C|0,i[a++]=c+ee|0,i[a++]=l+te|0,i[a++]=u+ne|0,i[a++]=d+re|0,i[a++]=f+w|0,i[a++]=p+T|0,i[a++]=m+ie|0,i[a++]=h+E|0,i[a++]=g+ae|0,i[a++]=_+oe|0,i[a++]=v+se|0,i[a++]=y+ce|0,i[a++]=b+le|0,i[a++]=x+ue|0}function Us(e,t,n,r,i){let a=r+0,o=r+16*i;for(let r=0;r<16;r++)n[o+r]=e[t+(2*i-1)*16+r];for(let r=0;r<i;r++,a+=16,t+=16)Hs(n,o,e,t,n,a),r>0&&(o+=16),Hs(n,a,e,t+=16,n,o)}function Ws(e,t,n){let{N:r,r:i,p:a,dkLen:o,asyncTick:s,maxmem:c,onProgress:l}=Xa({dkLen:32,asyncTick:10,maxmem:1024**3+1024},n);if(Na(r),Na(i),Na(a),Na(o),Na(s),Na(c),l!==void 0&&typeof l!=`function`)throw Error(`progressCb should be function`);let u=128*i,d=u/4;if(r<=1||r&r-1||r>=2**(u/8)||r>2**32)throw Error(`Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32`);if(a<0||a>(2**32-1)*32/u)throw Error(`Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)`);if(o<0||o>(2**32-1)*32)throw Error(`Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32`);let f=u*(r+a);if(f>c)throw Error(`Scrypt: parameters too large, ${f} (128 * r * (N + p)) > ${c} (maxmem)`);let p=ro(po,e,t,{c:1,dkLen:u*a}),m=Ba(p),h=Ba(new Uint8Array(u*r)),g=Ba(new Uint8Array(u)),_=()=>{};if(l){let e=2*r*a,t=Math.max(Math.floor(e/1e4),1),n=0;_=()=>{n++,l&&(!(n%t)||n===e)&&l(n/e)}}return{N:r,r:i,p:a,dkLen:o,blockSize32:d,V:h,B32:m,B:p,tmp:g,blockMixCb:_,asyncTick:s}}function Gs(e,t,n,r,i){let a=ro(po,e,n,{c:1,dkLen:t});return n.fill(0),r.fill(0),i.fill(0),a}function Ks(e,t,n){let{N:r,r:i,p:a,dkLen:o,blockSize32:s,V:c,B32:l,B:u,tmp:d,blockMixCb:f}=Ws(e,t,n);for(let e=0;e<a;e++){let t=s*e;for(let e=0;e<s;e++)c[e]=l[t+e];for(let e=0,t=0;e<r-1;e++)Us(c,t,c,t+=s,i),f();Us(c,(r-1)*s,l,t,i),f();for(let e=0;e<r;e++){let e=l[t+s-16]%r;for(let n=0;n<s;n++)d[n]=l[t+n]^c[e*s+n];Us(d,0,l,t,i),f()}}return Gs(e,o,u,c,d)}async function qs(e,t,n){let{N:r,r:i,p:a,dkLen:o,blockSize32:s,V:c,B32:l,B:u,tmp:d,blockMixCb:f,asyncTick:p}=Ws(e,t,n);for(let e=0;e<a;e++){let t=s*e;for(let e=0;e<s;e++)c[e]=l[t+e];let n=0;await Wa(r-1,p,()=>{Us(c,n,c,n+=s,i),f()}),Us(c,(r-1)*s,l,t,i),f(),await Wa(r,p,()=>{let e=l[t+s-16]%r;for(let n=0;n<s;n++)d[n]=l[t+n]^c[e*s+n];Us(d,0,l,t,i),f()})}return Gs(e,o,u,c,d)}var Js=!1,Ys=!1,Xs=async function(e,t,n,r,i,a,o){return await qs(e,t,{N:n,r,p:i,dkLen:a,onProgress:o})},Zs=function(e,t,n,r,i,a){return Ks(e,t,{N:n,r,p:i,dkLen:a})},Qs=Xs,$s=Zs;async function ec(e,t,n,r,i,a,o){let s=H(e,`passwd`),c=H(t,`salt`);return U(await Qs(s,c,n,r,i,a,o))}ec._=Xs,ec.lock=function(){Ys=!0},ec.register=function(e){if(Ys)throw Error(`scrypt is locked`);Qs=e},Object.freeze(ec);function tc(e,t,n,r,i,a){let o=H(e,`passwd`),s=H(t,`salt`);return U($s(o,s,n,r,i,a))}tc._=Zs,tc.lock=function(){Js=!0},tc.register=function(e){if(Js)throw Error(`scryptSync is locked`);$s=e},Object.freeze(tc);var nc=function(e){return Vo(`sha256`).update(e).digest()},rc=function(e){return Vo(`sha512`).update(e).digest()},ic=nc,ac=rc,oc=!1,sc=!1;function cc(e){let t=H(e,`data`);return U(ic(t))}cc._=nc,cc.lock=function(){oc=!0},cc.register=function(e){if(oc)throw Error(`sha256 is locked`);ic=e},Object.freeze(cc);function lc(e){let t=H(e,`data`);return U(ac(t))}lc._=rc,lc.lock=function(){sc=!0},lc.register=function(e){if(sc)throw Error(`sha512 is locked`);ac=e},Object.freeze(cc);var uc=e({bitGet:()=>Ac,bitLen:()=>kc,bitMask:()=>Mc,bitSet:()=>jc,bytesToHex:()=>gc,bytesToNumberBE:()=>bc,bytesToNumberLE:()=>xc,concatBytes:()=>Ec,createHmacDrbg:()=>Fc,ensureBytes:()=>Tc,equalBytes:()=>Dc,hexToBytes:()=>yc,hexToNumber:()=>vc,numberToBytesBE:()=>Sc,numberToBytesLE:()=>Cc,numberToHexUnpadded:()=>_c,numberToVarBytesBE:()=>wc,utf8ToBytes:()=>Oc,validateObject:()=>Lc}),dc=BigInt(0),fc=BigInt(1),pc=BigInt(2),mc=e=>e instanceof Uint8Array,hc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function gc(e){if(!mc(e))throw Error(`Uint8Array expected`);let t=``;for(let n=0;n<e.length;n++)t+=hc[e[n]];return t}function _c(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function vc(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return BigInt(e===``?`0`:`0x${e}`)}function yc(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=e.length;if(t%2)throw Error(`padded hex string expected, got unpadded hex of length `+t);let n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){let r=t*2,i=e.slice(r,r+2),a=Number.parseInt(i,16);if(Number.isNaN(a)||a<0)throw Error(`Invalid byte sequence`);n[t]=a}return n}function bc(e){return vc(gc(e))}function xc(e){if(!mc(e))throw Error(`Uint8Array expected`);return vc(gc(Uint8Array.from(e).reverse()))}function Sc(e,t){return yc(e.toString(16).padStart(t*2,`0`))}function Cc(e,t){return Sc(e,t).reverse()}function wc(e){return yc(_c(e))}function Tc(e,t,n){let r;if(typeof t==`string`)try{r=yc(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else if(mc(t))r=Uint8Array.from(t);else throw Error(`${e} must be hex string or Uint8Array`);let i=r.length;if(typeof n==`number`&&i!==n)throw Error(`${e} expected ${n} bytes, got ${i}`);return r}function Ec(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!mc(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}function Dc(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Oc(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function kc(e){let t=0;for(;e>dc;e>>=fc,t+=1);return t}function Ac(e,t){return e>>BigInt(t)&fc}var jc=(e,t,n)=>e|(n?fc:dc)<<BigInt(t),Mc=e=>(pc<<BigInt(e-1))-fc,Nc=e=>new Uint8Array(e),Pc=e=>Uint8Array.from(e);function Fc(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=Nc(e),i=Nc(e),a=0,o=()=>{r.fill(1),i.fill(0),a=0},s=(...e)=>n(i,r,...e),c=(e=Nc())=>{i=s(Pc([0]),e),r=s(),e.length!==0&&(i=s(Pc([1]),e),r=s())},l=()=>{if(a++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){r=s();let t=r.slice();n.push(t),e+=r.length}return Ec(...n)};return(e,t)=>{o(),c(e);let n;for(;!(n=t(l()));)c();return o(),n}}var Ic={bigint:e=>typeof e==`bigint`,function:e=>typeof e==`function`,boolean:e=>typeof e==`boolean`,string:e=>typeof e==`string`,stringOrUint8Array:e=>typeof e==`string`||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==`function`&&Number.isSafeInteger(e.outputLen)};function Lc(e,t,n={}){let r=(t,n,r)=>{let i=Ic[n];if(typeof i!=`function`)throw Error(`Invalid validator "${n}", expected function`);let a=e[t];if(!(r&&a===void 0)&&!i(a,e))throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`)};for(let[e,n]of Object.entries(t))r(e,n,!1);for(let[e,t]of Object.entries(n))r(e,t,!0);return e}var Rc=BigInt(0),zc=BigInt(1),Bc=BigInt(2),Vc=BigInt(3),Hc=BigInt(4),Uc=BigInt(5),Wc=BigInt(8),Gc=BigInt(16);function Kc(e,t){let n=e%t;return n>=Rc?n:t+n}function qc(e,t,n){if(n<=Rc||t<Rc)throw Error(`Expected power/modulo > 0`);if(n===zc)return Rc;let r=zc;for(;t>Rc;)t&zc&&(r=r*e%n),e=e*e%n,t>>=zc;return r}function Jc(e,t,n){let r=e;for(;t-->Rc;)r*=r,r%=n;return r}function Yc(e,t){if(e===Rc||t<=Rc)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Kc(e,t),r=t,i=Rc,a=zc,o=zc,s=Rc;for(;n!==Rc;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==zc)throw Error(`invert: does not exist`);return Kc(i,t)}function Xc(e){let t=(e-zc)/Bc,n,r,i;for(n=e-zc,r=0;n%Bc===Rc;n/=Bc,r++);for(i=Bc;i<e&&qc(i,t,e)!==e-zc;i++);if(r===1){let t=(e+zc)/Hc;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}let a=(n+zc)/Bc;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw Error(`Cannot find square root`);let s=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(o,a),u=e.pow(o,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<s&&!e.eql(n,e.ONE);t++)n=e.sqr(n);let n=e.pow(c,zc<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),u=e.mul(u,c),s=t}return l}}function Zc(e){if(e%Hc===Vc){let t=(e+zc)/Hc;return function(e,n){let r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error(`Cannot find square root`);return r}}if(e%Wc===Uc){let t=(e-Uc)/Wc;return function(e,n){let r=e.mul(n,Bc),i=e.pow(r,t),a=e.mul(n,i),o=e.mul(e.mul(a,Bc),i),s=e.mul(a,e.sub(o,e.ONE));if(!e.eql(e.sqr(s),n))throw Error(`Cannot find square root`);return s}}return e%Gc,Xc(e)}var Qc=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function $c(e){return Lc(e,Qc.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,MASK:`bigint`,BYTES:`isSafeInteger`,BITS:`isSafeInteger`}))}function el(e,t,n){if(n<Rc)throw Error(`Expected power > 0`);if(n===Rc)return e.ONE;if(n===zc)return t;let r=e.ONE,i=t;for(;n>Rc;)n&zc&&(r=e.mul(r,i)),i=e.sqr(i),n>>=zc;return r}function tl(e,t){let n=Array(t.length),r=t.reduce((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r)),e.ONE),i=e.inv(r);return t.reduceRight((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r)),i),n}function nl(e,t){let n=t===void 0?e.toString(2).length:t;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function rl(e,t,n=!1,r={}){if(e<=Rc)throw Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:a}=nl(e,t);if(a>2048)throw Error(`Field lengths over 2048 bytes are not supported`);let o=Zc(e),s=Object.freeze({ORDER:e,BITS:i,BYTES:a,MASK:Mc(i),ZERO:Rc,ONE:zc,create:t=>Kc(t,e),isValid:t=>{if(typeof t!=`bigint`)throw Error(`Invalid field element: expected bigint, got ${typeof t}`);return Rc<=t&&t<e},is0:e=>e===Rc,isOdd:e=>(e&zc)===zc,neg:t=>Kc(-t,e),eql:(e,t)=>e===t,sqr:t=>Kc(t*t,e),add:(t,n)=>Kc(t+n,e),sub:(t,n)=>Kc(t-n,e),mul:(t,n)=>Kc(t*n,e),pow:(e,t)=>el(s,e,t),div:(t,n)=>Kc(t*Yc(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Yc(t,e),sqrt:r.sqrt||(e=>o(s,e)),invertBatch:e=>tl(s,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Cc(e,a):Sc(e,a),fromBytes:e=>{if(e.length!==a)throw Error(`Fp.fromBytes: expected ${a}, got ${e.length}`);return n?xc(e):bc(e)}});return Object.freeze(s)}function il(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);let t=e.toString(2).length;return Math.ceil(t/8)}function al(e){let t=il(e);return t+Math.ceil(t/2)}function ol(e,t,n=!1){let r=e.length,i=il(t),a=al(t);if(r<16||r<a||r>1024)throw Error(`expected ${a}-1024 bytes of input, got ${r}`);let o=Kc(n?bc(e):xc(e),t-zc)+zc;return n?Cc(o,i):Sc(o,i)}var sl=BigInt(0),cl=BigInt(1);function ll(e,t){let n=(e,t)=>{let n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>sl;)n&cl&&(r=r.add(i)),i=i.double(),n>>=cl;return r},precomputeWindow(e,t){let{windows:n,windowSize:i}=r(t),a=[],o=e,s=o;for(let e=0;e<n;e++){s=o,a.push(s);for(let e=1;e<i;e++)s=s.add(o),a.push(s);o=s.double()}return a},wNAF(t,i,a){let{windows:o,windowSize:s}=r(t),c=e.ZERO,l=e.BASE,u=BigInt(2**t-1),d=2**t,f=BigInt(t);for(let e=0;e<o;e++){let t=e*s,r=Number(a&u);a>>=f,r>s&&(r-=d,a+=cl);let o=t,p=t+Math.abs(r)-1,m=e%2!=0,h=r<0;r===0?l=l.add(n(m,i[o])):c=c.add(n(h,i[p]))}return{p:c,f:l}},wNAFCached(e,t,n,r){let i=e._WINDOW_SIZE||1,a=t.get(e);return a||(a=this.precomputeWindow(e,i),i!==1&&t.set(e,r(a))),this.wNAF(i,a,n)}}}function ul(e){return $c(e.Fp),Lc(e,{n:`bigint`,h:`bigint`,Gx:`field`,Gy:`field`},{nBitLength:`isSafeInteger`,nByteLength:`isSafeInteger`}),Object.freeze({...nl(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function dl(e){let t=ul(e);Lc(t,{a:`field`,b:`field`},{allowedPrivateKeyLengths:`array`,wrapPrivateKey:`boolean`,isTorsionFree:`function`,clearCofactor:`function`,allowInfinityPoint:`boolean`,fromBytes:`function`,toBytes:`function`});let{endo:n,Fp:r,a:i}=t;if(n){if(!r.eql(i,r.ZERO))throw Error(`Endomorphism can only be defined for Koblitz curves that have a=0`);if(typeof n!=`object`||typeof n.beta!=`bigint`||typeof n.splitScalar!=`function`)throw Error(`Expected endomorphism with beta: bigint and splitScalar: function`)}return Object.freeze({...t})}var{bytesToNumberBE:fl,hexToBytes:pl}=uc,ml={Err:class extends Error{constructor(e=``){super(e)}},_parseInt(e){let{Err:t}=ml;if(e.length<2||e[0]!==2)throw new t(`Invalid signature integer tag`);let n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t(`Invalid signature integer: wrong length`);if(r[0]&128)throw new t(`Invalid signature integer: negative`);if(r[0]===0&&!(r[1]&128))throw new t(`Invalid signature integer: unnecessary leading zero`);return{d:fl(r),l:e.subarray(n+2)}},toSig(e){let{Err:t}=ml,n=typeof e==`string`?pl(e):e;if(!(n instanceof Uint8Array))throw Error(`ui8a expected`);let r=n.length;if(r<2||n[0]!=48)throw new t(`Invalid signature tag`);if(n[1]!==r-2)throw new t(`Invalid signature: incorrect length`);let{d:i,l:a}=ml._parseInt(n.subarray(2)),{d:o,l:s}=ml._parseInt(a);if(s.length)throw new t(`Invalid signature: left bytes after parsing`);return{r:i,s:o}},hexFromSig(e){let t=e=>Number.parseInt(e[0],16)&8?`00`+e:e,n=e=>{let t=e.toString(16);return t.length&1?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),a=r.length/2,o=i.length/2,s=n(a),c=n(o);return`30${n(o+a+4)}02${c}${i}02${s}${r}`}},hl=BigInt(0),gl=BigInt(1),_l=BigInt(3);function vl(e){let t=dl(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{let i=t.toAffine();return Ec(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),i=t.fromBytes||(e=>{let t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){let{a:r,b:i}=t,a=n.sqr(e),o=n.mul(a,e);return n.add(n.add(o,n.mul(e,r)),i)}if(!n.eql(n.sqr(t.Gy),a(t.Gx)))throw Error(`bad generator point: equation left != right`);function o(e){return typeof e==`bigint`&&hl<e&&e<t.n}function s(e){if(!o(e))throw Error(`Expected valid bigint: 0 < bigint < curve.n`)}function c(e){let{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:a}=t;if(n&&typeof e!=`bigint`){if(e instanceof Uint8Array&&(e=gc(e)),typeof e!=`string`||!n.includes(e.length))throw Error(`Invalid key`);e=e.padStart(r*2,`0`)}let o;try{o=typeof e==`bigint`?e:bc(Tc(`private key`,e,r))}catch{throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=Kc(o,a)),s(o),o}let l=new Map;function u(e){if(!(e instanceof d))throw Error(`ProjectivePoint expected`)}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,e==null||!n.isValid(e))throw Error(`x required`);if(t==null||!n.isValid(t))throw Error(`y required`);if(r==null||!n.isValid(r))throw Error(`z required`)}static fromAffine(e){let{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error(`invalid affine point`);if(e instanceof d)throw Error(`projective point not allowed`);let i=e=>n.eql(e,n.ZERO);return i(t)&&i(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){let t=d.fromAffine(i(Tc(`pointHex`,e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw Error(`bad point: ZERO`)}let{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw Error(`bad point: x or y not FE`);let i=n.sqr(r),o=a(e);if(!n.eql(i,o))throw Error(`bad point: equation left != right`);if(!this.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw Error(`Field doesn't support isOdd`)}equals(e){u(e);let{px:t,py:r,pz:i}=this,{px:a,py:o,pz:s}=e,c=n.eql(n.mul(t,s),n.mul(a,i)),l=n.eql(n.mul(r,s),n.mul(o,i));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){let{a:e,b:r}=t,i=n.mul(r,_l),{px:a,py:o,pz:s}=this,c=n.ZERO,l=n.ZERO,u=n.ZERO,f=n.mul(a,a),p=n.mul(o,o),m=n.mul(s,s),h=n.mul(a,o);return h=n.add(h,h),u=n.mul(a,s),u=n.add(u,u),c=n.mul(e,u),l=n.mul(i,m),l=n.add(c,l),c=n.sub(p,l),l=n.add(p,l),l=n.mul(c,l),c=n.mul(h,c),u=n.mul(i,u),m=n.mul(e,m),h=n.sub(f,m),h=n.mul(e,h),h=n.add(h,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,m),f=n.mul(f,h),l=n.add(l,f),m=n.mul(o,s),m=n.add(m,m),f=n.mul(m,h),c=n.sub(c,f),u=n.mul(m,p),u=n.add(u,u),u=n.add(u,u),new d(c,l,u)}add(e){u(e);let{px:r,py:i,pz:a}=this,{px:o,py:s,pz:c}=e,l=n.ZERO,f=n.ZERO,p=n.ZERO,m=t.a,h=n.mul(t.b,_l),g=n.mul(r,o),_=n.mul(i,s),v=n.mul(a,c),y=n.add(r,i),b=n.add(o,s);y=n.mul(y,b),b=n.add(g,_),y=n.sub(y,b),b=n.add(r,a);let x=n.add(o,c);return b=n.mul(b,x),x=n.add(g,v),b=n.sub(b,x),x=n.add(i,a),l=n.add(s,c),x=n.mul(x,l),l=n.add(_,v),x=n.sub(x,l),p=n.mul(m,b),l=n.mul(h,v),p=n.add(l,p),l=n.sub(_,p),p=n.add(_,p),f=n.mul(l,p),_=n.add(g,g),_=n.add(_,g),v=n.mul(m,v),b=n.mul(h,b),_=n.add(_,v),v=n.sub(g,v),v=n.mul(m,v),b=n.add(b,v),g=n.mul(_,b),f=n.add(f,g),g=n.mul(x,b),l=n.mul(y,l),l=n.sub(l,g),g=n.mul(y,_),p=n.mul(x,p),p=n.add(p,g),new d(l,f,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.wNAFCached(this,l,e,e=>{let t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){let r=d.ZERO;if(e===hl)return r;if(s(e),e===gl)return this;let{endo:i}=t;if(!i)return p.unsafeLadder(this,e);let{k1neg:a,k1:o,k2neg:c,k2:l}=i.splitScalar(e),u=r,f=r,m=this;for(;o>hl||l>hl;)o&gl&&(u=u.add(m)),l&gl&&(f=f.add(m)),m=m.double(),o>>=gl,l>>=gl;return a&&(u=u.negate()),c&&(f=f.negate()),f=new d(n.mul(f.px,i.beta),f.py,f.pz),u.add(f)}multiply(e){s(e);let r=e,i,a,{endo:o}=t;if(o){let{k1neg:e,k1:t,k2neg:s,k2:c}=o.splitScalar(r),{p:l,f:u}=this.wNAF(t),{p:f,f:m}=this.wNAF(c);l=p.constTimeNegate(e,l),f=p.constTimeNegate(s,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=l.add(f),a=u.add(m)}else{let{p:e,f:t}=this.wNAF(r);i=e,a=t}return d.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){let r=d.BASE,i=(e,t)=>t===hl||t===gl||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),a=i(this,t).add(i(e,n));return a.is0()?void 0:a}toAffine(e){let{px:t,py:r,pz:i}=this,a=this.is0();e??=a?n.ONE:n.inv(i);let o=n.mul(t,e),s=n.mul(r,e),c=n.mul(i,e);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw Error(`invZ was invalid`);return{x:o,y:s}}isTorsionFree(){let{h:e,isTorsionFree:n}=t;if(e===gl)return!0;if(n)return n(d,this);throw Error(`isTorsionFree() has not been declared for the elliptic curve`)}clearCofactor(){let{h:e,clearCofactor:n}=t;return e===gl?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return gc(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);let f=t.nBitLength,p=ll(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:o}}function yl(e){let t=ul(e);return Lc(t,{hash:`hash`,hmac:`function`,randomBytes:`function`},{bits2int:`function`,bits2int_modN:`function`,lowS:`boolean`}),Object.freeze({lowS:!0,...t})}function bl(e){let t=yl(e),{Fp:n,n:r}=t,i=n.BYTES+1,a=2*n.BYTES+1;function o(e){return hl<e&&e<n.ORDER}function s(e){return Kc(e,r)}function c(e){return Yc(e,r)}let{ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:d,isWithinCurveOrder:f}=vl({...t,toBytes(e,t,r){let i=t.toAffine(),a=n.toBytes(i.x),o=Ec;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),a):o(Uint8Array.from([4]),a,n.toBytes(i.y))},fromBytes(e){let t=e.length,r=e[0],s=e.subarray(1);if(t===i&&(r===2||r===3)){let e=bc(s);if(!o(e))throw Error(`Point is not on curve`);let t=d(e),i=n.sqrt(t),a=(i&gl)===gl;return(r&1)==1!==a&&(i=n.neg(i)),{x:e,y:i}}if(t===a&&r===4)return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))};throw Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${a} uncompressed bytes`)}}),p=e=>gc(Sc(e,t.nByteLength));function m(e){return e>r>>gl}function h(e){return m(e)?s(-e):e}let g=(e,t,n)=>bc(e.slice(t,n));class _{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){let n=t.nByteLength;return e=Tc(`compactSignature`,e,n*2),new _(g(e,0,n),g(e,n,2*n))}static fromDER(e){let{r:t,s:n}=ml.toSig(Tc(`DER`,e));return new _(t,n)}assertValidity(){if(!f(this.r))throw Error(`r must be 0 < r < CURVE.n`);if(!f(this.s))throw Error(`s must be 0 < s < CURVE.n`)}addRecoveryBit(e){return new _(this.r,this.s,e)}recoverPublicKey(e){let{r,s:i,recovery:a}=this,o=C(Tc(`msgHash`,e));if(a==null||![0,1,2,3].includes(a))throw Error(`recovery id invalid`);let u=a===2||a===3?r+t.n:r;if(u>=n.ORDER)throw Error(`recovery id 2 or 3 invalid`);let d=a&1?`03`:`02`,f=l.fromHex(d+p(u)),m=c(u),h=s(-o*m),g=s(i*m),_=l.BASE.multiplyAndAddUnsafe(f,h,g);if(!_)throw Error(`point at infinify`);return _.assertValidity(),_}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new _(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return yc(this.toDERHex())}toDERHex(){return ml.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return yc(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let v={isValidPrivateKey(e){try{return u(e),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let e=al(t.n);return ol(t.randomBytes(e),t.n)},precompute(e=8,t=l.BASE){return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function y(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)}function b(e){let t=e instanceof Uint8Array,n=typeof e==`string`,r=(t||n)&&e.length;return t?r===i||r===a:n?r===2*i||r===2*a:e instanceof l}function x(e,t,n=!0){if(b(e))throw Error(`first arg must be private key`);if(!b(t))throw Error(`second arg must be public key`);return l.fromHex(t).multiply(u(e)).toRawBytes(n)}let S=t.bits2int||function(e){let n=bc(e),r=e.length*8-t.nBitLength;return r>0?n>>BigInt(r):n},C=t.bits2int_modN||function(e){return s(S(e))},ee=Mc(t.nBitLength);function te(e){if(typeof e!=`bigint`)throw Error(`bigint expected`);if(!(hl<=e&&e<ee))throw Error(`bigint expected < 2^${t.nBitLength}`);return Sc(e,t.nByteLength)}function ne(e,r,i=re){if([`recovered`,`canonical`].some(e=>e in i))throw Error(`sign() legacy options not supported`);let{hash:a,randomBytes:o}=t,{lowS:d,prehash:p,extraEntropy:g}=i;d??=!0,e=Tc(`msgHash`,e),p&&(e=Tc(`prehashed msgHash`,a(e)));let v=C(e),y=u(r),b=[te(y),te(v)];if(g!=null){let e=g===!0?o(n.BYTES):g;b.push(Tc(`extraEntropy`,e))}let x=Ec(...b),ee=v;function ne(e){let t=S(e);if(!f(t))return;let n=c(t),r=l.BASE.multiply(t).toAffine(),i=s(r.x);if(i===hl)return;let a=s(n*s(ee+i*y));if(a===hl)return;let o=(r.x===i?0:2)|Number(r.y&gl),u=a;return d&&m(a)&&(u=h(a),o^=1),new _(i,u,o)}return{seed:x,k2sig:ne}}let re={lowS:t.lowS,prehash:!1},w={lowS:t.lowS,prehash:!1};function T(e,n,r=re){let{seed:i,k2sig:a}=ne(e,n,r),o=t;return Fc(o.hash.outputLen,o.nByteLength,o.hmac)(i,a)}l.BASE._setWindowSize(8);function ie(e,n,r,i=w){let a=e;if(n=Tc(`msgHash`,n),r=Tc(`publicKey`,r),`strict`in i)throw Error(`options.strict was renamed to lowS`);let{lowS:o,prehash:u}=i,d,f;try{if(typeof a==`string`||a instanceof Uint8Array)try{d=_.fromDER(a)}catch(e){if(!(e instanceof ml.Err))throw e;d=_.fromCompact(a)}else if(typeof a==`object`&&typeof a.r==`bigint`&&typeof a.s==`bigint`){let{r:e,s:t}=a;d=new _(e,t)}else throw Error(`PARSE`);f=l.fromHex(r)}catch(e){if(e.message===`PARSE`)throw Error(`signature must be Signature instance, Uint8Array or hex string`);return!1}if(o&&d.hasHighS())return!1;u&&(n=t.hash(n));let{r:p,s:m}=d,h=C(n),g=c(m),v=s(h*g),y=s(p*g),b=l.BASE.multiplyAndAddUnsafe(f,v,y)?.toAffine();return b?s(b.x)===p:!1}return{CURVE:t,getPublicKey:y,getSharedSecret:x,sign:T,verify:ie,ProjectivePoint:l,Signature:_,utils:v}}function xl(e){return{hash:e,hmac:(t,...n)=>eo(e,t,qa(...n)),randomBytes:Qa}}function Sl(e,t){let n=t=>bl({...e,...xl(t)});return Object.freeze({...n(t),create:n})}var Cl=BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),wl=BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),Tl=BigInt(1),El=BigInt(2),Dl=(e,t)=>(e+t/El)/t;function Ol(e){let t=Cl,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=Jc(Jc(Jc(u,n,t)*u%t,n,t)*u%t,El,t)*l%t,f=Jc(d,i,t)*d%t,p=Jc(f,a,t)*f%t,m=Jc(p,s,t)*p%t,h=Jc(Jc(Jc(Jc(Jc(Jc(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,El,t);if(!kl.eql(kl.sqr(h),e))throw Error(`Cannot find square root`);return h}var kl=rl(Cl,void 0,void 0,{sqrt:Ol}),Al=Sl({a:BigInt(0),b:BigInt(7),Fp:kl,n:wl,Gx:BigInt(`55066263022277343669578718895168534326250603453777594175500187360389116729240`),Gy:BigInt(`32670510020758816978083085130507043184471273380659243275938904335757337482424`),h:BigInt(1),lowS:!0,endo:{beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),splitScalar:e=>{let t=wl,n=BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),r=-Tl*BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`),i=BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),a=n,o=BigInt(`0x100000000000000000000000000000000`),s=Dl(a*e,t),c=Dl(-r*e,t),l=Kc(e-s*n-c*i,t),u=Kc(-s*r-c*a,t),d=l>o,f=u>o;if(d&&(l=t-l),f&&(u=t-u),l>o||u>o)throw Error(`splitScalar: Endomorphism failed, k=`+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}}},po);Al.ProjectivePoint;var jl=`0x0000000000000000000000000000000000000000`,Ml=`0x0000000000000000000000000000000000000000000000000000000000000000`,Nl=`Ethereum Signed Message:
|
|
@@ -282,4 +282,4 @@ CAUSE: `+e.stack)}}}return t[e]=n,n};function r(e){return typeof e==`object`}e.d
|
|
|
282
282
|
.ledger-select-button:hover {
|
|
283
283
|
opacity: 0.7;
|
|
284
284
|
}
|
|
285
|
-
`;function iE(){let e=document.createElement(`div`),t=document.createElement(`style`);t.textContent=rE,document.body.append(t),document.body.append(e);function n(){e.remove(),t.remove()}return{onClose:n,div:e}}function aE(){let{onClose:e,div:t}=iE();return zT($(eE,{title:YT().loadingTitle,onClose:e,children:$($T,{})}),t),e}function oE(e){let{onClose:t,div:n}=iE();return zT($(eE,{width:550,title:YT().loadingTitle,onClose:t,children:$(QT,{address:e})}),n),t}function sE(e){let{onClose:t,div:n}=iE(),r=YT();return new Promise((i,a)=>{function o(e){i(e),t()}function s(){a(Error(`Operation is canceled.`)),t()}zT($(eE,{title:r.loadingTitle,onClose:s,children:$(nE,{accounts:e.accounts,selectedIndex:e.selectedIndex||0,onConfirm:o,onCancel:s,getAccounts:e.getAccounts})}),n)})}w();var cE=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function lE(e){return typeof e==`function`}var uE=function(e){return cE(this,arguments,void 0,function*({accounts:e,ledgerUtils:t}){let n=yield sE({accounts:e,getAccounts:t.getAccounts}),r=oE(n.address);try{yield t.getAddress(n.index,!0)}finally{r?.()}return n})},dE=class{constructor(e={}){this.app=null,this.transport=null,this.queue=Promise.resolve(),this.selectedIndex=0,this._address=``,this.getAccounts=(e,t)=>cE(this,void 0,void 0,function*(){if(e<0)throw Error(`getAccount parameter error: from cannot be smaller than 0.`);if(e>=t)throw Error(`getAccount parameter error: from cannot be bigger than to.`);return this.enqueue(()=>cE(this,void 0,void 0,function*(){try{yield this.makeApp();let n={};for(let r=e;r<t;r++){let e=yield this.getAccount(r);n[e.index]=e}return Object.keys(n).forEach(e=>{this.accounts[+e]=n[e]}),this.accounts.slice(e,t)}finally{yield this.cleanUp()}}))}),this.getAddress=(e,...t)=>cE(this,[e,...t],void 0,function*(e,t=!1){return this.enqueue(()=>cE(this,void 0,void 0,function*(){let n=this.getPathForIndex(e);try{return yield this.makeApp(),yield this.app.getAddress(n,t)}finally{yield this.cleanUp()}}))}),this.accounts=[];let{accountNumber:t=1}=e;if([`beforeConnect`,`selectAccount`,`getDerivationPath`].forEach(t=>{if(e[t]&&!lE(e[t]))throw Error(`[Ledger]: ${t} must be a function!`)}),t&&!Number.isInteger(+t))throw Error(`[Ledger]: accountNumber must be an integer!`);this.config=Object.assign(Object.assign({},e),{accountNumber:t})}get address(){return this._address}connect(e){return cE(this,void 0,void 0,function*(){if(e?.account&&typeof e.account==`object`){let t=e.account;this.selectedIndex=+t.index,this._address=t.address,t.index===void 0||t.address;return}let t={getAccounts:this.getAccounts,getAddress:this.getAddress};this.accounts=[],this._address=``,this.selectedIndex=0;let{accountNumber:n=1,beforeConnect:r,selectAccount:i=uE}=this.config,a=null;try{r?yield r():a=aE();let e=yield this.getAccounts(0,n);a?.(),a=null;let o=yield i({accounts:e,ledgerUtils:t});this.selectedIndex=o.index,this._address=o.address}finally{a?.()}})}disconnect(){this.selectedIndex=0,this._address=``}signPersonalMessage(e){return cE(this,void 0,void 0,function*(){return this._withApp((t,n)=>{let r=T.from(e).toString(`hex`);return t.signPersonalMessage(n,r)})})}signTransaction(e){return cE(this,void 0,void 0,function*(){let t=yield this._withApp((t,n)=>t.signTransaction(n,e.raw_data_hex,[]));return this._mergeSignature(e,t)})}signTransactionHash(e){return cE(this,void 0,void 0,function*(){let t=yield this._withApp((t,n)=>t.signTransactionHash(n,e.txID));return this._mergeSignature(e,t)})}_withApp(e){return cE(this,void 0,void 0,function*(){return this.enqueue(()=>cE(this,void 0,void 0,function*(){let t=this.selectedIndex,n=this.getPathForIndex(t);try{return yield this.makeApp(),yield e(this.app,n)}finally{yield this.cleanUp()}}))})}_mergeSignature(e,t){let n=e.signature,r=Array.isArray(n)?n.includes(t)?n:[...n,t]:[t];return Object.assign(Object.assign({},e),{signature:r})}getAccount(e){return cE(this,void 0,void 0,function*(){let t=this.getPathForIndex(e),{address:n}=yield this.app.getAddress(t);return{path:t,address:n,index:e}})}enqueue(e){let t=this.queue.then(e);return this.queue=t.catch(()=>void 0),t}getPathForIndex(e){return this.config.getDerivationPath?this.config.getDerivationPath(e):`44'/195'/${e}'/0/0`}makeApp(){return cE(this,void 0,void 0,function*(){this.transport&&this.app||(this.transport=yield cw.create(),this.app=new NC(this.transport))})}cleanUp(){return cE(this,void 0,void 0,function*(){let e=this.transport;this.app=null,this.transport=null;try{yield e?.close()}catch{}})}},fE=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},pE=()=>!!(globalThis.navigator&&globalThis.navigator.hid),mE=`Ledger`,hE=class extends Rr{constructor(e={}){super(),this.name=mE,this.url=`https://www.ledger.com/`,this.icon=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAYAAACLz2ctAAAAAXNSR0IArs4c6QAAFMhJREFUeAHtXXuMFEUeruW5PJbwFEVQjAtcvBCJmoASiUG4O3ICioBiEM5gNPgHJubERzw2HuApHOrxh3gcRLISlA2eghLfiCTKGgNBucNDFgiKILsIeyy77LI87vua7rmZ2Zme7pl+VPf8Kunp7urq+v3qq29+9eyqEiUuBYGysrK+586dG3bx4kXr6FdSUlKGQGXwM868t67Nlxvg1wC/Btwb1zzzHv51OPby6NChw96Ghobj5jtyAgIlxYpC//79u9XX148GSW4ABsOSjt4+Y3IC8e+1DhBzZ8+ePb84duxYo89ytYy+aAhYXl7e+fDhw6OQC2NBOh4jcd1Rk1xpBRG/wrEF+mwZOHBgdU1NTYsmuvmqRqwJ2Llz5yEg2lRk7O043wIku/iKpneRn4HOX0LnT3He0NLSss+7qPWKKXYE7NGjR29k2D3IvPsB9c16wZ23NttBxNfxh1p/6tQpFuGxcbEg4I033thx9+7dv0cm3Q/i3YHc6RSbHEpNyFmk8T2k8fXhw4dv3rFjR2vq4+jdRZqA3bp1648W62PIkDmAvk/04C9I419AxtVoWb/Y2Nh4rKCYQnw5kgTs0qXLoAsXLswH8R4EdqUh4qeD6GYQcVW7du2WnDlz5kcdFHKjQ6QIiDpQORL3JIg3C2ddWrBu8PYzLFvSlRDwPOrANX4K8jLuSBDQbM0+i4RPx9HeSwBiGNd5pKkKZKyIQutZ68x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GUyqwWKXucmWL6psHyBrWwUKAGJNVaqH4kZ1e+CiDJspxH5QLw6jnB42cnsJHmBF4dMIMcRkeBtThSUMP4jwLxgngRNPqYscAJSKMcRJ02aNBb/uMW4lfmEBCUcd4F5wLzwamzXbTICL4LTFUS9cDz81qJIlpnV6eD4eA+rV4voZ6K+97GPYnJGHYoFTNaKAJhF8tZkf7n2DwGQbysxD5t8TGHoBKQSMP9HUQzwK7uneEs/cb4gQGyfItbE3BcJLiMNvQhO15ffHaM4Xo6DfYbiPEIAVm8Tjnluv9v1SHzWaLQjoKUplwHBNYl4jeUnZ/cIgHRcNmseilvHy2W4l5L/G1oUwZnUJ2Bc5AattEV4XvgyVZmExNuvhdgRQ13JR/i1tYDJ3IA1HAJL+Cz8puMIZPgwWX7ErrkyaRUsXwWI52iJtDDTFwkCWgCBiOW4fhJknIVzR8tfzgYC3NulElfPg3g1UcEkUgS0QMVw3iAM580HETnXsNTyL9JzM4i3CsXtEoxk/Bg1DCJJQAtkrI7aH58AcKrXHPj1sfyL5PwLiLeam8DY7cOhOxbaNkKcAEfgUdw8gX3IrkD4u5Ah/GAmzg2Ws2Ya72KamfYok495HGkLyASkux49evRGxtxj1hNHpT+P6H01iFeJOvD6TFueRjRNhtqxI2ByZpit56nIvNtByFvwrEvyc42vz0DnL6HzpzhvwB9K+9ZsvljGmoDJoJSXl3fGwtm0iGORsTxG4lqXljRbsPywfwt02oIF4aux50dLsv5xvS4aAqZnYP/+/bvV19ePBhFvwLNhSUfv9LAe359AfHutA6Tb2bNnzy+wGWOjx3IiEV3REjBb7pSVlfVFy3oYiGkdl4EkZQhfBj+eu/PevOY9XQP8GuDHD/JP85p+vMd1LY69PNBi3Yu9So7zBXGXEPgf30hvKVSaI9kAAAAASUVORK5CYII=`,this._readyState=Pr.Loading,this._state=Fr.NotFound,this._connecting=!1,this._address=null,this.config=e,this._wallet=new dE(e),pE()?(this._readyState=Pr.Found,this._state=Fr.Disconnect):this._readyState=Pr.NotFound}get address(){return this._address}get state(){return this._state}get connecting(){return this._connecting}get readyState(){return this._readyState}get ledgerUtils(){return{getAccounts:this._wallet.getAccounts,getAddress:this._wallet.getAddress}}connect(e){return fE(this,void 0,void 0,function*(){try{if(this.connected||this.connecting)return;if(this.state===Fr.NotFound)throw this.config.openUrlWhenWalletNotFound!==!1&&zr()&&window.open(this.url,`_blank`),new Tr;this._connecting=!0;try{yield this._wallet.connect(e)}catch(e){throw new Dr(`${e.message}.`)}this._address=this._wallet.address,this._state=Fr.Connected,this.emit(`connect`,this.address||``),this.emit(`stateChanged`,this._state)}catch(e){throw this.emit(`error`,e),e}finally{this._connecting=!1}})}disconnect(){return fE(this,void 0,void 0,function*(){if(this.state===Fr.Connected)try{this._wallet.disconnect(),this._state=Fr.Disconnect,this._address=null,this.emit(`disconnect`),this.emit(`stateChanged`,this._state)}catch(e){throw this.emit(`error`,e),new Or(e.message)}})}_checkAndSign(e,t,n){return fE(this,void 0,void 0,function*(){try{if(this.state!==Fr.Connected)throw new Er;n&&n();try{return yield e()}catch(e){throw new t(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}})}signTransaction(e){return fE(this,arguments,void 0,function*(e,t={}){let{fallbackToHashSign:n=!0}=t;return this._checkAndSign(()=>fE(this,void 0,void 0,function*(){try{return yield this._wallet.signTransaction(e)}catch(t){if(n&&/Too many bytes to encode/.test(t?.message))return yield this._wallet.signTransactionHash(e);throw t}}),Ar,()=>{if(!zx(e))throw new Ar(`Invalid transaction`)})})}signTransactionHash(e){return fE(this,void 0,void 0,function*(){return this._checkAndSign(()=>this._wallet.signTransactionHash(e),Ar,()=>{if(!zx(e))throw new Ar(`Invalid transaction`)})})}signMessage(e,t){return fE(this,void 0,void 0,function*(){return this._checkAndSign(()=>fE(this,void 0,void 0,function*(){let n=yield this._wallet.signPersonalMessage(e),{convertSuffix:r=!0}=t??{};return r?n.replace(/(00|01)$/,e=>e===`00`?`1b`:`1c`):n}),kr)})}},gE=`tron:0x2b6653dc`,_E=c([o({result:oe}).pipe(l(oe,s({decode:({result:e})=>e,encode:e=>({result:e})}))),oe]),vE=e=>e.accounts.find(e=>e.startsWith(`${gE}:`))?.slice(16),yE=({walletConnectProtocol:e,runWalletEffect:t})=>{let n=new Set,r,i=0,o=e.sessions(`tron`).pipe(ee(e=>e.find(e=>vE(e)!==void 0))),s=()=>{r?.unsubscribeEnded(),r=void 0};return{address:()=>r?.address??null,isAuthorized:()=>t(o.pipe(ee(a))),connect:({isReconnecting:c})=>{let l=++i;return t(_(function*(){let t=yield*o.pipe(x(a,()=>c?g(new S({message:`No Tron WalletConnect session to restore`,operation:`tron-reconnect`})):e.connect({namespace:`tron`,chains:[gE],requiredMethods:[],optionalMethods:[`tron_signTransaction`,`tron_signMessage`]})));if(l!==i)return yield*new S({message:`Tron connection superseded`,operation:`tron-connect`});let u=vE(t);if(u===void 0)return yield*new S({message:`No Tron mainnet account approved`,operation:`tron-connect`});s(),r={session:t,address:u,unsubscribeEnded:e.subscribeEnded(t.topic,()=>{s();for(let e of n)e()})}}))},disconnect:async()=>{++i;let n=r?.session.topic;s(),n&&await t(e.disconnect(n))},signTransaction:n=>t(_(function*(){if(!r)return yield*new S({message:`Tron wallet is not connected`,operation:`tron-sign-transaction`});let{session:t,address:i}=r;return yield*e.request({topic:t.topic,chainId:gE,method:`tron_signTransaction`,params:{address:i,transaction:t.sessionProperties.tron_method_version===`v1`?n:{transaction:n}},response:_E})})),onEnded:e=>{n.add(e)}}},bE=c([o({tron:o({isTronLink:u(!0)})}),o({tronLink:o({})})]),xE=o({isBitKeep:u(!0),tronLink:o({})}),SE=(e,t)=>({address:()=>e().address,connect:()=>e().connect().catch(e=>{throw e instanceof xn?new v({walletId:t}):e}),disconnect:()=>e().disconnect(),signTransaction:t=>e().signTransaction(t),isAuthorized:async()=>e().connected&&!!e().address}),CE=({wallet:e,metaConfig:t,walletDetailsParams:n})=>b(r=>{e.onEnded?.(()=>r.emitter.emit(`disconnect`));let i=()=>{let t=e.address();if(!t)throw Error(`No account found`);return[t]};return{...n,id:se[t].id,name:se[t].name,type:se[t].type,signTransaction:e.signTransaction,connect:async t=>(r.emitter.emit(`message`,{type:`connecting`}),await e.connect({isReconnecting:t?.isReconnecting??!1}),r.storage?.removeItem(`tron.disconnected`),C(t?.withCapabilities,i(),ae.id)),disconnect:()=>(r.storage?.setItem(`tron.disconnected`,!0),e.disconnect()),getAccounts:async()=>i(),switchChain:async()=>ae,getChainId:async()=>ae.id,isAuthorized:async()=>!await r.storage?.getItem(`tron.disconnected`)&&e.isAuthorized(),...ve(r.emitter),getProvider:async()=>e,$filteredChains:h([ae])}}),wE=({walletConnectProtocol:e,runWalletEffect:t})=>{let n={iconUrl:m(`tron`),title:`Tron`,id:`tron`},r=({metaConfig:e,iconUrl:t,installUrl:r,isInjected:i,makeAdapter:a})=>()=>{let o=a(),s=()=>(o.readyState===Pn.NotFound&&i(globalThis)&&(o=a()),o);return{id:se[e].id,name:se[e].name,iconUrl:t,iconBackground:`#fff`,chainGroup:n,availability:{_tag:`Injected`,detect:y(()=>o.readyState===Pn.Found||i(globalThis)),installUrl:r},createConnector:t=>CE({walletDetailsParams:t,metaConfig:e,wallet:SE(s,se[e].id)})}},i={openUrlWhenWalletNotFound:!1};return{groupName:`Tron`,wallets:[r({metaConfig:`tronLink`,iconUrl:f(`trx`),installUrl:`https://chromewebstore.google.com/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec`,isInjected:d(bE),makeAdapter:()=>new vr(i)}),()=>({id:se.tronWc.id,name:se.tronWc.name,iconUrl:p.wcLogo,iconBackground:`#fff`,availability:{_tag:`Remote`},chainGroup:n,createConnector:n=>CE({walletDetailsParams:n,metaConfig:`tronWc`,wallet:yE({walletConnectProtocol:e,runWalletEffect:t})})}),r({metaConfig:`tronBg`,iconUrl:p.bitget,installUrl:`https://chromewebstore.google.com/detail/bitget-wallet-crypto-web3/jiidiaalihmmhddjgbnbgdfflelocpak`,isInjected:d(xE),makeAdapter:()=>new Cr(i)}),()=>({id:se.tronLedger.id,name:se.tronLedger.name,iconUrl:p.ledgerLogo,iconBackground:`#fff`,availability:{_tag:`Remote`},chainGroup:n,createConnector:e=>{let t=new hE;return CE({walletDetailsParams:e,metaConfig:`tronLedger`,wallet:SE(()=>t,se.tronLedger.id)})}})]}};export{wE as getTronConnectors};
|
|
285
|
+
`;function iE(){let e=document.createElement(`div`),t=document.createElement(`style`);t.textContent=rE,document.body.append(t),document.body.append(e);function n(){e.remove(),t.remove()}return{onClose:n,div:e}}function aE(){let{onClose:e,div:t}=iE();return zT($(eE,{title:YT().loadingTitle,onClose:e,children:$($T,{})}),t),e}function oE(e){let{onClose:t,div:n}=iE();return zT($(eE,{width:550,title:YT().loadingTitle,onClose:t,children:$(QT,{address:e})}),n),t}function sE(e){let{onClose:t,div:n}=iE(),r=YT();return new Promise((i,a)=>{function o(e){i(e),t()}function s(){a(Error(`Operation is canceled.`)),t()}zT($(eE,{title:r.loadingTitle,onClose:s,children:$(nE,{accounts:e.accounts,selectedIndex:e.selectedIndex||0,onConfirm:o,onCancel:s,getAccounts:e.getAccounts})}),n)})}w();var cE=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function lE(e){return typeof e==`function`}var uE=function(e){return cE(this,arguments,void 0,function*({accounts:e,ledgerUtils:t}){let n=yield sE({accounts:e,getAccounts:t.getAccounts}),r=oE(n.address);try{yield t.getAddress(n.index,!0)}finally{r?.()}return n})},dE=class{constructor(e={}){this.app=null,this.transport=null,this.queue=Promise.resolve(),this.selectedIndex=0,this._address=``,this.getAccounts=(e,t)=>cE(this,void 0,void 0,function*(){if(e<0)throw Error(`getAccount parameter error: from cannot be smaller than 0.`);if(e>=t)throw Error(`getAccount parameter error: from cannot be bigger than to.`);return this.enqueue(()=>cE(this,void 0,void 0,function*(){try{yield this.makeApp();let n={};for(let r=e;r<t;r++){let e=yield this.getAccount(r);n[e.index]=e}return Object.keys(n).forEach(e=>{this.accounts[+e]=n[e]}),this.accounts.slice(e,t)}finally{yield this.cleanUp()}}))}),this.getAddress=(e,...t)=>cE(this,[e,...t],void 0,function*(e,t=!1){return this.enqueue(()=>cE(this,void 0,void 0,function*(){let n=this.getPathForIndex(e);try{return yield this.makeApp(),yield this.app.getAddress(n,t)}finally{yield this.cleanUp()}}))}),this.accounts=[];let{accountNumber:t=1}=e;if([`beforeConnect`,`selectAccount`,`getDerivationPath`].forEach(t=>{if(e[t]&&!lE(e[t]))throw Error(`[Ledger]: ${t} must be a function!`)}),t&&!Number.isInteger(+t))throw Error(`[Ledger]: accountNumber must be an integer!`);this.config=Object.assign(Object.assign({},e),{accountNumber:t})}get address(){return this._address}connect(e){return cE(this,void 0,void 0,function*(){if(e?.account&&typeof e.account==`object`){let t=e.account;this.selectedIndex=+t.index,this._address=t.address,t.index===void 0||t.address;return}let t={getAccounts:this.getAccounts,getAddress:this.getAddress};this.accounts=[],this._address=``,this.selectedIndex=0;let{accountNumber:n=1,beforeConnect:r,selectAccount:i=uE}=this.config,a=null;try{r?yield r():a=aE();let e=yield this.getAccounts(0,n);a?.(),a=null;let o=yield i({accounts:e,ledgerUtils:t});this.selectedIndex=o.index,this._address=o.address}finally{a?.()}})}disconnect(){this.selectedIndex=0,this._address=``}signPersonalMessage(e){return cE(this,void 0,void 0,function*(){return this._withApp((t,n)=>{let r=T.from(e).toString(`hex`);return t.signPersonalMessage(n,r)})})}signTransaction(e){return cE(this,void 0,void 0,function*(){let t=yield this._withApp((t,n)=>t.signTransaction(n,e.raw_data_hex,[]));return this._mergeSignature(e,t)})}signTransactionHash(e){return cE(this,void 0,void 0,function*(){let t=yield this._withApp((t,n)=>t.signTransactionHash(n,e.txID));return this._mergeSignature(e,t)})}_withApp(e){return cE(this,void 0,void 0,function*(){return this.enqueue(()=>cE(this,void 0,void 0,function*(){let t=this.selectedIndex,n=this.getPathForIndex(t);try{return yield this.makeApp(),yield e(this.app,n)}finally{yield this.cleanUp()}}))})}_mergeSignature(e,t){let n=e.signature,r=Array.isArray(n)?n.includes(t)?n:[...n,t]:[t];return Object.assign(Object.assign({},e),{signature:r})}getAccount(e){return cE(this,void 0,void 0,function*(){let t=this.getPathForIndex(e),{address:n}=yield this.app.getAddress(t);return{path:t,address:n,index:e}})}enqueue(e){let t=this.queue.then(e);return this.queue=t.catch(()=>void 0),t}getPathForIndex(e){return this.config.getDerivationPath?this.config.getDerivationPath(e):`44'/195'/${e}'/0/0`}makeApp(){return cE(this,void 0,void 0,function*(){this.transport&&this.app||(this.transport=yield cw.create(),this.app=new NC(this.transport))})}cleanUp(){return cE(this,void 0,void 0,function*(){let e=this.transport;this.app=null,this.transport=null;try{yield e?.close()}catch{}})}},fE=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},pE=()=>!!(globalThis.navigator&&globalThis.navigator.hid),mE=`Ledger`,hE=class extends Rr{constructor(e={}){super(),this.name=mE,this.url=`https://www.ledger.com/`,this.icon=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAYAAACLz2ctAAAAAXNSR0IArs4c6QAAFMhJREFUeAHtXXuMFEUeruW5PJbwFEVQjAtcvBCJmoASiUG4O3ICioBiEM5gNPgHJubERzw2HuApHOrxh3gcRLISlA2eghLfiCTKGgNBucNDFgiKILsIeyy77LI87vua7rmZ2Zme7pl+VPf8Kunp7urq+v3qq29+9eyqEiUuBYGysrK+586dG3bx4kXr6FdSUlKGQGXwM868t67Nlxvg1wC/Btwb1zzzHv51OPby6NChw96Ghobj5jtyAgIlxYpC//79u9XX148GSW4ABsOSjt4+Y3IC8e+1DhB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evRGxtxj1hNHpT+P6H01iFeJOvD6TFueRjRNhtqxI2ByZpit56nIvNtByFvwrEvyc42vz0DnL6HzpzhvwB9K+9ZsvljGmoDJoJSXl3fGwtm0iGORsTxG4lqXljRbsPywfwt02oIF4aux50dLsv5xvS4aAqZnYP/+/bvV19ePBhFvwLNhSUfv9LAe359AfHutA6Tb2bNnzy+wGWOjx3IiEV3REjBb7pSVlfVFy3oYiGkdl4EkZQhfBj+eu/PevOY9XQP8GuDHD/JP85p+vMd1LY69PNBi3Yu9So7zBXGXEPgf30hvKVSaI9kAAAAASUVORK5CYII=`,this._readyState=Pr.Loading,this._state=Fr.NotFound,this._connecting=!1,this._address=null,this.config=e,this._wallet=new dE(e),pE()?(this._readyState=Pr.Found,this._state=Fr.Disconnect):this._readyState=Pr.NotFound}get address(){return this._address}get state(){return this._state}get connecting(){return this._connecting}get readyState(){return this._readyState}get ledgerUtils(){return{getAccounts:this._wallet.getAccounts,getAddress:this._wallet.getAddress}}connect(e){return fE(this,void 0,void 0,function*(){try{if(this.connected||this.connecting)return;if(this.state===Fr.NotFound)throw this.config.openUrlWhenWalletNotFound!==!1&&zr()&&window.open(this.url,`_blank`),new Tr;this._connecting=!0;try{yield this._wallet.connect(e)}catch(e){throw new Dr(`${e.message}.`)}this._address=this._wallet.address,this._state=Fr.Connected,this.emit(`connect`,this.address||``),this.emit(`stateChanged`,this._state)}catch(e){throw this.emit(`error`,e),e}finally{this._connecting=!1}})}disconnect(){return fE(this,void 0,void 0,function*(){if(this.state===Fr.Connected)try{this._wallet.disconnect(),this._state=Fr.Disconnect,this._address=null,this.emit(`disconnect`),this.emit(`stateChanged`,this._state)}catch(e){throw this.emit(`error`,e),new Or(e.message)}})}_checkAndSign(e,t,n){return fE(this,void 0,void 0,function*(){try{if(this.state!==Fr.Connected)throw new Er;n&&n();try{return yield e()}catch(e){throw new t(e?.message,e)}}catch(e){throw this.emit(`error`,e),e}})}signTransaction(e){return fE(this,arguments,void 0,function*(e,t={}){let{fallbackToHashSign:n=!0}=t;return this._checkAndSign(()=>fE(this,void 0,void 0,function*(){try{return yield this._wallet.signTransaction(e)}catch(t){if(n&&/Too many bytes to encode/.test(t?.message))return yield this._wallet.signTransactionHash(e);throw t}}),Ar,()=>{if(!zx(e))throw new Ar(`Invalid transaction`)})})}signTransactionHash(e){return fE(this,void 0,void 0,function*(){return this._checkAndSign(()=>this._wallet.signTransactionHash(e),Ar,()=>{if(!zx(e))throw new Ar(`Invalid transaction`)})})}signMessage(e,t){return fE(this,void 0,void 0,function*(){return this._checkAndSign(()=>fE(this,void 0,void 0,function*(){let n=yield this._wallet.signPersonalMessage(e),{convertSuffix:r=!0}=t??{};return r?n.replace(/(00|01)$/,e=>e===`00`?`1b`:`1c`):n}),kr)})}},gE=`tron:0x2b6653dc`,_E=m([o({result:oe}).pipe(c(oe,s({decode:({result:e})=>e,encode:e=>({result:e})}))),oe]),vE=e=>e.accounts.find(e=>e.startsWith(`${gE}:`))?.slice(16),yE=({walletConnectProtocol:e,runWalletEffect:t})=>{let n=new Set,r,i=0,o=e.sessions(`tron`).pipe(ee(e=>e.find(e=>vE(e)!==void 0))),s=()=>{r?.unsubscribeEnded(),r=void 0};return{address:()=>r?.address??null,isAuthorized:()=>t(o.pipe(ee(a))),connect:({isReconnecting:c})=>{let l=++i;return t(_(function*(){let t=yield*o.pipe(x(a,()=>c?g(new S({message:`No Tron WalletConnect session to restore`,operation:`tron-reconnect`})):e.connect({namespace:`tron`,chains:[gE],requiredMethods:[],optionalMethods:[`tron_signTransaction`,`tron_signMessage`]})));if(l!==i)return yield*new S({message:`Tron connection superseded`,operation:`tron-connect`});let u=vE(t);if(u===void 0)return yield*new S({message:`No Tron mainnet account approved`,operation:`tron-connect`});s(),r={session:t,address:u,unsubscribeEnded:e.subscribeEnded(t.topic,()=>{s();for(let e of n)e()})}}))},disconnect:async()=>{++i;let n=r?.session.topic;s(),n&&await t(e.disconnect(n))},signTransaction:n=>t(_(function*(){if(!r)return yield*new S({message:`Tron wallet is not connected`,operation:`tron-sign-transaction`});let{session:t,address:i}=r;return yield*e.request({topic:t.topic,chainId:gE,method:`tron_signTransaction`,params:{address:i,transaction:t.sessionProperties.tron_method_version===`v1`?n:{transaction:n}},response:_E})})),onEnded:e=>{n.add(e)}}},bE=m([o({tron:o({isTronLink:l(!0)})}),o({tronLink:o({})})]),xE=o({isBitKeep:l(!0),tronLink:o({})}),SE=(e,t)=>({address:()=>e().address,connect:()=>e().connect().catch(e=>{throw e instanceof xn?new v({walletId:t}):e}),disconnect:()=>e().disconnect(),signTransaction:t=>e().signTransaction(t),isAuthorized:async()=>e().connected&&!!e().address}),CE=({wallet:e,metaConfig:t,walletDetailsParams:n})=>b(r=>{e.onEnded?.(()=>r.emitter.emit(`disconnect`));let i=()=>{let t=e.address();if(!t)throw Error(`No account found`);return[t]};return{...n,id:se[t].id,name:se[t].name,type:se[t].type,signTransaction:e.signTransaction,connect:async t=>(r.emitter.emit(`message`,{type:`connecting`}),await e.connect({isReconnecting:t?.isReconnecting??!1}),r.storage?.removeItem(`tron.disconnected`),C(t?.withCapabilities,i(),ae.id)),disconnect:()=>(r.storage?.setItem(`tron.disconnected`,!0),e.disconnect()),getAccounts:async()=>i(),switchChain:async()=>ae,getChainId:async()=>ae.id,isAuthorized:async()=>!await r.storage?.getItem(`tron.disconnected`)&&e.isAuthorized(),...ve(r.emitter),getProvider:async()=>e,$filteredChains:h([ae])}}),wE=({walletConnectProtocol:e,runWalletEffect:t})=>{let n={iconUrl:p(`tron`),title:`Tron`,id:`tron`},r=({metaConfig:e,iconUrl:t,installUrl:r,isInjected:i,makeAdapter:a})=>()=>{let o=a(),s=()=>(o.readyState===Pn.NotFound&&i(globalThis)&&(o=a()),o);return{id:se[e].id,name:se[e].name,iconUrl:t,iconBackground:`#fff`,chainGroup:n,availability:{_tag:`Injected`,detect:y(()=>o.readyState===Pn.Found||i(globalThis)),installUrl:r},createConnector:t=>CE({walletDetailsParams:t,metaConfig:e,wallet:SE(s,se[e].id)})}},i={openUrlWhenWalletNotFound:!1};return{groupName:`Tron`,wallets:[r({metaConfig:`tronLink`,iconUrl:d(`trx`),installUrl:`https://chromewebstore.google.com/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec`,isInjected:u(bE),makeAdapter:()=>new vr(i)}),()=>({id:se.tronWc.id,name:se.tronWc.name,iconUrl:f.wcLogo,iconBackground:`#fff`,availability:{_tag:`Remote`},chainGroup:n,createConnector:n=>CE({walletDetailsParams:n,metaConfig:`tronWc`,wallet:yE({walletConnectProtocol:e,runWalletEffect:t})})}),r({metaConfig:`tronBg`,iconUrl:f.bitget,installUrl:`https://chromewebstore.google.com/detail/bitget-wallet-crypto-web3/jiidiaalihmmhddjgbnbgdfflelocpak`,isInjected:u(xE),makeAdapter:()=>new Cr(i)}),()=>({id:se.tronLedger.id,name:se.tronLedger.name,iconUrl:f.ledgerLogo,iconBackground:`#fff`,availability:{_tag:`Remote`},chainGroup:n,createConnector:e=>{let t=new hE;return CE({walletDetailsParams:e,metaConfig:`tronLedger`,wallet:SE(()=>t,se.tronLedger.id)})}})]}};export{wE as getTronConnectors};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-BcKkbAw3.js";import{t}from"./axios-Dl6BaS8Y.js";import{n,r,t as i}from"./wallet-manager-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-BcKkbAw3.js";import{t}from"./axios-Dl6BaS8Y.js";import{n,r,t as i}from"./wallet-manager-Dysx00HR.js";var a=async(e,t,n)=>await s(e,t,!1,n)===!1?Promise.reject(`Invalid endpoint.`):e,o=async(e,t,n)=>{try{let r=await Promise.any(e.map(e=>a(e,t,n)));return n?.debug(`rpcEndpoint won the race:`,r),r}catch(e){return Promise.reject(e)}},s=async(e,n,r,i)=>{if(r)return i?.debug(`Skipping test of accessibility for`,e),!0;i?.debug(`Testing accessibility of`,e);try{let r;if(r=typeof e==`string`?n===`rest`?await t.get(`${e}/cosmos/base/tendermint/v1beta1/node_info`):await t.post(e):n===`rest`?await t.get(`${e.url}/cosmos/base/tendermint/v1beta1/node_info`,{headers:e.headers}):await t.post(e.url,{headers:e.headers}),r.status==200)return i?.debug(`Access successfully.`),!0}catch(e){i?.debug(`${e.name}: ${e.message}`)}return i?.debug(`Access failed.`),!1},c=(e,t,n,r,i)=>r===void 0?n===void 0?t===void 0?e!==void 0&&e:t:n:r,l=Error(`Client Not Exist!`),u=Error(`Request Rejected!`),d=class extends Error{walletName;constructor(e){super(`Wallet ${e} is not provided.`),this.walletName=e}},f=class extends Error{name=`ConnectError`;constructor(e){super(e)}},p;(function(e){e.Init=`Init`,e.Pending=`Pending`,e.Done=`Done`,e.Error=`Error`})(p||={});var m;(function(e){e.WalletList=`WalletList`,e.Connecting=`Connecting`,e.Connected=`Connected`,e.Error=`Error`,e.NotExist=`NotExist`,e.Rejected=`Rejected`,e.QRCode=`QRCode`})(m||={});var h;(function(e){e.Disconnected=`Disconnected`,e.Connecting=`Connecting`,e.Connected=`Connected`,e.NotExist=`NotExist`,e.Rejected=`Rejected`,e.Error=`Error`})(h||={});var g=(e,t)=>{switch(e){case`Pending`:return h.Connecting;case`Done`:return h.Connected;case`Error`:switch(t){case l.message:return h.NotExist;case u.message:return h.Rejected;default:return h.Error}case`Init`:return h.Disconnected;default:return h.Disconnected}},_=[{name:`icns`,contract:`osmo1xk0s8xgktn9x5vwcgtjdxqzadg88fgn33p8u9cnpdxwemvxscvast52cdd`,chainName:`osmosis`,getQueryMsg:e=>({icns_names:{address:e}}),slip173:`osmo`},{name:`stargaze`,contract:`stars1fx74nkqkw2748av8j7ew7r3xt9cgjqduwn8m0ur5lhe49uhlsasszc5fhr`,chainName:`stargaze`,getQueryMsg:e=>({name:{address:e}}),slip173:`stars`}],v=e=>{let t=_.find(t=>t.chainName===e);if(!t)throw Error(`No such name service registered with chain `+e);return t},y=e=>_.find(t=>t.name===e),b=e({ClientNotExistError:()=>l,ConnectError:()=>f,Logger:()=>n,RejectedError:()=>u,Session:()=>i,WalletNotProvidedError:()=>d,convertChain:()=>r,getFastestEndpoint:()=>o,getIsLazy:()=>c,getNameServiceRegistryFromChainName:()=>v,getNameServiceRegistryFromName:()=>y,getWalletStatusFromState:()=>g,isValidEndpoint:()=>s});export{l as a,d as c,p as i,c as l,g as n,f as o,h as r,u as s,b as t};
|