LavaPack.loadBundle([[556,{"@metamask/utils":4109,lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=i,function(e){if(!(0,n.hasProperty)(e,"TokensController"))return;const t=e.TokensController;if(!(0,n.isObject)(t))return void global.sentry?.captureException(new Error(`Migration ${i}: Invalid TokensController state of type '${typeof t}'`));(0,n.hasProperty)(t,"allTokens")&&((0,n.isObject)(t.allTokens)?t.allTokens=s(t.allTokens,"allTokens"):global.sentry?.captureException(new Error(`Migration ${i}: Invalid allTokens state of type '${typeof t.allTokens}'`)));(0,n.hasProperty)(t,"allDetectedTokens")&&((0,n.isObject)(t.allDetectedTokens)?t.allDetectedTokens=s(t.allDetectedTokens,"allDetectedTokens"):global.sentry?.captureException(new Error(`Migration ${i}: Invalid allDetectedTokens state of type '${typeof t.allDetectedTokens}'`)));(0,n.hasProperty)(t,"tokens")&&Array.isArray(t.tokens)?t.tokens=t.tokens.filter(e=>!((0,n.isObject)(e)&&(0,n.hasProperty)(e,"decimals")&&null===e.decimals&&(0,n.hasProperty)(e,"address"))||(global.sentry?.captureMessage(`Migration ${i}: Removed token with decimals === null in tokens. Address: ${e.address}`),!1)):(0,n.hasProperty)(t,"tokens")&&global.sentry?.captureException(new Error(`Migration ${i}: Invalid tokens state of type '${typeof t.tokens}'`));(0,n.hasProperty)(t,"detectedTokens")&&Array.isArray(t.detectedTokens)?t.detectedTokens=t.detectedTokens.filter(e=>!((0,n.isObject)(e)&&(0,n.hasProperty)(e,"decimals")&&null===e.decimals&&(0,n.hasProperty)(e,"address"))||(global.sentry?.captureMessage(`Migration ${i}: Removed token with decimals === null in detectedTokens. Address: ${e.address}`),!1)):(0,n.hasProperty)(t,"detectedTokens")&&global.sentry?.captureException(new Error(`Migration ${i}: Invalid detectedTokens state of type '${typeof t.detectedTokens}'`))}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=133.1;function s(e,t){const r={};for(const[o,s]of Object.entries(e))if((0,n.isObject)(s)){const e={};for(const[r,o]of Object.entries(s))if(Array.isArray(o)){const s=o.filter(e=>(0,n.isObject)(e)&&(0,n.hasProperty)(e,"decimals")&&null===e.decimals&&(0,n.hasProperty)(e,"address")?(global.sentry?.captureMessage(`Migration ${i}: Removed token with decimals === null in ${t}. Address: ${e.address}`),!1):(0,n.isObject)(e)&&(0,n.hasProperty)(e,"decimals")&&null!==e.decimals);e[r]=s}r[o]=e}return r}}}},{package:"$root$",file:"app/scripts/migrations/133.1.ts"}],[5560,{"./commonjs/core.js":5557,"./commonjs/duplex.js":5558,"./commonjs/helpers.js":5559},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=e("./commonjs/core.js");Object.assign(r,n);var o=e("./commonjs/duplex.js");Object.assign(r,o);var i=e("./commonjs/helpers.js");r.JsonPatchError=i.PatchError,r.deepClone=i._deepClone,r.escapePathComponent=i.escapePathComponent,r.unescapePathComponent=i.unescapePathComponent}}},{package:"fast-json-patch",file:"node_modules/fast-json-patch/index.js"}],[5565,{"@firebase/app":917},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("@firebase/app");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}}))});
/**
 * @license
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @license
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
(0,n.registerVersion)("firebase","11.2.0","app")}}},{package:"@metamask/notification-services-controller>firebase",file:"node_modules/firebase/app/dist/esm/index.esm.js"}],[5566,{"@firebase/messaging":921},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("@firebase/messaging");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}}))})}}},{package:"@metamask/notification-services-controller>firebase",file:"node_modules/firebase/messaging/dist/esm/index.esm.js"}],[5567,{"@firebase/messaging/sw":922},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("@firebase/messaging/sw");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}}))})}}},{package:"@metamask/notification-services-controller>firebase",file:"node_modules/firebase/messaging/sw/dist/esm/index.esm.js"}],[557,{"@metamask/utils":4109,lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=i,function(e){if(!(0,n.hasProperty)(e,"TokensController")||!(0,n.isObject)(e.TokensController)||!(0,n.isObject)(e.TokensController.allTokens))return;const t=["0x1"];for(const r of t){const t=e.TokensController.allTokens[r];if((0,n.isObject)(t))for(const[e,r]of Object.entries(t))Array.isArray(r)&&(t[e]=r.filter(e=>"0x0000000000000000000000000000000000000000"!==e?.address))}}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=133.2}}},{package:"$root$",file:"app/scripts/migrations/133.2.ts"}],[558,{"@metamask/utils":4109,lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=i,function(e){(0,n.hasProperty)(e,"NotificationController")&&delete e.NotificationController}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=133}}},{package:"$root$",file:"app/scripts/migrations/133.ts"}],[559,{"@metamask/utils":4109,lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=i,t.data=function(e){if(!(0,n.hasProperty)(e,"AccountsController"))return global.sentry?.captureException?.(new Error(`Migration ${i}: Missing AccountsController.`)),e;const t=e.AccountsController;if(!(0,n.isObject)(t))return global.sentry?.captureException?.(new Error(`Migration ${i}: AccountsController is type '${typeof t}', expected object.`)),e;if(!(0,n.hasProperty)(t,"internalAccounts")||!(0,n.isObject)(t.internalAccounts))return global.sentry?.captureException?.(new Error(`Migration ${i}: Missing or invalid AccountsController.internalAccounts.`)),e;const{internalAccounts:r}=t;if(!(0,n.hasProperty)(r,"selectedAccount")||"string"!=typeof r.selectedAccount||""===r.selectedAccount)return e;if(!(0,n.hasProperty)(r,"accounts")||!(0,n.isObject)(r.accounts))return global.sentry?.captureException?.(new Error(`Migration ${i}: Missing or invalid internalAccounts.accounts.`)),e;const{accounts:o}=r,s=r.selectedAccount;if(!(0,n.hasProperty)(o,s)||!(0,n.isObject)(o[s]))return global.sentry?.captureException?.(new Error(`Migration ${i}: Selected account entry not found in internalAccounts.accounts.`)),e;const a=o[s];if(!(0,n.hasProperty)(a,"address")||"string"!=typeof a.address||""===a.address)return global.sentry?.captureException?.(new Error(`Migration ${i}: Invalid or missing address in selected account entry.`)),e;const c=a.address;if(!(0,n.hasProperty)(e,"NetworkController"))return global.sentry?.captureException?.(new Error(`Migration ${i}: Missing NetworkController.`)),e;const u=e.NetworkController;if(!(0,n.isObject)(u))return global.sentry?.captureException?.(new Error(`Migration ${i}: NetworkController is type '${typeof u}', expected object.`)),e;if(!(0,n.hasProperty)(u,"selectedNetworkClientId")||"string"!=typeof u.selectedNetworkClientId||!u.selectedNetworkClientId)return global.sentry?.captureException?.(new Error(`Migration ${i}: Invalid or missing selectedNetworkClientId.`)),e;const{selectedNetworkClientId:f}=u;if(!(0,n.hasProperty)(u,"networkConfigurationsByChainId")||!(0,n.isObject)(u.networkConfigurationsByChainId))return global.sentry?.captureException?.(new Error(`Migration ${i}: Missing or invalid networkConfigurationsByChainId.`)),e;const{networkConfigurationsByChainId:l}=u,d=function(e,t){for(const[r,n]of Object.entries(e))if(Array.isArray(n.rpcEndpoints))for(const e of n.rpcEndpoints)if(e.networkClientId===t)return r;return global.sentry?.captureException?.(new Error(`Migration ${i}: No chainId found for "${t}".`)),undefined}(l,f);if(!d)return global.sentry?.captureException?.(new Error(`Migration ${i}: Could not find chainId for networkClientId '${f}'.`)),e;if(!(0,n.hasProperty)(e,"TokensController"))return global.sentry?.captureException?.(new Error(`Migration ${i}: Missing TokensController.`)),e;const h=e.TokensController;if(!(0,n.isObject)(h))return global.sentry?.captureException?.(new Error(`Migration ${i}: TokensController is type '${typeof h}', expected object.`)),e;if(!(0,n.hasProperty)(h,"allTokens")||!(0,n.isObject)(h.allTokens))return global.sentry?.captureException?.(new Error(`Migration ${i}: Missing or invalid TokensController.allTokens.`)),e;const{tokens:p}=h,{allTokens:g}=h,m=g[d];if(Array.isArray(p)&&p.length>0&&!(0,n.isObject)(m))return global.sentry?.captureException?.(new Error(`Migration ${i}: tokens is not an empty array, but allTokensForChain is not an object.`)),e;if(!(0,n.isObject)(m))return e;const y=m[c];if(!Array.isArray(y))return e;return h.tokens=y,e}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=134.1}}},{package:"$root$",file:"app/scripts/migrations/134.1.ts"}],[5598,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){let n;return n=(null==r?void 0:r.registry)?r.registry.endsWith("/")?r.registry:`${r.registry}/`:"https://registry.npmjs.org/",`${n}${e}/-/${function(e){if("@"!==e[0])return e;return e.split("/")[1]}(e)}-${function(e){const t=e.indexOf("+");return-1===t?e:e.substring(0,t)}(t)}.tgz`}}}},{package:"@metamask/snaps-controllers>get-npm-tarball-url",file:"node_modules/get-npm-tarball-url/lib/index.js"}],[56,{"./state-utils":148,"@metamask/utils":4109,lodash:5981,uuid:6943},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.PatchStore=void 0;var n=e("@metamask/utils"),o=e("uuid"),i=e("lodash"),s=e("./state-utils");function a(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const c=(0,n.createProjectLogger)("patch-store");r.PatchStore=class{constructor(e){a(this,"id",void 0),a(this,"observableStore",void 0),a(this,"pendingPatches",[]),a(this,"listener",void 0),this.id=(0,o.v4)(),this.observableStore=e,this.listener=this._onStateChange.bind(this),c("Created",this.id)}init(){this.observableStore.on("stateChange",this.listener)}flushPendingPatches(){const e=this.pendingPatches;this.pendingPatches=[];for(const t of e)c("Flushed",t.path.join("."),this.id,t);return e}destroy(){this.observableStore.removeListener("stateChange",this.listener),c("Destroyed",this.id)}_onStateChange({newState:e,oldState:t,patches:r}){let n=[];if(r){const e=this._normalizeEventPatches(r,t);n=(0,s.sanitizePatches)(e??[])}else{const r=(0,s.sanitizeUIState)(e);n=this._generatePatches(t,r)}const o=Boolean(e.vault);if(o&&n.push({op:"replace",path:["isInitialized"],value:o}),n.length)for(const e of n){const t=e.path.join(".");this.pendingPatches.push(e),c("Added",t,this.id,e)}}_generatePatches(e,t){return Object.keys(t).map(r=>{const n=e[r],o=t[r];return n===o?null:{op:"replace",path:[r],value:o}}).filter(Boolean)}_normalizeEventPatches(e,t){return e?.flatMap(e=>{if(e.path.length>0)return[e];return(0,i.uniq)([...Object.keys(t),...Object.keys(e.value)]).map(t=>({op:t in e.value?"replace":"remove",path:[t],...t in e.value?{value:e.value[t]}:{}}))})}}}}},{package:"$root$",file:"app/scripts/lib/PatchStore.ts"}],[560,{"@metamask/utils":4109,lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=i,function(e){(0,n.hasProperty)(e,"AppStateController")&&(0,n.isObject)(e.AppStateController)&&(0,n.hasProperty)(e.AppStateController,"usedNetworks")&&(console.log("Removing usedNetworks from AppStateController"),delete e.AppStateController.usedNetworks)}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=134}}},{package:"$root$",file:"app/scripts/migrations/134.ts"}],[561,{"../../../shared/lib/manifestFlags":7538,"@metamask/transaction-controller":3900,"@metamask/utils":4109,lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=a,function(e){const t=(0,s.getManifestFlags)();if(!0===t.testing?.disableSmartTransactionsOverride)return e;if(!(0,n.hasProperty)(e,"PreferencesController")||!(0,n.isObject)(e.PreferencesController))return global.sentry?.captureException?.(new Error("Invalid PreferencesController state: "+typeof e.PreferencesController)),e;const{PreferencesController:r}=e,o=r.preferences?.smartTransactionsOptInStatus;o===undefined||!1===o&&!function(e){const t=e?.SmartTransactionsController?.smartTransactionsState?.smartTransactions;if(!(0,n.isObject)(t))return!1;return(t[i.CHAIN_IDS.MAINNET]||[]).length>0}(e)?e.PreferencesController.preferences={...e.PreferencesController.preferences,smartTransactionsOptInStatus:!0,smartTransactionsMigrationApplied:!0}:e.PreferencesController.preferences={...e.PreferencesController.preferences,smartTransactionsMigrationApplied:!1}}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash"),i=e("@metamask/transaction-controller"),s=e("../../../shared/lib/manifestFlags");const a=r.version=135}}},{package:"$root$",file:"app/scripts/migrations/135.ts"}],[5612,{"@ethereumjs/rlp":5614,"@metamask/eth-sig-util":2430,"aes-js":5070,bech32:5175,"bignumber.js":5630,"bn.js":5182,bs58check:5632,buffer:5233,cbor:5256,"cbor-bigdecimal":5633,"crc-32":5318,elliptic:5421,"hash.js/lib/hash/ripemd.js":5732,"lodash/inRange.js":5961,"lodash/isEmpty.js":5967,"lodash/isInteger.js":5970,ox:5720,secp256k1:5721,uuid:6943,viem:7133,zod:7313},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(r){(function(){function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o,i=Object.create,s=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,u=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,l=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of c(t))f.call(e,o)||o===r||s(e,o,{get:()=>t[o],enumerable:!(n=a(t,o))||n.enumerable});return e},d=(e,t,r)=>(r=null!=e?i(u(e)):{},l(!t&&e&&e.__esModule?r:s(r,"default",{value:e,enumerable:!0}),e)),h={};((e,t)=>{for(var r in t)s(e,r,{get:t[r],enumerable:!0})})(h,{BTC_LEGACY_XPUB_PATH:()=>te,BTC_SEGWIT_ZPUB_PATH:()=>ne,BTC_WRAPPED_SEGWIT_YPUB_PATH:()=>re,Calldata:()=>O,Client:()=>Dn,Constants:()=>C,Utils:()=>dt,addAddressTags:()=>eo,connect:()=>yo,fetchActiveWallets:()=>go,fetchAddress:()=>Mn,fetchAddressTags:()=>to,fetchAddresses:()=>Un,fetchAddressesByDerivationPath:()=>Yn,fetchBip44ChangeAddresses:()=>Zn,fetchBtcLegacyAddresses:()=>zn,fetchBtcLegacyChangeAddresses:()=>$n,fetchBtcSegwitAddresses:()=>Fn,fetchBtcSegwitChangeAddresses:()=>Gn,fetchBtcWrappedSegwitAddresses:()=>Hn,fetchBtcWrappedSegwitChangeAddresses:()=>qn,fetchBtcXpub:()=>Jn,fetchBtcYpub:()=>Xn,fetchBtcZpub:()=>Qn,fetchLedgerLegacyAddresses:()=>Kn,fetchLedgerLiveAddresses:()=>Wn,fetchSolanaAddresses:()=>Vn,getClient:()=>fe,pair:()=>bo,parseDerivationPath:()=>ge,removeAddressTags:()=>ro,setup:()=>mo,sign:()=>so,signAuthorization:()=>co,signAuthorizationList:()=>uo,signBtcLegacyTx:()=>fo,signBtcSegwitTx:()=>lo,signBtcWrappedSegwitTx:()=>ho,signMessage:()=>ao,signSolanaTx:()=>po}),t.exports=(o=h,l(s({},"__esModule",{value:!0}),o));var p=e("ox"),g=e("viem");function m(e){return`0x${r.from(p.Hash.keccak256(r.from(e))).toString("hex").slice(0,8)}`}function y(e){if("string"!=typeof e||10!==e.length&&8!==e.length)throw new Error("`sig` must be a hex string with 4 bytes of data.");return 8===e.length&&(e=`0x${e}`),e}function b(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];let o=_[n[1]];if(n[2]&&(o=`${o}${8*n[2]}`),n[3].length>0&&n[3].forEach(e=>{o=0===n[3][e]?`${o}[]`:`${o}[${n[3][e]}]`}),n[4]){const e=b(n[4]);o=`${o}(${e.join(",")})`}t.push(o)}return t}function w(e){if(P(e))return I(e);if(e.indexOf(",")>-1)return e.slice(0,e.indexOf(","));if(e.indexOf(")")>-1)return e.slice(0,e.indexOf(")"));throw new Error(k)}function E(e){if(!P(e))return[v(e)];const t={szBytes:0,typeIdx:_.indexOf("tuple"),arraySzs:[]};let r=I(e,!1);const n=e.slice(r.length);t.arraySzs=S(n),r=r.slice(1);let o=[];for(;r.length>0;){const e=w(r);r=r.slice(e.length+1),o=o.concat(E(e))}if(!o.length)throw new Error(k);return[t,o]}function v(e){const t={szBytes:0,typeIdx:0,arraySzs:[]};let r=!1;if(_.forEach((n,o)=>{if(e.indexOf(n)>-1&&!r){t.typeIdx=o,t.arraySzs=S(e);const i=t.arraySzs.length>0?e.indexOf("["):e.length,s=e.slice(n.length,i);if(parseInt(s)&&(t.szBytes=parseInt(s)/8,t.szBytes>32))throw new Error(k);r=!0}}),!r)throw new Error(k);return t}function x(e,t="",r=[],n=!1){if(!n){const n=e.name||"";r.push(n),t+=n}return e.inputs&&(t+="(",e.inputs.forEach(e=>{const n=function(e){if(!e.type)throw new Error("No type in input");const t=[e.name],{typeIdx:r,szBytes:n,arraySzs:o}=function(e){const t={szBytes:0,typeIdx:0,arraySzs:[]};let r;_.forEach((n,o)=>{e.indexOf(n)>-1&&!r&&(r=n,t.typeIdx=o)}),t.arraySzs=S(e);const n=t.arraySzs.length>0?e.indexOf("["):e.length;if(["uint","int","bytes"].indexOf(r)>-1){const o=parseInt(e.slice(r.length,n))||0;if(o>256)throw new Error("Invalid param size");t.szBytes=o/8}else t.szBytes=0;return t}(e.type);return t.push(r),t.push(n),t.push(o),t}(e);if(e.type.indexOf("tuple")>-1&&e.components){const r=x({inputs:e.components},t,[],!0);t=r.canonicalName,t+=`${e.type.slice(5)},`,n.push(r.def)}else t+=e.type,t+=",";r.push(n)}),","===t[t.length-1]&&(t=t.slice(0,t.length-1)),t+=")"),{def:r,canonicalName:t}}function B(e,t=""){const r=[];let n=0;return e.forEach((e,o)=>{Array.isArray(e)?r[r.length-1].push(B(e,`${o}-`)):r.push([`#${t}${o+1-n}`,e.typeIdx,e.szBytes,e.arraySzs]),e.typeIdx===_.indexOf("tuple")&&(n+=1)}),r}function S(e){if("string"!=typeof e)throw new Error("Invalid type");const t=[];let r=e;for(;r.length>0;){const e=r.indexOf("[");if(e<0)return t;const n=r.slice(e),o=n.indexOf("]");if(o<0)throw new Error("Bad param type");const i=n.slice(1,o);0===i.length?t.push(0):t.push(parseInt(i)),r=n.slice(o+1)}return t}function I(e,t=!0){let r=0,n=!1;for(let o=0;o<e.length;o++){"("===e[o]?(r+=1,n=!0):")"===e[o]&&(r-=1);let i=","===e[o+1]||")"===e[o+1]||o===e.length-1;if(t||"["!==e[o+1]||(i=!0),!r&&n&&i)return e.slice(0,o+1)}throw new Error(k)}function P(e){return"("===e[0]}function T(e){return"bytes"===_[e[1]]}function A(e){return T(e)&&0===e[3].length}function j(e){return T(e)&&1===e[3].length&&0===e[3][0]}var k="Could not parse canonical function name.",_=[null,"address","bool","uint","int","bytes","string","tuple","nestedDef"],O={EVM:{type:1,parsers:{parseSolidityJSONABI:function(e,t){e=y(e);const r=t.filter(e=>"function"===e.type).find(t=>m(x(t).canonicalName)===e);if(r){return{def:x(r).def}}throw new Error("Unable to find matching function in ABI")},parseCanonicalName:function(e,t){if((e=y(e))!==m(t))throw new Error("Name does not match provided sig.");const r=[],n=t.indexOf("(");if(n<0)throw new Error(k);r.push(t.slice(0,n)),t=t.slice(n+1);let o=[];for(;t.length>1;){const e=w(t);o=o.concat(E(e)),t=t.slice(e.length+1)}const i=B(o);return r.concat(i)}},processors:{getNestedCalldata:function(e,t){const n=[],o=e.slice(1),i=b(o),s="0x"+t.slice(4).toString("hex"),a=i.map(e=>e.startsWith("tuple(")?e.replace("tuple",""):e),c=(0,g.parseAbiParameters)(a.join(","));function u(e){return(e.length-4)%32==0}return(0,g.decodeAbiParameters)(c,s).forEach((e,t)=>{if(T(o[t])){let i=!0;if(j(o[t]))Array.isArray(e)?e.forEach(e=>{if("string"!=typeof e||!e.startsWith("0x"))return void(i=!1);u(r.from(e.slice(2),"hex"))||(i=!1)}):i=!1;else if(A(o[t]))if("string"==typeof e&&e.startsWith("0x")){const t=e,n=r.from(t.slice(2),"hex");i=u(n)}else i=!1;else i=!1;n.push(i?e:null)}else n.push(null)}),n},replaceNestedDefs:function(e,t){for(let r=0;r<t.length;r++){const n=j(e[1+r]),o=A(e[1+r]);if(null!==t[r]&&(n||o)){e[1+r][1]=_.indexOf("nestedDef");const o=n?t[r]:[t[r]];e[1+r]=e[1+r].concat([o])}}return e}}}},N={aesIv:[109,121,115,101,99,114,101,116,112,97,115,115,119,111,114,100],addrStrLen:129,pairingStatus:{notPaired:0,paired:1},responseMsg:{0:"",128:"Invalid Request",129:"Unsupported Version",130:"Device Busy",131:"Timeout waiting for user",132:"Request declined by user",133:"Pairing failed",134:"Pairing is currently disabled",135:"Automated signing is currently disabled",136:"Device Error",137:"Device Timeout",138:"Active wallet does not match request",139:"Device Locked",140:"Feature Disabled",141:"Record already exists on device",142:"Request failed - needs resync"},msgSizes:{header:8,checksum:4,secure:{payload:{request:{connect:66,encrypted:1733},response:{connect:215,encrypted:3457}},data:{request:{connect:65,encrypted:{encryptedData:1728,0:99,1:54,3:1680,4:0,7:9,8:1391,9:405,12:1025,13:506}},response:{encrypted:{encryptedData:1728,0:0,1:1290,3:1090,4:142,7:1395,8:0,9:0,12:1608,13:1646}}}}}},C={GET_ADDR_FLAGS:{SECP256K1_PUB:3,ED25519_PUB:4,BLS12_381_G1_PUB:5,SECP256K1_XPUB:6},SIGNING:{HASHES:{NONE:0,KECCAK256:1,SHA256:2},CURVES:{SECP256K1:0,ED25519:1,BLS12_381_G2:2},ENCODINGS:{NONE:1,SOLANA:2,EVM:4,ETH_DEPOSIT:5,EIP7702_AUTH:6,EIP7702_AUTH_LIST:7},BLS_DST:{BLS_DST_NUL:1,BLS_DST_POP:2}},ENC_DATA:{SCHEMAS:{BLS_KEYSTORE_EIP2335_PBKDF_V4:0}},ETH_CONSENSUS_SPEC:{NETWORKS:{MAINNET_GENESIS:{networkName:"mainnet",forkVersion:r.alloc(4),validatorsRoot:r.alloc(32)}},DOMAINS:{DEPOSIT:r.from("03000000","hex"),VOLUNTARY_EXIT:r.from("04000000","hex")}}},R={ETH:"ETH",BTC:"BTC",ETH_MSG:"ETH_MSG"},D=2147483648,U={PURPOSES:{ETH:D+44,BTC_LEGACY:D+44,BTC_WRAPPED_SEGWIT:D+49,BTC_SEGWIT:D+84},COINS:{ETH:D+60,BTC:D,BTC_TESTNET:D+1}},M={address:1,bool:2,uint8:3,uint16:4,uint24:5,uint32:6,uint40:7,uint48:8,uint56:9,uint64:10,uint72:11,uint80:12,uint88:13,uint96:14,uint104:15,uint112:16,uint120:17,uint128:18,uint136:19,uint144:20,uint152:21,uint160:22,uint168:23,uint176:24,uint184:25,uint192:26,uint200:27,uint208:28,uint216:29,uint224:30,uint232:31,uint240:32,uint248:33,uint256:34,int8:35,int16:36,int24:37,int32:38,int40:39,int48:40,int56:41,int64:42,int72:43,int80:44,int88:45,int96:46,int104:47,int112:48,int120:49,int128:50,int136:51,int144:52,int152:53,int160:54,int168:55,int176:56,int184:57,int192:58,int200:59,int208:60,int216:61,int224:62,int232:63,int240:64,int248:65,int256:66,uint:67,bytes1:69,bytes2:70,bytes3:71,bytes4:72,bytes5:73,bytes6:74,bytes7:75,bytes8:76,bytes9:77,bytes10:78,bytes11:79,bytes12:80,bytes13:81,bytes14:82,bytes15:83,bytes16:84,bytes17:85,bytes18:86,bytes19:87,bytes20:88,bytes21:89,bytes22:90,bytes23:91,bytes24:92,bytes25:93,bytes26:94,bytes27:95,bytes28:96,bytes29:97,bytes30:98,bytes31:99,bytes32:100,bytes:101,string:102},L={SIGN_PERSONAL:{str:"signPersonal",enumIdx:0},TYPED_DATA:{str:"typedData",enumIdx:1,rawDataMaxLen:1629,typeCodes:M}};var z,F,H,$=/^[\x00-\x7F]+$/,G=10,q={1:{name:"ethereum",baseUrl:"https://api.etherscan.io",apiRoute:"api?module=contract&action=getabi"},137:{name:"polygon",baseUrl:"https://api.polygonscan.com",apiRoute:"api?module=contract&action=getabi"},56:{name:"binance",baseUrl:"https://api.bscscan.com",apiRoute:"api?module=contract&action=getabi"},42220:{name:"celo",baseUrl:"https://api.celoscan.io",apiRoute:"api?module=contract&action=getabi"},43114:{name:"avalanche",baseUrl:"https://api.snowtrace.io",apiRoute:"api?module=contract&action=getabi"}},V=r.alloc(32),W={internal:{uid:V,external:!1,name:r.alloc(0),capabilities:0},external:{uid:V,external:!0,name:r.alloc(0),capabilities:0}},K=[D+44,D+60,D,0,0],Z=[D+44,D+0,D,0,0],Y=[D+44,D+0,D,0,0],J=[D+84,D,D,0,0],X=[D+84,D,D,1,0],Q=[D+49,D,D,0,0],ee=[D+49,D,D,0,0],te="44'/0'/0'",re="49'/0'/0'",ne="84'/0'/0'",oe=[D+44,D+501,D,D],ie=[D+49,D+60,D,0,0],se=[D+49,D+60,D,0],ae=()=>H,ce=e=>{H=e},ue=async e=>{const t=await F();if(!t)throw new Error("Client not initialized");return ae()||ce(Promise.resolve()),ce(ae().then(async()=>await e(t).catch(e=>{throw ce(Promise.resolve()),e}).then(e=>(z(t.getStateData()),e)))),ae()},fe=async()=>{const e=F?await F():void 0;if(!e)throw new Error("Client not initialized");return e},le=e=>async t=>{if(!t)return;const n=(e=>r.from(e).toString("base64"))(t);await e(n)},de=e=>async()=>{const t=await e();if(!t)return;const n=(e=>r.from(e,"base64").toString())(t);if(!n)return;const o=new Dn({stateData:n});if(!o)throw new Error("Client not initialized");return o},he=(e,t=0,r=4)=>{const n=[...e];return t>0&&(n[r]=e[r]+t),n},pe=e=>"string"!=typeof e&&"types"in e&&"domain"in e&&"primaryType"in e&&"message"in e;function ge(e){if(!e)return[];return me(e.split("/").filter(Boolean))}function me(e){return e.map(e=>{const t=e.toLowerCase();if("x"===t)return 0;if("x'"===t)return D;if(e.endsWith("'"))return parseInt(e.slice(0,-1))+D;const r=parseInt(e);if(isNaN(r))throw new Error(`Invalid part in derivation path: ${e}`);return r})}var ye,be=e("@ethereumjs/rlp"),we=d(e("aes-js"),1),Ee=d(e("bignumber.js"),1),ve=e("bn.js"),xe=e("buffer"),Be=d(e("crc-32"),1),Se=d(e("elliptic"),1),Ie=e("ox"),Pe=d(e("lodash/inRange.js"),1),Te=d(e("lodash/isInteger.js"),1),Ae=d(e("secp256k1"),1),je=e("viem"),ke=d(e("lodash/isEmpty.js"),1),_e=e=>{if("number"!=typeof e||!tt(e))throw new Error("Must be an integer between 0 and 15 inclusive");return e},Oe=e=>{if(!e)throw new Error("The number of addresses is required.");if(e>G)throw new Error("You may only request 10 addresses at once.");return e},Ne=e=>{if(!e)throw new Error("Start path is required");if(e.length<1||e.length>5)throw new Error("Path must include between 1 and 5 indices");return e},Ce=e=>{if("ECONNABORTED"===e.code&&"ETIME"===e.errno)throw new Error("Timeout waiting for device. Please ensure it is connected to the internet and try again in a minute.");throw new Error(`Failed to make request to device:\n${e.message}`)},Re=e=>{if(!e||null===e)throw new Error("No active wallet.");return e},De=e=>({appName:(e=>{if(!e)throw new Error("Name is required.");if(e.length<5||e.length>24)throw new Error("Invalid length for name provided. Must be 5-24 characters.");return e})(e.getAppName()),ephemeralPub:Ue(e.ephemeralPub),sharedSecret:Me(e.sharedSecret),url:(e=>{if(!e)throw new Error("URL does not exist. Please reconnect.");try{new URL(e)}catch(e){throw console.error("Invalid URL format:",e),new Error("Invalid URL provided. Please use a valid URL.")}return e})(e.url),fwConstants:(e=>{if(!e)throw new Error("Firmware constants do not exist. Please reconnect.");return e})(e.getFwConstants()),fwVersion:(e=>{if(!e)throw new Error("Firmware version does not exist. Please reconnect.");if("number"!=typeof e.fix||"number"!=typeof e.minor||"number"!=typeof e.major)throw new Error("Firmware version improperly formatted. Please reconnect.");return e})(e.getFwVersion()),key:Le(e.key)}),Ue=e=>{if(!e)throw new Error("`ephemeralPub` (ephemeral public key) is required. Please reconnect.");return e},Me=e=>{if(!e)throw new Error("Shared secret required. Please reconnect.");return e},Le=e=>{if(!e)throw new Error("Key is required. Please reconnect.");return e},ze=Se.default.ec,{ecdsaRecover:Fe}=Ae.default,{COINS:He,PURPOSES:$e}=U,Ge=function(e){return Be.default.buf(e)>>>0},qe=function(e,t){const r=[],n=Math.ceil(e.length/t);let o=0;for(let i=0;i<n;i++)r.push(e.slice(o,o+t)),o+=t;return r};var Ve=function(e,t=!0){try{if(null===e||("number"==typeof e&&0===e||"bigint"==typeof e&&0n===e)&&!0===t)return xe.Buffer.alloc(0);const r="number"==typeof e||"bigint"==typeof e||"string"==typeof e&&function(e){const t=new Ee.default(e).toFixed().split(".").join(""),r=new String(e);return t.slice(0,8)===r.slice(0,8)}(e);let n;if(r){const t="bigint"==typeof e?e.toString(10):e;n=new Ee.default(t).toString(16)}else if("string"==typeof e&&"0x"===e.slice(0,2))n=e.slice(2);else{if(xe.Buffer.isBuffer(e))return e;n=e.toString()}return n.length%2>0&&(n=`0${n}`),"00"!==n||r?xe.Buffer.from(n,"hex"):xe.Buffer.alloc(0)}catch(t){throw new Error(`Cannot convert ${e.toString()} to hex buffer (${t.message})`)}},We=function(e,t){const r=xe.Buffer.alloc(t);return e.length<t?(e.copy(r,t-e.length),r):e.slice(-t)},Ke=function(e,t){const r=xe.Buffer.from(N.aesIv),n=new we.default.ModeOfOperation.cbc(t,r);return xe.Buffer.from(n.decrypt(e))},Ze=function(e){if(48!==e[0]||2!==e[2])throw new Error("Failed to decode DER signature");let t=3;const r=e[t];t++;const n=e.slice(t,t+r);if(t+=r,2!==e[t])throw new Error("Failed to decode DER signature");t++;const o=e[t];t++;return{r:n,s:e.slice(t,t+o)}},Ye=function(e){return void 0===ye&&(ye=new ze("p256")),ye.keyFromPrivate(e,"hex")},Je=function(e){void 0===ye&&(ye=new ze("p256"));const t=xe.Buffer.isBuffer(e)?e.toString("hex"):e;return ye.keyFromPublic(t,"hex")},Xe=function(e,t){const r=xe.Buffer.alloc(24);let n=0;if(t&&e.length>5)throw new Error("Signer path must be <=5 indices.");if(!t&&5!==e.length)throw new Error("Your Lattice firmware only supports 5-index derivation paths. Please upgrade.");r.writeUInt32LE(e.length,n),n+=4;for(let t=0;t<5;t++)t<e.length?r.writeUInt32LE(e[t],n):r.writeUInt32LE(0,n),n+=4;return r},Qe=function(e,t){return Object.keys(t).some(r=>t[r]===e)},et=function(e){const t=xe.Buffer.alloc(e);for(let r=0;r<e;r++)t[r]=Math.round(255*Math.random());return t},tt=e=>(0,Te.default)(e)&&(0,Pe.default)(e,0,16);function rt(e,t){let r;if(e.length>1&&console.warn("WARNING: There are multiple results. Using the first one."),e.sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).find(e=>{try{return r=O.EVM.parsers.parseCanonicalName(t,e.text_signature),!!r}catch(e){return console.error("Failed to parse canonical name:",e),!1}}),r)return r;throw new Error("Could not find definition for selector")}async function nt(e,t){try{if(globalThis.caches&&globalThis.Request){const r=await caches.open("gp-calldata"),n=new Request(e,t),o=await r.match(n);if(o)return o;{const e=await fetch(n,t),o=e.clone(),i=await e.json();return e.ok&&((e=>{try{const t=JSON.parse(e.result);return!(0,ke.default)(t)}catch(e){return console.error("Invalid block explorer response:",e),!1}})(i)||(e=>{try{return!(0,ke.default)(e.results)}catch(e){return console.error("Invalid 4byte response:",e),!1}})(i))?(await r.put(n,o),r.match(n)):e}}return fetch(e,t)}catch(e){throw console.error(e),e}}async function ot(e){const t=`https://www.4byte.directory/api/v1/signatures/?hex_signature=0x${e}`;return await fetch(t).then(e=>e.json()).then(e=>{if(e&&e.results)return e.results;throw new Error("No results found")}).catch(e=>{throw new Error(`Fetching data from 4byte failed: ${e.message}`)})}function it(e){return xe.Buffer.from(be.RLP.encode(e))}async function st(e,t){const r=O.EVM.processors.getNestedCalldata(e,t),n=await async function(e){const t=[];for await(const r of e)if(null!==r)if(Array.isArray(r)){const e=[];let n=!0;for await(const t of r)try{const r=t.slice(2,10),n=rt(await ot(r),r);e.push(n)}catch(t){console.error("Failed to fetch nested 4byte data:",t),n=!1,e.push(null)}n?t.push(e):t.push(null)}else try{const e=r.slice(2,10),n=rt(await ot(e),e);t.push(n)}catch(e){console.error("Failed to fetch nested definition:",e),t.push(null)}else t.push(null);return t}(r);for await(const[e]of n.entries())if(Array.isArray(n[e])&&"string"!=typeof n[e][0])for await(const[t]of n[e].entries())null!==n[e][t]&&(n[e][t]=await st(n[e][t],xe.Buffer.from(r[e][t].slice(2),"hex")));else null!==n[e]&&(n[e]=await st(n[e],xe.Buffer.from(r[e].slice(2),"hex")));return O.EVM.processors.replaceNestedDefs(e,n)}async function at(e,t,r,n=!0){try{if(!e||e.length<2)throw new Error("Data is either undefined or less than two bytes");const o="string"==typeof e&&"0x"===e.slice(0,2)?xe.Buffer.from(e.slice(2),"hex"):xe.Buffer.from(e,"hex");if(0===o.length)return{def:null,abi:null};if(o.length<4)throw new Error("Data must contain at least 4 bytes of data to define the selector");const i=xe.Buffer.from(o.slice(0,4)).toString("hex"),s=Number(r),a=q[s],c=a||await async function(e){try{const t=await fetch("https://gridplus.github.io/chains/chains.json").then(e=>e.json());return t?t[e]:void 0}catch(e){console.warn("Fetching external networks failed.\n",e)}}(s);try{if(c){const e=await async function(e,t){const r=function({supportedChain:e,address:t}){return`${e.baseUrl}/${e.apiRoute}&address=${t}`}({address:e,supportedChain:t});return nt(r).then(e=>e.json()).then(e=>{if(!e||!e.result)throw new Error("Server response was malformed");try{return JSON.parse(e.result)}catch{throw new Error(`Invalid JSON in response: ${e.result.substring(0,50)}`)}}).catch(e=>{throw console.log(e),new Error("Fetching data from external network failed")})}(t,c);let r=O.EVM.parsers.parseSolidityJSONABI(i,e).def;return n&&(r=await st(r,o)),{abi:e,def:it(r)}}throw new Error(`Chain (id: ${s}) is not supported`)}catch(e){console.warn(e.message,"\n","Falling back to 4byte")}const u=await ot(i);let f=rt(u,i);return n&&(f=await st(f,o)),{abi:u,def:it(f)}}catch(e){console.warn(`Fetching calldata failed: ${e.message}`)}return{def:null,abi:null}}var ct=(e,t,r)=>{const n="string"==typeof e?xe.Buffer.from(e):e,o="string"==typeof t?xe.Buffer.from(t):t,i="string"==typeof r?xe.Buffer.from(r):r,s=xe.Buffer.concat([n,o,i]);return xe.Buffer.from(Ie.Hash.sha256(s))},ut=function(e,t){let r,n,o,i=!1;if(!xe.Buffer.isBuffer(e)&&"string"!=typeof e)throw new Error("Unsupported transaction format. Expected Buffer or hex string.");{const t=xe.Buffer.isBuffer(e)?`0x${e.toString("hex")}`:e,s=xe.Buffer.isBuffer(e)?e:xe.Buffer.from(e.slice(2),"hex");n=xe.Buffer.from(Ie.Hash.keccak256(s));try{const e=(0,je.parseTransaction)(t);if(o=e.type,void 0!==e.chainId&&null!==e.chainId&&(r=e.chainId.toString(),"legacy"===o&&(i=!0)),"legacy"===o&&!i){const e=be.RLP.decode(s);if(e.length>=9){const t=e[6];t&&t.length>0&&(r=new ve.BN(t).toString(),i=!0)}}}catch(t){console.error("Failed to parse transaction, trying legacy format:",t);try{const t=xe.Buffer.isBuffer(e)?e:xe.Buffer.from(e.slice(2),"hex"),n=be.RLP.decode(t);if(o="legacy",n.length>=9){const e=n[6];e&&e.length>0&&(r=new ve.BN(e).toString(),i=!0)}}catch{throw new Error("Could not recover V. Bad transaction data.")}}}const s=xe.Buffer.isBuffer(t.sig.r)?t.sig.r:xe.Buffer.from(t.sig.r.slice(2),"hex"),a=xe.Buffer.isBuffer(t.sig.s)?t.sig.s:xe.Buffer.from(t.sig.s.slice(2),"hex"),c=new Uint8Array(xe.Buffer.concat([s,a])),u=t.pubkey;if(!u)throw new Error("Response did not include a public key.");let f;if(xe.Buffer.isBuffer(u))f=xe.Buffer.from(u);else if(u instanceof Uint8Array)f=xe.Buffer.from(u);else if("string"==typeof u){const e=u.startsWith("0x")?u.slice(2):u;f=xe.Buffer.from(e,"hex")}else f=xe.Buffer.from(u);64===f.length&&(f=xe.Buffer.concat([xe.Buffer.from([4]),f]));const l=33===f.length&&(2===f[0]||3===f[0]),d=65===f.length&&4===f[0];if(!l&&!d)throw new Error("Unsupported public key format returned by device.");const h=xe.Buffer.from(Fe(c,0,n,l)),p=xe.Buffer.from(Fe(c,1,n,l)),g=f.toString("hex"),m=h.toString("hex"),y=p.toString("hex");let b;if(g===m)b=0;else{if(g!==y)throw new Error("Failed to recover V parameter. Bad signature or transaction data.");b=1}const w=ft(b,{chainId:r,useEIP155:i,type:o});return xe.Buffer.isBuffer(w)?0===w.length?new ve.BN(0):new ve.BN(w.toString("hex"),16):w},ft=function(e,t={}){const{chainId:r,useEIP155:n,type:o}=t;return 1===o||2===o||4===o||"eip2930"===o||"eip1559"===o||"eip7702"===o?Ve(e,!0):n&&r?new ve.BN(r).muln(2).addn(35).addn(e):new ve.BN(e).addn(27)},lt=function(e,t,r){if("object"==typeof e&&e&&"messageHash"in e)return lt(e.messageHash,e.signature,e.publicKey);if(t&&t.sig&&t.pubkey&&!r)return lt(e,t.sig,t.pubkey);if(!t||!r)throw new Error("Response with sig and pubkey required for legacy format");if(!t.r||!t.s)throw new Error("Response with sig and pubkey required for legacy format");let n=e;if("object"==typeof e&&e&&"function"==typeof e.getMessageToSign){const t=e._type;if(null!=t)n=e.getMessageToSign(!0);else{const t=be.RLP.encode(e.getMessageToSign(!1));n=xe.Buffer.from(Ie.Hash.keccak256(t))}}else xe.Buffer.isBuffer(e)&&32!==e.length&&(n=xe.Buffer.from(Ie.Hash.keccak256(e)));const o=e=>{if(!e)throw new Error("Invalid data");if(xe.Buffer.isBuffer(e))return e;if(e instanceof Uint8Array)return xe.Buffer.from(e);if("string"==typeof e)return xe.Buffer.from(e.replace(/^0x/i,""),"hex");throw new Error("Invalid data type")},i=o(n),s=o(t.r),a=o(t.s),c=o(r),u=32===i.length?i:xe.Buffer.from(Ie.Hash.keccak256(i)),f=new Uint8Array(xe.Buffer.concat([s,a])),l=new Uint8Array(u),d=33===c.length;for(let e=0;e<=1;e++)try{const t=Fe(f,e,l,d);if(xe.Buffer.from(t).equals(c))return e}catch{continue}throw new Error("Failed to recover Y parity. Bad signature or transaction data.")},dt={fetchCalldataDecoder:at,generateAppSecret:ct,getV:ut,getYParity:lt,convertRecoveryToV:ft},ht=e("ox"),pt=e("bech32"),gt=d(e("bs58check"),1),mt=e("ox"),yt=e("hash.js/lib/hash/ripemd.js"),bt=r.from("01","hex"),{PURPOSES:wt,COINS:Et}=U,vt=0,xt=169,Bt=118,St=135,It=136,Pt=172,Tt=208,At=240;function jt(e,t){return r.concat([e,t])}function kt(e){const t=r.alloc(4);return t.writeUInt32LE(e,0),t}function _t(e){let t;return e<253?(t=r.alloc(1),t.writeUInt8(e,0)):e<=65535?(t=r.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967295?(t=r.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=r.alloc(9),t.writeUInt8(255,0),t.writeUInt32LE(e>>>0,1),t.writeUInt32LE(e/4294967296|0,5)),t}function Ot(e,t,n){"number"==typeof e&&(e=e.toString(16));const o=r.alloc(8),i=e.length%2==0?e.toString(16):`0${e.toString(16)}`;return r.from(i,"hex").reverse().copy(o,0),o.copy(t,n),o}function Nt(e){let t,n;try{t=gt.default.decode(e)[0],n=r.from(gt.default.decode(e).slice(1))}catch(o){console.error("Failed to decode base58 address, trying bech32:",o);try{const o=pt.bech32.decode(e);if("bc"===o.prefix)t=Tt;else{if("tb"!==o.prefix)throw new Error("Unsupported prefix: must be bc or tb.");t=At}if(0!==o.words[0])throw new Error(`Unsupported segwit version: must be 0, got ${o.words[0]}`);if(33!==o.words.length){const t=53===o.words.length;throw new Error(`Unsupported address${t?" (P2WSH not supported)":""}: ${e}`)}n=r.from(pt.bech32.fromWords(o.words.slice(1)))}catch(t){throw new Error(`Unable to decode address: ${e}: ${t.message}`)}}return{versionByte:t,pkh:n}}function Ct(e){if(e.length<2)throw new Error("Path must be >1 index");const t=e[0],r=e[1];if(t===wt.BTC_SEGWIT&&r===Et.BTC)return Tt;if(t===wt.BTC_SEGWIT&&r===Et.BTC_TESTNET)return At;if(t===wt.BTC_WRAPPED_SEGWIT&&r===Et.BTC)return 5;if(t===wt.BTC_WRAPPED_SEGWIT&&r===Et.BTC_TESTNET)return 196;if(t===wt.BTC_LEGACY&&r===Et.BTC)return 0;if(t===wt.BTC_LEGACY&&r===Et.BTC_TESTNET)return 111;throw new Error("Invalid Bitcoin path provided. Cannot determine address format.")}function Rt(e){switch(e.signerPath[0]){case wt.BTC_LEGACY:return 1;case wt.BTC_WRAPPED_SEGWIT:return 3;case wt.BTC_SEGWIT:return 4;default:throw new Error(`Unsupported path purpose (${e.signerPath[0]}): cannot determine BTC script type.`)}}var Dt={buildBitcoinTxRequest:function(e){const{prevOuts:t,recipient:n,value:o,changePath:i,fee:s}=e;if(!i)throw new Error("No changePath provided.");if(5!==i.length)throw new Error("Please provide a full change path.");const a=r.alloc(59+69*t.length);let c=0;const u=Ct(i);a.writeUInt8(u,0),c++,a.writeUInt32LE(i.length,c),c+=4;for(let e=0;e<i.length;e++)a.writeUInt32LE(i[e],c),c+=4;a.writeUInt32LE(s,c),c+=4;const f=Nt(n);a.writeUInt8(f.versionByte,c),c++,f.pkh.copy(a,c),c+=f.pkh.length,Ot(o,a,c),c+=8,a.writeUInt8(t.length,c),c++;let l=0;return t.forEach(e=>{if(!e.signerPath||5!==e.signerPath.length)throw new Error("Full recipient path not specified ");a.writeUInt32LE(e.signerPath.length,c),c+=4;for(let t=0;t<e.signerPath.length;t++)a.writeUInt32LE(e.signerPath[t],c),c+=4;a.writeUInt32LE(e.index,c),c+=4,Ot(e.value,a,c),c+=8,l+=e.value;const t=Rt(e);a.writeUInt8(t,c),c++,r.isBuffer(e.txHash)||(e.txHash=r.from(e.txHash,"hex")),e.txHash.copy(a,c),c+=e.txHash.length}),{payload:a,schema:0,origData:e,changeData:{value:l-(o+s)}}},serializeTx:function(e){const{inputs:t,outputs:n,lockTime:o=0}=e;let i=r.alloc(4),s=0;const a=function(e){let t=!1;return e.forEach(e=>{e.signerPath[0]!==wt.BTC_SEGWIT&&e.signerPath[0]!==wt.BTC_WRAPPED_SEGWIT||(t=!0)}),t}(t);i.writeUInt32LE(2,s),s+=4,a&&(i=jt(i,r.from("00","hex")),i=jt(i,r.from("01","hex")));const c=_t(t.length);i=jt(i,c),s+=c.length,t.forEach(e=>{i=jt(i,e.hash.reverse()),s+=e.hash.length;const t=kt(e.index);i=jt(i,t),s+=t.length;const n=Rt(e);if(3===n){const t=function(e){const t=r.alloc(22),n=r.from(mt.Hash.sha256(e)),o=r.from((0,yt.ripemd160)().update(n).digest("hex"),"hex");return t.writeUInt8(vt,0),t.writeUInt8(o.length,1),o.copy(t,2),t}(e.pubkey),n=_t(t.length),o=r.concat([n,t]),a=_t(o.length);i=jt(i,a),s+=a.length,i=jt(i,o),s+=o.length}else if(1===n){const t=function(e,t){const n=_t((e=r.concat([e,bt])).length),o=_t(t.length),i=r.concat([n,e,o,t]),s=_t(i.length);return r.concat([s,i])}(e.sig,e.pubkey);i=jt(i,t),s+=t.length}else if(4===n){const e=r.from("00","hex");i=jt(i,e),s+=1}const o=kt(4294967295);i=jt(i,o),s+=o.length});const u=_t(n.length);if(i=jt(i,u),s+=u.length,n.forEach(e=>{const t=function(e){const t=r.alloc(8);return Ot(e,t,0),t}(e.value);i=jt(i,t),s+=t.length;const n=function(e){const t=Nt(e);switch(t.versionByte){case Tt:case At:return function(e){const t=r.alloc(2+e.length);return t.writeUInt8(vt,0),t.writeUInt8(e.length,1),e.copy(t,2),t}(t.pkh);case 5:case 196:return function(e){const t=r.alloc(3+e.length);let n=0;return t.writeUInt8(xt,n),n++,t.writeUInt8(e.length,n),n++,e.copy(t,n),n+=e.length,t.writeUInt8(St,n),n++,t}(t.pkh);case 0:case 111:return function(e){const t=r.alloc(5+e.length);let n=0;return t.writeUInt8(Bt,n),n++,t.writeUInt8(xt,n),n++,t.writeUInt8(e.length,n),n++,e.copy(t,n),n+=e.length,t.writeUInt8(It,n),n++,t.writeUInt8(Pt,n),n++,t}(t.pkh);default:throw new Error(`Unknown version byte: ${t.versionByte}. Cannot build BTC transaction.`)}}(e.recipient),o=_t(n.length);i=jt(i,o),s+=o.length,i=jt(i,n),s+=n.length}),a){const e=[],n=[];for(let r=0;r<t.length;r++)e.push(t[r].sig),n.push(t[r].pubkey);const o=function(e,t){let n=r.alloc(0);const o=r.alloc(1);o.writeUInt8(2,0);for(let i=0;i<e.length;i++){const s=r.concat([e[i],bt]),a=_t(s.length),c=t[i],u=_t(c.length);n=r.concat([n,o,a,s,u,c])}return n}(e,n);i=jt(i,o),s+=o.length}return r.concat([i,kt(o)]).toString("hex")},getBitcoinAddress:function(e,t){let n=null,o=null;if(t===Tt?(n="bc",o=0):t===At&&(n="tb",o=0),null!==n&&null!==o){const t=pt.bech32.toWords(e);return t.unshift(o),pt.bech32.encode(n,t)}return gt.default.encode(r.concat([r.from([t]),e]))},getAddressFormat:Ct},Ut=d(e("bignumber.js"),1),Mt=e("@metamask/eth-sig-util"),Lt=e("ox"),zt=e("@ethereumjs/rlp"),Ft=d(e("secp256k1"),1),Ht=d(e("cbor"),1),$t=d(e("cbor-bigdecimal"),1),Gt=e("viem"),qt=0,Vt=1,Wt=2,Kt=4,Zt=5,Yt=e("ox"),Jt=e("@ethereumjs/rlp"),Xt=e("viem"),Qt=function(e){const{signerPath:t,curveType:n,hashType:o,encodingType:i=null,decoder:s=null,omitPubkey:a=!1,fwConstants:c,blsDst:u=C.SIGNING.BLS_DST.BLS_DST_NUL}=e,{extraDataFrameSz:f,extraDataMaxFrames:l,prehashAllowed:d,genericSigning:h,varAddrPathSzAllowed:p}=c,{curveTypes:g,encodingTypes:m,hashTypes:y,baseDataSz:b,baseReqSz:w,calldataDecoding:E}=h,v=rr(e.payload,i,m),{encoding:x}=v;let{payloadBuf:B}=v;const S=B;let I=B.length;const P=b+l*f;if(!I)throw new Error("Payload could not be handled.");if(!(h&&f&&l&&d))throw new Error("Unsupported. Please update your Lattice firmware.");if(!Qe(n,g))throw new Error("Unsupported curve type.");if(!Qe(o,y))throw new Error("Unsupported hash type.");const T=s&&E&&s.length<=E.maxSz,A=T&&B.length+s.length<=P;if(T&&A){const e=r.alloc(8+s.length);e.writeUInt32LE(E.reserved,0),e.writeUInt32LE(s.length,4),r.from(s).copy(e,8),B=r.concat([B,e])}if(n===g.ED25519){if(o!==y.NONE)throw new Error("Signing on ed25519 requires unhashed message");t.forEach(e=>{if(e<D)throw new Error("Signing on ed25519 requires all signer path indices be hardened.")})}else if(n===g.BLS12_381_G2){const e=r.alloc(4);e.writeUInt32LE(u),B=r.concat([e,B]),I+=e.length}const j=r.alloc(w);let k=0;j.writeUInt32LE(x,k),k+=4,j.writeUInt8(o,k),k+=1,j.writeUInt8(n,k),k+=1;const _=Xe(t,p);_.copy(j,k),k+=_.length,j.writeUInt8(a?1:0,k),k+=1;const O=[];let N=null,R=!1;if(B.length>b)if(d&&B.length>P){j.writeUInt16LE(B.length,k),k+=2,R=!0;const e=B.slice(0,I);if(o===y.NONE)throw new Error("Message too large to send and could not be prehashed (hashType=NONE).");if(o===y.KECCAK256)N=r.from(Yt.Hash.keccak256(e));else{if(o!==y.SHA256)throw new Error("Unsupported hash type.");N=r.from(Yt.Hash.sha256(e))}}else{qe(B.slice(b),f).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),O.push(r.concat([t,e]))})}R||(j.writeUInt16LE(I,k),k+=2);return(N||B).copy(j,k),{payload:j,extraDataPayloads:O,schema:5,curveType:n,encodingType:i,hashType:o,omitPubkey:a,origPayloadBuf:S}};function er(e,t){if(t&&32===t.length&&t.some(e=>0!==e))return t;if(e.hashType===C.SIGNING.HASHES.SHA256)return r.from(Yt.Hash.sha256(e.origPayloadBuf));if(e.hashType===C.SIGNING.HASHES.KECCAK256)return r.from(Yt.Hash.keccak256(e.origPayloadBuf));throw new Error("Unsupported hash type for message hash computation.")}function tr(e,t,r){if(t.encodingType===C.SIGNING.ENCODINGS.EVM)try{const n=`0x${t.origPayloadBuf.toString("hex")}`,o=(0,Xt.parseTransaction)(n),i={chainId:o.chainId,to:o.to??void 0,value:o.value??0n,data:o.data??"0x",nonce:o.nonce??0n,gas:o.gas??o.gasLimit??0n};void 0!==o.maxFeePerGas&&(i.maxFeePerGas=o.maxFeePerGas),void 0!==o.maxPriorityFeePerGas&&(i.maxPriorityFeePerGas=o.maxPriorityFeePerGas),void 0!==o.gasPrice&&(i.gasPrice=o.gasPrice),void 0!==o.accessList&&(i.accessList=o.accessList),void 0!==o.authorizationList&&(i.authorizationList=o.authorizationList),void 0!==o.type&&null!==o.type&&(i.type=o.type);const s="legacy"===o.type||void 0===o.type?{v:e,r:r.sig.r,s:r.sig.s}:{yParity:Number(e),r:r.sig.r,s:r.sig.s};r.viemTx=(0,Xt.serializeTransaction)(i,s)}catch(e){console.debug("Failed to build viemTx from response",e)}}var rr=function(e,t,n){if(t||(t=C.SIGNING.ENCODINGS.NONE),!Qe(t,n))throw new Error("Encoding not supported by Lattice firmware. You may want to update.");let o;if(!e)throw new Error("No payload included");return o="string"==typeof e&&"0x"===e.slice(0,2)?r.from(e.slice(2),"hex"):r.from(e),{payloadBuf:o,encoding:t}},nr=e("zod"),or=e("viem"),ir=nr.z.union([nr.z.string().regex(/^(0x[0-9a-fA-F]+|[0-9]+)$/,"Invalid number format"),nr.z.number(),nr.z.bigint()]).transform((e,t)=>{try{const r="string"==typeof e&&(0,or.isHex)(e)?(0,or.hexToBigInt)(e):BigInt(e);return r<0n?(t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Value must be non-negative"}),nr.z.NEVER):r}catch{return t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Invalid numeric value"}),nr.z.NEVER}}),sr=ir.refine(e=>e>=0n,{message:"Gas values must be non-negative"}),ar=nr.z.union([nr.z.string(),nr.z.number()]).transform(e=>"string"==typeof e&&(0,or.isHex)(e)?Number((0,or.hexToBigInt)(e)):Number(e)).refine(e=>Number.isInteger(e)&&e>0,{message:"Chain ID must be a positive integer"}),cr=nr.z.string().refine(or.isAddress,"Invalid address").transform(e=>(0,or.getAddress)(e)),ur=nr.z.string().refine(or.isHex,"Data must be a valid hex string").default("0x"),fr=nr.z.union([nr.z.string().regex(/^(0x[0-9a-fA-F]+|[0-9]+)$/,"Invalid nonce format"),nr.z.number().int().nonnegative(),nr.z.bigint()]).transform((e,t)=>{try{const r="string"==typeof e?(0,or.isHex)(e)?(0,or.hexToBigInt)(e):BigInt(e):"number"==typeof e?BigInt(e):e;if(r<0n)return t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Nonce must be non-negative"}),nr.z.NEVER;return r>BigInt(Number.MAX_SAFE_INTEGER)?(t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Nonce exceeds JavaScript safe integer range"}),nr.z.NEVER):Number(r)}catch{return t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Invalid nonce value"}),nr.z.NEVER}}),lr=nr.z.object({address:cr,storageKeys:nr.z.array(nr.z.string().refine(or.isHex,"Storage key must be a hex string"))}),dr=nr.z.object({chainId:nr.z.number().int().positive(),address:cr,nonce:nr.z.number().int().nonnegative(),yParity:nr.z.number().optional().default(0),r:nr.z.string().refine(or.isHex).optional(),s:nr.z.string().refine(or.isHex).optional()}),hr=nr.z.object({to:cr.optional(),value:ir.optional(),data:ur,nonce:fr.optional(),gas:sr.optional(),gasLimit:sr.optional(),chainId:ar.optional().default(1),accessList:nr.z.array(lr).optional()}),pr=hr.extend({type:nr.z.union([nr.z.literal("legacy"),nr.z.literal(qt)]).optional(),gasPrice:sr}),gr=hr.extend({type:nr.z.union([nr.z.literal("eip2930"),nr.z.literal(Vt)]),gasPrice:sr}),mr=hr.extend({type:nr.z.union([nr.z.literal("eip1559"),nr.z.literal(Wt)]),maxFeePerGas:sr,maxPriorityFeePerGas:sr}),yr=hr.extend({type:nr.z.union([nr.z.literal("eip7702"),nr.z.literal(Kt),nr.z.literal(Zt)]),maxFeePerGas:sr,maxPriorityFeePerGas:sr,authorizationList:nr.z.array(dr).min(1)}),br=nr.z.any().refine(e=>{try{return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t),!0}catch{return!1}},{message:"Circular reference detected in transaction object"}).transform(e=>(e.gasLimit&&(e.gas=e.gasLimit),null!==e.data&&void 0!==e.data&&""!==e.data||(e.data="0x"),e.authorization&&(e.authorizationList=[e.authorization]),e)).transform(e=>{const t=!!e.authorizationList,r=!!e.maxFeePerGas||!!e.maxPriorityFeePerGas,n=!!e.accessList,o=!!e.gasPrice;let i="legacy",s=pr;if("eip7702"===e.type||4===e.type||5===e.type||t?(i="eip7702",s=yr):"eip1559"===e.type||2===e.type||r?(i="eip1559",s=mr):("eip2930"===e.type||1===e.type||n)&&(i="eip2930",s=gr),"legacy"===i&&!o)throw new Error("Legacy transactions require a `gasPrice` field.");const a=s.parse(e);return a.type=i,"legacy"===i&&void 0===a.gas&&(a.gas=21000n),"legacy"!==i&&"eip2930"!==i&&delete a.gasPrice,"eip1559"!==i&&"eip7702"!==i&&(delete a.maxFeePerGas,delete a.maxPriorityFeePerGas),delete a.gasLimit,"eip7702"!==i&&delete a.authorizationList,a}),{ecdsaRecover:wr}=Ft.default;(0,$t.default)(Ht.default);function Er(e){if(null==e)return e;if("string"==typeof e){const t=e.trim();if(/^0x[0-9a-fA-F]+$/.test(t))try{const e=BigInt(t);return e<=BigInt(Number.MAX_SAFE_INTEGER)&&e>=BigInt(Number.MIN_SAFE_INTEGER)?Number(e):e.toString(10)}catch{return t}return t}if("bigint"==typeof e){const t=Number(e);return Number.isSafeInteger(t)?t:e.toString(10)}if(Ut.default.isBigNumber(e)){const t=Number(e.toString(10));return Number.isSafeInteger(t)?t:e.toString(10)}if(e&&"object"==typeof e&&"function"==typeof e.toString&&e.constructor&&"BN"===e.constructor.name&&"function"==typeof e.toArray){const t=e.toString(10),r=Number(t);return Number.isSafeInteger(r)?r:t}if(r.isBuffer(e)||e instanceof Uint8Array)return`0x${r.from(e).toString("hex")}`;if(Array.isArray(e))return e.map(e=>Er(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=Er(n);return t}return e}function vr(e){return void 0===e?e:Br?Br(e):xr(e)}function xr(e){if(null===e||"object"!=typeof e)return e;if(r.isBuffer(e))return r.from(e);if(e instanceof Uint8Array)return new Uint8Array(e);if(Array.isArray(e))return e.map(e=>xr(e));if(Ut.default.isBigNumber(e))return new Ut.default(e);if(e&&"object"==typeof e&&"BN"===e.constructor?.name&&"function"==typeof e.clone)return e.clone();if(e instanceof Date)return new Date(e.getTime());const t={};for(const[r,n]of Object.entries(e))t[r]=xr(n);return t}var Br="undefined"!=typeof globalThis&&"function"==typeof globalThis.structuredClone?globalThis.structuredClone:null;function Sr(e){let t=e[0];for(;e.length>0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e}function Ir(e,t,n,o={}){try{const i=new Uint8Array(e),s=r.isBuffer(n)?n:Ve(n,!1);if(20!==s.length)throw new Error("Invalid signer address provided.");let a=0;const c=We(t.r,32);t.r=c;const u=We(t.s,32);t.s=u;const f=new Uint8Array(r.concat([c,u]));let l=wr(f,a,i,!1).slice(1);const d=s.toString("hex"),h=[];let p=Pr(l);if(h.push(p),p===d)return t.v=Tr(a,o),t;if(a=1,l=wr(f,a,i,!1).slice(1),p=Pr(l),h.push(p),p===d)return t.v=Tr(a,o),t;throw new Error(`Invalid Ethereum signature returned. expected=${d}, recovered=${h.join(",")}`)}catch(e){if(e instanceof Error)throw e;throw new Error(String(e))}}function Pr(e){return r.from(Lt.Hash.keccak256(e)).slice(-20).toString("hex")}function Tr(e,t={}){const n=ft(e,t);return r.isBuffer(n)?n:Ve(`0x${n.toString(16)}`)}var Ar={mainnet:1,roptsten:3,rinkeby:4,kovan:42,goerli:5};function jr(e){let t,n;if(t=!0===kr(e)?Ve(e):Ve(`0x${new Ut.default(e).toString(16)}`),t.length>8)throw new Error("ChainID provided is too large.");return t.length<=2||4===t.length||8===t.length?t:(3===t.length?(n=r.alloc(4),n.writeUInt32BE(e)):t.length<=8&&(n=r.alloc(8),t.copy(n,8-t.length)),n)}function kr(e){if("string"!=typeof e)return!1;if("0x"!==e.slice(0,2))return!1;try{return!1===new Ut.default(e,16).isNaN()}catch(e){return console.error("Invalid chain ID hex string:",e),!1}}function _r(e,t){const{ethMaxMsgSz:n,extraDataFrameSz:o,extraDataMaxFrames:i}=t.fwConstants,s=n,a=o>0&&i>0,c=[];if(e.length>s){const t=s+i*o;if(!a)throw new Error(`Your message is ${e.length} bytes, but can only be a maximum of ${s}`);if(a&&e.length>t)throw new Error(`Your message is ${e.length} bytes, but can only be a maximum of ${t}`);qe(e.slice(s),o).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),c.push(r.concat([t,e]))})}return c}function Or(e,t,r,n=!1){return r[t].forEach(t=>{const o=t.type.indexOf("[")>-1,i=o?t.type.slice(0,t.type.indexOf("[")):t.type,s=Object.keys(r).indexOf(i)>-1;if(s&&Array.isArray(e))for(let o=0;o<e.length;o++)e[o][t.name]=Or(e[o][t.name],i,r,n);else if(s)e[t.name]=Or(e[t.name],i,r,n);else if(Array.isArray(e))for(let r=0;r<e.length;r++)if(o)for(let o=0;o<e[r][t.name].length;o++)e[r][t.name][o]=Nr(e[r][t.name][o],i,n);else e[r][t.name]=Nr(e[r][t.name],i,n);else if(o)for(let r=0;r<e[t.name].length;r++)e[t.name][r]=Nr(e[t.name][r],i,n);else e[t.name]=Nr(e[t.name],i,n)}),e}function Nr(e,t,n=!1){if("bytes"===t)e=Ve(e),n&&(e=`0x${e.toString("hex")}`);else if("bytes"===t.slice(0,5)){const o=parseInt(t.slice(5));if(0===(e=Ve(e)).length&&(e=r.alloc(o)),e.length!==o)throw new Error(`Expected ${t} type, but got ${e.length} bytes`);n&&(e=`0x${e.toString("hex")}`)}else if("address"===t){if(0===(e=Ve(e)).length&&(e=r.alloc(20)),20!==e.length)throw new Error(`Address type must be 20 bytes, but got ${e.length} bytes`);n&&(e=`0x${e.toString("hex")}`)}else if(L.TYPED_DATA.typeCodes[t]&&-1===t.indexOf("uint")&&t.indexOf("int")>-1)if(n){e=new Ut.default(e).toFixed()}else e=new Ut.default(e);else if(L.TYPED_DATA.typeCodes[t]&&(t.indexOf("uint")>-1||t.indexOf("int")>-1)){let t=Ve(e);0===t.length&&(t=r.from("00","hex")),e=n?`0x${t.toString("hex")}`:new Ut.default(t.toString("hex"),16)}else"bool"===t&&(e=!0===e?1:0);return e}function Cr(e){return r.from(`Ethereum Signed Message:\n${e.toString()}`,"utf-8")}function Rr(e,t){return t?r.concat([r.from([t]),r.from(zt.RLP.encode(e))]):r.from(zt.RLP.encode(e))}var Dr=e=>{const t=br.parse(e);return{...t,to:t.to,data:t.data,gas:t.gas,value:t.value,nonce:t.nonce,chainId:t.chainId,gasPrice:"gasPrice"in t?t.gasPrice:void 0,maxFeePerGas:"maxFeePerGas"in t?t.maxFeePerGas:void 0,maxPriorityFeePerGas:"maxPriorityFeePerGas"in t?t.maxPriorityFeePerGas:void 0,accessList:"accessList"in t?t.accessList:void 0,authorizationList:"authorizationList"in t?t.authorizationList:void 0}},Ur=function(e){const t=Dr(e),n=(0,Gt.serializeTransaction)(t);return r.from(n.slice(2),"hex")},Mr=function(e){if(!e.payload||!e.protocol||!e.signerPath)throw new Error("You must provide `payload`, `signerPath`, and `protocol` arguments in the messsage request");if(e.signerPath.length>5||e.signerPath.length<2)throw new Error("Please provide a signer path with 2-5 indices");const t={schema:3,payload:null,input:e,msg:null};switch(e.protocol){case"signPersonal":return function(e,t){const n=t.fwConstants.ethMaxMsgSz,o=t.fwConstants.varAddrPathSzAllowed,i=24+n+4;let s=0;e.payload=r.alloc(i),e.payload.writeUInt8(L.SIGN_PERSONAL,0),s+=1;const a=Xe(t.signerPath,o);a.copy(e.payload,s),s+=a.length;let c=t.payload,u=!1;if("string"==typeof t.payload)if("0x"===t.payload.slice(0,2))c=Ve(t.payload),u=!1===$.test(r.from(t.payload.slice(2),"hex").toString());else{if(!1===function(e,t=!1){if("string"!=typeof e)return!1;const r=t?[32,10]:[];for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(r.indexOf(n)<0&&(n<32||n>127))return!1}return!0}(t.payload))throw new Error("Currently, the Lattice can only display ASCII strings.");c=r.from(t.payload)}else if("boolean"==typeof t.displayHex)u=t.displayHex;else{if(!t.payload.toString)throw new Error("Unsupported input data type");u=!1===$.test(t.payload.toString())}const f=t.fwConstants;let l=n+f.extraDataMaxFrames*f.extraDataFrameSz;f.personalSignHeaderSz&&(l-=f.personalSignHeaderSz);if(f.ethMsgPreHashAllowed&&c.length>l){e.payload.writeUInt8(u,s),s+=1,e.payload.writeUInt16LE(c.length,s),s+=2;const t=r.from(Lt.Hash.keccak256(r.concat([Cr(c.length),c])));t.copy(e.payload,s),e.prehash=t}else{const r=_r(c,t);e.extraDataPayloads=r,e.msg=c,e.payload.writeUInt8(u,s),s+=1,e.payload.writeUInt16LE(c.length,s),s+=2,c.copy(e.payload,s)}return e}(t,e);case"eip712":if(!e.fwConstants.eip712Supported)throw new Error("EIP712 is not supported by your Lattice firmware version. Please upgrade.");return function(e,t){const{ethMaxMsgSz:n,varAddrPathSzAllowed:o,eip712MaxTypeParams:i}=t.fwConstants,{TYPED_DATA:s}=L,a=24+n+4;let c=0;e.payload=r.alloc(a),e.payload.writeUInt8(s.enumIdx,0),c+=1;const u=Xe(t.signerPath,o);u.copy(e.payload,c),c+=u.length;const f=vr(t.payload);if(!f.primaryType||!f.types[f.primaryType])throw new Error("primaryType must be specified and the type must be included.");if(!f.message||!f.domain)throw new Error("message and domain must be specified.");if(0>Object.keys(f.types).indexOf("EIP712Domain"))throw new Error("EIP712Domain type must be defined.");const l=vr(f);l.message=Or(vr(f.message),vr(f.primaryType),vr(f.types),!0),l.domain=Or(vr(f.domain),"EIP712Domain",vr(f.types),!0),e.validationPayload=l,f.domain=Or(f.domain,"EIP712Domain",f.types,!1),f.message=Or(f.message,f.primaryType,f.types,!1);const d=r.from(Ht.default.encode(f)),h=t.fwConstants,p=n+h.extraDataMaxFrames*h.extraDataFrameSz;let g=d.length>p;if(Object.keys(f.types).forEach(e=>{f.types[e].length>i&&(g=!0)}),h.ethMsgPreHashAllowed&&g){e.payload.writeUInt16LE(d.length,c),c+=2;const t=Mt.TypedDataUtils.eip712Hash(e.validationPayload,Mt.SignTypedDataVersion.V4);r.from(t).copy(e.payload,c),e.prehash=t}else{const r=_r(d,t);e.extraDataPayloads=r,e.payload.writeUInt16LE(d.length,c),c+=2,d.copy(e.payload,c),c+=d.length,e.payload=e.payload.slice(0,c)}return e}(t,e);default:throw new Error("Unsupported protocol")}},Lr=function(e,t){const{signer:n,sig:o}=e,{input:i,msg:s,prehash:a=null}=t;if("signPersonal"===i.protocol){return Ir(a||r.from(Lt.Hash.keccak256(r.concat([Cr(s.length),s]))),o,n,{chainId:1,useEIP155:!1})}if("eip712"===i.protocol){const e=t.validationPayload||t.input.payload,r=t.validationPayload?vr(t.validationPayload):Er(e),s=Mt.TypedDataUtils.eip712Hash(r,Mt.SignTypedDataVersion.V4),c=a||s;let u=i.payload.domain?.chainId||r.domain?.chainId;return"string"==typeof u?u=u.startsWith("0x")?parseInt(u,16):parseInt(u,10):"bigint"==typeof u&&(u=Number(u)),Ir(c,o,n,{chainId:u,useEIP155:!1})}throw new Error("Unsupported protocol")},zr=function(e){try{let{chainId:t=1}=e;const{signerPath:n,eip155:o=null,fwConstants:i,type:s=null}=e,{contractDeployKey:a,extraDataFrameSz:c,extraDataMaxFrames:u,prehashAllowed:f}=i,l=c>0&&u>0,d=i.ethMaxDataSz,h=i.varAddrPathSzAllowed;if("number"!=typeof t&&!1===kr(t)&&(t=Ar[t]),!t)throw new Error("Unsupported chain ID or name");if(!n)throw new Error("`signerPath` not provided");if(null===e.to&&!a)throw new Error("Contract deployment not supported. Please update your Lattice firmware.");const p=null===e.to&&a,g=i.allowedEthTxTypes&&i.allowedEthTxTypes.indexOf(2)>-1,m=i.allowedEthTxTypes&&i.allowedEthTxTypes.indexOf(1)>-1,y=g&&(2===s||"eip1559"===s),b=m&&(1===s||"eip2930"===s);if(null!==s&&!y&&!b)throw new Error("Unsupported Ethereum transaction type");let w=function(e){switch(e){case 3:case 4:return!1;default:return!0}}(t);null!==o&&"boolean"==typeof o?w=o:(y||b)&&(w=!1),e.value||(e.value=0);const E=[],v=Ve(t),x=Ve(e.nonce);let B;const S=Ve(e.gasLimit);let I,P;p?(I=r.alloc(0),P=Ve(a)):(I=Ve(e.to),P=Ve(e.to));const T=Ve(e.value),A=Ve(e.data);let j,k;if((y||b)&&E.push(v),E.push(x),y){if(!e.maxPriorityFeePerGas)throw new Error("EIP1559 transactions must include `maxPriorityFeePerGas`");j=Ve(e.maxPriorityFeePerGas),E.push(j),k=Ve(e.maxFeePerGas),E.push(k),B=k}else B=Ve(e.gasPrice),E.push(B);E.push(S),E.push(I),E.push(T),E.push(A);let _=!1;if(y||b){const t=[];Array.isArray(e.accessList)&&e.accessList.forEach(e=>{const r=[];e.storageKeys.forEach(e=>{r.push(Ve(e))}),t.push([Ve(e.address),r]),_=!0}),E.push(t)}else!0===w&&(E.push(v),E.push(Ve(null)),E.push(Ve(null)));const O=122,N=r.alloc(d+O);let C,R=0;N.writeUInt8(Number(w),R),R++;let D=0;if(!0===function(e){const t=jr(e);return 1!==t.length||255===t.readUInt8(0)}(t)){if(C=jr(t),D=C.length,D>8)throw new Error("ChainID provided is too large.");N.writeUInt8(255,R),R++}else{if(C=Ve(t),1!==C.length)throw new Error("Error parsing chainID");C.copy(N,R),R+=C.length}const U=Xe(n,h);if(U.copy(N,R),R+=U.length,x.length>4)throw new Error("Nonce too large");if(x.copy(N,R+(4-x.length)),R+=4,B.length>8)throw new Error("Gas price too large");if(B.copy(N,R+(8-B.length)),R+=8,S.length>4)throw new Error("Gas limit too large");if(S.copy(N,R+(4-S.length)),R+=4,20!==P.length)throw new Error("Invalid `to` address");if(P.copy(N,R),R+=20,T.length>32)throw new Error("Value too large");T.copy(N,R+(32-T.length)),R+=32;let M=!1;if(i.allowedEthTxTypes)if(_&&(M=!0),N.writeUInt8(M?1:0,R),R+=1,y){if(N.writeUInt8(2,R),R+=1,j.length>8)throw new Error("maxPriorityFeePerGasBytes too large");j.copy(N,R+(8-j.length)),R+=8}else b?(N.writeUInt8(1,R),R+=1,R+=8):R+=9;const L=[];let z=null;const F=A.length||0,H=D>0?D+1:0,$=r.alloc(F+H);if(H>0&&($.writeUInt8(D,0),C.copy($,1)),A.copy($,H),F>d){const e=F+H,t=d+u*c;if(f&&e>t)z=r.from(Lt.Hash.keccak256(Rr(E,s)));else{if(!l||l&&e>t)throw new Error(`Data field too large (got ${A.length}; must be <=${t-H} bytes)`);qe($.slice(d),c).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),L.push(r.concat([t,e]))})}}else M&&(z=r.from(Lt.Hash.keccak256(Rr(E,s))));return N.writeUInt16BE(A.length,R),R+=2,D>0&&(N.writeUInt8(D,R),R++,C.copy(N,R),R+=D),z?(z.copy(N,R),R+=d):(A.slice(0,d).copy(N,R),R+=d),{rawTx:E,type:s,payload:N.slice(0,R),extraDataPayloads:L,schema:1,chainId:t,useEIP155:w,signerPath:n}}catch(e){return{err:e.message}}},Fr=function(e,t,n){const o=Ir(r.from(Lt.Hash.keccak256(Rr(e.rawTx,e.type))),t,n,e),i=e.useEIP155?e.rawTx.slice(0,-3):e.rawTx;i.push(o.v),i.push(Sr(o.r)),i.push(Sr(o.s));const s=r.from(zt.RLP.encode(i)),a=e.type?r.concat([r.from([e.type]),s]):s;return e.type===Kt||e.type===Zt?a.toString("hex"):{rawTx:a.toString("hex"),sigWithV:o}},Hr=function(e){return Lt.Hash.keccak256(r.from(e,"hex"))},$r=Ur,Gr=class extends Error{constructor(e,t){const r=(({responseCode:e,errorMessage:t})=>{const r=[];return e&&r.push(`${N.responseMsg[e]}`),t&&(r.push("Error Message: "),r.push(t)),r.join("\n")})({responseCode:e,errorMessage:t});super(r),this.responseCode=e,this.errorMessage=t,this.name="LatticeResponseError",this.responseCode=e,this.errorMessage=t}},qr=(e,t=!1)=>{const n=e.getPublic().encode("hex",!1),o=r.from(n,"hex");if(!0===t){const e=o.slice(1,33).reverse(),t=o.slice(33,65).reverse();return r.concat([o[0],e,t])}return o},Vr=function(e){let t="m";return e.forEach(e=>{t+=e>=D?`/${e-D}'`:`/${e}`}),t},Wr=async({url:e,payload:t,timeout:r=6e4})=>async function(e,t){const{timeout:r=8e3}=t,n=new AbortController,o=setTimeout(()=>n.abort(),r),i=await fetch(e,{...t,signal:n.signal});return clearTimeout(o),i}(e,{method:"POST",body:JSON.stringify({data:t}),headers:{"Content-Type":"application/json"},timeout:r}).catch(Ce).then(e=>e.json()).then(e=>{if(!e||!e.message)throw new Error("Invalid response");if(200!==e.status)throw new Error(`Error code ${e.status}: ${e.message}`);const{data:t,errorMessage:r,responseCode:n}=function(e){const t={errorMessage:null,data:null},r=xe.Buffer.from(e,"hex");let n=0;const o=r.readUInt8(n);if(n++,1!==o)return t.errorMessage="Incorrect protocol version. Please update your SDK",t;const i=r.readUInt8(n);if(n++,0!==i)return t.errorMessage="Incorrect response from Lattice1",t;r.readUInt32BE(n),n+=4;const s=r.readUInt16BE(n);n+=2;const a=r.slice(n,n+s);n+=s;const c=a.readUInt8(0);if(0!==c){const e=N.responseMsg[c];return t.errorMessage=`[Lattice] ${e||"Unknown Error"}`,t.responseCode=c,t}return t.data=a.slice(1,a.length),r.readUInt32BE(n)!==Ge(r.slice(0,r.length-4))?(t.errorMessage="Invalid checksum from device response",t.data=null,t):t}(e.message);if(r||n)throw new Gr(n,r);return t});var Kr=(e,t)=>(r,n)=>Zr({fn:r,params:{...n,client:e},retries:t,client:e}),Zr=async({fn:e,params:t,retries:r,client:n})=>e({...t}).catch(async o=>{if(o instanceof Gr){const s=o.errorMessage,a=o.responseCode;if((s||a)&&r){if((e=>130===e||137===e)(a))await(i=3e3,new Promise(e=>setTimeout(e,i)));else if((e=>138===e)(a)&&!n.skipRetryOnWrongWallet)await n.fetchActiveWallet();else{if(!(e=>142===e)(a))throw o;await n.connect(n.deviceId)}return Zr({fn:e,params:t,retries:r-1,client:n})}}var i;throw o}),{msgSizes:Yr}=N,{secure:Jr}=Yr;async function Xr({url:e,pubkey:t}){const n=function(e){const t=r.alloc(Jr.data.request.connect);return e.pubkey.copy(t,0),t}({pubkey:t}),o=en(et(4),1,n),i=await Wr({url:e,payload:o});if(i.length!==Jr.payload.response.connect-1)throw new Error("Wrong Lattice response message size.");return i}async function Qr({data:e,requestType:t,sharedSecret:n,ephemeralPub:o,url:i}){const s=et(4),a=function({data:e,requestType:t,ephemeralPub:n,sharedSecret:o}){if(e.length>Jr.data.request.encrypted.encryptedData)throw new Error("Encrypted request data too large");Ue(n);const i=Jr.data.request.encrypted[t];if(e.length!==i)throw new Error(`Invalid request datasize (wanted ${i}, got ${e.length})`);const s=r.alloc(1+i);s[0]=t,e.copy(s,1);const a=Ge(s),c=r.alloc(Jr.data.request.encrypted.encryptedData);s.copy(c,0),c.writeUInt32LE(a,s.length);const u=function(e,t){const r=xe.Buffer.from(N.aesIv),n=new we.default.ModeOfOperation.cbc(t,r),o=e.length%16==0?e:we.default.padding.pkcs7.pad(e);return xe.Buffer.from(n.encrypt(o))}(c,o),f=(e=>{const t=r.from(ht.Hash.sha256(e));return parseInt(t.slice(0,4).toString("hex"),16)})(o),l=r.alloc(Jr.payload.request.encrypted-1);return l.writeUInt32LE(f),u.copy(l,4),l}({data:e,requestType:t,ephemeralPub:o,sharedSecret:n}),c=en(s,2,a),u=await Wr({url:i,payload:c});if(u.length!==Jr.payload.response.encrypted-1)throw new Error("Wrong Lattice response message size.");return function({encPayloadData:e,requestType:t,sharedSecret:r}){const n=Ke(e,r),o=65,i=o+Jr.data.response.encrypted[t],s={ephemeralPub:n.slice(0,o),data:n.slice(o,i),checksum:n.readUInt32BE(i)},a=Ge(n.slice(0,i));if(s.checksum!==a)throw new Error("Checksum mismatch in decrypted Lattice data");const c=Jr.data.response.encrypted[t];if(s.data.length!==c)throw new Error("Incorrect response data returned from Lattice");const u=Je(s.ephemeralPub);return{decryptedData:s.data,newEphemeralPub:u}}({encPayloadData:u.slice(0,Jr.data.response.encrypted.encryptedData),requestType:t,sharedSecret:n})}function en(e,t,n){if(4!==e.length)throw new Error("msgId must be four bytes");if(1!==t&&2!==t)throw new Error("Invalid Lattice secure request type");const o=1===t&&n.length===Jr.payload.request.connect-1,i=2===t&&n.length===Jr.payload.request.encrypted-1;let s,a=Yr.header+Yr.checksum;const c={requestType:t,data:n};if(o)s=Jr.payload.request.connect;else{if(!i)throw new Error("Invalid Lattice secure request payload size");s=Jr.payload.request.encrypted}a+=s;const u={header:{version:1,type:2,id:e,len:s},payload:c},f=r.alloc(a);let l=0;if(f.writeUInt8(u.header.version,l),l+=1,f.writeUInt8(u.header.type,l),l+=1,u.header.id.copy(f,l),l+=u.header.id.length,f.writeUInt16BE(u.header.len,l),l+=2,f.writeUInt8(u.payload.requestType,l),l+=1,u.payload.data.copy(f,l),l+=u.payload.data.length,f.writeUInt32BE(Ge(f.slice(0,l)),l),l+=4,l!==a)throw new Error("Failed to build request message");return f}async function tn({client:e,records:t,type:r,caseSensitive:n}){const{url:o,sharedSecret:i,ephemeralPub:s,fwConstants:a}=De(e);rn({records:t,fwConstants:a});const c=nn({records:t,type:r,caseSensitive:n,fwConstants:a}),{decryptedData:u,newEphemeralPub:f}=await Qr({data:c,requestType:8,sharedSecret:i,ephemeralPub:s,url:o});return e.mutate({ephemeralPub:f}),u}var rn=({records:e,fwConstants:t})=>{((e,t)=>{if(!t||!t.kvActionsAllowed)throw new Error("Unsupported. Please update firmware.");if("object"!=typeof e||Object.keys(e).length<1)throw new Error("One or more key-value mapping must be provided in `records` param.");if(Object.keys(e).length>t.kvActionMaxNum)throw new Error(`Too many keys provided. Please only provide up to ${t.kvActionMaxNum}.`)})(e,t)},nn=({records:e,type:t,caseSensitive:n,fwConstants:o})=>{const i=r.alloc(1+139*o.kvActionMaxNum);i.writeUInt8(Object.keys(e).length,0);let s=1;return Object.entries(e).forEach(([e,a])=>{const{key:c,val:u}=(({key:e,val:t},r)=>{if("string"!=typeof e||String(e).length>r.kvKeyMaxStrSz)throw new Error(`Key ${e} too large. Must be <=${r.kvKeyMaxStrSz} characters.`);if("string"!=typeof t||String(t).length>r.kvValMaxStrSz)throw new Error(`Value ${t} too large. Must be <=${r.kvValMaxStrSz} characters.`);if(0===String(e).length||0===String(t).length)throw new Error("Keys and values must be >0 characters.");if(!$.test(e)||!$.test(t))throw new Error("Unicode characters are not supported.");return{key:e,val:t}})({key:e,val:a},o);i.writeUInt32LE(0,s),s+=4,i.writeUInt32LE(t,s),s+=4,i.writeUInt8(n?1:0,s),s+=1,i.writeUInt8(String(c).length+1,s),s+=1,r.from(String(c)).copy(i,s),s+=o.kvKeyMaxStrSz+1,i.writeUInt8(String(u).length+1,s),s+=1,r.from(String(u)).copy(i,s),s+=o.kvValMaxStrSz+1}),i};async function on({client:e,id:t}){const{deviceId:r,key:n,baseUrl:o}=sn({deviceId:t,key:e.key,baseUrl:e.baseUrl}),i=`${o}/${r}`,s=await Xr({url:i,pubkey:e.publicKey}),{isPaired:a,fwVersion:c,activeWallets:u,ephemeralPub:f}=await an(s,n);return e.mutate({deviceId:r,ephemeralPub:f,url:i,isPaired:a,fwVersion:c,activeWallets:u}),a&&!(e=>((e,t)=>{const{major:r,minor:n,fix:o}=e,{major:i,minor:s,fix:a}=t;return r>i||r>=i&&n>s||r>=i&&n>=s&&o>=a})(e,{major:0,minor:14,fix:1}))(e.getFwVersion())&&await e.fetchActiveWallet(),a}var sn=({deviceId:e,key:t,baseUrl:r})=>{const n=(e=>{if(!e)throw new Error("No device ID has been stored. Please connect with your device ID first.");return e})(e),o=Le(t),i=(e=>{if(!e)throw new Error("Base URL is required.");try{new URL(e)}catch(e){throw console.error("Invalid Base URL format:",e),new Error("Invalid Base URL provided. Please use a valid URL.")}return e})(r);return{deviceId:n,key:o,baseUrl:i}},an=(e,t)=>{let n=0;const o=e.readUInt8(n)===N.pairingStatus.paired;n++;const i=e.slice(n,n+65).toString("hex");n+=65;const s=Je(i),a=e.slice(n,n+4);if(n+=4,o){const i=e.slice(n,n+160);n+=160;const c=((e,t)=>r.from(e.derive(t.getPublic()).toArray("be",32)))(t,s),u=Ke(i,c);if(0!==u[u.length-2]||0!==u[u.length-1])throw new Error("Failed to connect to Lattice.");const f=(e=>{let t=0;const r={internal:{uid:void 0,capabilities:void 0,name:void 0,external:!1},external:{uid:void 0,capabilities:void 0,name:void 0,external:!0}};return r.internal.uid=e.slice(t,t+32),t+=71,r.external.uid=e.slice(t,t+32),r})(u);return{isPaired:o,fwVersion:a,activeWallets:f,ephemeralPub:s}}return{isPaired:o,fwVersion:a,activeWallets:void 0,ephemeralPub:s}},cn=e("uuid"),{ENC_DATA:un}=C,fn="Unknown encrypted data export type requested. Exiting.",ln={CIPHERTEXT:32,SALT:32,CHECKSUM:32,IV:16,PUBKEY:48};async function dn({client:e,schema:t,params:r}){const{url:n,sharedSecret:o,ephemeralPub:i,fwVersion:s}=De(e),a=Re(e.getActiveWallet());hn({params:r});const c=pn({schema:t,params:r,fwVersion:s,activeWallet:a}),{decryptedData:u,newEphemeralPub:f}=await Qr({data:c,requestType:12,sharedSecret:o,ephemeralPub:i,url:n});return e.mutate({ephemeralPub:f}),gn({data:u,schema:t,params:r})}var hn=({params:e})=>{Ne(e.path)},pn=({schema:e,params:t,fwVersion:n,activeWallet:o})=>{if(n.major<1&&n.minor<17)throw new Error("Firmware version >=v0.17.0 is required for encrypted data export.");if(e!==un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4)throw new Error(fn);t.walletUID=o.uid;const i=r.alloc(1025);let s=0;if(i.writeUInt8(e,s),s+=1,e===un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4){t.walletUID.copy(i,s),s+=t.walletUID.length,i.writeUInt8(t.path.length,s),s+=1;for(let e=0;e<5;e++)e<=t.path.length&&i.writeUInt32LE(t.path[e],s),s+=4;return t.c&&i.writeUInt32LE(t.c,s),s+=4,i}throw new Error(fn)},gn=({data:e,schema:t,params:r})=>{let n=0;if(t===un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4){const t={},{CIPHERTEXT:o,SALT:i,CHECKSUM:s,IV:a,PUBKEY:c}=ln,u=4+o+i+s+a+c,f=e.readUInt32LE(n);if(n+=4,f!==u)throw new Error("Invalid data returned from Lattice. Expected EIP2335 data.");return t.iterations=e.readUInt32LE(n),n+=4,t.cipherText=e.slice(n,n+o),n+=o,t.salt=e.slice(n,n+i),n+=i,t.checksum=e.slice(n,n+s),n+=s,t.iv=e.slice(n,n+a),n+=a,t.pubkey=e.slice(n,n+c),n+=c,mn(t,r.path)}throw new Error(fn)},mn=(e,t)=>{try{const{iterations:n,salt:o,checksum:i,iv:s,cipherText:a,pubkey:c}=e;return r.from(JSON.stringify({version:4,uuid:(0,cn.v4)(),path:Vr(t),pubkey:c.toString("hex"),crypto:{kdf:{function:"pbkdf2",params:{dklen:32,c:n,prf:"hmac-sha256",salt:o.toString("hex")},message:""},checksum:{function:"sha256",params:{},message:i.toString("hex")},cipher:{function:"aes-128-ctr",params:{iv:s.toString("hex")},message:a.toString("hex")}}}))}catch(e){throw Error(`Failed to format EIP2335 return data: ${e.toString()}`)}};async function yn({client:e}){const{url:t,sharedSecret:n,ephemeralPub:o}=De(e),{decryptedData:i,newEphemeralPub:s}=await Qr({data:r.alloc(0),requestType:4,sharedSecret:n,ephemeralPub:o,url:t}),a=(e=>{if(!e||e?.internal?.uid?.equals(V)&&e?.external?.uid?.equals(V))throw new Error("No active wallet.");return e})(bn(i));return e.mutate({ephemeralPub:s,activeWallets:a}),a}var bn=e=>{const t={internal:{uid:V,external:!1,name:r.alloc(0),capabilities:0},external:{uid:V,external:!0,name:r.alloc(0),capabilities:0}};let n=0;return t.internal.uid=e.slice(n,n+32),t.internal.capabilities=e.readUInt32BE(n+32),t.internal.name=e.slice(n+36,n+71),n+=71,t.external.uid=e.slice(n,n+32),t.external.capabilities=e.readUInt32BE(n+32),t.external.name=e.slice(n+36,n+71),t};async function wn({client:e,startPath:t,n:r,flag:n,iterIdx:o}){const{url:i,sharedSecret:s,ephemeralPub:a,fwConstants:c}=De(e),u=Re(e.getActiveWallet()),{startPath:f,n:l,flag:d}=En({startPath:t,n:r,flag:n}),h=vn({startPath:f,n:l,flag:d,fwConstants:c,wallet:u,iterIdx:o}),{decryptedData:p,newEphemeralPub:g}=await Qr({data:h,requestType:1,sharedSecret:s,ephemeralPub:a,url:i});return e.mutate({ephemeralPub:g}),xn(p,d)}var En=({startPath:e,n:t,flag:r})=>({startPath:Ne(e),n:Oe(t),flag:_e(r)}),vn=({startPath:e,n:t,flag:n,fwConstants:o,wallet:i,iterIdx:s})=>{if(!((o.getAddressFlags||[]).indexOf(n)>-1&&(4===n||3===n||5===n))&&!(6===n)&&!function(e,t){const r=[$e.ETH,$e.BTC_LEGACY,$e.BTC_WRAPPED_SEGWIT,$e.BTC_SEGWIT],n=[He.ETH,He.BTC,He.BTC_TESTNET];return!((e[1]===He.BTC||e[1]===He.BTC_TESTNET)&&e[0]!==$e.BTC_WRAPPED_SEGWIT&&!t.allowBtcLegacyAndSegwitAddrs)&&r.indexOf(e[0])>=0&&(n.indexOf(e[1])>=0||[60,61,966,700,9006,9e3,1007,553,178,137,37310,108,40,889,1987,820,6060,1620,1313114,76,246529,246785,1001,227,916,464,2221,344,73799,246].indexOf(e[1]-D)>0)}(e,o))throw new Error("Derivation path or flag is not supported. Try updating Lattice firmware.");if(e.length<2||e.length>5)throw new Error("Derivation path must include 2-5 indices.");if(s<0||s>5)throw new Error("Iteration index must be between 0 and 5.");if(s>e.length)throw new Error("Iteration index cannot be greater than path depth.");const a=r.alloc(54);let c=0;i.uid.copy(a,c),c+=32;const u=(15&s)<<4|15&e.length;a.writeUInt8(u,c),c+=1;for(let t=0;t<5;t++){const r=t<e.length?e[t]:0;a.writeUInt32BE(r,c),c+=4}const f=15&t,l=(15&n)<<4;return a.writeUInt8(f|l,c),a},xn=(e,t)=>{let r=0;const n=4===t?113:65,o=[],i=3===t||4===t||5===t;i&&(r+=1);const s=N.msgSizes.secure.data.response.encrypted[1];for(;r<s;)if(i){const i=e.slice(r,r+n),s=i.every(e=>0===e);s||4!==t?s||5!==t?s||o.push(i):o.push(i.slice(0,48)):o.push(i.slice(0,32)),r+=n}else{const t=e.slice(r,r+N.addrStrLen);r+=N.addrStrLen;const n=t.indexOf(0);if(n>0){const e=t.slice(0,n).toString().replace(/[\x00-\x1F\x7F-\x9F]/g,"");o.push(e)}}return o};async function Bn({client:e,type:t,n:r,start:n}){const{url:o,sharedSecret:i,ephemeralPub:s,fwConstants:a}=De(e),{type:c,n:u,start:f}=Sn({type:t,n:r,start:n,fwConstants:a}),l=In({type:c,n:u,start:f}),{decryptedData:d,newEphemeralPub:h}=await Qr({data:l,requestType:7,sharedSecret:i,ephemeralPub:s,url:o});return e.mutate({ephemeralPub:h}),Pn(d,a)}var Sn=({fwConstants:e,n:t,type:r,start:n})=>{if(!e.kvActionsAllowed)throw new Error("Unsupported. Please update firmware.");if(!t||t<1)throw new Error("You must request at least one record.");if(t>e.kvActionMaxNum)throw new Error(`You may only request up to ${e.kvActionMaxNum} records at once.`);if(0!==r&&!r)throw new Error("You must specify a type.");if(0!==n&&!n)throw new Error("You must specify a type.");return{fwConstants:e,n:t,type:r,start:n}},In=({type:e,n:t,start:n})=>{const o=r.alloc(9);return o.writeUInt32LE(e,0),o.writeUInt8(t,4),o.writeUInt32LE(n,5),o},Pn=(e,t)=>{let r=0;const n=e.readUInt32BE(r);r+=4;const o=parseInt(e.slice(r,r+1).toString("hex"),16);if(r+=1,o>t.kvActionMaxNum)throw new Error("Too many records fetched. Firmware error.");const i=[];for(let n=0;n<o;n++){const n={};n.id=e.readUInt32BE(r),r+=4,n.type=e.readUInt32BE(r),r+=4,n.caseSensitive=1===parseInt(e.slice(r,r+1).toString("hex"),16),r+=1;const o=parseInt(e.slice(r,r+1).toString("hex"),16);r+=1,n.key=e.slice(r,r+o-1).toString(),r+=t.kvKeyMaxStrSz+1;const s=parseInt(e.slice(r,r+1).toString("hex"),16);r+=1,n.val=e.slice(r,r+s-1).toString(),r+=t.kvValMaxStrSz+1,i.push(n)}return{records:i,total:n,fetched:o}};async function Tn({client:e,pairingSecret:t}){const{url:r,sharedSecret:n,ephemeralPub:o,appName:i,key:s}=De(e),a=An({pairingSecret:t,key:s,appName:i}),{newEphemeralPub:c}=await Qr({data:a,requestType:0,sharedSecret:n,ephemeralPub:o,url:r});return e.mutate({ephemeralPub:c,isPaired:!0}),await e.fetchActiveWallet(),e.hasActiveWallet()}var An=({key:e,pairingSecret:t,appName:n})=>{const o=qr(e),i=r.alloc(25);t.length>0&&i.write(n);const s=ct(o,i,r.from(t)),a=function(e){const t=xe.Buffer.alloc(74);return xe.Buffer.from(e.toDER()).copy(t),t}(e.sign(s));return r.concat([i,a])};async function jn({client:e,type:t,ids:r}){const{url:n,sharedSecret:o,ephemeralPub:i,fwConstants:s}=De(e),{type:a,ids:c}=kn({fwConstants:s,type:t,ids:r}),u=_n({type:a,ids:c,fwConstants:s}),{decryptedData:f,newEphemeralPub:l}=await Qr({data:u,requestType:9,sharedSecret:o,ephemeralPub:i,url:n});return e.mutate({ephemeralPub:l}),f}var kn=({fwConstants:e,type:t,ids:r})=>{if(!e.kvActionsAllowed)throw new Error("Unsupported. Please update firmware.");if(!Array.isArray(r)||r.length<1)throw new Error("You must include one or more `ids` to removed.");if(r.length>e.kvRemoveMaxNum)throw new Error(`Only up to ${e.kvRemoveMaxNum} records may be removed at once.`);if(0!==t&&!t)throw new Error("You must specify a type.");return{type:t,ids:r}},_n=({fwConstants:e,type:t,ids:n})=>{const o=r.alloc(5+4*e.kvRemoveMaxNum);o.writeUInt32LE(t,0),o.writeUInt8(n.length,4);for(let e=0;e<n.length;e++){const t=parseInt(n[e]);o.writeUInt32LE(t,5+4*e)}return o},On=e("ox");async function Nn({client:e,data:t,currency:r,cachedData:n,nextCode:o}){try{const{url:i,sharedSecret:s,ephemeralPub:a,fwConstants:c}=De(e),u=Re(e.getActiveWallet()),{requestData:f,isGeneric:l}=(({data:e,currency:t,fwConstants:r})=>{if("ETH"===t&&(e=>e.genericSigning&&e.genericSigning.encodingTypes&&e.genericSigning.encodingTypes.EVM)(r)){let t;console.log("Using the legacy ETH signing path. This will soon be deprecated. Please switch to general signing request.");try{t=$r(e)}catch(e){throw console.error("Failed to convert legacy Ethereum transaction:",e),new Error("Could not convert legacy request. Please switch to a general signing request. See gridplus-sdk docs for more information.")}return e={fwConstants:r,encodingType:C.SIGNING.ENCODINGS.EVM,curveType:C.SIGNING.CURVES.SECP256K1,hashType:C.SIGNING.HASHES.KECCAK256,signerPath:e.signerPath,payload:t},{requestData:Qt({...e,fwConstants:r}),isGeneric:!0}}return"ETH"===t?{requestData:zr({...e,fwConstants:r}),isGeneric:!1}:"ETH_MSG"===t?{requestData:Mr({...e,fwConstants:r}),isGeneric:!1}:"BTC"===t?{requestData:Dt.buildBitcoinTxRequest({...e,fwConstants:r}),isGeneric:!1}:{requestData:Qt({...e,fwConstants:r}),isGeneric:!0}})({data:t,currency:r,fwConstants:c}),{payload:d,hasExtraPayloads:h}=Cn({fwConstants:c,wallet:u,requestData:f,cachedData:n,nextCode:o}),{decryptedData:p,newEphemeralPub:g}=await Qr({data:d,requestType:3,sharedSecret:s,ephemeralPub:a,url:i});if(e.mutate({ephemeralPub:g}),h)return e.sign({data:t,currency:r,cachedData:f,nextCode:p.slice(0,8)});return Rn({data:p,request:f,isGeneric:l,currency:r})}catch(e){throw console.error("Error signing transaction:",{message:e.message,payload:JSON.stringify({data:t,currency:r},(e,t)=>"bigint"==typeof t?t.toString():t)}),e}}var Cn=({fwConstants:e,wallet:t,requestData:n,cachedData:o,nextCode:i})=>{let s,a,c=0;const u=n;if(o&&i){const e=o,t=e.extraDataPayloads.shift();if(!t)throw new Error("No cached extra payload available for multipart sign request.");u.extraDataPayloads&&(u.extraDataPayloads=e.extraDataPayloads),s=r.concat([i,t]),a=4,c=Number((e.extraDataPayloads?.length??0)>0)}else s=u.payload,a=u.schema,c=Number((u.extraDataPayloads?.length??0)>0);const f=r.alloc(2+e.reqMaxDataSz);let l=0;return f.writeUInt8(c,l),l+=1,f.writeUInt8(a,l),l+=1,t.uid?.copy(f,l),l+=t.uid?.length??0,s.copy(f,l),{payload:f,hasExtraPayloads:c}},Rn=({data:e,request:t,isGeneric:n,currency:o})=>{let i=0;if(o===R.BTC){const n=t,o=20,s=760,a=Dt.getAddressFormat(n.origData.changePath),c=e.slice(i,i+o);i+=o;const u=Dt.getBitcoinAddress(c,a),f=33,l=[],d=[];let h=0;for(;i<e.length&&48===e[i];){const t=i,r=i+2+e[i+1];d.push(e.slice(t,r)),i+=74;const n=h*f+s,o=(h+1)*f+s;l.push(e.slice(n,o)),h+=1}const p={inputs:[],outputs:[]};p.outputs.push({value:n.origData.value,recipient:n.origData.recipient}),n.changeData?.value&&n.changeData.value>0&&p.outputs.push({value:n.changeData.value,recipient:u});for(let e=0;e<d.length;e++)p.inputs.push({hash:n.origData.prevOuts[e].txHash,index:n.origData.prevOuts[e].index,sig:d[e],pubkey:l[e],signerPath:n.origData.prevOuts[e].signerPath});const g=Dt.serializeTx(p),m=g,y=r.from(On.Hash.sha256(r.from(m,"hex")));return{tx:g,txHash:`0x${r.from(On.Hash.sha256(y)).toString("hex")}`,changeRecipient:u,sigs:d}}if(o!==R.ETH||n){if(o===R.ETH_MSG){const r=Ze(e.slice(i,i+2+e[i+1]));i+=74;const n=e.slice(i,i+20),o=Lr({signer:n,sig:r},t);return{sig:{v:BigInt(`0x${o.v.toString("hex")}`),r:`0x${o.r.toString("hex")}`,s:`0x${o.s.toString("hex")}`},signer:`0x${n.toString("hex")}`}}return function(e,t,n){const o={pubkey:null,sig:null};let i;if(n.curveType===C.SIGNING.CURVES.SECP256K1){if(n.omitPubkey)t+=65;else{const n=e.readUInt8(t);if(t+=1,2===n||3===n)o.pubkey=r.alloc(33),o.pubkey.writeUInt8(n,0),e.slice(t,t+32).copy(o.pubkey,1);else{if(4!==n)throw new Error("Bad compression byte in signing response.");o.pubkey=r.alloc(65),o.pubkey.writeUInt8(n,0),e.slice(t).copy(o.pubkey,1)}t+=64}const s=2+e[t+1],a=e.slice(t,t+s),c=Ze(a),u=We(c.r,32),f=We(c.s,32);if(o.sig={r:`0x${u.toString("hex")}`,s:`0x${f.toString("hex")}`},t+=s,e.length>=t+32&&(i=r.from(e.slice(t,t+32)),t+=32),n.encodingType===C.SIGNING.ENCODINGS.EVM){const e=ut(n.origPayloadBuf,o);o.sig.v=BigInt(e.toString()),tr(o.sig.v,n,o)}else if(n.hashType===C.SIGNING.HASHES.KECCAK256&&n.encodingType!==C.SIGNING.ENCODINGS.EVM){let e=!1;try{let t=n.origPayloadBuf;t[0]<=127&&(t=t.slice(1));const r=Jt.RLP.decode(t);e=Array.isArray(r)&&r.length>=6}catch{e=!1}if(e)try{const e=ut(n.origPayloadBuf,o);o.sig.v=BigInt(e.toString()),tr(o.sig.v,n,o)}catch(e){console.error("Failed to get V from transaction, using fallback:",e);const t=er(n,i),r=lt({messageHash:t,signature:o.sig,publicKey:o.pubkey});o.sig.v=BigInt(27+r)}else{const e=er(n,i),t=lt({messageHash:e,signature:o.sig,publicKey:o.pubkey});o.sig.v=BigInt(27+t)}}}else if(n.curveType===C.SIGNING.CURVES.ED25519)n.omitPubkey||(o.pubkey=r.alloc(32),e.slice(t,t+32).copy(o.pubkey)),t+=32,o.sig={r:`0x${e.slice(t,t+32).toString("hex")}`,s:`0x${e.slice(t+32,t+64).toString("hex")}`},t+=64;else{if(n.curveType!==C.SIGNING.CURVES.BLS12_381_G2)throw new Error("Unsupported curve.");n.omitPubkey||(o.pubkey=r.alloc(48),e.slice(t,t+48).copy(o.pubkey)),t+=48,o.sig=r.alloc(96),e.slice(t,t+96).copy(o.sig),t+=96}return o}(e,i,t)}{const r=Ze(e.slice(i,i+2+e[i+1]));i+=74;const n=e.slice(i,i+20),o=Fr(t,r,n);if("string"==typeof o)return{tx:`0x${o}`,txHash:`0x${Hr(o)}`,sig:{v:0n,r:"0x",s:"0x"},signer:`0x${n.toString("hex")}`};return{tx:`0x${o.rawTx}`,txHash:`0x${Hr(o.rawTx)}`,sig:{v:BigInt(`0x${o.sigWithV.v.toString("hex")}`),r:`0x${o.sigWithV.r.toString("hex")}`,s:`0x${o.sigWithV.s.toString("hex")}`},signer:`0x${n.toString("hex")}`}}},Dn=class{constructor({baseUrl:e,name:t,privKey:r,stateData:o,timeout:i,retryCount:s,skipRetryOnWrongWallet:a,deviceId:c,setStoredClient:u}){n(this,"isPaired",void 0),n(this,"timeout",void 0),n(this,"baseUrl",void 0),n(this,"url",void 0),n(this,"name",void 0),n(this,"key",void 0),n(this,"privKey",void 0),n(this,"retryCount",void 0),n(this,"fwVersion",void 0),n(this,"skipRetryOnWrongWallet",void 0),n(this,"_ephemeralPub",void 0),n(this,"deviceId",void 0),n(this,"activeWallets",void 0),n(this,"retryWrapper",void 0),n(this,"setStoredClient",void 0),this.name=t||"Unknown",this.baseUrl=e||"https://signing.gridpl.us",this.deviceId=c,this.isPaired=!1,this.activeWallets=W,this.timeout=i||6e4,this.retryCount=s||3,this.skipRetryOnWrongWallet=a||!1,this.privKey=r||et(32),this.key=Ye(this.privKey),this.retryWrapper=Kr(this,this.retryCount),this.setStoredClient=u?le(u):void 0,o&&this.unpackAndApplyStateData(o)}get publicKey(){return qr(this.key)}getAppName(){return this.name}getDeviceId(){return this.deviceId}get sharedSecret(){return r.from(this.key.derive(this.ephemeralPub.getPublic()).toArray("be",32))}get ephemeralPub(){return this._ephemeralPub}set ephemeralPub(e){Ue(e),this._ephemeralPub=e}async connect(e){return this.retryWrapper(on,{id:e})}async pair(e){return this.retryWrapper(Tn,{pairingSecret:e})}async getAddresses({startPath:e,n:t=1,flag:r=0,iterIdx:n=0}){return this.retryWrapper(wn,{startPath:e,n:t,flag:r,iterIdx:n})}async sign({data:e,currency:t,cachedData:r,nextCode:n}){return this.retryWrapper(Nn,{data:e,currency:t,cachedData:r,nextCode:n})}async fetchActiveWallet(){return this.retryWrapper(yn)}async addKvRecords({type:e=0,records:t,caseSensitive:r=!1}){return this.retryWrapper(tn,{type:e,records:t,caseSensitive:r})}async getKvRecords({type:e=0,n:t=1,start:r=0}){return this.retryWrapper(Bn,{type:e,n:t,start:r})}async removeKvRecords({type:e=0,ids:t=[]}){return this.retryWrapper(jn,{type:e,ids:t})}async fetchEncryptedData(e){return this.retryWrapper(dn,e)}getActiveWallet(){return this.activeWallets.external.uid&&!V.equals(this.activeWallets.external.uid)?this.activeWallets.external:this.activeWallets.internal.uid&&!V.equals(this.activeWallets.internal.uid)?this.activeWallets.internal:void 0}hasActiveWallet(){return!!this.getActiveWallet()}resetActiveWallets(){this.activeWallets=W}getStateData(){return this.packStateData()}getFwConstants(){return function(e){const t={extraDataFrameSz:0,extraDataMaxFrames:0,genericSigning:{}};function r(e,t){return e[2]>t[0]||e[2]===t[0]&&e[1]>t[1]||e[2]===t[0]&&e[1]===t[1]&&e[0]>t[2]||e[2]===t[0]&&e[1]===t[1]&&e[0]===t[2]}const n=0===e.length;return!n&&r(e,[0,10,4])||!n&&r(e,[0,10,0])?(t.reqMaxDataSz=1678,t.ethMaxGasPrice=2e13,t.addrFlagsAllowed=!0):(t.reqMaxDataSz=1152,t.ethMaxGasPrice=5e11,t.addrFlagsAllowed=!1),t.ethMaxDataSz=t.reqMaxDataSz-128,t.ethMaxMsgSz=t.ethMaxDataSz,t.eip712MaxTypeParams=18,!n&&r(e,[0,10,4])&&(t.extraDataFrameSz=1500,t.extraDataMaxFrames=1),!n&&r(e,[0,10,5])&&(t.varAddrPathSzAllowed=!0,t.eip712Supported=!0),!n&&r(e,[0,10,8])&&(t.prehashAllowed=!0),!n&&r(e,[0,10,10])&&(t.ethMsgPreHashAllowed=!0),!n&&r(e,[0,11,0])&&(t.allowedEthTxTypes=[1,2],t.ethMaxDataSz-=10,t.ethMaxMsgSz=t.ethMaxDataSz),!n&&r(e,[0,11,2])&&(t.personalSignHeaderSz=72),!n&&r(e,[0,12,0])&&(t.kvActionsAllowed=!0,t.kvKeyMaxStrSz=63,t.kvValMaxStrSz=63,t.kvActionMaxNum=10,t.kvRemoveMaxNum=100),!n&&r(e,[0,13,0])&&(t.allowBtcLegacyAndSegwitAddrs=!0,t.contractDeployKey="0x08002e0fec8e6acf00835f43c9764f7364fa3f42"),!n&&r(e,[0,14,0])&&(t.abiCategorySz=32,t.abiMaxRmv=200,t.genericSigning.baseReqSz=1552,t.genericSigning.baseDataSz=1519,t.genericSigning.hashTypes=C.SIGNING.HASHES,t.genericSigning.curveTypes=C.SIGNING.CURVES,t.genericSigning.encodingTypes={NONE:C.SIGNING.ENCODINGS.NONE,SOLANA:C.SIGNING.ENCODINGS.SOLANA},t.getAddressFlags=[C.GET_ADDR_FLAGS.ED25519_PUB,C.GET_ADDR_FLAGS.SECP256K1_PUB],t.eip712MaxTypeParams=36),!n&&r(e,[0,15,0])&&(t.genericSigning.encodingTypes.EVM=C.SIGNING.ENCODINGS.EVM,t.ethMaxDataSz=1519,t.maxDecoderBufSz=1600,t.genericSigning.calldataDecoding={reserved:2895728,maxSz:1024}),!n&&r(e,[0,17,0])&&(t.getAddressFlags.push(C.GET_ADDR_FLAGS.BLS12_381_G1_PUB),t.genericSigning.encodingTypes.ETH_DEPOSIT=C.SIGNING.ENCODINGS.ETH_DEPOSIT),!n&&r(e,[0,18,0])&&(t.genericSigning.encodingTypes={...t.genericSigning.encodingTypes,EIP7702_AUTH:C.SIGNING.ENCODINGS.EIP7702_AUTH,EIP7702_AUTH_LIST:C.SIGNING.ENCODINGS.EIP7702_AUTH_LIST}),t}(this.fwVersion??r.alloc(0))}getFwVersion(){return this.fwVersion&&this.fwVersion.length>=3?{fix:this.fwVersion[0],minor:this.fwVersion[1],major:this.fwVersion[2]}:{fix:0,minor:0,major:0}}mutate({deviceId:e,ephemeralPub:t,url:r,isPaired:n,fwVersion:o,activeWallets:i}){void 0!==e&&(this.deviceId=e),void 0!==t&&(this.ephemeralPub=t),void 0!==r&&(this.url=r),void 0!==n&&(this.isPaired=n),void 0!==o&&(this.fwVersion=o),void 0!==i&&(this.activeWallets=i),this.setStoredClient&&this.setStoredClient(this.getStateData())}packStateData(){try{const e={activeWallets:{internal:{uid:this.activeWallets.internal.uid?.toString("hex"),name:this.activeWallets.internal.name?.toString(),capabilities:this.activeWallets.internal.capabilities},external:{uid:this.activeWallets.external.uid?.toString("hex"),name:this.activeWallets.external.name?.toString(),capabilities:this.activeWallets.external.capabilities}},ephemeralPub:this.ephemeralPub?.getPublic()?.encode("hex",!1),fwVersion:this.fwVersion?.toString("hex"),deviceId:this.deviceId,name:this.name,baseUrl:this.baseUrl,privKey:this.privKey.toString("hex"),retryCount:this.retryCount,timeout:this.timeout};return JSON.stringify(e)}catch(e){return console.warn("Could not pack state data:",e),null}}unpackAndApplyStateData(e){try{const t=JSON.parse(e),n={uid:r.from(t.activeWallets.internal.uid,"hex"),name:t.activeWallets.internal.name?r.from(t.activeWallets.internal.name):null,capabilities:t.activeWallets.internal.capabilities,external:!1},o={uid:r.from(t.activeWallets.external.uid,"hex"),name:t.activeWallets.external.name?r.from(t.activeWallets.external.name):null,capabilities:t.activeWallets.external.capabilities,external:!0},i=r.from(t.ephemeralPub,"hex"),s=r.from(t.fwVersion,"hex"),a=r.from(t.privKey,"hex");this.activeWallets.internal=n,this.activeWallets.external=o,this.ephemeralPub=Je(i),this.fwVersion=s,this.deviceId=t.deviceId,this.name=t.name,this.baseUrl=t.baseUrl,this.url=`${this.baseUrl}/${this.deviceId}`,this.privKey=a,this.key=Ye(this.privKey),this.retryCount=t.retryCount,this.timeout=t.timeout,this.retryWrapper=Kr(this,this.retryCount)}catch(e){console.warn("Could not apply state data:",e)}}},Un=async e=>{let t=[],r=0;const n=e?.n||G;for(;r<n;){const o=Math.min(G,n-r),i=he(K,r);await ue(n=>n.getAddresses({startPath:i,...e,n:o}).then(e=>{e.length>0&&(t=[...t,...e],r+=e.length)}))}return t},Mn=async(e=0)=>Un({startPath:"number"==typeof e?he(K,e):e,n:1}).then(e=>e[0]);function Ln(e){return async({n:t,startPathIndex:r}={n:G,startPathIndex:0})=>Un({startPath:he(e,r),n:t})}var zn=Ln(Z),Fn=Ln(J),Hn=Ln(Q),$n=Ln(Y),Gn=Ln(X),qn=Ln(ee),Vn=async({n:e,startPathIndex:t}={n:G,startPathIndex:0})=>Un({startPath:he(oe,t,2),n:e,flag:4}),Wn=async({n:e,startPathIndex:t}={n:G,startPathIndex:0})=>{const r=[];for(let n=0;n<e;n++)r.push(ue(e=>e.getAddresses({startPath:he(ie,t+n,2),n:1}).then(e=>e.map(e=>`${e}`))));return Promise.all(r)},Kn=async({n:e,startPathIndex:t}={n:G,startPathIndex:0})=>{const r=[];for(let n=0;n<e;n++)r.push(ue(e=>e.getAddresses({startPath:he(se,t+n,3),n:1}).then(e=>e.map(e=>`${e}`))));return Promise.all(r)},Zn=async({n:e=10,startPathIndex:t=0}={})=>{const r=[];for(let n=0;n<e;n++)r.push(ue(e=>{const r=[44+D,501+D,t+n+D,0+D];return e.getAddresses({startPath:r,n:1,flag:4}).then(e=>e.map(e=>`${e}`))}));return Promise.all(r)};async function Yn(e,{n:t=1,startPathIndex:r=0,flag:n}={}){const o=e.split("/").filter(Boolean),i=me(o),s=function(e){if(e.length>=2&&e[1]===501+D)return C.GET_ADDR_FLAGS.ED25519_PUB}(i),a=o.findIndex(e=>e.toLowerCase().includes("x"));if(-1===a)return ue(e=>e.getAddresses({startPath:i,flag:n||s,n:t}));const c=[];for(let e=0;e<t;e++){const t=[...i];t[a]=t[a]+r+e;const o=await ue(e=>e.getAddresses({startPath:t,flag:n||s,n:1}));c.push(...o)}return c}async function Jn(){return(await Yn(te,{flag:6}))[0]}async function Xn(){return(await Yn(re,{flag:6}))[0]}async function Qn(){return(await Yn(ne,{flag:6}))[0]}var eo=async e=>{const t=e.reduce((e,t)=>{const r=Object.keys(t)[0];return e[r]=t[r],e},{});return ue(e=>e.addKvRecords({records:t}))},to=async({n:e=10,start:t=0}={})=>{const r=[];let n=e,o=t;for(;n>0;)await ue(e=>e.getKvRecords({start:o,n:n>G?G:n}).then(async e=>{r.push(...e.records),o=e.fetched+o,n=e.total-o}));return r},ro=async e=>{const t=e.map(e=>`${e.id}`);return ue(e=>e.removeKvRecords({ids:t}))},no=e("@ethereumjs/rlp"),oo=e("ox"),io=e("viem");var so=async(e,t)=>{const n="string"==typeof(o=e)||o instanceof Uint8Array||r.isBuffer(o);var o;const i=n?function(e){if("string"==typeof e)return e.startsWith("0x")?e:`0x${e}`;return r.from(e)}(e):(0,io.serializeTransaction)(e);let s,a=C.SIGNING.ENCODINGS.EVM;if(!n&&"eip7702"===e.type){const t=e;a=t.authorizationList&&t.authorizationList.length>0?C.SIGNING.ENCODINGS.EIP7702_AUTH_LIST:C.SIGNING.ENCODINGS.EIP7702_AUTH}!n&&"data"in e&&"to"in e&&"chainId"in e&&(s=await async function({data:e,to:t,chainId:r}){try{const n=await fe();De(n);const o=n.getFwVersion(),i=o.major>0||o.minor>=16,{def:s}=await at(e,t,r,i);return s}catch(e){return void console.warn("Failed to fetch ABI:",e)}}({data:e.data,to:e.to,chainId:e.chainId}));const c={signerPath:K,curveType:C.SIGNING.CURVES.SECP256K1,hashType:C.SIGNING.HASHES.KECCAK256,encodingType:a,payload:i,decoder:s};return ue(e=>e.sign({data:c,...t}))};function ao(e,t){const r={data:{signerPath:K,curveType:C.SIGNING.CURVES.SECP256K1,hashType:C.SIGNING.HASHES.KECCAK256,protocol:pe(e)?"eip712":"signPersonal",payload:e},currency:t?.currency??R.ETH_MSG,...t??{}};return ue(e=>e.sign(r))}var co=async(e,t)=>{const n=r.from([5]),o="address"in e?e.address:e.contractAddress,i=r.concat([n,r.from(no.RLP.encode([e.chainId,o,e.nonce]))]),s={signerPath:K,curveType:C.SIGNING.CURVES.SECP256K1,hashType:C.SIGNING.HASHES.KECCAK256,encodingType:C.SIGNING.ENCODINGS.EIP7702_AUTH,payload:i},a=await ue(e=>e.sign({data:s,...t}));if(a.sig&&a.pubkey){const t=r.from(oo.Hash.keccak256(i)),n=lt(t,a.sig,a.pubkey),s=r.isBuffer(a.sig.r)?`0x${a.sig.r.toString("hex")}`:a.sig.r,c=r.isBuffer(a.sig.s)?`0x${a.sig.s.toString("hex")}`:a.sig.s;return{address:o,chainId:e.chainId,nonce:e.nonce,yParity:n,r:s,s:c}}throw new Error("Failed to get signature from device")},uo=async e=>{const t=(0,io.serializeTransaction)(e),r={signerPath:K,curveType:C.SIGNING.CURVES.SECP256K1,hashType:C.SIGNING.HASHES.KECCAK256,encodingType:C.SIGNING.ENCODINGS.EIP7702_AUTH_LIST,payload:t};return await ue(e=>e.sign({data:r}))},fo=async e=>{const t={data:{signerPath:Z,...e},currency:R.BTC};return ue(e=>e.sign(t))},lo=async e=>{const t={data:{signerPath:J,...e},currency:R.BTC};return ue(e=>e.sign(t))},ho=async e=>{const t={data:{signerPath:Q,...e},currency:R.BTC};return ue(e=>e.sign(t))},po=async(e,t)=>{const r={data:{signerPath:oe,curveType:C.SIGNING.CURVES.ED25519,hashType:C.SIGNING.HASHES.NONE,encodingType:C.SIGNING.ENCODINGS.SOLANA,payload:e,...t}};return ue(e=>e.sign(r))},go=async()=>ue(e=>e.fetchActiveWallet()),mo=async e=>{if(!e.getStoredClient)throw new Error("Client data getter required");var t;if(t=de(e.getStoredClient),F=t,!e.setStoredClient)throw new Error("Client data setter required");if((e=>{z=e})(le(e.setStoredClient)),"deviceId"in e&&"password"in e&&"name"in e){const t=e.appSecret||dt.generateAppSecret(e.deviceId,e.password,e.name),r=new Dn({deviceId:e.deviceId,privKey:t,name:e.name,baseUrl:e.baseUrl});return r.connect(e.deviceId).then(async e=>(await z(r.getStateData()),e))}{const e=await F();if(!e)throw new Error("Client not initialized");const t=e.getDeviceId();return!e.ephemeralPub&&t?yo(t):(await z(e.getStateData()),Promise.resolve(!0))}},yo=async e=>ue(t=>t.connect(e)),bo=async e=>ue(t=>t.pair(e))}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"eth-lattice-keyring>gridplus-sdk",file:"node_modules/gridplus-sdk/dist/index.cjs"}],[5613,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.EthereumJSError=r.DEFAULT_ERROR_CODE=void 0,r.EthereumJSErrorWithoutCode=function(e,t){return new n({code:r.DEFAULT_ERROR_CODE},e,t)},r.DEFAULT_ERROR_CODE="ETHEREUMJS_DEFAULT_ERROR_CODE";class n extends Error{constructor(e,t,r){super(t??e.code),this.type=e,r!==undefined&&(this.stack=r)}getMetadata(){return this.type}toObject(){return{type:this.getMetadata(),message:this.message??"",stack:this.stack??"",className:this.constructor.name}}}r.EthereumJSError=n}}},{package:"eth-lattice-keyring>gridplus-sdk>@ethereumjs/rlp",file:"node_modules/gridplus-sdk/node_modules/@ethereumjs/rlp/dist/cjs/errors.js"}],[5614,{"./errors.js":5613},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=Object.create?function(e,t,r,n){n===undefined&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]},o=function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.RLP=r.utils=void 0,r.hexToBytes=p,r.encode=E,r.decode=v;const i=e("./errors.js");function s(e){if(0===e[0])throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: extra zeros");return function(e){const t=Number.parseInt(e,16);if(Number.isNaN(t))throw(0,i.EthereumJSErrorWithoutCode)("Invalid byte sequence");return t}(l(e))}function a(e,t){if(e<56)return Uint8Array.from([e+t]);const r=y(e),n=y(t+55+r.length/2);return Uint8Array.from(p(n+r))}function c(e,t,r){if(r>e.length)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function u(e){let t,r,n,o,a;const f=[],l=e[0];if(l<=127)return{data:e.slice(0,1),remainder:e.subarray(1)};if(l<=183){if(t=l-127,n=128===l?Uint8Array.from([]):c(e,1,t),2===t&&n[0]<128)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:n,remainder:e.subarray(t)}}if(l<=191){if(r=l-182,e.length-1<r)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: not enough bytes for string length");if(t=s(c(e,1,r)),t<=55)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: expected string length to be greater than 55");return n=c(e,r,t+r),{data:n,remainder:e.subarray(t+r)}}if(l<=247){for(t=l-191,o=c(e,1,t);o.length;)a=u(o),f.push(a.data),o=a.remainder;return{data:f,remainder:e.subarray(t)}}{if(r=l-246,t=s(c(e,1,r)),t<56)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: encoded list too short");const n=r+t;if(n>e.length)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: total length is larger than the data");for(o=c(e,r,n);o.length;)a=u(o),f.push(a.data),o=a.remainder;return{data:f,remainder:e.subarray(n)}}}o(e("./errors.js"),r);const f=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function l(e){let t="";for(let r=0;r<e.length;r++)t+=f[e[r]];return t}const d={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function h(e){return e>=d._0&&e<=d._9?e-d._0:e>=d._A&&e<=d._F?e-(d._A-10):e>=d._a&&e<=d._f?e-(d._a-10):void 0}function p(e){if("0x"===e.slice(0,2)&&(e=e.slice(0,2)),"string"!=typeof e)throw(0,i.EthereumJSErrorWithoutCode)("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw(0,i.EthereumJSErrorWithoutCode)("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,o=0;t<r;t++,o+=2){const r=h(e.charCodeAt(o)),s=h(e.charCodeAt(o+1));if(r===undefined||s===undefined){const t=e[o]+e[o+1];throw(0,i.EthereumJSErrorWithoutCode)('hex string expected, got non-hex character "'+t+'" at index '+o)}n[t]=16*r+s}return n}function g(...e){if(1===e.length)return e[0];const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}function m(e){return(new TextEncoder).encode(e)}function y(e){if(e<0)throw(0,i.EthereumJSErrorWithoutCode)("Invalid integer as argument, must be unsigned!");const t=e.toString(16);return t.length%2?`0${t}`:t}function b(e){return e.length>=2&&"0"===e[0]&&"x"===e[1]}function w(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return b(e)?p((t="string"!=typeof(r=e)?r:b(r)?r.slice(2):r).length%2?`0${t}`:t):m(e);var t,r;if("number"==typeof e||"bigint"==typeof e)return e?p(y(e)):Uint8Array.from([]);if(null===e||e===undefined)return Uint8Array.from([]);throw(0,i.EthereumJSErrorWithoutCode)("toBytes: received unsupported type "+typeof e)}function E(e){if(Array.isArray(e)){const t=[];let r=0;for(let n=0;n<e.length;n++){const o=E(e[n]);t.push(o),r+=o.length}return g(a(r,192),...t)}const t=w(e);return 1===t.length&&t[0]<128?t:g(a(t.length,128),t)}function v(e,t=!1){if(null==e||0===e.length)return Uint8Array.from([]);const r=u(w(e));if(t)return{data:r.data,remainder:r.remainder.slice()};if(0!==r.remainder.length)throw(0,i.EthereumJSErrorWithoutCode)("invalid RLP: remainder must be zero");return r.data}r.utils={bytesToHex:l,concatBytes:g,hexToBytes:p,utf8ToBytes:m},r.RLP={encode:E,decode:v}}}},{package:"eth-lattice-keyring>gridplus-sdk>@ethereumjs/rlp",file:"node_modules/gridplus-sdk/node_modules/@ethereumjs/rlp/dist/cjs/index.js"}],[5615,{"./abstract/weierstrass.js":5624,"@noble/hashes/hmac":4337,"@noble/hashes/utils":4346},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getHash=s,r.createCurve=function(e,t){const r=t=>(0,i.weierstrass)({...e,...s(t)});return{...r(t),create:r}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/hmac"),o=e("@noble/hashes/utils"),i=e("./abstract/weierstrass.js");function s(e){return{hash:e,hmac:(t,...r)=>(0,n.hmac)(e,t,(0,o.concatBytes)(...r)),randomBytes:o.randomBytes}}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/_shortw_utils.js"}],[5616,{"./hash-to-curve.js":5619,"./modular.js":5620,"./utils.js":5623,"./weierstrass.js":5624},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bls=function(e){const{Fp:t,Fr:r,Fp2:l,Fp6:d,Fp12:h}=e.fields,p=e.params.xNegative,g=e.params.twistType,m=(0,s.weierstrassPoints)({n:r.ORDER,...e.G1}),y=Object.assign(m,(0,n.createHasher)(m.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),b=(0,s.weierstrassPoints)({n:r.ORDER,...e.G2}),w=Object.assign(b,(0,n.createHasher)(b.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults}));let E;if("multiplicative"===g)E=(e,t,r,n,o,i)=>h.mul014(n,e,l.mul(t,o),l.mul(r,i));else{if("divisive"!==g)throw new Error("bls: unknown twist type");E=(e,t,r,n,o,i)=>h.mul034(n,l.mul(r,i),l.mul(t,o),e)}const v=l.div(l.ONE,l.mul(l.ONE,u));function x(e,t,r,n){const o=l.sqr(r),i=l.sqr(n),s=l.mulByB(l.mul(i,f)),a=l.mul(s,f),c=l.sub(l.sub(l.sqr(l.add(r,n)),i),o),u=l.sub(s,o),d=l.mul(l.sqr(t),f),h=l.neg(c);return e.push([u,d,h]),{Rx:t=l.mul(l.mul(l.mul(l.sub(o,a),t),r),v),Ry:r=l.sub(l.sqr(l.mul(l.add(o,a),v)),l.mul(l.sqr(s),f)),Rz:n=l.mul(o,c)}}function B(e,t,r,n,o,i){const s=l.sub(r,l.mul(i,n)),a=l.sub(t,l.mul(o,n)),c=l.sub(l.mul(s,o),l.mul(a,i)),f=l.neg(s),d=a;e.push([c,f,d]);const h=l.sqr(a),p=l.mul(h,a),g=l.mul(h,t),m=l.add(l.sub(p,l.mul(g,u)),l.mul(l.sqr(s),n));return{Rx:t=l.mul(a,m),Ry:r=l.sub(l.mul(l.sub(g,m),s),l.mul(p,r)),Rz:n=l.mul(n,p)}}const S=function(e){const t=[];for(;e>c;e>>=c)(e&c)===a?t.unshift(0):(e&f)===f?(t.unshift(-1),e+=c):t.unshift(1);return t}(e.params.ateLoopSize),I=(0,i.memoized)(t=>{const r=t,{x:n,y:o}=r.toAffine(),i=n,s=o,a=l.neg(o);let c=i,u=s,f=l.ONE;const d=[];for(const e of S){const t=[];({Rx:c,Ry:u,Rz:f}=x(t,c,u,f)),e&&({Rx:c,Ry:u,Rz:f}=B(t,c,u,f,i,-1===e?a:s)),d.push(t)}if(e.postPrecompute){const t=d[d.length-1];e.postPrecompute(c,u,f,i,s,B.bind(null,t))}return d});function P(e,t=!1){let r=h.ONE;if(e.length){const t=e[0][0].length;for(let n=0;n<t;n++){r=h.sqr(r);for(const[t,o,i]of e)for(const[e,s,a]of t[n])r=E(e,s,a,r,o,i)}}return p&&(r=h.conjugate(r)),t?h.finalExponentiate(r):r}function T(e,t=!0){const r=[];y.ProjectivePoint.normalizeZ(e.map(({g1:e})=>e)),w.ProjectivePoint.normalizeZ(e.map(({g2:e})=>e));for(const{g1:t,g2:n}of e){if(t.equals(y.ProjectivePoint.ZERO)||n.equals(w.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");t.assertValidity(),n.assertValidity();const e=t.toAffine();r.push([I(n),e.x,e.y])}return P(r,t)}const A={randomPrivateKey:()=>{const t=(0,o.getMinHashLength)(r.ORDER);return(0,o.mapHashToField)(e.randomBytes(t),r.ORDER)},calcPairingPrecomputes:I},{ShortSignature:j}=e.G1,{Signature:k}=e.G2;function _(e){return e instanceof y.ProjectivePoint?e:y.ProjectivePoint.fromHex(e)}function O(e,t){return e instanceof y.ProjectivePoint?e:y.hashToCurve((0,i.ensureBytes)("point",e),t)}function N(e){return e instanceof w.ProjectivePoint?e:k.fromHex(e)}function C(e,t){return e instanceof w.ProjectivePoint?e:w.hashToCurve((0,i.ensureBytes)("point",e),t)}function R(e){if(!Array.isArray(e)||0===e.length)throw new Error("expected non-empty array")}return y.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:function(e){return y.ProjectivePoint.fromPrivateKey(e).toRawBytes(!0)},getPublicKeyForShortSignatures:function(e){return w.ProjectivePoint.fromPrivateKey(e).toRawBytes(!0)},sign:function(e,t,r){const n=C(e,r);n.assertValidity();const o=n.multiply(y.normPrivateKeyToScalar(t));return e instanceof w.ProjectivePoint?o:k.toRawBytes(o)},signShortSignature:function(e,t,r){const n=O(e,r);n.assertValidity();const o=n.multiply(y.normPrivateKeyToScalar(t));return e instanceof y.ProjectivePoint?o:j.toRawBytes(o)},verify:function(e,t,r,n){const o=_(r),i=C(t,n),s=y.ProjectivePoint.BASE,a=N(e),c=T([{g1:o.negate(),g2:i},{g1:s,g2:a}]);return h.eql(c,h.ONE)},verifyBatch:function(e,t,r,n){if(R(t),r.length!==t.length)throw new Error("amount of public keys and messages should be equal");const o=N(e),i=t.map(e=>C(e,n)),s=r.map(_),a=new Map;for(let e=0;e<s.length;e++){const t=s[e],r=i[e];let n=a.get(r);n===undefined&&(n=[],a.set(r,n)),n.push(t)}const c=[];try{for(const[e,t]of a){const r=t.reduce((e,t)=>e.add(t));c.push({g1:r,g2:e})}return c.push({g1:y.ProjectivePoint.BASE.negate(),g2:o}),h.eql(T(c),h.ONE)}catch{return!1}},verifyShortSignature:function(e,t,r,n){const o=N(r),i=O(t,n),s=w.ProjectivePoint.BASE,a=_(e),c=T([{g1:i,g2:o},{g1:a,g2:s.negate()}]);return h.eql(c,h.ONE)},aggregatePublicKeys:function(e){R(e);const t=e.map(_).reduce((e,t)=>e.add(t),y.ProjectivePoint.ZERO);if(e[0]instanceof y.ProjectivePoint)return t.assertValidity(),t;return t.toRawBytes(!0)},aggregateSignatures:function(e){R(e);const t=e.map(N).reduce((e,t)=>e.add(t),w.ProjectivePoint.ZERO);if(e[0]instanceof w.ProjectivePoint)return t.assertValidity(),t;return k.toRawBytes(t)},aggregateShortSignatures:function(e){R(e);const t=e.map(_).reduce((e,t)=>e.add(t),y.ProjectivePoint.ZERO);if(e[0]instanceof y.ProjectivePoint)return t.assertValidity(),t;return j.toRawBytes(t)},millerLoopBatch:P,pairing:function(e,t,r=!0){return T([{g1:e,g2:t}],r)},pairingBatch:T,G1:y,G2:w,Signature:k,ShortSignature:j,fields:{Fr:r,Fp:t,Fp2:l,Fp6:d,Fp12:h},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:A}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./hash-to-curve.js"),o=e("./modular.js"),i=e("./utils.js"),s=e("./weierstrass.js"),a=BigInt(0),c=BigInt(1),u=BigInt(2),f=BigInt(3)}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/bls.js"}],[5617,{"./modular.js":5620,"./utils.js":5623},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.wNAF=function(e,t){return{constTimeNegate:a,hasPrecomputes:e=>1!==g(e),unsafeLadder(t,r,n=e.ZERO){let o=t;for(;r>i;)r&s&&(n=n.add(o)),o=o.double(),r>>=s;return n},precomputeWindow(e,r){const{windows:n,windowSize:o}=u(r,t),i=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,i.push(a);for(let e=1;e<o;e++)a=a.add(s),i.push(a);s=a.double()}return i},wNAF(r,n,o){let i=e.ZERO,s=e.BASE;const c=u(r,t);for(let e=0;e<c.windows;e++){const{nextN:t,offset:r,isZero:u,isNeg:l,isNegF:d,offsetF:h}=f(o,e,c);o=t,u?s=s.add(a(d,n[h])):i=i.add(a(l,n[r]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,s=e.ZERO){const a=u(r,t);for(let e=0;e<a.windows&&o!==i;e++){const{nextN:t,offset:r,isZero:i,isNeg:c}=f(o,e,a);if(o=t,!i){const e=n[r];s=s.add(c?e.negate():e)}}return s},getPrecomputes(e,t,r){let n=h.get(t);return n||(n=this.precomputeWindow(t,e),1!==e&&h.set(t,r(n))),n},wNAFCached(e,t,r){const n=g(e);return this.wNAF(n,this.getPrecomputes(n,e,r),t)},wNAFCachedUnsafe(e,t,r,n){const o=g(e);return 1===o?this.unsafeLadder(e,t,n):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),t,n)},setWindowSize(e,r){c(r,t),p.set(e,r),h.delete(e)}}},r.pippenger=function(e,t,r,n){l(r,e),d(n,t);const i=r.length,s=n.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,c=(0,o.bitLen)(BigInt(i));let u=1;c>12?u=c-3:c>4?u=c-2:c>0&&(u=2);const f=(0,o.bitMask)(u),h=new Array(Number(f)+1).fill(a),p=Math.floor((t.BITS-1)/u)*u;let g=a;for(let e=p;e>=0;e-=u){h.fill(a);for(let t=0;t<s;t++){const o=n[t],i=Number(o>>BigInt(e)&f);h[i]=h[i].add(r[t])}let t=a;for(let e=h.length-1,r=a;e>0;e--)r=r.add(h[e]),t=t.add(r);if(g=g.add(t),0!==e)for(let e=0;e<u;e++)g=g.double()}return g},r.precomputeMSMUnsafe=function(e,t,r,n){c(n,t.BITS),l(r,e);const i=e.ZERO,s=2**n-1,a=Math.ceil(t.BITS/n),u=(0,o.bitMask)(n),f=r.map(e=>{const t=[];for(let r=0,n=e;r<s;r++)t.push(n),n=n.add(e);return t});return e=>{if(d(e,t),e.length>r.length)throw new Error("array of scalars must be smaller than array of points");let o=i;for(let t=0;t<a;t++){if(o!==i)for(let e=0;e<n;e++)o=o.double();const r=BigInt(a*n-(t+1)*n);for(let t=0;t<e.length;t++){const n=e[t],i=Number(n>>r&u);i&&(o=o.add(f[t][i-1]))}}return o}},r.validateBasic=function(e){return(0,n.validateField)(e.Fp),(0,o.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),o=e("./utils.js"),i=BigInt(0),s=BigInt(1);function a(e,t){const r=t.negate();return e?r:t}function c(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function u(e,t){c(e,t);const r=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:(0,o.bitMask)(e),maxNumber:r,shiftBy:BigInt(e)}}function f(e,t,r){const{windowSize:n,mask:o,maxNumber:i,shiftBy:a}=r;let c=Number(e&o),u=e>>a;c>n&&(c-=i,u+=s);const f=t*n;return{nextN:u,offset:f+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:t%2!=0,offsetF:f}}function l(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)})}function d(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)})}const h=new WeakMap,p=new WeakMap;function g(e){return p.get(e)||1}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/curve.js"}],[5618,{"./curve.js":5617,"./modular.js":5620,"./utils.js":5623},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.twistedEdwards=function(e){const t=function(e){const t=(0,n.validateBasic)(e);return(0,i.validateObject)(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n:l,prehash:d,hash:h,randomBytes:p,nByteLength:g,h:m}=t,y=c<<BigInt(8*g)-a,b=r.create,w=(0,o.Field)(t.n,t.nBitLength);if(!function(e,n){const o=r.sqr(e),i=r.sqr(n),s=r.add(r.mul(t.a,o),i),a=r.add(r.ONE,r.mul(t.d,r.mul(o,i)));return r.eql(s,a)}(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const E=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(e){return{isValid:!1,value:s}}}),v=t.adjustScalarBytes||(e=>e),x=t.domain||((e,t,r)=>{if((0,i.abool)("phflag",r),t.length||r)throw new Error("Contexts/pre-hash are not supported");return e});function B(e,t,r=!1){const n=r?a:s;(0,i.aInRange)("coordinate "+e,t,n,y)}function S(e){if(!(e instanceof T))throw new Error("ExtendedPoint expected")}const I=(0,i.memoized)((e,t)=>{const{ex:n,ey:o,ez:i}=e,c=e.is0();null==t&&(t=c?u:r.inv(i));const f=b(n*t),l=b(o*t),d=b(i*t);if(c)return{x:s,y:a};if(d!==a)throw new Error("invZ was invalid");return{x:f,y:l}}),P=(0,i.memoized)(e=>{const{a:r,d:n}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:o,ey:i,ez:s,et:a}=e,c=b(o*o),u=b(i*i),f=b(s*s),l=b(f*f),d=b(c*r);if(b(f*b(d+u))!==b(l+b(n*b(c*u))))throw new Error("bad point: equation left != right (1)");if(b(o*i)!==b(s*a))throw new Error("bad point: equation left != right (2)");return!0});class T{constructor(e,t,r,n){B("x",e),B("y",t),B("z",r,!0),B("t",n),this.ex=e,this.ey=t,this.ez=r,this.et=n,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof T)throw new Error("extended point not allowed");const{x:t,y:r}=e||{};return B("x",t),B("y",r),new T(t,r,a,b(t*r))}static normalizeZ(e){const t=(0,o.FpInvertBatch)(r,e.map(e=>e.ez));return e.map((e,r)=>e.toAffine(t[r])).map(T.fromAffine)}static msm(e,t){return(0,n.pippenger)(T,w,e,t)}_setWindowSize(e){k.setWindowSize(this,e)}assertValidity(){P(this)}equals(e){S(e);const{ex:t,ey:r,ez:n}=this,{ex:o,ey:i,ez:s}=e,a=b(t*s),c=b(o*n),u=b(r*s),f=b(i*n);return a===c&&u===f}is0(){return this.equals(T.ZERO)}negate(){return new T(b(-this.ex),this.ey,this.ez,b(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:o}=this,i=b(r*r),s=b(n*n),a=b(c*b(o*o)),u=b(e*i),f=r+n,l=b(b(f*f)-i-s),d=u+s,h=d-a,p=u-s,g=b(l*h),m=b(d*p),y=b(l*p),w=b(h*d);return new T(g,m,w,y)}add(e){S(e);const{a:r,d:n}=t,{ex:o,ey:i,ez:s,et:a}=this,{ex:c,ey:u,ez:f,et:l}=e,d=b(o*c),h=b(i*u),p=b(a*n*l),g=b(s*f),m=b((o+i)*(c+u)-d-h),y=g-p,w=g+p,E=b(h-r*d),v=b(m*y),x=b(w*E),B=b(m*E),I=b(y*w);return new T(v,x,I,B)}subtract(e){return this.add(e.negate())}wNAF(e){return k.wNAFCached(this,e,T.normalizeZ)}multiply(e){const t=e;(0,i.aInRange)("scalar",t,a,l);const{p:r,f:n}=this.wNAF(t);return T.normalizeZ([r,n])[0]}multiplyUnsafe(e,t=T.ZERO){const r=e;return(0,i.aInRange)("scalar",r,s,l),r===s?j:this.is0()||r===a?this:k.wNAFCachedUnsafe(this,r,T.normalizeZ,t)}isSmallOrder(){return this.multiplyUnsafe(m).is0()}isTorsionFree(){return k.unsafeLadder(this,l).is0()}toAffine(e){return I(this,e)}clearCofactor(){const{h:e}=t;return e===a?this:this.multiplyUnsafe(e)}static fromHex(e,n=!1){const{d:o,a:c}=t,u=r.BYTES;e=(0,i.ensureBytes)("pointHex",e,u),(0,i.abool)("zip215",n);const f=e.slice(),l=e[u-1];f[u-1]=-129&l;const d=(0,i.bytesToNumberLE)(f),h=n?y:r.ORDER;(0,i.aInRange)("pointHex.y",d,s,h);const p=b(d*d),g=b(p-a),m=b(o*p-c);let{isValid:w,value:v}=E(g,m);if(!w)throw new Error("Point.fromHex: invalid y coordinate");const x=(v&a)===a,B=!!(128&l);if(!n&&v===s&&B)throw new Error("Point.fromHex: x=0 and x_0=1");return B!==x&&(v=b(-v)),T.fromAffine({x:v,y:d})}static fromPrivateKey(e){const{scalar:t}=N(e);return A.multiply(t)}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=(0,i.numberToBytesLE)(t,r.BYTES);return n[n.length-1]|=e&a?128:0,n}toHex(){return(0,i.bytesToHex)(this.toRawBytes())}}T.BASE=new T(t.Gx,t.Gy,a,b(t.Gx*t.Gy)),T.ZERO=new T(s,a,a,s);const{BASE:A,ZERO:j}=T,k=(0,n.wNAF)(T,8*g);function _(e){return(0,o.mod)(e,l)}function O(e){return _((0,i.bytesToNumberLE)(e))}function N(e){const t=r.BYTES;e=(0,i.ensureBytes)("private key",e,t);const n=(0,i.ensureBytes)("hashed private key",h(e),2*t),o=v(n.slice(0,t));return{head:o,prefix:n.slice(t,2*t),scalar:O(o)}}function C(e){const{head:t,prefix:r,scalar:n}=N(e),o=A.multiply(n),i=o.toRawBytes();return{head:t,prefix:r,scalar:n,point:o,pointBytes:i}}function R(e=Uint8Array.of(),...t){const r=(0,i.concatBytes)(...t);return O(h(x(r,(0,i.ensureBytes)("context",e),!!d)))}const D=f;A._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return C(e).pointBytes},sign:function(e,t,n={}){e=(0,i.ensureBytes)("message",e),d&&(e=d(e));const{prefix:o,scalar:a,pointBytes:c}=C(t),u=R(n.context,o,e),f=A.multiply(u).toRawBytes(),h=_(u+R(n.context,f,c,e)*a);(0,i.aInRange)("signature.s",h,s,l);const p=(0,i.concatBytes)(f,(0,i.numberToBytesLE)(h,r.BYTES));return(0,i.ensureBytes)("result",p,2*r.BYTES)},verify:function(e,t,n,o=D){const{context:s,zip215:a}=o,c=r.BYTES;e=(0,i.ensureBytes)("signature",e,2*c),t=(0,i.ensureBytes)("message",t),n=(0,i.ensureBytes)("publicKey",n,c),a!==undefined&&(0,i.abool)("zip215",a),d&&(t=d(t));const u=(0,i.bytesToNumberLE)(e.slice(c,2*c));let f,l,h;try{f=T.fromHex(n,a),l=T.fromHex(e.slice(0,c),a),h=A.multiplyUnsafe(u)}catch(e){return!1}if(!a&&f.isSmallOrder())return!1;const p=R(s,l.toRawBytes(),f.toRawBytes(),t);return l.add(f.multiplyUnsafe(p)).subtract(h).clearCofactor().equals(T.ZERO)},ExtendedPoint:T,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>p(r.BYTES),precompute:(e=8,t=T.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./curve.js"),o=e("./modular.js"),i=e("./utils.js"),s=BigInt(0),a=BigInt(1),c=BigInt(2),u=BigInt(8),f={zip215:!0}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/edwards.js"}],[5619,{"./modular.js":5620,"./utils.js":5623},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.expand_message_xmd=u,r.expand_message_xof=f,r.hash_to_field=l,r.isogenyMap=function(e,t){const r=t.map(e=>Array.from(e).reverse());return(t,o)=>{const[i,s,a,c]=r.map(r=>r.reduce((r,n)=>e.add(e.mul(r,t),n))),[u,f]=(0,n.FpInvertBatch)(e,[s,c],!0);return t=e.mul(i,u),o=e.mul(o,e.mul(a,f)),{x:t,y:o}}},r.createHasher=function(e,t,r){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");function n(r){return e.fromAffine(t(r))}function o(t){const r=t.clearCofactor();return r.equals(e.ZERO)?e.ZERO:(r.assertValidity(),r)}return{defaults:r,hashToCurve(e,t){const i=l(e,2,{...r,DST:r.DST,...t}),s=n(i[0]),a=n(i[1]);return o(s.add(a))},encodeToCurve:(e,t)=>o(n(l(e,1,{...r,DST:r.encodeDST,...t})[0])),mapToCurve(e){if(!Array.isArray(e))throw new Error("expected array of bigints");for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return o(n(e))}}};const n=e("./modular.js"),o=e("./utils.js"),i=o.bytesToNumberBE;function s(e,t){if(c(e),c(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=255&e,e>>>=8;return new Uint8Array(r)}function a(e,t){const r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function c(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function u(e,t,r,n){(0,o.abytes)(e),(0,o.abytes)(t),c(r),t.length>255&&(t=n((0,o.concatBytes)((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:u}=n,f=Math.ceil(r/i);if(r>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");const l=(0,o.concatBytes)(t,s(t.length,1)),d=s(0,u),h=s(r,2),p=new Array(f),g=n((0,o.concatBytes)(d,e,h,s(0,1),l));p[0]=n((0,o.concatBytes)(g,s(1,1),l));for(let e=1;e<=f;e++){const t=[a(g,p[e-1]),s(e+1,1),l];p[e]=n((0,o.concatBytes)(...t))}return(0,o.concatBytes)(...p).slice(0,r)}function f(e,t,r,n,i){if((0,o.abytes)(e),(0,o.abytes)(t),c(r),t.length>255){const e=Math.ceil(2*n/8);t=i.create({dkLen:e}).update((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(s(r,2)).update(t).update(s(t.length,1)).digest()}function l(e,t,r){(0,o.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:a,m:l,hash:d,expand:h,DST:p}=r;(0,o.abytes)(e),c(t);const g="string"==typeof p?(0,o.utf8ToBytes)(p):p,m=s.toString(2).length,y=Math.ceil((m+a)/8),b=t*l*y;let w;if("xmd"===h)w=u(e,g,b,d);else if("xof"===h)w=f(e,g,b,a,d);else{if("_internal_pass"!==h)throw new Error('expand must be "xmd" or "xof"');w=e}const E=new Array(t);for(let e=0;e<t;e++){const t=new Array(l);for(let r=0;r<l;r++){const o=y*(r+e*l),a=w.subarray(o,o+y);t[r]=(0,n.mod)(i(a),s)}E[e]=t}return E}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/hash-to-curve.js"}],[562,{"@metamask/utils":4109,lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=i,function(e){(0,n.hasProperty)(e,"PreferencesController")&&(0,n.isObject)(e.PreferencesController)&&(0,n.hasProperty)(e.PreferencesController,"useRequestQueue")&&delete e.PreferencesController.useRequestQueue}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=136}}},{package:"$root$",file:"app/scripts/migrations/136.ts"}],[5620,{"./utils.js":5623,"@noble/hashes/utils":4346},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.isNegativeLE=void 0,r.mod=d,r.pow=function(e,t,r){return w(B(r),e,t)},r.pow2=function(e,t,r){let n=e;for(;t-- >i;)n*=n,n%=r;return n},r.invert=h,r.tonelliShanks=m,r.FpSqrt=y,r.validateField=function(e){const t=b.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,o.validateObject)(e,t)},r.FpPow=w,r.FpInvertBatch=E,r.FpDiv=function(e,t,r){return e.mul(t,"bigint"==typeof r?h(r,e.ORDER):e.inv(r))},r.FpLegendre=v,r.FpIsSquare=function(e,t){return 1===v(e,t)},r.nLength=x,r.Field=B,r.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)},r.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r},r.hashToPrivateScalar=function(e,t,r=!1){const n=(e=(0,o.ensureBytes)("privateHash",e)).length,i=x(t).nByteLength+8;if(i<24||n<i||n>1024)throw new Error("hashToPrivateScalar: expected "+i+"-1024 bytes of input, got "+n);return d(r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e),t-s)+s},r.getFieldBytesLength=S,r.getMinHashLength=I,r.mapHashToField=function(e,t,r=!1){const n=e.length,i=S(t),a=I(t);if(n<16||n<a||n>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+n);const c=d(r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e),t-s)+s;return r?(0,o.numberToBytesLE)(c,i):(0,o.numberToBytesBE)(c,i)};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/utils"),o=e("./utils.js"),i=BigInt(0),s=BigInt(1),a=BigInt(2),c=BigInt(3),u=BigInt(4),f=BigInt(5),l=BigInt(8);function d(e,t){const r=e%t;return r>=i?r:t+r}function h(e,t){if(e===i)throw new Error("invert: expected non-zero number");if(t<=i)throw new Error("invert: expected positive modulus, got "+t);let r=d(e,t),n=t,o=i,a=s,c=s,u=i;for(;r!==i;){const e=n/r,t=n%r,i=o-c*e,s=a-u*e;n=r,r=t,o=c,a=u,c=i,u=s}if(n!==s)throw new Error("invert: does not exist");return d(o,t)}function p(e,t){const r=(e.ORDER+s)/u,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function g(e,t){const r=(e.ORDER-f)/l,n=e.mul(t,a),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,a),o),c=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(c),t))throw new Error("Cannot find square root");return c}function m(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-s,r=0;for(;t%a===i;)t/=a,r++;let n=a;const o=B(e);for(;1===v(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return p;let c=o.pow(n,t);const u=(t+s)/a;return function(e,n){if(e.is0(n))return n;if(1!==v(e,n))throw new Error("Cannot find square root");let o=r,i=e.mul(e.ONE,c),a=e.pow(n,t),f=e.pow(n,u);for(;!e.eql(a,e.ONE);){if(e.is0(a))return e.ZERO;let t=1,r=e.sqr(a);for(;!e.eql(r,e.ONE);)if(t++,r=e.sqr(r),t===o)throw new Error("Cannot find square root");const n=s<<BigInt(o-t-1),c=e.pow(i,n);o=t,i=e.sqr(c),a=e.mul(a,i),f=e.mul(f,c)}return f}}function y(e){return e%u===c?p:e%l===f?g:m(e)}r.isNegativeLE=(e,t)=>(d(e,t)&s)===s;const b=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function w(e,t,r){if(r<i)throw new Error("invalid exponent, negatives unsupported");if(r===i)return e.ONE;if(r===s)return t;let n=e.ONE,o=t;for(;r>i;)r&s&&(n=e.mul(n,o)),o=e.sqr(o),r>>=s;return n}function E(e,t,r=!1){const n=new Array(t.length).fill(r?e.ZERO:undefined),o=t.reduce((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r)),e.ONE),i=e.inv(o);return t.reduceRight((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r)),i),n}function v(e,t){const r=(e.ORDER-s)/a,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),c=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!c)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function x(e,t){t!==undefined&&(0,n.anumber)(t);const r=t!==undefined?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function B(e,t,r=!1,n={}){if(e<=i)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:a,nByteLength:c}=x(e,t);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const f=Object.freeze({ORDER:e,isLE:r,BITS:a,BYTES:c,MASK:(0,o.bitMask)(a),ZERO:i,ONE:s,create:t=>d(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return i<=t&&t<e},is0:e=>e===i,isOdd:e=>(e&s)===s,neg:t=>d(-t,e),eql:(e,t)=>e===t,sqr:t=>d(t*t,e),add:(t,r)=>d(t+r,e),sub:(t,r)=>d(t-r,e),mul:(t,r)=>d(t*r,e),pow:(e,t)=>w(f,e,t),div:(t,r)=>d(t*h(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>h(t,e),sqrt:n.sqrt||(t=>(u||(u=y(e)),u(f,t))),toBytes:e=>r?(0,o.numberToBytesLE)(e,c):(0,o.numberToBytesBE)(e,c),fromBytes:e=>{if(e.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+e.length);return r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e)},invertBatch:e=>E(f,e),cmov:(e,t,r)=>r?t:e});return Object.freeze(f)}function S(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function I(e){const t=S(e);return t+Math.ceil(t/2)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/modular.js"}],[5621,{"./modular.js":5620,"./utils.js":5623},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.montgomery=function(e){const t=(d=e,(0,o.validateObject)(d,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...d})),{P:r,type:c,adjustScalarBytes:u,powPminus2:f}=t,l="x25519"===c;var d;if(!l&&"x448"!==c)throw new Error("invalid type");const h=l?255:448,p=l?32:56,g=l?BigInt(9):BigInt(5),m=l?BigInt(121665):BigInt(39081),y=l?a**BigInt(254):a**BigInt(447),b=l?BigInt(8)*a**BigInt(251)-s:BigInt(4)*a**BigInt(445)-s,w=y+b+s,E=e=>(0,n.mod)(e,r),v=x(g);function x(e){return(0,o.numberToBytesLE)(E(e),p)}function B(e,t){const n=function(e,t){(0,o.aInRange)("u",e,i,r),(0,o.aInRange)("scalar",t,y,w);const n=t,a=e;let c=s,u=i,l=e,d=s,p=i;for(let e=BigInt(h-1);e>=i;e--){const t=n>>e&s;p^=t,({x_2:c,x_3:l}=I(p,c,l)),({x_2:u,x_3:d}=I(p,u,d)),p=t;const r=c+u,o=E(r*r),i=c-u,f=E(i*i),h=o-f,g=l+d,y=E((l-d)*r),b=E(g*i),w=y+b,v=y-b;l=E(w*w),d=E(a*E(v*v)),c=E(o*f),u=E(h*(o+E(m*h)))}({x_2:c,x_3:l}=I(p,c,l)),({x_2:u,x_3:d}=I(p,u,d));const g=f(u);return E(c*g)}(function(e){const t=(0,o.ensureBytes)("u coordinate",e,p);return l&&(t[31]&=127),E((0,o.bytesToNumberLE)(t))}(t),function(e){return(0,o.bytesToNumberLE)(u((0,o.ensureBytes)("scalar",e,p)))}(e));if(n===i)throw new Error("invalid private or public key received");return x(n)}function S(e){return B(e,v)}function I(e,t,r){const n=E(e*(t-r));return{x_2:t=E(t-n),x_3:r=E(r+n)}}return{scalarMult:B,scalarMultBase:S,getSharedSecret:(e,t)=>B(e,t),getPublicKey:e=>S(e),utils:{randomPrivateKey:()=>t.randomBytes(p)},GuBytes:v.slice()}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),o=e("./utils.js"),i=BigInt(0),s=BigInt(1),a=BigInt(2)}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/montgomery.js"}],[5622,{"./modular.js":5620,"./utils.js":5623},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.psiFrobenius=function(e,t,r){const n=t.pow(r,(e.ORDER-s)/c),o=t.pow(r,(e.ORDER-s)/a);function i(e,r){return[t.mul(t.frobeniusMap(e,1),n),t.mul(t.frobeniusMap(r,1),o)]}const u=t.pow(r,(e.ORDER**a-s)/c),f=t.pow(r,(e.ORDER**a-s)/a);if(!t.eql(f,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function l(e,r){return[t.mul(e,u),t.neg(r)]}const d=e=>(t,r)=>{const n=r.toAffine(),o=e(n.x,n.y);return t.fromAffine({x:o[0],y:o[1]})},h=d(i),p=d(l);return{psi:i,psi2:l,G2psi:h,G2psi2:p,PSI_X:n,PSI_Y:o,PSI2_X:u,PSI2_Y:f}},r.tower12=function(e){const{ORDER:t}=e,r=n.Field(t),c=r.create(e.NONRESIDUE||BigInt(-1)),f=r.div(r.ONE,a),l=u(r,c,r.ORDER,2)[0],d=({c0:e,c1:t},{c0:n,c1:o})=>({c0:r.add(e,n),c1:r.add(t,o)}),h=({c0:e,c1:t},{c0:n,c1:o})=>({c0:r.sub(e,n),c1:r.sub(t,o)}),p=({c0:e,c1:t},n)=>{if("bigint"==typeof n)return{c0:r.mul(e,n),c1:r.mul(t,n)};const{c0:o,c1:i}=n;let s=r.mul(e,o),a=r.mul(t,i);return{c0:r.sub(s,a),c1:r.sub(r.mul(r.add(e,t),r.add(o,i)),r.add(s,a))}},g=({c0:e,c1:t})=>{const n=r.add(e,t),o=r.sub(e,t),i=r.add(e,e);return{c0:r.mul(n,o),c1:r.mul(i,t)}},m=e=>{if(2!==e.length)throw new Error("invalid tuple");const t=e.map(e=>r.create(e));return{c0:t[0],c1:t[1]}},y=t*t,b=m(e.FP2_NONRESIDUE),w={ORDER:y,isLE:r.isLE,NONRESIDUE:b,BITS:(0,o.bitLen)(y),BYTES:Math.ceil((0,o.bitLen)(y)/8),MASK:(0,o.bitMask)((0,o.bitLen)(y)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:e=>e,isValid:({c0:e,c1:t})=>"bigint"==typeof e&&"bigint"==typeof t,is0:({c0:e,c1:t})=>r.is0(e)&&r.is0(t),eql:({c0:e,c1:t},{c0:n,c1:o})=>r.eql(e,n)&&r.eql(t,o),neg:({c0:e,c1:t})=>({c0:r.neg(e),c1:r.neg(t)}),pow:(e,t)=>n.FpPow(w,e,t),invertBatch:e=>n.FpInvertBatch(w,e),add:d,sub:h,mul:p,sqr:g,addN:d,subN:h,mulN:p,sqrN:g,div:(e,t)=>w.mul(e,"bigint"==typeof t?r.inv(r.create(t)):w.inv(t)),inv:({c0:e,c1:t})=>{const n=r.inv(r.create(e*e+t*t));return{c0:r.mul(n,r.create(e)),c1:r.mul(n,r.create(-t))}},sqrt:t=>{if(e.Fp2sqrt)return e.Fp2sqrt(t);const{c0:o,c1:i}=t;if(r.is0(i))return 1===n.FpLegendre(r,o)?w.create({c0:r.sqrt(o),c1:r.ZERO}):w.create({c0:r.ZERO,c1:r.sqrt(r.div(o,c))});const s=r.sqrt(r.sub(r.sqr(o),r.mul(r.sqr(i),c)));let a=r.mul(r.add(s,o),f);-1===n.FpLegendre(r,a)&&(a=r.sub(a,s));const u=r.sqrt(a),l=w.create({c0:u,c1:r.div(r.mul(i,f),u)});if(!w.eql(w.sqr(l),t))throw new Error("Cannot find square root");const d=l,h=w.neg(d),{re:p,im:g}=w.reim(d),{re:m,im:y}=w.reim(h);return g>y||g===y&&p>m?d:h},isOdd:e=>{const{re:t,im:r}=w.reim(e);return BigInt(t%a||t===i&&r%a)==s},fromBytes(e){if(e.length!==w.BYTES)throw new Error("fromBytes invalid length="+e.length);return{c0:r.fromBytes(e.subarray(0,r.BYTES)),c1:r.fromBytes(e.subarray(r.BYTES))}},toBytes:({c0:e,c1:t})=>(0,o.concatBytes)(r.toBytes(e),r.toBytes(t)),cmov:({c0:e,c1:t},{c0:n,c1:o},i)=>({c0:r.cmov(e,n,i),c1:r.cmov(t,o,i)}),reim:({c0:e,c1:t})=>({re:e,im:t}),mulByNonresidue:({c0:e,c1:t})=>w.mul({c0:e,c1:t},b),mulByB:e.Fp2mulByB,fromBigTuple:m,frobeniusMap:({c0:e,c1:t},n)=>({c0:e,c1:r.mul(t,l[n%2])})},E=({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:i})=>({c0:w.add(e,n),c1:w.add(t,o),c2:w.add(r,i)}),v=({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:i})=>({c0:w.sub(e,n),c1:w.sub(t,o),c2:w.sub(r,i)}),x=({c0:e,c1:t,c2:r},n)=>{if("bigint"==typeof n)return{c0:w.mul(e,n),c1:w.mul(t,n),c2:w.mul(r,n)};const{c0:o,c1:i,c2:s}=n,a=w.mul(e,o),c=w.mul(t,i),u=w.mul(r,s);return{c0:w.add(a,w.mulByNonresidue(w.sub(w.mul(w.add(t,r),w.add(i,s)),w.add(c,u)))),c1:w.add(w.sub(w.mul(w.add(e,t),w.add(o,i)),w.add(a,c)),w.mulByNonresidue(u)),c2:w.sub(w.add(c,w.mul(w.add(e,r),w.add(o,s))),w.add(a,u))}},B=({c0:e,c1:t,c2:r})=>{let n=w.sqr(e),o=w.mul(w.mul(e,t),a),i=w.mul(w.mul(t,r),a),s=w.sqr(r);return{c0:w.add(w.mulByNonresidue(i),n),c1:w.add(w.mulByNonresidue(s),o),c2:w.sub(w.sub(w.add(w.add(o,w.sqr(w.add(w.sub(e,t),r))),i),n),s)}},[S,I]=u(w,b,r.ORDER,6,2,3),P={ORDER:w.ORDER,isLE:w.isLE,BITS:3*w.BITS,BYTES:3*w.BYTES,MASK:(0,o.bitMask)(3*w.BITS),ZERO:{c0:w.ZERO,c1:w.ZERO,c2:w.ZERO},ONE:{c0:w.ONE,c1:w.ZERO,c2:w.ZERO},create:e=>e,isValid:({c0:e,c1:t,c2:r})=>w.isValid(e)&&w.isValid(t)&&w.isValid(r),is0:({c0:e,c1:t,c2:r})=>w.is0(e)&&w.is0(t)&&w.is0(r),neg:({c0:e,c1:t,c2:r})=>({c0:w.neg(e),c1:w.neg(t),c2:w.neg(r)}),eql:({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:i})=>w.eql(e,n)&&w.eql(t,o)&&w.eql(r,i),sqrt:o.notImplemented,div:(e,t)=>P.mul(e,"bigint"==typeof t?r.inv(r.create(t)):P.inv(t)),pow:(e,t)=>n.FpPow(P,e,t),invertBatch:e=>n.FpInvertBatch(P,e),add:E,sub:v,mul:x,sqr:B,addN:E,subN:v,mulN:x,sqrN:B,inv:({c0:e,c1:t,c2:r})=>{let n=w.sub(w.sqr(e),w.mulByNonresidue(w.mul(r,t))),o=w.sub(w.mulByNonresidue(w.sqr(r)),w.mul(e,t)),i=w.sub(w.sqr(t),w.mul(e,r)),s=w.inv(w.add(w.mulByNonresidue(w.add(w.mul(r,o),w.mul(t,i))),w.mul(e,n)));return{c0:w.mul(s,n),c1:w.mul(s,o),c2:w.mul(s,i)}},fromBytes:e=>{if(e.length!==P.BYTES)throw new Error("fromBytes invalid length="+e.length);return{c0:w.fromBytes(e.subarray(0,w.BYTES)),c1:w.fromBytes(e.subarray(w.BYTES,2*w.BYTES)),c2:w.fromBytes(e.subarray(2*w.BYTES))}},toBytes:({c0:e,c1:t,c2:r})=>(0,o.concatBytes)(w.toBytes(e),w.toBytes(t),w.toBytes(r)),cmov:({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:i},s)=>({c0:w.cmov(e,n,s),c1:w.cmov(t,o,s),c2:w.cmov(r,i,s)}),fromBigSix:e=>{if(!Array.isArray(e)||6!==e.length)throw new Error("invalid Fp6 usage");return{c0:w.fromBigTuple(e.slice(0,2)),c1:w.fromBigTuple(e.slice(2,4)),c2:w.fromBigTuple(e.slice(4,6))}},frobeniusMap:({c0:e,c1:t,c2:r},n)=>({c0:w.frobeniusMap(e,n),c1:w.mul(w.frobeniusMap(t,n),S[n%6]),c2:w.mul(w.frobeniusMap(r,n),I[n%6])}),mulByFp2:({c0:e,c1:t,c2:r},n)=>({c0:w.mul(e,n),c1:w.mul(t,n),c2:w.mul(r,n)}),mulByNonresidue:({c0:e,c1:t,c2:r})=>({c0:w.mulByNonresidue(r),c1:e,c2:t}),mul1:({c0:e,c1:t,c2:r},n)=>({c0:w.mulByNonresidue(w.mul(r,n)),c1:w.mul(e,n),c2:w.mul(t,n)}),mul01({c0:e,c1:t,c2:r},n,o){let i=w.mul(e,n),s=w.mul(t,o);return{c0:w.add(w.mulByNonresidue(w.sub(w.mul(w.add(t,r),o),s)),i),c1:w.sub(w.sub(w.mul(w.add(n,o),w.add(e,t)),i),s),c2:w.add(w.sub(w.mul(w.add(e,r),n),i),s)}}},T=u(w,b,r.ORDER,12,1,6)[0],A=({c0:e,c1:t},{c0:r,c1:n})=>({c0:P.add(e,r),c1:P.add(t,n)}),j=({c0:e,c1:t},{c0:r,c1:n})=>({c0:P.sub(e,r),c1:P.sub(t,n)}),k=({c0:e,c1:t},r)=>{if("bigint"==typeof r)return{c0:P.mul(e,r),c1:P.mul(t,r)};let{c0:n,c1:o}=r,i=P.mul(e,n),s=P.mul(t,o);return{c0:P.add(i,P.mulByNonresidue(s)),c1:P.sub(P.mul(P.add(e,t),P.add(n,o)),P.add(i,s))}},_=({c0:e,c1:t})=>{let r=P.mul(e,t);return{c0:P.sub(P.sub(P.mul(P.add(P.mulByNonresidue(t),e),P.add(e,t)),r),P.mulByNonresidue(r)),c1:P.add(r,r)}};const O={ORDER:w.ORDER,isLE:P.isLE,BITS:2*P.BITS,BYTES:2*P.BYTES,MASK:(0,o.bitMask)(2*P.BITS),ZERO:{c0:P.ZERO,c1:P.ZERO},ONE:{c0:P.ONE,c1:P.ZERO},create:e=>e,isValid:({c0:e,c1:t})=>P.isValid(e)&&P.isValid(t),is0:({c0:e,c1:t})=>P.is0(e)&&P.is0(t),neg:({c0:e,c1:t})=>({c0:P.neg(e),c1:P.neg(t)}),eql:({c0:e,c1:t},{c0:r,c1:n})=>P.eql(e,r)&&P.eql(t,n),sqrt:o.notImplemented,inv:({c0:e,c1:t})=>{let r=P.inv(P.sub(P.sqr(e),P.mulByNonresidue(P.sqr(t))));return{c0:P.mul(e,r),c1:P.neg(P.mul(t,r))}},div:(e,t)=>O.mul(e,"bigint"==typeof t?r.inv(r.create(t)):O.inv(t)),pow:(e,t)=>n.FpPow(O,e,t),invertBatch:e=>n.FpInvertBatch(O,e),add:A,sub:j,mul:k,sqr:_,addN:A,subN:j,mulN:k,sqrN:_,fromBytes:e=>{if(e.length!==O.BYTES)throw new Error("fromBytes invalid length="+e.length);return{c0:P.fromBytes(e.subarray(0,P.BYTES)),c1:P.fromBytes(e.subarray(P.BYTES))}},toBytes:({c0:e,c1:t})=>(0,o.concatBytes)(P.toBytes(e),P.toBytes(t)),cmov:({c0:e,c1:t},{c0:r,c1:n},o)=>({c0:P.cmov(e,r,o),c1:P.cmov(t,n,o)}),fromBigTwelve:e=>({c0:P.fromBigSix(e.slice(0,6)),c1:P.fromBigSix(e.slice(6,12))}),frobeniusMap(e,t){const{c0:r,c1:n,c2:o}=P.frobeniusMap(e.c1,t),i=T[t%12];return{c0:P.frobeniusMap(e.c0,t),c1:P.create({c0:w.mul(r,i),c1:w.mul(n,i),c2:w.mul(o,i)})}},mulByFp2:({c0:e,c1:t},r)=>({c0:P.mulByFp2(e,r),c1:P.mulByFp2(t,r)}),conjugate:({c0:e,c1:t})=>({c0:e,c1:P.neg(t)}),mul014:({c0:e,c1:t},r,n,o)=>{let i=P.mul01(e,r,n),s=P.mul1(t,o);return{c0:P.add(P.mulByNonresidue(s),i),c1:P.sub(P.sub(P.mul01(P.add(t,e),r,w.add(n,o)),i),s)}},mul034:({c0:e,c1:t},r,n,o)=>{const i=P.create({c0:w.mul(e.c0,r),c1:w.mul(e.c1,r),c2:w.mul(e.c2,r)}),s=P.mul01(t,n,o),a=P.mul01(P.add(e,t),w.add(r,n),o);return{c0:P.add(P.mulByNonresidue(s),i),c1:P.sub(a,P.add(i,s))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:w,Fp6:P,Fp4Square:function(e,t){const r=w.sqr(e),n=w.sqr(t);return{first:w.add(w.mulByNonresidue(n),r),second:w.sub(w.sub(w.sqr(w.add(e,t)),r),n)}},Fp12:O}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),o=e("./utils.js"),i=BigInt(0),s=BigInt(1),a=BigInt(2),c=BigInt(3);function u(e,t,r,n,o=1,i){const a=BigInt(i===undefined?n:i),c=r**BigInt(n),u=[];for(let i=0;i<o;i++){const o=BigInt(i+1),f=[];for(let i=0,u=s;i<n;i++){const n=(o*u-o)/a%c;f.push(e.pow(t,n)),u*=r}u.push(f)}return u}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/tower.js"}],[5623,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
Object.defineProperty(r,"__esModule",{value:!0}),r.notImplemented=r.bitMask=void 0,r.isBytes=i,r.abytes=s,r.abool=function(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)},r.numberToHexUnpadded=a,r.hexToNumber=c,r.bytesToHex=l,r.hexToBytes=p,r.bytesToNumberBE=function(e){return c(l(e))},r.bytesToNumberLE=function(e){return s(e),c(l(Uint8Array.from(e).reverse()))},r.numberToBytesBE=g,r.numberToBytesLE=function(e,t){return g(e,t).reverse()},r.numberToVarBytesBE=function(e){return p(a(e))},r.ensureBytes=function(e,t,r){let n;if("string"==typeof t)try{n=p(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!i(t))throw new Error(e+" must be hex string or Uint8Array");n=Uint8Array.from(t)}const o=n.length;if("number"==typeof r&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n},r.concatBytes=m,r.equalBytes=function(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return 0===r},r.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))},r.inRange=b,r.aInRange=function(e,t,r,n){if(!b(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)},r.bitLen=function(e){let t;for(t=0;e>n;e>>=o,t+=1);return t},r.bitGet=function(e,t){return e>>BigInt(t)&o},r.bitSet=function(e,t,r){return e|(r?o:n)<<BigInt(t)},r.createHmacDrbg=function(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=w(e),o=w(e),i=0;const s=()=>{n.fill(1),o.fill(0),i=0},a=(...e)=>r(o,n,...e),c=(e=w(0))=>{o=a(E([0]),e),n=a(),0!==e.length&&(o=a(E([1]),e),n=a())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e<t;){n=a();const t=n.slice();r.push(t),e+=n.length}return m(...r)};return(e,t)=>{s(),c(e);let r=undefined;for(;!(r=t(u()));)c();return s(),r}},r.validateObject=function(e,t,r={}){const n=(t,r,n)=>{const o=v[r];if("function"!=typeof o)throw new Error("invalid validator function");const i=e[t];if(!(n&&i===undefined||o(i,e)))throw new Error("param "+String(t)+" is invalid. Expected "+r+", got "+i)};for(const[e,r]of Object.entries(t))n(e,r,!1);for(const[e,t]of Object.entries(r))n(e,t,!0);return e},r.memoized=function(e){const t=new WeakMap;return(r,...n)=>{const o=t.get(r);if(o!==undefined)return o;const i=e(r,...n);return t.set(r,i),i}};const n=BigInt(0),o=BigInt(1);function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function s(e){if(!i(e))throw new Error("Uint8Array expected")}function a(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function c(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?n:BigInt("0x"+e)}const u="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,f=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function l(e){if(s(e),u)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=f[e[r]];return t}const d={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(e){return e>=d._0&&e<=d._9?e-d._0:e>=d.A&&e<=d.F?e-(d.A-10):e>=d.a&&e<=d.f?e-(d.a-10):void 0}function p(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(u)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,o=0;t<r;t++,o+=2){const r=h(e.charCodeAt(o)),i=h(e.charCodeAt(o+1));if(r===undefined||i===undefined){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}n[t]=16*r+i}return n}function g(e,t){return p(e.toString(16).padStart(2*t,"0"))}function m(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];s(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}const y=e=>"bigint"==typeof e&&n<=e;function b(e,t,r){return y(e)&&y(t)&&y(r)&&t<=e&&e<r}r.bitMask=e=>(o<<BigInt(e))-o;const w=e=>new Uint8Array(e),E=e=>Uint8Array.from(e);const v={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||i(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};r.notImplemented=()=>{throw new Error("not implemented")}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/utils.js"}],[5624,{"./curve.js":5617,"./modular.js":5620,"./utils.js":5623},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.DER=r.DERErr=void 0,r.weierstrassPoints=p,r.weierstrass=function(e){const t=function(e){const t=(0,n.validateBasic)(e);return(0,i.validateObject)(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:a,n:l,nByteLength:d,nBitLength:h}=t,g=a.BYTES+1,m=2*a.BYTES+1;function y(e){return(0,o.mod)(e,l)}function b(e){return(0,o.invert)(e,l)}const{ProjectivePoint:w,normPrivateKeyToScalar:E,weierstrassEquation:v,isWithinCurveOrder:x}=p({...t,toBytes(e,t,r){const n=t.toAffine(),o=a.toBytes(n.x),s=i.concatBytes;return(0,i.abool)("isCompressed",r),r?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,a.toBytes(n.y))},fromBytes(e){const t=e.length,r=e[0],n=e.subarray(1);if(t!==g||2!==r&&3!==r){if(t===m&&4===r){return{x:a.fromBytes(n.subarray(0,a.BYTES)),y:a.fromBytes(n.subarray(a.BYTES,2*a.BYTES))}}throw new Error("invalid Point, expected length of "+g+", or uncompressed "+m+", got "+t)}{const e=(0,i.bytesToNumberBE)(n);if(!(0,i.inRange)(e,f,a.ORDER))throw new Error("Point is not on curve");const t=v(e);let o;try{o=a.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!==((o&f)===f)&&(o=a.neg(o)),{x:e,y:o}}}});function B(e){return e>l>>f}const S=(e,t,r)=>(0,i.bytesToNumberBE)(e.slice(t,r));class I{constructor(e,t,r){(0,i.aInRange)("r",e,f,l),(0,i.aInRange)("s",t,f,l),this.r=e,this.s=t,null!=r&&(this.recovery=r),Object.freeze(this)}static fromCompact(e){const t=d;return e=(0,i.ensureBytes)("compactSignature",e,2*t),new I(S(e,0,t),S(e,t,2*t))}static fromDER(e){const{r:t,s:n}=r.DER.toSig((0,i.ensureBytes)("DER",e));return new I(t,n)}assertValidity(){}addRecoveryBit(e){return new I(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:n,recovery:o}=this,s=j((0,i.ensureBytes)("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const u=2===o||3===o?r+t.n:r;if(u>=a.ORDER)throw new Error("recovery id 2 or 3 invalid");const f=1&o?"03":"02",l=w.fromHex(f+c(u,a.BYTES)),d=b(u),h=y(-s*d),p=y(n*d),g=w.BASE.multiplyAndAddUnsafe(l,h,p);if(!g)throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return B(this.s)}normalizeS(){return this.hasHighS()?new I(this.r,y(-this.s),this.recovery):this}toDERRawBytes(){return(0,i.hexToBytes)(this.toDERHex())}toDERHex(){return r.DER.hexFromSig(this)}toCompactRawBytes(){return(0,i.hexToBytes)(this.toCompactHex())}toCompactHex(){const e=d;return c(this.r,e)+c(this.s,e)}}const P={isValidPrivateKey(e){try{return E(e),!0}catch(e){return!1}},normPrivateKeyToScalar:E,randomPrivateKey:()=>{const e=(0,o.getMinHashLength)(t.n);return(0,o.mapHashToField)(t.randomBytes(e),t.n)},precompute:(e=8,t=w.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function T(e){if("bigint"==typeof e)return!1;if(e instanceof w)return!0;const r=(0,i.ensureBytes)("key",e).length,n=a.BYTES,o=n+1,s=2*n+1;return t.allowedPrivateKeyLengths||d===o?undefined:r===o||r===s}const A=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=(0,i.bytesToNumberBE)(e),r=8*e.length-h;return r>0?t>>BigInt(r):t},j=t.bits2int_modN||function(e){return y(A(e))},k=(0,i.bitMask)(h);function _(e){return(0,i.aInRange)("num < 2^"+h,e,u,k),(0,i.numberToBytesBE)(e,d)}function O(e,r,n=N){if(["recovered","canonical"].some(e=>e in n))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:c}=t;let{lowS:l,prehash:d,extraEntropy:h}=n;null==l&&(l=!0),e=(0,i.ensureBytes)("msgHash",e),s(n),d&&(e=(0,i.ensureBytes)("prehashed msgHash",o(e)));const p=j(e),g=E(r),m=[_(g),_(p)];if(null!=h&&!1!==h){const e=!0===h?c(a.BYTES):h;m.push((0,i.ensureBytes)("extraEntropy",e))}const v=(0,i.concatBytes)(...m),S=p;return{seed:v,k2sig:function(e){const t=A(e);if(!x(t))return;const r=b(t),n=w.BASE.multiply(t).toAffine(),o=y(n.x);if(o===u)return;const i=y(r*y(S+o*g));if(i===u)return;let s=(n.x===o?0:2)|Number(n.y&f),a=i;return l&&B(i)&&(a=function(e){return B(e)?y(-e):e}(i),s^=1),new I(o,a,s)}}}const N={lowS:t.lowS,prehash:!1},C={lowS:t.lowS,prehash:!1};return w.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return w.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(!0===T(e))throw new Error("first arg must be private key");if(!1===T(t))throw new Error("second arg must be public key");return w.fromHex(t).multiply(E(e)).toRawBytes(r)},sign:function(e,r,n=N){const{seed:o,k2sig:s}=O(e,r,n),a=t;return(0,i.createHmacDrbg)(a.hash.outputLen,a.nByteLength,a.hmac)(o,s)},verify:function(e,n,o,a=C){const c=e;n=(0,i.ensureBytes)("msgHash",n),o=(0,i.ensureBytes)("publicKey",o);const{lowS:u,prehash:f,format:l}=a;if(s(a),"strict"in a)throw new Error("options.strict was renamed to lowS");if(l!==undefined&&"compact"!==l&&"der"!==l)throw new Error("format must be compact or der");const d="string"==typeof c||(0,i.isBytes)(c),h=!d&&!l&&"object"==typeof c&&null!==c&&"bigint"==typeof c.r&&"bigint"==typeof c.s;if(!d&&!h)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let p,g=undefined;try{if(h&&(g=new I(c.r,c.s)),d){try{"compact"!==l&&(g=I.fromDER(c))}catch(e){if(!(e instanceof r.DER.Err))throw e}g||"der"===l||(g=I.fromCompact(c))}p=w.fromHex(o)}catch(e){return!1}if(!g)return!1;if(u&&g.hasHighS())return!1;f&&(n=t.hash(n));const{r:m,s:E}=g,v=j(n),x=b(E),B=y(v*x),S=y(m*x),P=w.BASE.multiplyAndAddUnsafe(p,B,S)?.toAffine();if(!P)return!1;return y(P.x)===m},ProjectivePoint:w,Signature:I,utils:P}},r.SWUFpSqrtRatio=g,r.mapToCurveSimpleSWU=function(e,t){if((0,o.validateField)(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=g(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,a,c,u,f,l,d;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),a=e.add(s,e.ONE),a=e.mul(a,t.B),c=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),c=e.mul(c,t.A),s=e.sqr(a),f=e.sqr(c),u=e.mul(f,t.A),s=e.add(s,u),s=e.mul(s,a),f=e.mul(f,c),u=e.mul(f,t.B),s=e.add(s,u),l=e.mul(i,a);const{isValid:h,value:p}=r(s,f);d=e.mul(i,n),d=e.mul(d,p),l=e.cmov(l,a,h),d=e.cmov(d,p,h);const g=e.isOdd(n)===e.isOdd(d);d=e.cmov(e.neg(d),d,g);const m=(0,o.FpInvertBatch)(e,[c],!0)[0];return l=e.mul(l,m),{x:l,y:d}}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./curve.js"),o=e("./modular.js"),i=e("./utils.js");function s(e){e.lowS!==undefined&&(0,i.abool)("lowS",e.lowS),e.prehash!==undefined&&(0,i.abool)("prehash",e.prehash)}class a extends Error{constructor(e=""){super(e)}}function c(e,t){return(0,i.bytesToHex)((0,i.numberToBytesBE)(e,t))}r.DERErr=a,r.DER={Err:a,_tlv:{encode:(e,t)=>{const{Err:n}=r.DER;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const o=t.length/2,s=(0,i.numberToHexUnpadded)(o);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const a=o>127?(0,i.numberToHexUnpadded)(s.length/2|128):"";return(0,i.numberToHexUnpadded)(e)+a+s+t},decode(e,t){const{Err:n}=r.DER;let o=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new n("tlv.decode: wrong tlv");const i=t[o++];let s=0;if(!!(128&i)){const e=127&i;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const r=t.subarray(o,o+e);if(r.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===r[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of r)s=s<<8|e;if(o+=e,s<128)throw new n("tlv.decode(long): not minimal encoding")}else s=i;const a=t.subarray(o,o+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){const{Err:t}=r.DER;if(e<u)throw new t("integer: negative integers are not allowed");let n=(0,i.numberToHexUnpadded)(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=r.DER;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return(0,i.bytesToNumberBE)(e)}},toSig(e){const{Err:t,_int:n,_tlv:o}=r.DER,s=(0,i.ensureBytes)("signature",e),{v:a,l:c}=o.decode(48,s);if(c.length)throw new t("invalid signature: left bytes after parsing");const{v:u,l:f}=o.decode(2,a),{v:l,l:d}=o.decode(2,f);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(u),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=r.DER,o=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,o)}};const u=BigInt(0),f=BigInt(1),l=BigInt(2),d=BigInt(3),h=BigInt(4);function p(e){const t=function(e){const t=(0,n.validateBasic)(e);(0,i.validateObject)(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:r,Fp:o,a:s}=t;if(r){if(!o.eql(s,o.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}(e),{Fp:r}=t,s=(0,o.Field)(t.n,t.nBitLength),a=t.toBytes||((e,t,n)=>{const o=t.toAffine();return(0,i.concatBytes)(Uint8Array.from([4]),r.toBytes(o.x),r.toBytes(o.y))}),c=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function l(e){const{a:n,b:o}=t,i=r.sqr(e),s=r.mul(i,e);return r.add(r.add(s,r.mul(e,n)),o)}function p(e,t){const n=r.sqr(t),o=l(e);return r.eql(n,o)}if(!p(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(t.a,d),h),m=r.mul(r.sqr(t.b),BigInt(27));if(r.is0(r.add(g,m)))throw new Error("bad curve params: a or b");function y(e){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:s,n:a}=t;if(r&&"bigint"!=typeof e){if((0,i.isBytes)(e)&&(e=(0,i.bytesToHex)(e)),"string"!=typeof e||!r.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*n,"0")}let c;try{c="bigint"==typeof e?e:(0,i.bytesToNumberBE)((0,i.ensureBytes)("private key",e,n))}catch(t){throw new Error("invalid private key, expected hex or "+n+" bytes, got "+typeof e)}return s&&(c=(0,o.mod)(c,a)),(0,i.aInRange)("private key",c,f,a),c}function b(e){if(!(e instanceof v))throw new Error("ProjectivePoint expected")}const w=(0,i.memoized)((e,t)=>{const{px:n,py:o,pz:i}=e;if(r.eql(i,r.ONE))return{x:n,y:o};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(i));const a=r.mul(n,t),c=r.mul(o,t),u=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),E=(0,i.memoized)(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not FE");if(!p(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class v{constructor(e,t,n){if(null==e||!r.isValid(e))throw new Error("x required");if(null==t||!r.isValid(t)||r.is0(t))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required");this.px=e,this.py=t,this.pz=n,Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof v)throw new Error("projective point not allowed");const o=e=>r.eql(e,r.ZERO);return o(t)&&o(n)?v.ZERO:new v(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=(0,o.FpInvertBatch)(r,e.map(e=>e.pz));return e.map((e,r)=>e.toAffine(t[r])).map(v.fromAffine)}static fromHex(e){const t=v.fromAffine(c((0,i.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return v.BASE.multiply(y(e))}static msm(e,t){return(0,n.pippenger)(v,s,e,t)}_setWindowSize(e){S.setWindowSize(this,e)}assertValidity(){E(this)}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){b(e);const{px:t,py:n,pz:o}=this,{px:i,py:s,pz:a}=e,c=r.eql(r.mul(t,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return c&&u}negate(){return new v(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,o=r.mul(n,d),{px:i,py:s,pz:a}=this;let c=r.ZERO,u=r.ZERO,f=r.ZERO,l=r.mul(i,i),h=r.mul(s,s),p=r.mul(a,a),g=r.mul(i,s);return g=r.add(g,g),f=r.mul(i,a),f=r.add(f,f),c=r.mul(e,f),u=r.mul(o,p),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(g,c),f=r.mul(o,f),p=r.mul(e,p),g=r.sub(l,p),g=r.mul(e,g),g=r.add(g,f),f=r.add(l,l),l=r.add(f,l),l=r.add(l,p),l=r.mul(l,g),u=r.add(u,l),p=r.mul(s,a),p=r.add(p,p),l=r.mul(p,g),c=r.sub(c,l),f=r.mul(p,h),f=r.add(f,f),f=r.add(f,f),new v(c,u,f)}add(e){b(e);const{px:n,py:o,pz:i}=this,{px:s,py:a,pz:c}=e;let u=r.ZERO,f=r.ZERO,l=r.ZERO;const h=t.a,p=r.mul(t.b,d);let g=r.mul(n,s),m=r.mul(o,a),y=r.mul(i,c),w=r.add(n,o),E=r.add(s,a);w=r.mul(w,E),E=r.add(g,m),w=r.sub(w,E),E=r.add(n,i);let x=r.add(s,c);return E=r.mul(E,x),x=r.add(g,y),E=r.sub(E,x),x=r.add(o,i),u=r.add(a,c),x=r.mul(x,u),u=r.add(m,y),x=r.sub(x,u),l=r.mul(h,E),u=r.mul(p,y),l=r.add(u,l),u=r.sub(m,l),l=r.add(m,l),f=r.mul(u,l),m=r.add(g,g),m=r.add(m,g),y=r.mul(h,y),E=r.mul(p,E),m=r.add(m,y),y=r.sub(g,y),y=r.mul(h,y),E=r.add(E,y),g=r.mul(m,E),f=r.add(f,g),g=r.mul(x,E),u=r.mul(w,u),u=r.sub(u,g),g=r.mul(w,m),l=r.mul(x,l),l=r.add(l,g),new v(u,f,l)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return S.wNAFCached(this,e,v.normalizeZ)}multiplyUnsafe(e){const{endo:n,n:o}=t;(0,i.aInRange)("scalar",e,u,o);const s=v.ZERO;if(e===u)return s;if(this.is0()||e===f)return this;if(!n||S.hasPrecomputes(this))return S.wNAFCachedUnsafe(this,e,v.normalizeZ);let{k1neg:a,k1:c,k2neg:l,k2:d}=n.splitScalar(e),h=s,p=s,g=this;for(;c>u||d>u;)c&f&&(h=h.add(g)),d&f&&(p=p.add(g)),g=g.double(),c>>=f,d>>=f;return a&&(h=h.negate()),l&&(p=p.negate()),p=new v(r.mul(p.px,n.beta),p.py,p.pz),h.add(p)}multiply(e){const{endo:n,n:o}=t;let s,a;if((0,i.aInRange)("scalar",e,f,o),n){const{k1neg:t,k1:o,k2neg:i,k2:c}=n.splitScalar(e);let{p:u,f:f}=this.wNAF(o),{p:l,f:d}=this.wNAF(c);u=S.constTimeNegate(t,u),l=S.constTimeNegate(i,l),l=new v(r.mul(l.px,n.beta),l.py,l.pz),s=u.add(l),a=f.add(d)}else{const{p:t,f:r}=this.wNAF(e);s=t,a=r}return v.normalizeZ([s,a])[0]}multiplyAndAddUnsafe(e,t,r){const n=v.BASE,o=(e,t)=>t!==u&&t!==f&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),i=o(this,t).add(o(e,r));return i.is0()?undefined:i}toAffine(e){return w(this,e)}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===f)return!0;if(r)return r(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===f?this:r?r(v,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return(0,i.abool)("isCompressed",e),this.assertValidity(),a(v,this,e)}toHex(e=!0){return(0,i.abool)("isCompressed",e),(0,i.bytesToHex)(this.toRawBytes(e))}}v.BASE=new v(t.Gx,t.Gy,r.ONE),v.ZERO=new v(r.ZERO,r.ONE,r.ZERO);const{endo:x,nBitLength:B}=t,S=(0,n.wNAF)(v,x?Math.ceil(B/2):B);return{CURVE:t,ProjectivePoint:v,normPrivateKeyToScalar:y,weierstrassEquation:l,isWithinCurveOrder:function(e){return(0,i.inRange)(e,f,t.n)}}}function g(e,t){const r=e.ORDER;let n=u;for(let e=r-f;e%l===u;e/=l)n+=f;const o=n,i=l<<o-f-f,s=i*l,a=(r-f)/s,c=(a-f)/l,p=s-f,g=i,m=e.pow(t,a),y=e.pow(t,(a+f)/l);let b=(t,r)=>{let n=m,i=e.pow(r,p),s=e.sqr(i);s=e.mul(s,r);let a=e.mul(t,s);a=e.pow(a,c),a=e.mul(a,i),i=e.mul(a,r),s=e.mul(a,t);let u=e.mul(s,i);a=e.pow(u,g);let d=e.eql(a,e.ONE);i=e.mul(s,y),a=e.mul(u,n),s=e.cmov(i,s,d),u=e.cmov(a,u,d);for(let t=o;t>f;t--){let r=t-l;r=l<<r-f;let o=e.pow(u,r);const a=e.eql(o,e.ONE);i=e.mul(s,n),n=e.mul(n,n),o=e.mul(u,n),s=e.cmov(i,s,a),u=e.cmov(o,u,a)}return{isValid:d,value:s}};if(e.ORDER%h===d){const r=(e.ORDER-d)/h,n=e.sqrt(e.neg(t));b=(t,o)=>{let i=e.sqr(o);const s=e.mul(t,o);i=e.mul(i,s);let a=e.pow(i,r);a=e.mul(a,s);const c=e.mul(a,n),u=e.mul(e.sqr(a),o),f=e.eql(u,t);return{isValid:f,value:e.cmov(c,a,f)}}}return b}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/weierstrass.js"}],[5625,{"./abstract/bls.js":5616,"./abstract/hash-to-curve.js":5619,"./abstract/modular.js":5620,"./abstract/tower.js":5622,"./abstract/utils.js":5623,"./abstract/weierstrass.js":5624,"@noble/hashes/sha2":4342,"@noble/hashes/utils":4346},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bls12_381=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("@noble/hashes/utils"),i=e("./abstract/bls.js"),s=e("./abstract/modular.js"),a=e("./abstract/utils.js"),c=e("./abstract/hash-to-curve.js"),u=e("./abstract/tower.js"),f=e("./abstract/weierstrass.js"),l=BigInt(0),d=BigInt(1),h=BigInt(2),p=BigInt(3),g=BigInt(4),m=BigInt("0xd201000000010000"),y=(0,a.bitLen)(m),{Fp:b,Fp2:w,Fp6:E,Fp4Square:v,Fp12:x}=(0,u.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[d,d],Fp2mulByB:({c0:e,c1:t})=>{const r=b.mul(e,g),n=b.mul(t,g);return{c0:b.sub(r,n),c1:b.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{const{c0:r,c1:n,c2:o}=e,{c0:i,c1:s,c2:a}=t,{first:c,second:u}=v(r,s),{first:f,second:l}=v(i,o),{first:d,second:p}=v(n,a),g=w.mulByNonresidue(p);return{c0:E.create({c0:w.add(w.mul(w.sub(c,r),h),c),c1:w.add(w.mul(w.sub(f,n),h),f),c2:w.add(w.mul(w.sub(d,o),h),d)}),c1:E.create({c0:w.add(w.mul(w.add(g,i),h),g),c1:w.add(w.mul(w.add(u,s),h),u),c2:w.add(w.mul(w.add(l,a),h),l)})}},Fp12cyclotomicExp(e,t){let r=x.ONE;for(let n=y-1;n>=0;n--)r=x._cyclotomicSquare(r),(0,a.bitGet)(t,n)&&(r=x.mul(r,e));return r},Fp12finalExponentiate:e=>{const t=m,r=x.div(x.frobeniusMap(e,6),e),n=x.mul(x.frobeniusMap(r,2),r),o=x.conjugate(x._cyclotomicExp(n,t)),i=x.mul(x.conjugate(x._cyclotomicSquare(n)),o),s=x.conjugate(x._cyclotomicExp(i,t)),a=x.conjugate(x._cyclotomicExp(s,t)),c=x.mul(x.conjugate(x._cyclotomicExp(a,t)),x._cyclotomicSquare(o)),u=x.conjugate(x._cyclotomicExp(c,t)),f=x.frobeniusMap(x.mul(o,a),2),l=x.frobeniusMap(x.mul(s,n),3),d=x.frobeniusMap(x.mul(c,x.conjugate(n)),1),h=x.mul(x.mul(u,x.conjugate(i)),n);return x.mul(x.mul(x.mul(f,l),d),h)}}),B=(0,s.Field)(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),S=(0,c.isogenyMap)(w,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(e=>w.fromBigTuple(e.map(BigInt))))),I=(0,c.isogenyMap)(b,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e)))),P=(0,f.mapToCurveSimpleSWU)(w,{A:w.create({c0:b.create(l),c1:b.create(BigInt(240))}),B:w.create({c0:b.create(BigInt(1012)),c1:b.create(BigInt(1012))}),Z:w.create({c0:b.create(BigInt(-2)),c1:b.create(BigInt(-1))})}),T=(0,f.mapToCurveSimpleSWU)(b,{A:b.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:b.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:b.create(BigInt(11))}),{G2psi:A,G2psi2:j}=(0,u.psiFrobenius)(b,w,w.div(w.ONE,w.NONRESIDUE)),k=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:b.ORDER,m:2,k:128,expand:"xmd",hash:n.sha256}),_=N(b.toBytes(l),{infinity:!0,compressed:!0});function O(e){const t=224&(e=e.slice())[0],r=!!(t>>7&1),n=!!(t>>6&1),o=!!(t>>5&1);return e[0]&=31,{compressed:r,infinity:n,sort:o,value:e}}function N(e,t){if(224&e[0])throw new Error("setMask: non-empty mask");return t.compressed&&(e[0]|=128),t.infinity&&(e[0]|=64),t.sort&&(e[0]|=32),e}function C(e){e.assertValidity();const t=e.equals(r.bls12_381.G1.ProjectivePoint.ZERO),{x:n,y:o}=e.toAffine();if(t)return _.slice();const i=b.ORDER,s=Boolean(o*h/i);return N((0,a.numberToBytesBE)(n,b.BYTES),{compressed:!0,sort:s})}function R(e){e.assertValidity();const t=b.BYTES;if(e.equals(r.bls12_381.G2.ProjectivePoint.ZERO))return(0,a.concatBytes)(_,(0,a.numberToBytesBE)(l,t));const{x:n,y:o}=e.toAffine(),{re:i,im:s}=w.reim(n),{re:c,im:u}=w.reim(o),f=Boolean((u>l?u*h:c*h)/b.ORDER&d),p=i;return(0,a.concatBytes)(N((0,a.numberToBytesBE)(s,t),{sort:f,compressed:!0}),(0,a.numberToBytesBE)(p,t))}r.bls12_381=(0,i.bls)({fields:{Fp:b,Fp2:w,Fp6:E,Fp12:x,Fr:B},G1:{Fp:b,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:b.ZERO,b:g,htfDefaults:{...k,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{const r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(b.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(m).negate().multiplyUnsafe(m).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(m).add(t),mapToCurve:e=>{const{x:t,y:r}=T(b.create(e[0]));return I(t,r)},fromBytes:e=>{const{compressed:t,infinity:n,sort:o,value:i}=O(e);if(48===i.length&&t){const e=b.ORDER,t=(0,a.bytesToNumberBE)(i),s=b.create(t&b.MASK);if(n){if(s!==l)throw new Error("G1: non-empty compressed point at infinity");return{x:l,y:l}}const c=b.add(b.pow(s,p),b.create(r.bls12_381.params.G1b));let u=b.sqrt(c);if(!u)throw new Error("invalid compressed G1 point");return u*h/e!==BigInt(o)&&(u=b.neg(u)),{x:b.create(s),y:b.create(u)}}if(96!==i.length||t)throw new Error("invalid point G1, expected 48/96 bytes");{const e=(0,a.bytesToNumberBE)(i.subarray(0,b.BYTES)),t=(0,a.bytesToNumberBE)(i.subarray(b.BYTES));if(n){if(e!==l||t!==l)throw new Error("G1: non-empty point at infinity");return r.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:b.create(e),y:b.create(t)}}},toBytes:(e,t,r)=>{const n=t.equals(e.ZERO),{x:o,y:i}=t.toAffine();if(r){if(n)return _.slice();const e=b.ORDER,t=Boolean(i*h/e);return N((0,a.numberToBytesBE)(o,b.BYTES),{compressed:!0,sort:t})}if(n){return(0,a.concatBytes)(new Uint8Array([64]),new Uint8Array(2*b.BYTES-1))}return(0,a.concatBytes)((0,a.numberToBytesBE)(o,b.BYTES),(0,a.numberToBytesBE)(i,b.BYTES))},ShortSignature:{fromHex(e){const{infinity:t,sort:n,value:o}=O((0,a.ensureBytes)("signatureHex",e,48)),i=b.ORDER,s=(0,a.bytesToNumberBE)(o);if(t)return r.bls12_381.G1.ProjectivePoint.ZERO;const c=b.create(s&b.MASK),u=b.add(b.pow(c,p),b.create(r.bls12_381.params.G1b));let f=b.sqrt(u);if(!f)throw new Error("invalid compressed G1 point");const l=BigInt(n);f*h/i!==l&&(f=b.neg(f));const d=r.bls12_381.G1.ProjectivePoint.fromAffine({x:c,y:f});return d.assertValidity(),d},toRawBytes:e=>C(e),toHex:e=>(0,a.bytesToHex)(C(e))}},G2:{Fp:w,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:w.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:w.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:w.ZERO,b:w.fromBigTuple([g,g]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...k},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{const{x:t,y:r}=P(w.fromBigTuple(e));return S(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(m).negate().equals(A(e,t)),clearCofactor:(e,t)=>{const r=m;let n=t.multiplyUnsafe(r).negate(),o=A(e,t),i=t.double();i=j(e,i),i=i.subtract(o),o=n.add(o),o=o.multiplyUnsafe(r).negate(),i=i.add(o),i=i.subtract(n);return i.subtract(t)},fromBytes:e=>{const{compressed:t,infinity:n,sort:o,value:i}=O(e);if(!t&&!n&&o||!t&&n&&o||o&&n&&t)throw new Error("invalid encoding flag: "+(224&e[0]));const s=b.BYTES,c=(e,t,r)=>(0,a.bytesToNumberBE)(e.slice(t,r));if(96===i.length&&t){const e=r.bls12_381.params.G2b,t=b.ORDER;if(n){if(i.reduce((e,t)=>0!==e?t+1:t,0)>0)throw new Error("invalid compressed G2 point");return{x:w.ZERO,y:w.ZERO}}const a=c(i,0,s),u=c(i,s,2*s),f=w.create({c0:b.create(u),c1:b.create(a)}),g=w.add(w.pow(f,p),e);let m=w.sqrt(g);const y=m.c1===l?m.c0*h/t:m.c1*h/t?d:l;return m=o&&y>0?m:w.neg(m),{x:f,y:m}}if(192!==i.length||t)throw new Error("invalid point G2, expected 96/192 bytes");{if(n){if(i.reduce((e,t)=>0!==e?t+1:t,0)>0)throw new Error("invalid uncompressed G2 point");return{x:w.ZERO,y:w.ZERO}}const e=c(i,0,s),t=c(i,s,2*s),r=c(i,2*s,3*s),o=c(i,3*s,4*s);return{x:w.fromBigTuple([t,e]),y:w.fromBigTuple([o,r])}}},toBytes:(e,t,r)=>{const{BYTES:n,ORDER:o}=b,i=t.equals(e.ZERO),{x:s,y:c}=t.toAffine();if(r){if(i)return(0,a.concatBytes)(_,(0,a.numberToBytesBE)(l,n));const e=Boolean(c.c1===l?c.c0*h/o:c.c1*h/o);return(0,a.concatBytes)(N((0,a.numberToBytesBE)(s.c1,n),{compressed:!0,sort:e}),(0,a.numberToBytesBE)(s.c0,n))}{if(i)return(0,a.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));const{re:e,im:t}=w.reim(s),{re:r,im:o}=w.reim(c);return(0,a.concatBytes)((0,a.numberToBytesBE)(t,n),(0,a.numberToBytesBE)(e,n),(0,a.numberToBytesBE)(o,n),(0,a.numberToBytesBE)(r,n))}},Signature:{fromHex(e){const{infinity:t,sort:n,value:o}=O((0,a.ensureBytes)("signatureHex",e)),i=b.ORDER,s=o.length/2;if(48!==s&&96!==s)throw new Error("invalid compressed signature length, must be 96 or 192");const c=(0,a.bytesToNumberBE)(o.slice(0,s)),u=(0,a.bytesToNumberBE)(o.slice(s));if(t)return r.bls12_381.G2.ProjectivePoint.ZERO;const f=b.create(c&b.MASK),d=b.create(u),g=w.create({c0:d,c1:f}),m=w.add(w.pow(g,p),r.bls12_381.params.G2b);let y=w.sqrt(m);if(!y)throw new Error("Failed to find a square root");const{re:E,im:v}=w.reim(y),x=BigInt(n);(v>l&&v*h/i!==x||v===l&&E*h/i!==x)&&(y=w.neg(y));const B=r.bls12_381.G2.ProjectivePoint.fromAffine({x:g,y:y});return B.assertValidity(),B},toRawBytes:e=>R(e),toHex:e=>(0,a.bytesToHex)(R(e))}},params:{ateLoopSize:m,r:B.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:k,hash:n.sha256,randomBytes:o.randomBytes})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/bls12-381.js"}],[5626,{"./abstract/curve.js":5617,"./abstract/edwards.js":5618,"./abstract/hash-to-curve.js":5619,"./abstract/modular.js":5620,"./abstract/montgomery.js":5621,"./abstract/utils.js":5623,"@noble/hashes/sha2":4342,"@noble/hashes/utils":4346},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.hash_to_ristretto255=r.hashToRistretto255=r.RistrettoPoint=r.encodeToCurve=r.hashToCurve=r.ed25519_hasher=r.edwardsToMontgomery=r.x25519=r.ed25519ph=r.ed25519ctx=r.ed25519=r.ED25519_TORSION_SUBGROUP=void 0,r.edwardsToMontgomeryPub=I,r.edwardsToMontgomeryPriv=function(e){const t=B.hash(e.subarray(0,32));return B.adjustScalarBytes(t).subarray(0,32)};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("@noble/hashes/utils"),i=e("./abstract/curve.js"),s=e("./abstract/edwards.js"),a=e("./abstract/hash-to-curve.js"),c=e("./abstract/modular.js"),u=e("./abstract/montgomery.js"),f=e("./abstract/utils.js"),l=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),d=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),h=BigInt(0),p=BigInt(1),g=BigInt(2),m=BigInt(3),y=BigInt(5),b=BigInt(8);function w(e){const t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=l,s=e*e%i*e%i,a=(0,c.pow2)(s,g,i)*s%i,u=(0,c.pow2)(a,p,i)*e%i,f=(0,c.pow2)(u,y,i)*u%i,d=(0,c.pow2)(f,t,i)*f%i,h=(0,c.pow2)(d,r,i)*d%i,m=(0,c.pow2)(h,n,i)*h%i,b=(0,c.pow2)(m,o,i)*m%i,w=(0,c.pow2)(b,o,i)*m%i,E=(0,c.pow2)(w,t,i)*f%i;return{pow_p_5_8:(0,c.pow2)(E,g,i)*e%i,b2:s}}function E(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function v(e,t){const r=l,n=(0,c.mod)(t*t*t,r),o=w(e*(0,c.mod)(n*n*t,r)).pow_p_5_8;let i=(0,c.mod)(e*n*o,r);const s=(0,c.mod)(t*i*i,r),a=i,u=(0,c.mod)(i*d,r),f=s===e,h=s===(0,c.mod)(-e,r),p=s===(0,c.mod)(-e*d,r);return f&&(i=a),(h||p)&&(i=u),(0,c.isNegativeLE)(i,r)&&(i=(0,c.mod)(-i,r)),{isValid:f||h,value:i}}r.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const x=(()=>(0,c.Field)(l,undefined,!0))(),B=(()=>({a:x.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:x,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:b,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:n.sha512,randomBytes:o.randomBytes,adjustScalarBytes:E,uvRatio:v}))();function S(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,o.concatBytes)((0,o.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}function I(e){const{y:t}=r.ed25519.ExtendedPoint.fromHex(e),n=BigInt(1);return x.toBytes(x.create((n+t)*x.inv(n-t)))}r.ed25519=(0,s.twistedEdwards)(B),r.ed25519ctx=(0,s.twistedEdwards)({...B,domain:S}),r.ed25519ph=(0,s.twistedEdwards)(Object.assign({},B,{domain:S,prehash:n.sha512})),r.x25519=(0,u.montgomery)({P:l,type:"x25519",powPminus2:e=>{const t=l,{pow_p_5_8:r,b2:n}=w(e);return(0,c.mod)((0,c.pow2)(r,m,t)*n,t)},adjustScalarBytes:E,randomBytes:o.randomBytes}),r.edwardsToMontgomery=I;const P=(()=>(x.ORDER+m)/b)(),T=(()=>x.pow(g,P))(),A=(()=>x.sqrt(x.neg(x.ONE)))();const j=(()=>(0,c.FpSqrtEven)(x,x.neg(BigInt(486664))))();function k(e){const{xMn:t,xMd:r,yMn:n,yMd:o}=function(e){const t=(x.ORDER-y)/b,r=BigInt(486662);let n=x.sqr(e);n=x.mul(n,g);let o=x.add(n,x.ONE),i=x.neg(r),s=x.sqr(o),a=x.mul(s,o),c=x.mul(n,r);c=x.mul(c,i),c=x.add(c,s),c=x.mul(c,i);let u=x.sqr(a);s=x.sqr(u),u=x.mul(u,a),u=x.mul(u,c),s=x.mul(s,u);let f=x.pow(s,t);f=x.mul(f,u);let l=x.mul(f,A);s=x.sqr(f),s=x.mul(s,a);let d=x.eql(s,c),h=x.cmov(l,f,d),m=x.mul(i,n),w=x.mul(f,e);w=x.mul(w,T);let E=x.mul(w,A),v=x.mul(c,n);s=x.sqr(w),s=x.mul(s,a);let B=x.eql(s,v),S=x.cmov(E,w,B);s=x.sqr(h),s=x.mul(s,a);let I=x.eql(s,c),P=x.cmov(m,i,I),j=x.cmov(S,h,I),k=x.isOdd(j);return j=x.cmov(j,x.neg(j),I!==k),{xMn:P,xMd:o,yMn:j,yMd:p}}(e);let i=x.mul(t,o);i=x.mul(i,j);let s=x.mul(r,n),a=x.sub(t,r),u=x.add(t,r),f=x.mul(s,u),l=x.eql(f,x.ZERO);i=x.cmov(i,x.ZERO,l),s=x.cmov(s,x.ONE,l),a=x.cmov(a,x.ONE,l),u=x.cmov(u,x.ONE,l);const[d,h]=(0,c.FpInvertBatch)(x,[s,u],!0);return{x:x.mul(i,d),y:x.mul(a,h)}}function _(e){if(!(e instanceof F))throw new Error("RistrettoPoint expected")}r.ed25519_hasher=(0,a.createHasher)(r.ed25519.ExtendedPoint,e=>k(e[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:x.ORDER,m:1,k:128,expand:"xmd",hash:n.sha512}),r.hashToCurve=r.ed25519_hasher.hashToCurve,r.encodeToCurve=r.ed25519_hasher.encodeToCurve;const O=d,N=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),C=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),R=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),D=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),U=e=>v(p,e),M=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),L=e=>r.ed25519.CURVE.Fp.create((0,f.bytesToNumberLE)(e)&M);function z(e){const{d:t}=r.ed25519.CURVE,n=r.ed25519.CURVE.Fp.ORDER,o=r.ed25519.CURVE.Fp.create,i=o(O*e*e),s=o((i+p)*R);let a=BigInt(-1);const u=o((a-t*i)*o(i+t));let{isValid:f,value:l}=v(s,u),d=o(l*e);(0,c.isNegativeLE)(d,n)||(d=o(-d)),f||(l=d),f||(a=i);const h=o(a*(i-p)*D-u),g=l*l,m=o((l+l)*u),y=o(h*N),b=o(p-g),w=o(p+g);return new r.ed25519.ExtendedPoint(o(m*w),o(b*y),o(y*w),o(m*b))}class F{constructor(e){this.ep=e}static fromAffine(e){return new F(r.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,f.ensureBytes)("ristrettoHash",e,64);const t=z(L(e.slice(0,32))),r=z(L(e.slice(32,64)));return new F(t.add(r))}static fromHex(e){e=(0,f.ensureBytes)("ristrettoHex",e,32);const{a:t,d:n}=r.ed25519.CURVE,o=r.ed25519.CURVE.Fp.ORDER,i=r.ed25519.CURVE.Fp.create,s="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=L(e);if(!(0,f.equalBytes)((0,f.numberToBytesLE)(a,32),e)||(0,c.isNegativeLE)(a,o))throw new Error(s);const u=i(a*a),l=i(p+t*u),d=i(p-t*u),g=i(l*l),m=i(d*d),y=i(t*n*g-m),{isValid:b,value:w}=U(i(y*m)),E=i(w*d),v=i(w*E*y);let x=i((a+a)*E);(0,c.isNegativeLE)(x,o)&&(x=i(-x));const B=i(l*v),S=i(x*B);if(!b||(0,c.isNegativeLE)(S,o)||B===h)throw new Error(s);return new F(new r.ed25519.ExtendedPoint(x,B,p,S))}static msm(e,t){const n=(0,c.Field)(r.ed25519.CURVE.n,r.ed25519.CURVE.nBitLength);return(0,i.pippenger)(F,n,e,t)}toRawBytes(){let{ex:e,ey:t,ez:n,et:o}=this.ep;const i=r.ed25519.CURVE.Fp.ORDER,s=r.ed25519.CURVE.Fp.create,a=s(s(n+t)*s(n-t)),u=s(e*t),l=s(u*u),{value:d}=U(s(a*l)),h=s(d*a),p=s(d*u),g=s(h*p*o);let m;if((0,c.isNegativeLE)(o*g,i)){let r=s(t*O),n=s(e*O);e=r,t=n,m=s(h*C)}else m=p;(0,c.isNegativeLE)(e*g,i)&&(t=s(-t));let y=s((n-t)*m);return(0,c.isNegativeLE)(y,i)&&(y=s(-y)),(0,f.numberToBytesLE)(y,32)}toHex(){return(0,f.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){_(e);const{ex:t,ey:n}=this.ep,{ex:o,ey:i}=e.ep,s=r.ed25519.CURVE.Fp.create,a=s(t*i)===s(n*o),c=s(n*i)===s(t*o);return a||c}add(e){return _(e),new F(this.ep.add(e.ep))}subtract(e){return _(e),new F(this.ep.subtract(e.ep))}multiply(e){return new F(this.ep.multiply(e))}multiplyUnsafe(e){return new F(this.ep.multiplyUnsafe(e))}double(){return new F(this.ep.double())}negate(){return new F(this.ep.negate())}}r.RistrettoPoint=(F.BASE||(F.BASE=new F(r.ed25519.ExtendedPoint.BASE)),F.ZERO||(F.ZERO=new F(r.ed25519.ExtendedPoint.ZERO)),F);r.hashToRistretto255=(e,t)=>{const r=t.DST,i="string"==typeof r?(0,o.utf8ToBytes)(r):r,s=(0,a.expand_message_xmd)(e,i,64,n.sha512);return F.hashToCurve(s)},r.hash_to_ristretto255=r.hashToRistretto255}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/ed25519.js"}],[5627,{"./_shortw_utils.js":5615,"./abstract/hash-to-curve.js":5619,"./abstract/modular.js":5620,"./abstract/weierstrass.js":5624,"@noble/hashes/sha2":4342},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.p521_hasher=r.secp521r1=r.p521=r.p384_hasher=r.secp384r1=r.p384=r.p256_hasher=r.secp256r1=r.p256=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("./_shortw_utils.js"),i=e("./abstract/hash-to-curve.js"),s=e("./abstract/modular.js"),a=e("./abstract/weierstrass.js"),c=(0,s.Field)(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),u=c.create(BigInt("-3")),f=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");r.p256=(0,o.createCurve)({a:u,b:f,Fp:c,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},n.sha256),r.secp256r1=r.p256;const l=(()=>(0,a.mapToCurveSimpleSWU)(c,{A:u,B:f,Z:c.create(BigInt("-10"))}))();r.p256_hasher=(0,i.createHasher)(r.secp256r1.ProjectivePoint,e=>l(e[0]),{DST:"P256_XMD:SHA-256_SSWU_RO_",encodeDST:"P256_XMD:SHA-256_SSWU_NU_",p:c.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256});const d=(0,s.Field)(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),h=d.create(BigInt("-3")),p=BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef");r.p384=(0,o.createCurve)({a:h,b:p,Fp:d,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},n.sha384),r.secp384r1=r.p384;const g=(()=>(0,a.mapToCurveSimpleSWU)(d,{A:h,B:p,Z:d.create(BigInt("-12"))}))();r.p384_hasher=(0,i.createHasher)(r.secp384r1.ProjectivePoint,e=>g(e[0]),{DST:"P384_XMD:SHA-384_SSWU_RO_",encodeDST:"P384_XMD:SHA-384_SSWU_NU_",p:d.ORDER,m:1,k:192,expand:"xmd",hash:n.sha384});const m=(0,s.Field)(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),y=m.create(BigInt("-3")),b=BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00");r.p521=(0,o.createCurve)({a:y,b:b,Fp:m,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1),lowS:!1,allowedPrivateKeyLengths:[130,131,132]},n.sha512),r.secp521r1=r.p521;const w=(()=>(0,a.mapToCurveSimpleSWU)(m,{A:y,B:b,Z:m.create(BigInt("-4"))}))();r.p521_hasher=(0,i.createHasher)(r.secp521r1.ProjectivePoint,e=>w(e[0]),{DST:"P521_XMD:SHA-512_SSWU_RO_",encodeDST:"P521_XMD:SHA-512_SSWU_NU_",p:m.ORDER,m:1,k:256,expand:"xmd",hash:n.sha512})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/nist.js"}],[5628,{"./nist.js":5627},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.encodeToCurve=r.hashToCurve=r.secp256r1=r.p256=void 0;const n=e("./nist.js");r.p256=n.p256,r.secp256r1=n.p256,r.hashToCurve=n.p256_hasher.hashToCurve,r.encodeToCurve=n.p256_hasher.encodeToCurve}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/p256.js"}],[5629,{"./_shortw_utils.js":5615,"./abstract/hash-to-curve.js":5619,"./abstract/modular.js":5620,"./abstract/utils.js":5623,"./abstract/weierstrass.js":5624,"@noble/hashes/sha2":4342,"@noble/hashes/utils":4346},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.encodeToCurve=r.hashToCurve=r.secp256k1_hasher=r.schnorr=r.secp256k1=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("@noble/hashes/utils"),i=e("./_shortw_utils.js"),s=e("./abstract/hash-to-curve.js"),a=e("./abstract/modular.js"),c=e("./abstract/utils.js"),u=e("./abstract/weierstrass.js"),f=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),d=BigInt(0),h=BigInt(1),p=BigInt(2),g=(e,t)=>(e+t/p)/t;function m(e){const t=f,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),u=BigInt(88),l=e*e*e%t,d=l*l*e%t,h=(0,a.pow2)(d,r,t)*d%t,g=(0,a.pow2)(h,r,t)*d%t,m=(0,a.pow2)(g,p,t)*l%t,b=(0,a.pow2)(m,o,t)*m%t,w=(0,a.pow2)(b,i,t)*b%t,E=(0,a.pow2)(w,c,t)*w%t,v=(0,a.pow2)(E,u,t)*E%t,x=(0,a.pow2)(v,c,t)*w%t,B=(0,a.pow2)(x,r,t)*d%t,S=(0,a.pow2)(B,s,t)*b%t,I=(0,a.pow2)(S,n,t)*l%t,P=(0,a.pow2)(I,p,t);if(!y.eql(y.sqr(P),e))throw new Error("Cannot find square root");return P}const y=(0,a.Field)(f,undefined,undefined,{sqrt:m});r.secp256k1=(0,i.createCurve)({a:d,b:BigInt(7),Fp:y,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=l,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-h*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),c=g(i*e,t),u=g(-n*e,t);let f=(0,a.mod)(e-c*r-u*o,t),d=(0,a.mod)(-c*n-u*i,t);const p=f>s,m=d>s;if(p&&(f=t-f),m&&(d=t-d),f>s||d>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:p,k1:f,k2neg:m,k2:d}}}},n.sha256);const b={};function w(e,...t){let r=b[e];if(r===undefined){const t=(0,n.sha256)(Uint8Array.from(e,e=>e.charCodeAt(0)));r=(0,c.concatBytes)(t,t),b[e]=r}return(0,n.sha256)((0,c.concatBytes)(r,...t))}const E=e=>e.toRawBytes(!0).slice(1),v=e=>(0,c.numberToBytesBE)(e,32),x=e=>(0,a.mod)(e,f),B=e=>(0,a.mod)(e,l),S=(()=>r.secp256k1.ProjectivePoint)();function I(e){let t=r.secp256k1.utils.normPrivateKeyToScalar(e),n=S.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:B(-t),bytes:E(n)}}function P(e){(0,c.aInRange)("x",e,h,f);const t=x(e*e);let r=m(x(t*e+BigInt(7)));r%p!==d&&(r=x(-r));const n=new S(e,r,h);return n.assertValidity(),n}const T=c.bytesToNumberBE;function A(...e){return B(T(w("BIP0340/challenge",...e)))}function j(e){return I(e).bytes}function k(e,t,r=(0,o.randomBytes)(32)){const n=(0,c.ensureBytes)("message",e),{bytes:i,scalar:s}=I(t),a=(0,c.ensureBytes)("auxRand",r,32),u=v(s^T(w("BIP0340/aux",a))),f=w("BIP0340/nonce",u,i,n),l=B(T(f));if(l===d)throw new Error("sign failed: k is zero");const{bytes:h,scalar:p}=I(l),g=A(h,i,n),m=new Uint8Array(64);if(m.set(h,0),m.set(v(B(p+g*s)),32),!_(m,n,i))throw new Error("sign: Invalid signature produced");return m}function _(e,t,r){const n=(0,c.ensureBytes)("signature",e,64),o=(0,c.ensureBytes)("message",t),i=(0,c.ensureBytes)("publicKey",r,32);try{const e=P(T(i)),t=T(n.subarray(0,32));if(!(0,c.inRange)(t,h,f))return!1;const r=T(n.subarray(32,64));if(!(0,c.inRange)(r,h,l))return!1;const d=A(v(t),E(e),o),p=(s=e,a=r,u=B(-d),S.BASE.multiplyAndAddUnsafe(s,a,u));return!(!p||!p.hasEvenY()||p.toAffine().x!==t)}catch(e){return!1}var s,a,u}r.schnorr={getPublicKey:j,sign:k,verify:_,utils:{randomPrivateKey:r.secp256k1.utils.randomPrivateKey,lift_x:P,pointToBytes:E,numberToBytesBE:c.numberToBytesBE,bytesToNumberBE:c.bytesToNumberBE,taggedHash:w,mod:a.mod}};const O=(()=>(0,s.isogenyMap)(y,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e)))))(),N=(()=>(0,u.mapToCurveSimpleSWU)(y,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:y.create(BigInt("-11"))}))();r.secp256k1_hasher=(0,s.createHasher)(r.secp256k1.ProjectivePoint,e=>{const{x:t,y:r}=N(y.create(e[0]));return O(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:y.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256}),r.hashToCurve=r.secp256k1_hasher.hashToCurve,r.encodeToCurve=r.secp256k1_hasher.encodeToCurve}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/secp256k1.js"}],[563,{lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,n.cloneDeep)(e);return t.meta.version=o,t.data,t},r.version=void 0;var n=e("lodash");const o=r.version=137}}},{package:"$root$",file:"app/scripts/migrations/137.ts"}],[5630,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){!function(e){var r,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,o=Math.ceil,i=Math.floor,s="[BigNumber Error] ",a=s+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,f=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,h=1e9;function p(e){var t=0|e;return e>0||e===t?t:t-1}function g(e){for(var t,r,n=1,o=e.length,i=e[0]+"";n<o;){for(t=e[n++]+"",r=u-t.length;r--;t="0"+t);i+=t}for(o=i.length;48===i.charCodeAt(--o););return i.slice(0,o+1||1)}function m(e,t){var r,n,o=e.c,i=t.c,s=e.s,a=t.s,c=e.e,u=t.e;if(!s||!a)return null;if(r=o&&!o[0],n=i&&!i[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=c==u,!o||!i)return n?0:!o^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=o.length)<(u=i.length)?c:u,s=0;s<a;s++)if(o[s]!=i[s])return o[s]>i[s]^r?1:-1;return c==u?0:c>u^r?1:-1}function y(e,t,r,n){if(e<t||e>r||e!==i(e))throw Error(s+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function b(e){var t=e.c.length-1;return p(e.e/u)==t&&e.c[t]%2!=0}function w(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function E(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}r=function e(t){var r,v,x,B,S,I,P,T,A,j,k=G.prototype={constructor:G,toString:null,valueOf:null},_=new G(1),O=20,N=4,C=-7,R=21,D=-1e7,U=1e7,M=!1,L=1,z=0,F={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz",$=!0;function G(e,t){var r,o,s,c,l,d,h,p,g=this;if(!(g instanceof G))return new G(e,t);if(null==t){if(e&&!0===e._isBigNumber)return g.s=e.s,void(!e.c||e.e>U?g.c=g.e=null:e.e<D?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice()));if((d="number"==typeof e)&&0*e==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,l=e;l>=10;l/=10,c++);return void(c>U?g.c=g.e=null:(g.e=c,g.c=[e]))}p=String(e)}else{if(!n.test(p=String(e)))return x(g,p,d);g.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(c=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(c<0&&(c=l),c+=+p.slice(l+1),p=p.substring(0,l)):c<0&&(c=p.length)}else{if(y(t,2,H.length,"Base"),10==t&&$)return K(g=new G(e),O+g.e+1,N);if(p=String(e),d="number"==typeof e){if(0*e!=0)return x(g,p,d,t);if(g.s=1/e<0?(p=p.slice(1),-1):1,G.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(a+e)}else g.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=H.slice(0,t),c=l=0,h=p.length;l<h;l++)if(r.indexOf(o=p.charAt(l))<0){if("."==o){if(l>c){c=h;continue}}else if(!s&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){s=!0,l=-1,c=0;continue}return x(g,String(e),d,t)}d=!1,(c=(p=v(p,t,10,g.s)).indexOf("."))>-1?p=p.replace(".",""):c=p.length}for(l=0;48===p.charCodeAt(l);l++);for(h=p.length;48===p.charCodeAt(--h););if(p=p.slice(l,++h)){if(h-=l,d&&G.DEBUG&&h>15&&(e>f||e!==i(e)))throw Error(a+g.s*e);if((c=c-l-1)>U)g.c=g.e=null;else if(c<D)g.c=[g.e=0];else{if(g.e=c,g.c=[],l=(c+1)%u,c<0&&(l+=u),l<h){for(l&&g.c.push(+p.slice(0,l)),h-=u;l<h;)g.c.push(+p.slice(l,l+=u));l=u-(p=p.slice(l)).length}else l-=h;for(;l--;p+="0");g.c.push(+p)}}else g.c=[g.e=0]}function q(e,t,r,n){var o,i,s,a,c;if(null==r?r=N:y(r,0,8),!e.c)return e.toString();if(o=e.c[0],s=e.e,null==t)c=g(e.c),c=1==n||2==n&&(s<=C||s>=R)?w(c,s):E(c,s,"0");else if(i=(e=K(new G(e),t,r)).e,a=(c=g(e.c)).length,1==n||2==n&&(t<=i||i<=C)){for(;a<t;c+="0",a++);c=w(c,i)}else if(t-=s+(2===n&&i>s),c=E(c,i,"0"),i+1>a){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=i-a)>0)for(i+1==a&&(c+=".");t--;c+="0");return e.s<0&&o?"-"+c:c}function V(e,t){for(var r,n,o=1,i=new G(e[0]);o<e.length;o++)(!(n=new G(e[o])).s||(r=m(i,n))===t||0===r&&i.s===t)&&(i=n);return i}function W(e,t,r){for(var n=1,o=t.length;!t[--o];t.pop());for(o=t[0];o>=10;o/=10,n++);return(r=n+r*u-1)>U?e.c=e.e=null:r<D?e.c=[e.e=0]:(e.e=r,e.c=t),e}function K(e,t,r,n){var s,a,f,d,h,p,g,m=e.c,y=l;if(m){e:{for(s=1,d=m[0];d>=10;d/=10,s++);if((a=t-s)<0)a+=u,f=t,h=m[p=0],g=i(h/y[s-f-1]%10);else if((p=o((a+1)/u))>=m.length){if(!n)break e;for(;m.length<=p;m.push(0));h=g=0,s=1,f=(a%=u)-u+1}else{for(h=d=m[p],s=1;d>=10;d/=10,s++);g=(f=(a%=u)-u+s)<0?0:i(h/y[s-f-1]%10)}if(n=n||t<0||null!=m[p+1]||(f<0?h:h%y[s-f-1]),n=r<4?(g||n)&&(0==r||r==(e.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(a>0?f>0?h/y[s-f]:0:m[p-1])%10&1||r==(e.s<0?8:7)),t<1||!m[0])return m.length=0,n?(t-=e.e+1,m[0]=y[(u-t%u)%u],e.e=-t||0):m[0]=e.e=0,e;if(0==a?(m.length=p,d=1,p--):(m.length=p+1,d=y[u-a],m[p]=f>0?i(h/y[s-f]%y[f])*d:0),n)for(;;){if(0==p){for(a=1,f=m[0];f>=10;f/=10,a++);for(f=m[0]+=d,d=1;f>=10;f/=10,d++);a!=d&&(e.e++,m[0]==c&&(m[0]=1));break}if(m[p]+=d,m[p]!=c)break;m[p--]=0,d=1}for(a=m.length;0===m[--a];m.pop());}e.e>U?e.c=e.e=null:e.e<D&&(e.c=[e.e=0])}return e}function Z(e){var t,r=e.e;return null===r?e.toString():(t=g(e.c),t=r<=C||r>=R?w(t,r):E(t,r,"0"),e.s<0?"-"+t:t)}return G.clone=e,G.ROUND_UP=0,G.ROUND_DOWN=1,G.ROUND_CEIL=2,G.ROUND_FLOOR=3,G.ROUND_HALF_UP=4,G.ROUND_HALF_DOWN=5,G.ROUND_HALF_EVEN=6,G.ROUND_HALF_CEIL=7,G.ROUND_HALF_FLOOR=8,G.EUCLID=9,G.config=G.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(s+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(y(r=e[t],0,h,t),O=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(y(r=e[t],0,8,t),N=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(y(r[0],-h,0,t),y(r[1],0,h,t),C=r[0],R=r[1]):(y(r,-h,h,t),C=-(R=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)y(r[0],-h,-1,t),y(r[1],1,h,t),D=r[0],U=r[1];else{if(y(r,-h,h,t),!r)throw Error(s+t+" cannot be zero: "+r);D=-(U=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(s+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw M=!r,Error(s+"crypto unavailable");M=r}else M=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(y(r=e[t],0,9,t),L=r),e.hasOwnProperty(t="POW_PRECISION")&&(y(r=e[t],0,h,t),z=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(s+t+" not an object: "+r);F=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(s+t+" invalid: "+r);$="0123456789"==r.slice(0,10),H=r}}return{DECIMAL_PLACES:O,ROUNDING_MODE:N,EXPONENTIAL_AT:[C,R],RANGE:[D,U],CRYPTO:M,MODULO_MODE:L,POW_PRECISION:z,FORMAT:F,ALPHABET:H}},G.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!G.DEBUG)return!0;var t,r,n=e.c,o=e.e,a=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===a||-1===a)&&o>=-h&&o<=h&&o===i(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break e}if((t=(o+1)%u)<1&&(t+=u),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=c||r!==i(r))break e;if(0!==r)return!0}}}else if(null===n&&null===o&&(null===a||1===a||-1===a))return!0;throw Error(s+"Invalid BigNumber: "+e)},G.maximum=G.max=function(){return V(arguments,-1)},G.minimum=G.min=function(){return V(arguments,1)},G.random=(B=9007199254740992,S=Math.random()*B&2097151?function(){return i(Math.random()*B)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,a,c,f=0,d=[],p=new G(_);if(null==e?e=O:y(e,0,h),a=o(e/u),M)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(a*=2));f<a;)(c=131072*t[f]+(t[f+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[f]=r[0],t[f+1]=r[1]):(d.push(c%1e14),f+=2);f=a/2}else{if(!crypto.randomBytes)throw M=!1,Error(s+"crypto unavailable");for(t=crypto.randomBytes(a*=7);f<a;)(c=281474976710656*(31&t[f])+1099511627776*t[f+1]+4294967296*t[f+2]+16777216*t[f+3]+(t[f+4]<<16)+(t[f+5]<<8)+t[f+6])>=9e15?crypto.randomBytes(7).copy(t,f):(d.push(c%1e14),f+=7);f=a/7}if(!M)for(;f<a;)(c=S())<9e15&&(d[f++]=c%1e14);for(a=d[--f],e%=u,a&&e&&(c=l[u-e],d[f]=i(a/c)*c);0===d[f];d.pop(),f--);if(f<0)d=[n=0];else{for(n=-1;0===d[0];d.splice(0,1),n-=u);for(f=1,c=d[0];c>=10;c/=10,f++);f<u&&(n-=u-f)}return p.e=n,p.c=d,p}),G.sum=function(){for(var e=1,t=arguments,r=new G(t[0]);e<t.length;)r=r.plus(t[e++]);return r},v=function(){var e="0123456789";function t(e,t,r,n){for(var o,i,s=[0],a=0,c=e.length;a<c;){for(i=s.length;i--;s[i]*=t);for(s[0]+=n.indexOf(e.charAt(a++)),o=0;o<s.length;o++)s[o]>r-1&&(null==s[o+1]&&(s[o+1]=0),s[o+1]+=s[o]/r|0,s[o]%=r)}return s.reverse()}return function(n,o,i,s,a){var c,u,f,l,d,h,p,m,y=n.indexOf("."),b=O,w=N;for(y>=0&&(l=z,z=0,n=n.replace(".",""),h=(m=new G(o)).pow(n.length-y),z=l,m.c=t(E(g(h.c),h.e,"0"),10,i,e),m.e=m.c.length),f=l=(p=t(n,o,i,a?(c=H,e):(c=e,H))).length;0==p[--l];p.pop());if(!p[0])return c.charAt(0);if(y<0?--f:(h.c=p,h.e=f,h.s=s,p=(h=r(h,m,b,w,i)).c,d=h.r,f=h.e),y=p[u=f+b+1],l=i/2,d=d||u<0||null!=p[u+1],d=w<4?(null!=y||d)&&(0==w||w==(h.s<0?3:2)):y>l||y==l&&(4==w||d||6==w&&1&p[u-1]||w==(h.s<0?8:7)),u<1||!p[0])n=d?E(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,d)for(--i;++p[--u]>i;)p[u]=0,u||(++f,p=[1].concat(p));for(l=p.length;!p[--l];);for(y=0,n="";y<=l;n+=c.charAt(p[y++]));n=E(n,f,c.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,o,i,s,a=0,c=e.length,u=t%d,f=t/d|0;for(e=e.slice();c--;)a=((o=u*(i=e[c]%d)+(n=f*i+(s=e[c]/d|0)*u)%d*d+a)/r|0)+(n/d|0)+f*s,e[c]=o%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var o,i;if(r!=n)i=r>n?1:-1;else for(o=i=0;o<r;o++)if(e[o]!=t[o]){i=e[o]>t[o]?1:-1;break}return i}function r(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]<t[r]?1:0,e[r]=o*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,o,s,a,f){var l,d,h,g,m,y,b,w,E,v,x,B,S,I,P,T,A,j=n.s==o.s?1:-1,k=n.c,_=o.c;if(!(k&&k[0]&&_&&_[0]))return new G(n.s&&o.s&&(k?!_||k[0]!=_[0]:_)?k&&0==k[0]||!_?0*j:j/0:NaN);for(E=(w=new G(j)).c=[],j=s+(d=n.e-o.e)+1,f||(f=c,d=p(n.e/u)-p(o.e/u),j=j/u|0),h=0;_[h]==(k[h]||0);h++);if(_[h]>(k[h]||0)&&d--,j<0)E.push(1),g=!0;else{for(I=k.length,T=_.length,h=0,j+=2,(m=i(f/(_[0]+1)))>1&&(_=e(_,m,f),k=e(k,m,f),T=_.length,I=k.length),S=T,x=(v=k.slice(0,T)).length;x<T;v[x++]=0);A=_.slice(),A=[0].concat(A),P=_[0],_[1]>=f/2&&P++;do{if(m=0,(l=t(_,v,T,x))<0){if(B=v[0],T!=x&&(B=B*f+(v[1]||0)),(m=i(B/P))>1)for(m>=f&&(m=f-1),b=(y=e(_,m,f)).length,x=v.length;1==t(y,v,b,x);)m--,r(y,T<b?A:_,b,f),b=y.length,l=1;else 0==m&&(l=m=1),b=(y=_.slice()).length;if(b<x&&(y=[0].concat(y)),r(v,y,x,f),x=v.length,-1==l)for(;t(_,v,T,x)<1;)m++,r(v,T<x?A:_,x,f),x=v.length}else 0===l&&(m++,v=[0]);E[h++]=m,v[0]?v[x++]=k[S]||0:(v=[k[S]],x=1)}while((S++<I||null!=v[0])&&j--);g=null!=v[0],E[0]||E.splice(0,1)}if(f==c){for(h=1,j=E[0];j>=10;j/=10,h++);K(w,s+(w.e=h+d*u-1)+1,a,g)}else w.e=d,w.r=+g;return w}}(),I=/^(-?)0([xbo])(?=\w[\w.]*$)/i,P=/^([^.]+)\.$/,T=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,j=/^\s*\+(?=[\w.])|^\s+|\s+$/g,x=function(e,t,r,n){var o,i=r?t:t.replace(j,"");if(A.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(I,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t}),n&&(o=n,i=i.replace(P,"$1").replace(T,"0.$1")),t!=i))return new G(i,o);if(G.DEBUG)throw Error(s+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},k.absoluteValue=k.abs=function(){var e=new G(this);return e.s<0&&(e.s=1),e},k.comparedTo=function(e,t){return m(this,new G(e,t))},k.decimalPlaces=k.dp=function(e,t){var r,n,o,i=this;if(null!=e)return y(e,0,h),null==t?t=N:y(t,0,8),K(new G(i),e+i.e+1,t);if(!(r=i.c))return null;if(n=((o=r.length-1)-p(this.e/u))*u,o=r[o])for(;o%10==0;o/=10,n--);return n<0&&(n=0),n},k.dividedBy=k.div=function(e,t){return r(this,new G(e,t),O,N)},k.dividedToIntegerBy=k.idiv=function(e,t){return r(this,new G(e,t),0,1)},k.exponentiatedBy=k.pow=function(e,t){var r,n,a,c,f,l,d,h,p=this;if((e=new G(e)).c&&!e.isInteger())throw Error(s+"Exponent not an integer: "+Z(e));if(null!=t&&(t=new G(t)),f=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return h=new G(Math.pow(+Z(p),f?e.s*(2-b(e)):+Z(e))),t?h.mod(t):h;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new G(NaN);(n=!l&&p.isInteger()&&t.isInteger())&&(p=p.mod(t))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||f&&p.c[1]>=24e7:p.c[0]<8e13||f&&p.c[0]<=9999975e7)))return c=p.s<0&&b(e)?-0:0,p.e>-1&&(c=1/c),new G(l?1/c:c);z&&(c=o(z/u+2))}for(f?(r=new G(.5),l&&(e.s=1),d=b(e)):d=(a=Math.abs(+Z(e)))%2,h=new G(_);;){if(d){if(!(h=h.times(p)).c)break;c?h.c.length>c&&(h.c.length=c):n&&(h=h.mod(t))}if(a){if(0===(a=i(a/2)))break;d=a%2}else if(K(e=e.times(r),e.e+1,1),e.e>14)d=b(e);else{if(0===(a=+Z(e)))break;d=a%2}p=p.times(p),c?p.c&&p.c.length>c&&(p.c.length=c):n&&(p=p.mod(t))}return n?h:(l&&(h=_.div(h)),t?h.mod(t):c?K(h,z,N,undefined):h)},k.integerValue=function(e){var t=new G(this);return null==e?e=N:y(e,0,8),K(t,t.e+1,e)},k.isEqualTo=k.eq=function(e,t){return 0===m(this,new G(e,t))},k.isFinite=function(){return!!this.c},k.isGreaterThan=k.gt=function(e,t){return m(this,new G(e,t))>0},k.isGreaterThanOrEqualTo=k.gte=function(e,t){return 1===(t=m(this,new G(e,t)))||0===t},k.isInteger=function(){return!!this.c&&p(this.e/u)>this.c.length-2},k.isLessThan=k.lt=function(e,t){return m(this,new G(e,t))<0},k.isLessThanOrEqualTo=k.lte=function(e,t){return-1===(t=m(this,new G(e,t)))||0===t},k.isNaN=function(){return!this.s},k.isNegative=function(){return this.s<0},k.isPositive=function(){return this.s>0},k.isZero=function(){return!!this.c&&0==this.c[0]},k.minus=function(e,t){var r,n,o,i,s=this,a=s.s;if(t=(e=new G(e,t)).s,!a||!t)return new G(NaN);if(a!=t)return e.s=-t,s.plus(e);var f=s.e/u,l=e.e/u,d=s.c,h=e.c;if(!f||!l){if(!d||!h)return d?(e.s=-t,e):new G(h?s:NaN);if(!d[0]||!h[0])return h[0]?(e.s=-t,e):new G(d[0]?s:3==N?-0:0)}if(f=p(f),l=p(l),d=d.slice(),a=f-l){for((i=a<0)?(a=-a,o=d):(l=f,o=h),o.reverse(),t=a;t--;o.push(0));o.reverse()}else for(n=(i=(a=d.length)<(t=h.length))?a:t,a=t=0;t<n;t++)if(d[t]!=h[t]){i=d[t]<h[t];break}if(i&&(o=d,d=h,h=o,e.s=-e.s),(t=(n=h.length)-(r=d.length))>0)for(;t--;d[r++]=0);for(t=c-1;n>a;){if(d[--n]<h[n]){for(r=n;r&&!d[--r];d[r]=t);--d[r],d[n]+=c}d[n]-=h[n]}for(;0==d[0];d.splice(0,1),--l);return d[0]?W(e,d,l):(e.s=3==N?-1:1,e.c=[e.e=0],e)},k.modulo=k.mod=function(e,t){var n,o,i=this;return e=new G(e,t),!i.c||!e.s||e.c&&!e.c[0]?new G(NaN):!e.c||i.c&&!i.c[0]?new G(i):(9==L?(o=e.s,e.s=1,n=r(i,e,0,3),e.s=o,n.s*=o):n=r(i,e,0,L),(e=i.minus(n.times(e))).c[0]||1!=L||(e.s=i.s),e)},k.multipliedBy=k.times=function(e,t){var r,n,o,i,s,a,f,l,h,g,m,y,b,w,E,v=this,x=v.c,B=(e=new G(e,t)).c;if(!(x&&B&&x[0]&&B[0]))return!v.s||!e.s||x&&!x[0]&&!B||B&&!B[0]&&!x?e.c=e.e=e.s=null:(e.s*=v.s,x&&B?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=p(v.e/u)+p(e.e/u),e.s*=v.s,(f=x.length)<(g=B.length)&&(b=x,x=B,B=b,o=f,f=g,g=o),o=f+g,b=[];o--;b.push(0));for(w=c,E=d,o=g;--o>=0;){for(r=0,m=B[o]%E,y=B[o]/E|0,i=o+(s=f);i>o;)r=((l=m*(l=x[--s]%E)+(a=y*l+(h=x[s]/E|0)*m)%E*E+b[i]+r)/w|0)+(a/E|0)+y*h,b[i--]=l%w;b[i]=r}return r?++n:b.splice(0,1),W(e,b,n)},k.negated=function(){var e=new G(this);return e.s=-e.s||null,e},k.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new G(e,t)).s,!o||!t)return new G(NaN);if(o!=t)return e.s=-t,n.minus(e);var i=n.e/u,s=e.e/u,a=n.c,f=e.c;if(!i||!s){if(!a||!f)return new G(o/0);if(!a[0]||!f[0])return f[0]?e:new G(a[0]?n:0*o)}if(i=p(i),s=p(s),a=a.slice(),o=i-s){for(o>0?(s=i,r=f):(o=-o,r=a),r.reverse();o--;r.push(0));r.reverse()}for((o=a.length)-(t=f.length)<0&&(r=f,f=a,a=r,t=o),o=0;t;)o=(a[--t]=a[t]+f[t]+o)/c|0,a[t]=c===a[t]?0:a[t]%c;return o&&(a=[o].concat(a),++s),W(e,a,s)},k.precision=k.sd=function(e,t){var r,n,o,i=this;if(null!=e&&e!==!!e)return y(e,1,h),null==t?t=N:y(t,0,8),K(new G(i),e,t);if(!(r=i.c))return null;if(n=(o=r.length-1)*u+1,o=r[o]){for(;o%10==0;o/=10,n--);for(o=r[0];o>=10;o/=10,n++);}return e&&i.e+1>n&&(n=i.e+1),n},k.shiftedBy=function(e){return y(e,-9007199254740991,f),this.times("1e"+e)},k.squareRoot=k.sqrt=function(){var e,t,n,o,i,s=this,a=s.c,c=s.s,u=s.e,f=O+4,l=new G("0.5");if(1!==c||!a||!a[0])return new G(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(c=Math.sqrt(+Z(s)))||c==1/0?(((t=g(a)).length+u)%2==0&&(t+="0"),c=Math.sqrt(+t),u=p((u+1)/2)-(u<0||u%2),n=new G(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new G(c+""),n.c[0])for((c=(u=n.e)+f)<3&&(c=0);;)if(i=n,n=l.times(i.plus(r(s,i,f,1))),g(i.c).slice(0,c)===(t=g(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(o||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(K(n,n.e+O+2,1),e=!n.times(n).eq(s));break}if(!o&&(K(i,i.e+O+2,0),i.times(i).eq(s))){n=i;break}f+=4,c+=4,o=1}return K(n,n.e+O+1,N,e)},k.toExponential=function(e,t){return null!=e&&(y(e,0,h),e++),q(this,e,t,1)},k.toFixed=function(e,t){return null!=e&&(y(e,0,h),e=e+this.e+1),q(this,e,t)},k.toFormat=function(e,t,r){var n,o=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=F;else if("object"!=typeof r)throw Error(s+"Argument not an object: "+r);if(n=o.toFixed(e,t),o.c){var i,a=n.split("."),c=+r.groupSize,u=+r.secondaryGroupSize,f=r.groupSeparator||"",l=a[0],d=a[1],h=o.s<0,p=h?l.slice(1):l,g=p.length;if(u&&(i=c,c=u,u=i,g-=i),c>0&&g>0){for(i=g%c||c,l=p.substr(0,i);i<g;i+=c)l+=f+p.substr(i,c);u>0&&(l+=f+p.slice(i)),h&&(l="-"+l)}n=d?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):l}return(r.prefix||"")+n+(r.suffix||"")},k.toFraction=function(e){var t,n,o,i,a,c,f,d,h,p,m,y,b=this,w=b.c;if(null!=e&&(!(f=new G(e)).isInteger()&&(f.c||1!==f.s)||f.lt(_)))throw Error(s+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+Z(f));if(!w)return new G(b);for(t=new G(_),h=n=new G(_),o=d=new G(_),y=g(w),a=t.e=y.length-b.e-1,t.c[0]=l[(c=a%u)<0?u+c:c],e=!e||f.comparedTo(t)>0?a>0?t:h:f,c=U,U=1/0,f=new G(y),d.c[0]=0;p=r(f,t,0,1),1!=(i=n.plus(p.times(o))).comparedTo(e);)n=o,o=i,h=d.plus(p.times(i=h)),d=i,t=f.minus(p.times(i=t)),f=i;return i=r(e.minus(n),o,0,1),d=d.plus(i.times(h)),n=n.plus(i.times(o)),d.s=h.s=b.s,m=r(h,o,a*=2,N).minus(b).abs().comparedTo(r(d,n,a,N).minus(b).abs())<1?[h,o]:[d,n],U=c,m},k.toNumber=function(){return+Z(this)},k.toPrecision=function(e,t){return null!=e&&y(e,1,h),q(this,e,t,2)},k.toString=function(e){var t,r=this,n=r.s,o=r.e;return null===o?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=o<=C||o>=R?w(g(r.c),o):E(g(r.c),o,"0"):10===e&&$?t=E(g((r=K(new G(r),O+o+1,N)).c),r.e,"0"):(y(e,2,H.length,"Base"),t=v(E(g(r.c),o,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},k.valueOf=k.toJSON=function(){return Z(this)},k._isBigNumber=!0,null!=t&&G.set(t),G}(),r.default=r.BigNumber=r,"function"==typeof define&&define.amd?define(function(){return r}):void 0!==t&&t.exports?t.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(void 0)}}},{package:"eth-lattice-keyring>gridplus-sdk>bignumber.js",file:"node_modules/gridplus-sdk/node_modules/bignumber.js/bignumber.js"}],[5631,{bs58:5237},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),o=e(r);if(!(n[0]^o[0]|n[1]^o[1]|n[2]^o[2]|n[3]^o[3]))return r}return{encode:function(t){var r=Uint8Array.from(t),n=e(r),i=r.length+4,s=new Uint8Array(i);return s.set(r,0),s.set(n.subarray(0,4),r.length),o.default.encode(s)},decode:function(e){var r=t(o.default.decode(e));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=o.default.decodeUnsafe(e);if(null!=r)return t(r)}}};var o=n(e("bs58"))}}},{package:"eth-lattice-keyring>gridplus-sdk>bs58check",file:"node_modules/gridplus-sdk/node_modules/bs58check/src/cjs/base.cjs"}],[5632,{"./base.cjs":5631,"@noble/hashes/sha256":4343},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var o=e("@noble/hashes/sha256"),i=n(e("./base.cjs"));r.default=(0,i.default)(function(e){return(0,o.sha256)((0,o.sha256)(e))})}}},{package:"eth-lattice-keyring>gridplus-sdk>bs58check",file:"node_modules/gridplus-sdk/node_modules/bs58check/src/cjs/index.cjs"}],[5633,{"bignumber.js":5630},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n,o;n=void 0,o=e=>{return t={68:(e,t,r)=>{const{BigNumber:n}=r(905);let o=null;const i=new n("0x20000000000000"),s=new n(2);function a(e,t){if(t.isNaN())return e._pushNaN();if(!t.isFinite())return e._pushInfinity(t.isNegative()?-1/0:1/0);if(t.isInteger())return e._pushJSBigint(BigInt(t.toFixed()));if(!e._pushTag(4)||!e._pushInt(2,4))return!1;const r=t.decimalPlaces(),n=t.shiftedBy(r);return!!e._pushIntNum(-r)&&(n.abs().isLessThan(i)?e._pushIntNum(n.toNumber()):e._pushJSBigint(BigInt(n.toFixed())))}function c(e){return new n(e[1]).shiftedBy(e[0])}function u(e){return s.pow(e[0]).times(e[1])}function f(e){return o=e,o.Encoder.SEMANTIC_TYPES[n.name]=a,o.Tagged.TAGS[4]=c,o.Tagged.TAGS[5]=u,o}f.BigNumber=n,e.exports=f},905:t=>{t.exports=e}},r={},function e(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return t[n](i,i.exports,e),i.exports}(68);var t,r},"object"==typeof r&&"object"==typeof t?t.exports=o(e("bignumber.js")):"function"==typeof define&&define.amd?define([],o):"object"==typeof r?r.cborBigDecimal=o(e("bignumber.js")):n.cborBigDecimal=o(n.BigNumber)}}},{package:"eth-lattice-keyring>gridplus-sdk>cbor-bigdecimal",file:"node_modules/gridplus-sdk/node_modules/cbor-bigdecimal/dist/cbor-bigdecimal.js"}],[5634,{"./internal/abi.js":5702,abitype:5047},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.format=function(e){return n.formatAbi(e)},r.from=function(e){return o.isSignatures(e)?n.parseAbi(e):e};const n=e("abitype"),o=e("./internal/abi.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Abi.js"}],[5635,{"./AbiItem.js":5639,"./AbiParameters.js":5640,"./Hex.js":5666,abitype:5047},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.decode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return[a(t),r]}return e})(),{bytecode:n}=r;if(0===t.inputs?.length)return undefined;const o=r.data.replace(n,"0x");return i.decode(t.inputs,o)},r.encode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return[a(t),r]}return e})(),{bytecode:n,args:o}=r;return s.concat(n,t.inputs?.length&&o?.length?i.encode(t.inputs,o):"0x")},r.format=function(e){return n.formatAbiItem(e)},r.from=function(e){return o.from(e)},r.fromAbi=a;const n=e("abitype"),o=e("./AbiItem.js"),i=e("./AbiParameters.js"),s=e("./Hex.js");function a(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new o.NotFoundError({name:"constructor"});return t}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiConstructor.js"}],[5636,{"./AbiItem.js":5639,"./AbiParameters.js":5640,"./Hex.js":5666,abitype:5047},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.solidityPanicSelector=r.solidityPanic=r.solidityErrorSelector=r.solidityError=r.panicReasons=void 0,r.decode=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,o]=e;return[c(t,r),n,o]}return e})();if(s.size(r)<4)throw new o.InvalidSelectorSizeError({data:r});if(0===t.inputs?.length)return undefined;const a=i.decode(t.inputs,s.slice(r,4),n);if(a&&1===Object.keys(a).length)return Array.isArray(a)?a[0]:Object.values(a)[0];return a},r.encode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,...n]=e;return[c(t,r),n]}const[t,...r]=e;return[t,r]})(),n=u(t),o=r.length>0?i.encode(t.inputs,r[0]):undefined;return o?s.concat(n,o):n},r.format=function(e){return n.formatAbiItem(e)},r.from=a,r.fromAbi=c,r.getSelector=u;const n=e("abitype"),o=e("./AbiItem.js"),i=e("./AbiParameters.js"),s=e("./Hex.js");function a(e,t={}){return o.from(e,t)}function c(e,t,n){if("Error"===t)return r.solidityError;if("Panic"===t)return r.solidityPanic;if(s.validate(t,{strict:!1})){const e=s.slice(t,0,4);if(e===r.solidityErrorSelector)return r.solidityError;if(e===r.solidityPanicSelector)return r.solidityPanic}const i=o.fromAbi(e,t,n);if("error"!==i.type)throw new o.NotFoundError({name:t,type:"error"});return i}function u(e){return o.getSelector(e)}r.panicReasons={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},r.solidityError=a({inputs:[{name:"message",type:"string"}],name:"Error",type:"error"}),r.solidityErrorSelector="0x08c379a0",r.solidityPanic=a({inputs:[{name:"reason",type:"uint8"}],name:"Panic",type:"error"}),r.solidityPanicSelector="0x4e487b71"}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiError.js"}],[5637,{"./AbiItem.js":5639,"./AbiParameters.js":5640,"./Address.js":5643,"./Bytes.js":5655,"./Errors.js":5661,"./Hash.js":5664,"./Hex.js":5666,"./internal/cursor.js":5707,"./internal/errors.js":5710,abitype:5047},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.FilterTypeNotSupportedError=r.SelectorTopicMismatchError=r.TopicsMismatchError=r.DataMismatchError=r.InputNotFoundError=r.ArgsMismatchError=void 0,r.assertArgs=function(e,t,r){if(!t||!r)throw new m({abiEvent:e,expected:t,given:r});function n(e,t,r){return"address"===e.type?s.isEqual(t,r):"string"===e.type?u.keccak256(a.fromString(t))===r:"bytes"===e.type?u.keccak256(t)===r:t===r}if(Array.isArray(t)&&Array.isArray(r))for(const[o,i]of r.entries()){if(null===i||i===undefined)continue;const s=e.inputs[o];if(!s)throw new y({abiEvent:e,name:`${o}`});const a=Array.isArray(i)?i:[i];let c=!1;for(const e of a)n(s,e,t[o])&&(c=!0);if(!c)throw new m({abiEvent:e,expected:t,given:r})}if("object"==typeof t&&!Array.isArray(t)&&"object"==typeof r&&!Array.isArray(r))for(const[o,i]of Object.entries(r)){if(null===i||i===undefined)continue;const s=e.inputs.find(e=>e.name===o);if(!s)throw new y({abiEvent:e,name:o});const a=Array.isArray(i)?i:[i];let c=!1;for(const e of a)n(s,e,t[o])&&(c=!0);if(!c)throw new m({abiEvent:e,expected:t,given:r})}},r.decode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[p(t,r),n]}return e})(),{data:n,topics:o}=r,[s,...a]=o,c=g(t);if(s!==c)throw new E({abiEvent:t,actual:s,expected:c});const{inputs:u}=t,d=u?.every(e=>!("name"in e&&e.name));let h=d?[]:{};const m=u.filter(e=>"indexed"in e&&e.indexed);for(let e=0;e<m.length;e++){const r=m[e],n=a[e];if(!n)throw new w({abiEvent:t,param:r});h[d?e:r.name||e]=(()=>{if("string"===r.type||"bytes"===r.type||"tuple"===r.type||r.type.match(/^(.*)\[(\d+)?\]$/))return n;return(i.decode([r],n)||[])[0]})()}const y=u.filter(e=>!("indexed"in e&&e.indexed));if(y.length>0){if(!n||"0x"===n)throw new b({abiEvent:t,data:"0x",parameters:y,size:0});try{const e=i.decode(y,n);if(e)if(d)h=[...h,...e];else for(let t=0;t<y.length;t++){const r=u.indexOf(y[t]);h[y[t].name||r]=e[t]}}catch(e){if(e instanceof i.DataSizeTooSmallError||e instanceof l.PositionOutOfBoundsError)throw new b({abiEvent:t,data:n,parameters:y,size:f.size(n)});throw e}}return Object.values(h).length>0?h:undefined},r.encode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[p(t,r),n]}const[t,r]=e;return[t,r]})();let n=[];if(r&&t.inputs){const e=t.inputs.filter(e=>"indexed"in e&&e.indexed),o=Array.isArray(r)?r:Object.values(r).length>0?e?.map((e,t)=>r[e.name??t])??[]:[];if(o.length>0){const t=(e,t)=>{if("string"===e.type)return u.keccak256(f.fromString(t));if("bytes"===e.type)return u.keccak256(t);if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new v(e.type);return i.encode([e],[t])};n=e?.map((e,r)=>Array.isArray(o[r])?o[r].map((n,i)=>t(e,o[r][i])):void 0!==o[r]&&null!==o[r]?t(e,o[r]):null)??[]}}return{topics:[t.hash?t.hash:g(t),...n]}},r.format=h,r.from=function(e,t={}){return o.from(e,t)},r.fromAbi=p,r.getSelector=g;const n=e("abitype"),o=e("./AbiItem.js"),i=e("./AbiParameters.js"),s=e("./Address.js"),a=e("./Bytes.js"),c=e("./Errors.js"),u=e("./Hash.js"),f=e("./Hex.js"),l=e("./internal/cursor.js"),d=e("./internal/errors.js");function h(e){return n.formatAbiItem(e)}function p(e,t,r){const n=o.fromAbi(e,t,r);if("event"!==n.type)throw new o.NotFoundError({name:t,type:"event"});return n}function g(e){return o.getSignatureHash(e)}class m extends c.BaseError{constructor({abiEvent:e,expected:t,given:r}){super("Given arguments do not match the expected arguments.",{metaMessages:[`Event: ${h(e)}`,"Expected Arguments: "+(t?"":"None"),t?(0,d.prettyPrint)(t):undefined,"Given Arguments: "+(r?"":"None"),r?(0,d.prettyPrint)(r):undefined]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.ArgsMismatchError"})}}r.ArgsMismatchError=m;class y extends c.BaseError{constructor({abiEvent:e,name:t}){super(`Parameter "${t}" not found on \`${h(e)}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.InputNotFoundError"})}}r.InputNotFoundError=y;class b extends c.BaseError{constructor({abiEvent:e,data:t,parameters:r,size:n}){super([`Data size of ${n} bytes is too small for non-indexed event parameters.`].join("\n"),{metaMessages:[`Non-indexed Parameters: (${i.format(r)})`,`Data:   ${t} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.DataMismatchError"}),Object.defineProperty(this,"abiEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parameters",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiEvent=e,this.data=t,this.parameters=r,this.size=n}}r.DataMismatchError=b;class w extends c.BaseError{constructor({abiEvent:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} for "${h(e)}".`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.TopicsMismatchError"}),Object.defineProperty(this,"abiEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiEvent=e}}r.TopicsMismatchError=w;class E extends c.BaseError{constructor({abiEvent:e,actual:t,expected:r}){super(`topics[0]="${t}" does not match the expected topics[0]="${r}".`,{metaMessages:[`Event: ${h(e)}`,`Selector: ${r}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.SelectorTopicMismatchError"})}}r.SelectorTopicMismatchError=E;class v extends c.BaseError{constructor(e){super(`Filter type "${e}" is not supported.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.FilterTypeNotSupportedError"})}}r.FilterTypeNotSupportedError=v}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiEvent.js"}],[5638,{"./AbiItem.js":5639,"./AbiParameters.js":5640,"./Hex.js":5666,abitype:5047},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.decodeData=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[a(t,r),n]}return e})(),{overloads:n}=t;if(s.size(r)<4)throw new o.InvalidSelectorSizeError({data:r});if(0===t.inputs?.length)return undefined;const c=n?a([t,...n],r):t;return s.size(r)<=4?undefined:i.decode(c.inputs,s.slice(r,4))},r.decodeResult=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,o]=e;return[a(t,r),n,o]}return e})(),o=i.decode(t.outputs,r,n);if(o&&0===Object.keys(o).length)return undefined;if(o&&1===Object.keys(o).length)return Array.isArray(o)?o[0]:Object.values(o)[0];return o},r.encodeData=function(...e){const[t,r=[]]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[a(t,r,{args:n}),n]}const[t,r]=e;return[t,r]})(),{overloads:n}=t,o=n?a([t,...n],t.name,{args:r}):t,u=c(o),f=r.length>0?i.encode(o.inputs,r):undefined;return f?s.concat(u,f):u},r.encodeResult=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,o]=e;return[a(t,r),n,o]}return e})(),{as:o="Array"}=n,s=1===t.outputs.length?[r]:Array.isArray(r)?r:"Object"===o?Object.values(r):[r];return i.encode(t.outputs,s)},r.format=function(e){return n.formatAbiItem(e)},r.from=function(e,t={}){return o.from(e,t)},r.fromAbi=a,r.getSelector=c;const n=e("abitype"),o=e("./AbiItem.js"),i=e("./AbiParameters.js"),s=e("./Hex.js");function a(e,t,r){const n=o.fromAbi(e,t,r);if("function"!==n.type)throw new o.NotFoundError({name:t,type:"function"});return n}function c(e){return o.getSelector(e)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiFunction.js"}],[5639,{"./Errors.js":5661,"./Hash.js":5664,"./Hex.js":5666,"./internal/abiItem.js":5703,abitype:5047},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidSelectorSizeError=r.NotFoundError=r.AmbiguityError=void 0,r.format=function(e){return n.formatAbiItem(e)},r.from=function(e,t={}){const{prepare:r=!0}=t,o=Array.isArray(e)||"string"==typeof e?n.parseAbiItem(e):e;return{...o,...r?{hash:l(o)}:{}}},r.fromAbi=c,r.getSelector=u,r.getSignature=f,r.getSignatureHash=l;const n=e("abitype"),o=e("./Errors.js"),i=e("./Hash.js"),s=e("./Hex.js"),a=e("./internal/abiItem.js");function c(e,t,r){const{args:n=[],prepare:o=!0}=r??{},i=s.validate(t,{strict:!1}),c=e.filter(e=>i?"function"===e.type||"error"===e.type?u(e)===s.slice(t,0,4):"event"===e.type&&l(e)===t:"name"in e&&e.name===t);if(0===c.length)throw new h({name:t});if(1===c.length)return{...c[0],...o?{hash:l(c[0])}:{}};let f;for(const e of c){if(!("inputs"in e))continue;if(!n||0===n.length){if(!e.inputs||0===e.inputs.length)return{...e,...o?{hash:l(e)}:{}};continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==n.length)continue;if(n.every((t,r)=>{const n="inputs"in e&&e.inputs[r];return!!n&&a.isArgOfType(t,n)})){if(f&&"inputs"in f&&f.inputs){const t=a.getAmbiguousTypes(e.inputs,f.inputs,n);if(t)throw new d({abiItem:e,type:t[0]},{abiItem:f,type:t[1]})}f=e}}const p=(()=>{if(f)return f;const[e,...t]=c;return{...e,overloads:t}})();if(!p)throw new h({name:t});return{...p,...o?{hash:l(p)}:{}}}function u(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return c(t,r)}return e[0]})();return s.slice(l(t),0,4)}function f(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return c(t,r)}return e[0]})(),r="string"==typeof t?t:n.formatAbiItem(t);return a.normalizeSignature(r)}function l(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return c(t,r)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:i.keccak256(s.fromString(f(t)))}class d extends o.BaseError{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${a.normalizeSignature(n.formatAbiItem(e.abiItem))}\`, and`,`\`${t.type}\` in \`${a.normalizeSignature(n.formatAbiItem(t.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}r.AmbiguityError=d;class h extends o.BaseError{constructor({name:e,data:t,type:r="item"}){super(`ABI ${r}${e?` with name "${e}"`:t?` with data "${t}"`:""} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}r.NotFoundError=h;class p extends o.BaseError{constructor({data:e}){super(`Selector size is invalid. Expected 4 bytes. Received ${s.size(e)} bytes ("${e}").`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.InvalidSelectorSizeError"})}}r.InvalidSelectorSizeError=p}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiItem.js"}],[564,{"@metamask/utils":4109,lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);return t.meta.version=i,function(e){const t=e?.PreferencesController,r=t?.preferences;r&&(0,n.hasProperty)(r,"redesignedTransactionsEnabled")&&delete r.redesignedTransactionsEnabled}(t.data),t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=138}}},{package:"$root$",file:"app/scripts/migrations/138.ts"}],[5640,{"./Address.js":5643,"./Bytes.js":5655,"./Errors.js":5661,"./Hex.js":5666,"./Solidity.js":5684,"./internal/abiParameters.js":5704,"./internal/cursor.js":5707,abitype:5047},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidTypeError=r.InvalidArrayError=r.LengthMismatchError=r.BytesSizeMismatchError=r.ArrayLengthMismatchError=r.ZeroDataError=r.DataSizeTooSmallError=void 0,r.decode=function(e,t,r={}){const{as:n="Array",checksumAddress:o=!1}=r,s="string"==typeof t?i.fromHex(t):t,f=u.create(s);if(0===i.size(s)&&e.length>0)throw new h;if(i.size(s)&&i.size(s)<32)throw new d({data:"string"==typeof t?t:a.fromBytes(t),parameters:e,size:i.size(s)});let l=0;const p="Array"===n?[]:{};for(let t=0;t<e.length;++t){const r=e[t];f.setPosition(l);const[i,s]=c.decodeParameter(f,r,{checksumAddress:o,staticPosition:0});l+=s,"Array"===n?p.push(i):p[r.name??t]=i}return p},r.encode=function(e,t,r){const{checksumAddress:n=!1}=r??{};if(e.length!==t.length)throw new m({expectedLength:e.length,givenLength:t.length});const o=c.prepareParameters({checksumAddress:n,parameters:e,values:t}),i=c.encode(o);return 0===i.length?"0x":i},r.encodePacked=l,r.format=function(e){return n.formatAbiParameters(e)},r.from=function(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?n.parseAbiParameters(e):e};const n=e("abitype"),o=e("./Address.js"),i=e("./Bytes.js"),s=e("./Errors.js"),a=e("./Hex.js"),c=e("./internal/abiParameters.js"),u=e("./internal/cursor.js"),f=e("./Solidity.js");function l(e,t){if(e.length!==t.length)throw new m({expectedLength:e.length,givenLength:t.length});const r=[];for(let n=0;n<e.length;n++){const o=e[n],i=t[n];r.push(l.encode(o,i))}return a.concat(...r)}!function(e){e.encode=function e(t,r,n=!1){if("address"===t){const e=r;return o.assert(e),a.padLeft(e.toLowerCase(),n?32:0)}if("string"===t)return a.fromString(r);if("bytes"===t)return r;if("bool"===t)return a.padLeft(a.fromBoolean(r),n?32:1);const i=t.match(f.integerRegex);if(i){const[e,t,o="256"]=i,s=Number.parseInt(o,10)/8;return a.fromNumber(r,{size:n?32:s,signed:"int"===t})}const s=t.match(f.bytesRegex);if(s){const[e,t]=s;if(Number.parseInt(t,10)!==(r.length-2)/2)throw new g({expectedSize:Number.parseInt(t,10),value:r});return a.padRight(r,n?32:0)}const c=t.match(f.arrayRegex);if(c&&Array.isArray(r)){const[t,n]=c,o=[];for(let t=0;t<r.length;t++)o.push(e(n,r[t],!0));return 0===o.length?"0x":a.concat(...o)}throw new b(t)}}(l||(r.encodePacked=l={}));class d extends s.BaseError{constructor({data:e,parameters:t,size:r}){super(`Data size of ${r} bytes is too small for given parameters.`,{metaMessages:[`Params: (${n.formatAbiParameters(t)})`,`Data:   ${e} (${r} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}r.DataSizeTooSmallError=d;class h extends s.BaseError{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}r.ZeroDataError=h;class p extends s.BaseError{constructor({expectedLength:e,givenLength:t,type:r}){super(`Array length mismatch for type \`${r}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}r.ArrayLengthMismatchError=p;class g extends s.BaseError{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${a.size(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}r.BytesSizeMismatchError=g;class m extends s.BaseError{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}r.LengthMismatchError=m;class y extends s.BaseError{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}r.InvalidArrayError=y;class b extends s.BaseError{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}r.InvalidTypeError=b}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiParameters.js"}],[5641,{"./Address.js":5643,"./Errors.js":5661,"./Hash.js":5664,"./Hex.js":5666},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidStorageKeySizeError=void 0,r.fromTupleList=function(e){const t=[];for(let r=0;r<e.length;r++){const[o,a]=e[r];o&&n.assert(o,{strict:!1}),t.push({address:o,storageKeys:a.map(e=>i.validate(e)?e:s.trimLeft(e))})}return t},r.toTupleList=function(e){if(!e||0===e.length)return[];const t=[];for(const{address:r,storageKeys:o}of e){for(let e=0;e<o.length;e++)if(32!==s.size(o[e]))throw new a({storageKey:o[e]});r&&n.assert(r,{strict:!1}),t.push([r,o])}return t};const n=e("./Address.js"),o=e("./Errors.js"),i=e("./Hash.js"),s=e("./Hex.js");class a extends o.BaseError{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${s.size(e)} bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AccessList.InvalidStorageKeySizeError"})}}r.InvalidStorageKeySizeError=a}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AccessList.js"}],[5642,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AccountProof.js"}],[5643,{"./Bytes.js":5655,"./Caches.js":5656,"./Errors.js":5661,"./Hash.js":5664,"./PublicKey.js":5675},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidChecksumError=r.InvalidInputError=r.InvalidAddressError=void 0,r.assert=u,r.checksum=f,r.from=l,r.fromPublicKey=function(e,t={}){return l(`0x${s.keccak256(`0x${a.toHex(e).slice(4)}`).substring(26)}`,t)},r.isEqual=function(e,t){return u(e,{strict:!1}),u(t,{strict:!1}),e.toLowerCase()===t.toLowerCase()},r.validate=function(e,t={}){const{strict:r=!0}=t??{};try{return u(e,{strict:r}),!0}catch{return!1}};const n=e("./Bytes.js"),o=e("./Caches.js"),i=e("./Errors.js"),s=e("./Hash.js"),a=e("./PublicKey.js"),c=/^0x[a-fA-F0-9]{40}$/;function u(e,t={}){const{strict:r=!0}=t;if(!c.test(e))throw new d({address:e,cause:new h});if(r){if(e.toLowerCase()===e)return;if(f(e)!==e)throw new d({address:e,cause:new p})}}function f(e){if(o.checksum.has(e))return o.checksum.get(e);u(e,{strict:!1});const t=e.substring(2).toLowerCase(),r=s.keccak256(n.fromString(t),{as:"Bytes"}),i=t.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(15&r[e>>1])>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());const a=`0x${i.join("")}`;return o.checksum.set(e,a),a}function l(e,t={}){const{checksum:r=!1}=t;return u(e),r?f(e):e}class d extends i.BaseError{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}r.InvalidAddressError=d;class h extends i.BaseError{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}r.InvalidInputError=h;class p extends i.BaseError{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}r.InvalidChecksumError=p}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Address.js"}],[5644,{"./Bytes.js":5655,"./Hex.js":5666},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.ivLength=void 0,r.decrypt=async function(e,t,i={}){const{as:s=("string"==typeof e?"Hex":"Bytes")}=i,a=n.from(e),c=a.slice(0,r.ivLength),u=a.slice(r.ivLength),f=await globalThis.crypto.subtle.decrypt({name:"AES-GCM",iv:c},t,n.from(u)),l=new Uint8Array(f);return"Bytes"===s?l:o.from(l)},r.encrypt=async function(e,t,i={}){const{as:s=("string"==typeof e?"Hex":"Bytes")}=i,a=n.random(r.ivLength),c=await globalThis.crypto.subtle.encrypt({name:"AES-GCM",iv:a},t,n.from(e)),u=n.concat(a,new Uint8Array(c));return"Bytes"===s?u:o.from(u)},r.getKey=async function(e){const{iterations:t=9e5,password:r,salt:o=i(32)}=e,s=await globalThis.crypto.subtle.importKey("raw",n.fromString(r),{name:"PBKDF2"},!1,["deriveBits","deriveKey"]);return await globalThis.crypto.subtle.deriveKey({name:"PBKDF2",salt:o,iterations:t,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])},r.randomSalt=i;const n=e("./Bytes.js"),o=e("./Hex.js");function i(e=32){return n.random(e)}r.ivLength=16}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AesGcm.js"}],[5645,{"./Hash.js":5664,"./Hex.js":5666,"./Rlp.js":5676,"./Signature.js":5682},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.from=a,r.fromRpc=c,r.fromRpcList=function(e){return e.map(c)},r.fromTuple=u,r.fromTupleList=function(e){const t=[];for(const r of e)t.push(u(r));return t},r.getSignPayload=function(e){return f(e,{presign:!0})},r.hash=f,r.toRpc=l,r.toRpcList=function(e){return e.map(l)},r.toTuple=d,r.toTupleList=function(e){if(!e||0===e.length)return[];const t=[];for(const r of e)t.push(d(r));return t};const n=e("./Hash.js"),o=e("./Hex.js"),i=e("./Rlp.js"),s=e("./Signature.js");function a(e,t={}){return"string"==typeof e.chainId?c(e):{...e,...t.signature}}function c(e){const{address:t,chainId:r,nonce:n}=e,o=s.extract(e);return{address:t,chainId:Number(r),nonce:BigInt(n),...o}}function u(e){const[t,r,n,o,i,c]=e;let u={address:r,chainId:"0x"===t?0:Number(t),nonce:"0x"===n?0n:BigInt(n)};return o&&i&&c&&(u={...u,...s.fromTuple([o,i,c])}),a(u)}function f(e,t={}){const{presign:r}=t;return n.keccak256(o.concat("0x05",i.fromHex(d(r?{address:e.address,chainId:e.chainId,nonce:e.nonce}:e))))}function l(e){const{address:t,chainId:r,nonce:n,...i}=e;return{address:t,chainId:o.fromNumber(r),nonce:o.fromNumber(n),...s.toRpc(i)}}function d(e){const{address:t,chainId:r,nonce:n}=e,i=s.extract(e);return[r?o.fromNumber(r):"0x",t,n?o.fromNumber(n):"0x",...i?s.toTuple(i):[]]}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Authorization.js"}],[5646,{"./Bytes.js":5655,"./Hex.js":5666,"./internal/base58.js":5705},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fromBytes=function(e){return i.from(e)},r.fromHex=function(e){return i.from(e)},r.fromString=function(e){return i.from(n.fromString(e))},r.toBytes=function(e){return n.fromHex(s(e))},r.toHex=s,r.toString=function(e){return o.toString(s(e))};const n=e("./Bytes.js"),o=e("./Hex.js"),i=e("./internal/base58.js");function s(e){let t=BigInt(0),r=0,n=!0;for(let o=0;o<e.length;o++){const s=e[o];if(n&&"1"===s?r++:n=!1,"bigint"!=typeof i.alphabetToInteger[s])throw new Error("invalid base58 character: "+s);t*=58n,t+=i.alphabetToInteger[s]}return r?`0x${"0".repeat(2*r)}${t.toString(16)}`:`0x${t.toString(16)}`}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Base58.js"}],[5647,{"./Bytes.js":5655,"./Hex.js":5666},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fromBytes=u,r.fromHex=function(e,t={}){return u(n.fromHex(e),t)},r.fromString=function(e,t={}){return u(n.fromString(e),t)},r.toBytes=f,r.toHex=function(e){return o.fromBytes(f(e))},r.toString=function(e){return n.toString(f(e))};const n=e("./Bytes.js"),o=e("./Hex.js"),i=new TextEncoder,s=new TextDecoder,a=Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[t,e.charCodeAt(0)])),c={...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[e.charCodeAt(0),t])),["=".charCodeAt(0)]:0,["-".charCodeAt(0)]:62,["_".charCodeAt(0)]:63};function u(e,t={}){const{pad:r=!0,url:n=!1}=t,o=new Uint8Array(4*Math.ceil(e.length/3));for(let t=0,r=0;r<e.length;t+=4,r+=3){const n=(e[r]<<16)+(e[r+1]<<8)+(0|e[r+2]);o[t]=a[n>>18],o[t+1]=a[n>>12&63],o[t+2]=a[n>>6&63],o[t+3]=a[63&n]}const i=e.length%3,c=4*Math.floor(e.length/3)+(i&&i+1);let u=s.decode(new Uint8Array(o.buffer,0,c));return r&&1===i&&(u+="=="),r&&2===i&&(u+="="),n&&(u=u.replaceAll("+","-").replaceAll("/","_")),u}function f(e){const t=e.replace(/=+$/,""),r=t.length,n=new Uint8Array(r+3);i.encodeInto(t+"===",n);for(let e=0,r=0;e<t.length;e+=4,r+=3){const t=(c[n[e]]<<18)+(c[n[e+1]]<<12)+(c[n[e+2]]<<6)+c[n[e+3]];n[r]=t>>16,n[r+1]=t>>8&255,n[r+2]=255&t}const o=3*(r>>2)+(r%4&&r%4-1);return new Uint8Array(n.buffer,0,o)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Base64.js"}],[5648,{"./Bytes.js":5655,"@noble/hashes/blake3":4334},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.create=function(){return{root:{type:"empty"}}},r.insert=function(e,t,r){const n=o.slice(t,0,31),s=o.slice(t,31)[0];if("empty"===e.root.type)return e.root=a(n),void(e.root.values[s]=r);e.root=function e(t,r,n,s,u){let f=t;if("empty"===f.type)return f=a(r),f.values[n]=s,f;const l=c(r);if("stem"===f.type)return o.isEqual(f.stem,r)?(f.values[n]=s,f):i(f,l,c(f.stem),n,s,u);if("internal"===f.type)return 0===l[u]?f.left=e(f.left,r,n,s,u+1):f.right=e(f.right,r,n,s,u+1),f;return{type:"empty"}}(e.root,n,s,r,0)},r.merkelize=function(e){return function e(t){if("empty"===t.type)return new Uint8Array(32).fill(0);if("internal"===t.type){const r=e(t.left),n=e(t.right);return u(o.concat(r,n))}let r=t.values.map(u);for(;r.length>1;){const e=[];for(let t=0;t<r.length;t+=2)e.push(u(o.concat(r[t],r[t+1])));r=e}return u(o.concat(t.stem,new Uint8Array(1).fill(0),r[0]))}(e.root)};const n=e("@noble/hashes/blake3"),o=e("./Bytes.js");function i(e,t,r,n,o,c){if(t[c]===r[c]){const a=s();return 0===t[c]?a.left=i(e,t,r,n,o,c+1):a.right=i(e,t,r,n,o,c+1),a}const u=s(),f=t[c],l=function(e){const t=new Uint8Array(e.length/8);for(let r=0;r<e.length;r+=8){let n=0;for(let t=0;t<8;t++)n|=e[r+t]<<7-t;t[r/8]=n}return t}(t);return 0===f?(u.left=a(l),u.left.values[n]=o,u.right=e):(u.right=a(l),u.right.values[n]=o,u.left=e),u}function s(){return{left:{type:"empty"},right:{type:"empty"},type:"internal"}}function a(e){return{stem:e,values:Array.from({length:256},()=>undefined),type:"stem"}}function c(e){const t=[];for(const r of e)for(let e=0;e<8;e++)t.push(r>>7-e&1);return t}function u(e){return e&&e.some(e=>0!==e)?(0,n.blake3)(e):new Uint8Array(32).fill(0)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/BinaryStateTree.js"}],[5649,{"./Bytes.js":5655,"./Errors.js":5661,"./Hash.js":5664,"./Hex.js":5666,"./Kzg.js":5669,"./internal/cursor.js":5707},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidVersionedHashVersionError=r.InvalidVersionedHashSizeError=r.EmptyBlobVersionedHashesError=r.EmptyBlobError=r.BlobSizeTooLargeError=r.maxBytesPerTransaction=r.bytesPerBlob=r.fieldElementsPerBlob=r.bytesPerFieldElement=void 0,r.commitmentsToVersionedHashes=u,r.commitmentToVersionedHash=f,r.from=function(e,t={}){const o=t.as??("string"==typeof e?"Hex":"Bytes"),i="string"==typeof e?n.fromHex(e):e,c=n.size(i);if(!c)throw new g;if(c>r.maxBytesPerTransaction)throw new p({maxSize:r.maxBytesPerTransaction,size:c});const u=[];let f=!0,l=0;for(;f;){const e=a.create(new Uint8Array(r.bytesPerBlob));let t=0;for(;t<r.fieldElementsPerBlob;){const n=i.slice(l,l+(r.bytesPerFieldElement-1));if(e.pushByte(0),e.pushBytes(n),n.length<31){e.pushByte(128),f=!1;break}t++,l+=31}u.push(e)}return"Bytes"===o?u.map(e=>e.bytes):u.map(e=>s.fromBytes(e.bytes))},r.sidecarsToVersionedHashes=function(e,t={}){const{version:r}=t,n=t.as??("string"==typeof e[0].blob?"Hex":"Bytes"),o=[];for(const{commitment:t}of e)o.push(f(t,{as:n,version:r}));return o},r.to=l,r.toHex=function(e){return l(e,"Hex")},r.toBytes=function(e){return l(e,"Bytes")},r.toCommitments=d,r.toProofs=h,r.toSidecars=function(e,t){const{kzg:r}=t,n=t.commitments??d(e,{kzg:r}),o=t.proofs??h(e,{commitments:n,kzg:r}),i=[];for(let t=0;t<e.length;t++)i.push({blob:e[t],commitment:n[t],proof:o[t]});return i},r.toVersionedHashes=function(e,t){return u(d(e,t),t)};const n=e("./Bytes.js"),o=e("./Errors.js"),i=e("./Hash.js"),s=e("./Hex.js"),a=e("./internal/cursor.js"),c=e("./Kzg.js");function u(e,t={}){const{version:r}=t,n=t.as??("string"==typeof e[0]?"Hex":"Bytes"),o=[];for(const t of e)o.push(f(t,{as:n,version:r}));return o}function f(e,t={}){const{version:r=1}=t,n=t.as??("string"==typeof e?"Hex":"Bytes"),o=i.sha256(e,{as:"Bytes"});return o.set([r],0),"Bytes"===n?o:s.fromBytes(o)}function l(e,t){const r=t??("string"==typeof e[0]?"Hex":"Bytes"),o="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,i=o.reduce((e,t)=>e+t.length,0),c=a.create(new Uint8Array(i));let u=!0;for(const e of o){const t=a.create(e);for(;u&&t.position<e.length;){t.incrementPosition(1);let r=31;e.length-t.position<31&&(r=e.length-t.position);for(const e in Array.from({length:r})){const e=t.readByte();if(128===e&&!t.inspectBytes(t.remaining).includes(128)){u=!1;break}c.pushByte(e)}}}const f=c.bytes.slice(0,c.position);return"Hex"===r?s.fromBytes(f):f}function d(e,t){const{kzg:r}=t,o=t.as??("string"==typeof e[0]?"Hex":"Bytes"),i="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,a=[];for(const e of i)a.push(Uint8Array.from(r.blobToKzgCommitment(e)));return"Bytes"===o?a:a.map(e=>s.fromBytes(e))}function h(e,t){const{kzg:r}=t,o=t.as??("string"==typeof e[0]?"Hex":"Bytes"),i="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,a="string"==typeof t.commitments[0]?t.commitments.map(e=>n.fromHex(e)):t.commitments,c=[];for(let e=0;e<i.length;e++){const t=i[e],n=a[e];c.push(Uint8Array.from(r.computeBlobKzgProof(t,n)))}return"Bytes"===o?c:c.map(e=>s.fromBytes(e))}r.bytesPerFieldElement=32,r.fieldElementsPerBlob=4096,r.bytesPerBlob=r.bytesPerFieldElement*r.fieldElementsPerBlob,r.maxBytesPerTransaction=6*r.bytesPerBlob-1-1*r.fieldElementsPerBlob*6;class p extends o.BaseError{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.BlobSizeTooLargeError"})}}r.BlobSizeTooLargeError=p;class g extends o.BaseError{constructor(){super("Blob data must not be empty."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.EmptyBlobError"})}}r.EmptyBlobError=g;class m extends o.BaseError{constructor(){super("Blob versioned hashes must not be empty."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.EmptyBlobVersionedHashesError"})}}r.EmptyBlobVersionedHashesError=m;class y extends o.BaseError{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.InvalidVersionedHashSizeError"})}}r.InvalidVersionedHashSizeError=y;class b extends o.BaseError{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${c.versionedHashVersion}`,`Received: ${t}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.InvalidVersionedHashVersionError"})}}r.InvalidVersionedHashVersionError=b}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Blobs.js"}],[565,{"@metamask/utils":4109,lodash:5981},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.migrate=async function(e){const t=(0,o.cloneDeep)(e);t.meta.version=i;const r=function(e){const t=(0,o.cloneDeep)(e);if(!(0,n.hasProperty)(t,"PermissionController"))return e;if(!(0,n.isObject)(t.PermissionController))return global.sentry?.captureException?.(new Error(`Migration ${i}: typeof state.PermissionController is ${typeof t.PermissionController}`)),e;if(!(0,n.hasProperty)(t,"NetworkController")||!(0,n.isObject)(t.NetworkController))return global.sentry?.captureException?.(new Error(`Migration ${i}: typeof state.NetworkController is ${typeof t.NetworkController}`)),e;(0,n.hasProperty)(t,"SelectedNetworkController")||(console.warn(`Migration ${i}: typeof state.SelectedNetworkController is ${typeof t.SelectedNetworkController}`),t.SelectedNetworkController={domains:{}});if(!(0,n.isObject)(t.SelectedNetworkController))return global.sentry?.captureException?.(new Error(`Migration ${i}: typeof state.SelectedNetworkController is ${typeof t.SelectedNetworkController}`)),e;const{NetworkController:{selectedNetworkClientId:r,networkConfigurationsByChainId:h},PermissionController:{subjects:p}}=t;if(!(0,n.isObject)(p))return global.sentry?.captureException?.(new Error(`Migration ${i}: typeof state.PermissionController.subjects is ${typeof p}`)),e;if(!r||"string"!=typeof r)return global.sentry?.captureException?.(new Error(`Migration ${i}: typeof state.NetworkController.selectedNetworkClientId is ${typeof r}`)),e;if(!(0,n.isObject)(h))return global.sentry?.captureException?.(new Error(`Migration ${i}: typeof state.NetworkController.networkConfigurationsByChainId is ${typeof t.NetworkController.networkConfigurationsByChainId}`)),e;if(!(0,n.hasProperty)(t.SelectedNetworkController,"domains")||!(0,n.isObject)(t.SelectedNetworkController.domains)){const{domains:r}=t.SelectedNetworkController;return global.sentry?.captureException?.(new Error(`Migration ${i}: typeof state.SelectedNetworkController.domains is ${typeof r}`)),e}const{domains:g}=t.SelectedNetworkController,m=(e,t)=>{let r,o=!1;for(const[t,s]of Object.entries(h))if((0,n.isObject)(s))if(Array.isArray(s.rpcEndpoints))for(const a of s.rpcEndpoints)(0,n.isObject)(a)?a.networkClientId===e&&(r=t):(global.sentry?.captureException(new Error(`Migration ${i}: typeof state.NetworkController.networkConfigurationsByChainId["${t}"].rpcEndpoints[] is ${typeof a}`)),o=!0);else global.sentry?.captureException(new Error(`Migration ${i}: typeof state.NetworkController.networkConfigurationsByChainId["${t}"].rpcEndpoints is ${typeof s.rpcEndpoints}`)),o=!0;else global.sentry?.captureException(new Error(`Migration ${i}: typeof state.NetworkController.networkConfigurationsByChainId["${t}"] is ${typeof s}`)),o=!0;if(o)return undefined;if(r)return r;const s=u.get(e);return s||global.sentry?.captureException(new Error(`Migration ${i}: No chainId found for ${t} "${e}"`)),s},y=m(r,"selectedNetworkClientId");if(!y)return e;for(const[t,r]of Object.entries(p)){if(!(0,n.isObject)(r))return global.sentry?.captureException?.(new Error(`Migration ${i}: Invalid subject for origin "${t}" of type ${typeof r}`)),e;if(!(0,n.hasProperty)(r,"permissions")||!(0,n.isObject)(r.permissions))return global.sentry?.captureException?.(new Error(`Migration ${i}: Invalid permissions for origin "${t}" of type ${typeof r.permissions}`)),e;const{permissions:o}=r;let u,h=[];const p=o[c.eth_accounts],b=o[c.permittedChains];if(!p){delete o[c.permittedChains];continue}if(!l(p))return global.sentry?.captureException?.(new Error(`Migration ${i}: Invalid state.PermissionController.subjects[${t}].permissions[${c.eth_accounts}]: ${JSON.stringify(p)}`)),e;const w=p.caveats?.[0]?.value;if(!d(w))return global.sentry?.captureException?.(new Error(`Migration ${i}: Invalid state.PermissionController.subjects[${t}].permissions[${c.eth_accounts}].caveats[0].value of type ${typeof p.caveats?.[0]?.value}`)),e;h=w,u=p,delete o[c.eth_accounts];let E=[];if(b){if(!l(b))return global.sentry?.captureException?.(new Error(`Migration ${i}: Invalid state.PermissionController.subjects[${t}].permissions[${c.permittedChains}]: ${JSON.stringify(b)}`)),e;const r=b.caveats?.[0]?.value;if(!d(r))return global.sentry?.captureException?.(new Error(`Migration ${i}: Invalid state.PermissionController.subjects[${t}].permissions[${c.permittedChains}].caveats[0].value of type ${typeof b.caveats?.[0]?.value}`)),e;E=r,u??(u=b),delete o[c.permittedChains]}if(0===E.length){E=[y];const e=g[t];if(e&&"string"==typeof e){const t=m(e,"networkClientIdForOrigin");t&&(E=[t])}}const v=f.some(e=>t.startsWith(e)),x={},B=v?[]:E.map(e=>`eip155:${(0,n.hexToBigInt)(e).toString(10)}`);B.push("wallet:eip155"),B.forEach(e=>{const t=h.map(t=>`${e}:${t}`);x[e]={accounts:t}});const S={...u,parentCapability:a,caveats:[{type:s,value:{requiredScopes:{},optionalScopes:x,isMultichainOrigin:!1}}]};o[a]=S}return t}(t.data);return t.data=r,t},r.version=void 0;var n=e("@metamask/utils"),o=e("lodash");const i=r.version=139,s="authorizedScopes",a="endowment:caip25",c={eth_accounts:"eth_accounts",permittedChains:"endowment:permitted-chains"},u=new Map([["sepolia","0xaa36a7"],["mainnet","0x1"],["linea-sepolia","0xe705"],["linea-mainnet","0xe708"]]),f=["npm:","local:"];function l(e){return(0,n.isObject)(e)&&null!==e&&(0,n.hasProperty)(e,"caveats")&&Array.isArray(e.caveats)&&e.caveats.length>0&&(0,n.hasProperty)(e,"date")&&"number"==typeof e.date&&(0,n.hasProperty)(e,"id")&&"string"==typeof e.id&&(0,n.hasProperty)(e,"invoker")&&"string"==typeof e.invoker&&(0,n.hasProperty)(e,"parentCapability")&&"string"==typeof e.parentCapability}function d(e){return Array.isArray(e)&&e.length>0&&e.every(e=>"string"==typeof e)}}}},{package:"$root$",file:"app/scripts/migrations/139.ts"}]],[],{});