UNPKG

coinley-checkout

Version:

A React SDK for Coinley cryptocurrency payment processing with multi-network support

1,553 lines (1,551 loc) 600 kB
import { e as eventsExports, N as Nt$3 } from "./events-856718af.mjs"; import { p as process$1, bg as getAugmentedNamespace, g as getDefaultExportFromCjs, c as commonjsGlobal } from "./index-1c96ce10.mjs"; import { g as global } from "./index-703c58ee.mjs"; import { B as Buffer } from "./index-2161e56b.mjs"; import { c as createStore, g as get, s as set$1, d as del, k as keys, a as clear } from "./index-ad797676.mjs"; var __spreadArray = globalThis && globalThis.__spreadArray || function(to2, from2, pack) { if (pack || arguments.length === 2) for (var i3 = 0, l2 = from2.length, ar2; i3 < l2; i3++) { if (ar2 || !(i3 in from2)) { if (!ar2) ar2 = Array.prototype.slice.call(from2, 0, i3); ar2[i3] = from2[i3]; } } return to2.concat(ar2 || Array.prototype.slice.call(from2)); }; var BrowserInfo = ( /** @class */ function() { function BrowserInfo2(name, version2, os2) { this.name = name; this.version = version2; this.os = os2; this.type = "browser"; } return BrowserInfo2; }() ); var NodeInfo = ( /** @class */ function() { function NodeInfo2(version2) { this.version = version2; this.type = "node"; this.name = "node"; this.os = process$1.platform; } return NodeInfo2; }() ); var SearchBotDeviceInfo = ( /** @class */ function() { function SearchBotDeviceInfo2(name, version2, os2, bot) { this.name = name; this.version = version2; this.os = os2; this.bot = bot; this.type = "bot-device"; } return SearchBotDeviceInfo2; }() ); var BotInfo = ( /** @class */ function() { function BotInfo2() { this.type = "bot"; this.bot = true; this.name = "bot"; this.version = null; this.os = null; } return BotInfo2; }() ); var ReactNativeInfo = ( /** @class */ function() { function ReactNativeInfo2() { this.type = "react-native"; this.name = "react-native"; this.version = null; this.os = null; } return ReactNativeInfo2; }() ); var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/; var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/; var REQUIRED_VERSION_PARTS = 3; var userAgentRules = [ ["aol", /AOLShield\/([0-9\._]+)/], ["edge", /Edge\/([0-9\._]+)/], ["edge-ios", /EdgiOS\/([0-9\._]+)/], ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], ["samsung", /SamsungBrowser\/([0-9\.]+)/], ["silk", /\bSilk\/([0-9._-]+)\b/], ["miui", /MiuiBrowser\/([0-9\.]+)$/], ["beaker", /BeakerBrowser\/([0-9\.]+)/], ["edge-chromium", /EdgA?\/([0-9\.]+)/], [ "chromium-webview", /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ ], ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], ["fxios", /FxiOS\/([0-9\.]+)/], ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], ["ie", /MSIE\s(7\.0)/], ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], ["android", /Android\s([0-9\.]+)/], ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], ["safari", /Version\/([0-9\._]+).*Safari/], ["facebook", /FB[AS]V\/([0-9\.]+)/], ["instagram", /Instagram\s([0-9\.]+)/], ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], ["curl", /^curl\/([0-9\.]+)$/], ["searchbot", SEARCHBOX_UA_REGEX] ]; var operatingSystemRules = [ ["iOS", /iP(hone|od|ad)/], ["Android OS", /Android/], ["BlackBerry OS", /BlackBerry|BB10/], ["Windows Mobile", /IEMobile/], ["Amazon OS", /Kindle/], ["Windows 3.11", /Win16/], ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], ["Windows 98", /(Windows 98)|(Win98)/], ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], ["Windows Server 2003", /(Windows NT 5.2)/], ["Windows Vista", /(Windows NT 6.0)/], ["Windows 7", /(Windows NT 6.1)/], ["Windows 8", /(Windows NT 6.2)/], ["Windows 8.1", /(Windows NT 6.3)/], ["Windows 10", /(Windows NT 10.0)/], ["Windows ME", /Windows ME/], ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], ["Open BSD", /OpenBSD/], ["Sun OS", /SunOS/], ["Chrome OS", /CrOS/], ["Linux", /(Linux)|(X11)/], ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], ["QNX", /QNX/], ["BeOS", /BeOS/], ["OS/2", /OS\/2/] ]; function detect(userAgent) { if (!!userAgent) { return parseUserAgent(userAgent); } if (typeof document === "undefined" && typeof navigator !== "undefined" && navigator.product === "ReactNative") { return new ReactNativeInfo(); } if (typeof navigator !== "undefined") { return parseUserAgent(navigator.userAgent); } return getNodeVersion(); } function matchUserAgent(ua2) { return ua2 !== "" && userAgentRules.reduce(function(matched, _a) { var browser2 = _a[0], regex = _a[1]; if (matched) { return matched; } var uaMatch = regex.exec(ua2); return !!uaMatch && [browser2, uaMatch]; }, false); } function parseUserAgent(ua2) { var matchedRule = matchUserAgent(ua2); if (!matchedRule) { return null; } var name = matchedRule[0], match = matchedRule[1]; if (name === "searchbot") { return new BotInfo(); } var versionParts = match[1] && match[1].split(".").join("_").split("_").slice(0, 3); if (versionParts) { if (versionParts.length < REQUIRED_VERSION_PARTS) { versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true); } } else { versionParts = []; } var version2 = versionParts.join("."); var os2 = detectOS(ua2); var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua2); if (searchBotMatch && searchBotMatch[1]) { return new SearchBotDeviceInfo(name, version2, os2, searchBotMatch[1]); } return new BrowserInfo(name, version2, os2); } function detectOS(ua2) { for (var ii2 = 0, count = operatingSystemRules.length; ii2 < count; ii2++) { var _a = operatingSystemRules[ii2], os2 = _a[0], regex = _a[1]; var match = regex.exec(ua2); if (match) { return os2; } } return null; } function getNodeVersion() { var isNode = typeof process$1 !== "undefined" && process$1.version; return isNode ? new NodeInfo(process$1.version.slice(1)) : null; } function createVersionParts(count) { var output = []; for (var ii2 = 0; ii2 < count; ii2++) { output.push("0"); } return output; } var cjs$3 = {}; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var extendStatics$1 = function(d4, b2) { extendStatics$1 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d5, b3) { d5.__proto__ = b3; } || function(d5, b3) { for (var p2 in b3) if (b3.hasOwnProperty(p2)) d5[p2] = b3[p2]; }; return extendStatics$1(d4, b2); }; function __extends$1(d4, b2) { extendStatics$1(d4, b2); function __() { this.constructor = d4; } d4.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __()); } var __assign$1 = function() { __assign$1 = Object.assign || function __assign2(t) { for (var s2, i3 = 1, n3 = arguments.length; i3 < n3; i3++) { s2 = arguments[i3]; for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t[p2] = s2[p2]; } return t; }; return __assign$1.apply(this, arguments); }; function __rest$1(s2, e2) { var t = {}; for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0) t[p2] = s2[p2]; if (s2 != null && typeof Object.getOwnPropertySymbols === "function") for (var i3 = 0, p2 = Object.getOwnPropertySymbols(s2); i3 < p2.length; i3++) { if (e2.indexOf(p2[i3]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i3])) t[p2[i3]] = s2[p2[i3]]; } return t; } function __decorate$1(decorators, target, key, desc) { var c2 = arguments.length, r2 = c2 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d4; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc); else for (var i3 = decorators.length - 1; i3 >= 0; i3--) if (d4 = decorators[i3]) r2 = (c2 < 3 ? d4(r2) : c2 > 3 ? d4(target, key, r2) : d4(target, key)) || r2; return c2 > 3 && r2 && Object.defineProperty(target, key, r2), r2; } function __param$1(paramIndex, decorator) { return function(target, key) { decorator(target, key, paramIndex); }; } function __metadata$1(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter$1(thisArg, _arguments, P3, generator) { function adopt(value) { return value instanceof P3 ? value : new P3(function(resolve) { resolve(value); }); } return new (P3 || (P3 = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e2) { reject(e2); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e2) { reject(e2); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator$1(thisArg, body) { var _3 = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f5, y3, t, g2; return g2 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g2[Symbol.iterator] = function() { return this; }), g2; function verb(n3) { return function(v2) { return step([n3, v2]); }; } function step(op) { if (f5) throw new TypeError("Generator is already executing."); while (_3) try { if (f5 = 1, y3 && (t = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t = y3["return"]) && t.call(y3), 0) : y3.next) && !(t = t.call(y3, op[1])).done) return t; if (y3 = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _3.label++; return { value: op[1], done: false }; case 5: _3.label++; y3 = op[1]; op = [0]; continue; case 7: op = _3.ops.pop(); _3.trys.pop(); continue; default: if (!(t = _3.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _3 = 0; continue; } if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { _3.label = op[1]; break; } if (op[0] === 6 && _3.label < t[1]) { _3.label = t[1]; t = op; break; } if (t && _3.label < t[2]) { _3.label = t[2]; _3.ops.push(op); break; } if (t[2]) _3.ops.pop(); _3.trys.pop(); continue; } op = body.call(thisArg, _3); } catch (e2) { op = [6, e2]; y3 = 0; } finally { f5 = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __createBinding$1(o3, m3, k2, k22) { if (k22 === void 0) k22 = k2; o3[k22] = m3[k2]; } function __exportStar$1(m3, exports) { for (var p2 in m3) if (p2 !== "default" && !exports.hasOwnProperty(p2)) exports[p2] = m3[p2]; } function __values$1(o3) { var s2 = typeof Symbol === "function" && Symbol.iterator, m3 = s2 && o3[s2], i3 = 0; if (m3) return m3.call(o3); if (o3 && typeof o3.length === "number") return { next: function() { if (o3 && i3 >= o3.length) o3 = void 0; return { value: o3 && o3[i3++], done: !o3 }; } }; throw new TypeError(s2 ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read$1(o3, n3) { var m3 = typeof Symbol === "function" && o3[Symbol.iterator]; if (!m3) return o3; var i3 = m3.call(o3), r2, ar2 = [], e2; try { while ((n3 === void 0 || n3-- > 0) && !(r2 = i3.next()).done) ar2.push(r2.value); } catch (error) { e2 = { error }; } finally { try { if (r2 && !r2.done && (m3 = i3["return"])) m3.call(i3); } finally { if (e2) throw e2.error; } } return ar2; } function __spread$1() { for (var ar2 = [], i3 = 0; i3 < arguments.length; i3++) ar2 = ar2.concat(__read$1(arguments[i3])); return ar2; } function __spreadArrays$1() { for (var s2 = 0, i3 = 0, il = arguments.length; i3 < il; i3++) s2 += arguments[i3].length; for (var r2 = Array(s2), k2 = 0, i3 = 0; i3 < il; i3++) for (var a2 = arguments[i3], j2 = 0, jl = a2.length; j2 < jl; j2++, k2++) r2[k2] = a2[j2]; return r2; } function __await$1(v2) { return this instanceof __await$1 ? (this.v = v2, this) : new __await$1(v2); } function __asyncGenerator$1(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g2 = generator.apply(thisArg, _arguments || []), i3, q2 = []; return i3 = {}, verb("next"), verb("throw"), verb("return"), i3[Symbol.asyncIterator] = function() { return this; }, i3; function verb(n3) { if (g2[n3]) i3[n3] = function(v2) { return new Promise(function(a2, b2) { q2.push([n3, v2, a2, b2]) > 1 || resume(n3, v2); }); }; } function resume(n3, v2) { try { step(g2[n3](v2)); } catch (e2) { settle(q2[0][3], e2); } } function step(r2) { r2.value instanceof __await$1 ? Promise.resolve(r2.value.v).then(fulfill, reject) : settle(q2[0][2], r2); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f5, v2) { if (f5(v2), q2.shift(), q2.length) resume(q2[0][0], q2[0][1]); } } function __asyncDelegator$1(o3) { var i3, p2; return i3 = {}, verb("next"), verb("throw", function(e2) { throw e2; }), verb("return"), i3[Symbol.iterator] = function() { return this; }, i3; function verb(n3, f5) { i3[n3] = o3[n3] ? function(v2) { return (p2 = !p2) ? { value: __await$1(o3[n3](v2)), done: n3 === "return" } : f5 ? f5(v2) : v2; } : f5; } } function __asyncValues$1(o3) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m3 = o3[Symbol.asyncIterator], i3; return m3 ? m3.call(o3) : (o3 = typeof __values$1 === "function" ? __values$1(o3) : o3[Symbol.iterator](), i3 = {}, verb("next"), verb("throw"), verb("return"), i3[Symbol.asyncIterator] = function() { return this; }, i3); function verb(n3) { i3[n3] = o3[n3] && function(v2) { return new Promise(function(resolve, reject) { v2 = o3[n3](v2), settle(resolve, reject, v2.done, v2.value); }); }; } function settle(resolve, reject, d4, v2) { Promise.resolve(v2).then(function(v3) { resolve({ value: v3, done: d4 }); }, reject); } } function __makeTemplateObject$1(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; } function __importStar$1(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k2 in mod) if (Object.hasOwnProperty.call(mod, k2)) result[k2] = mod[k2]; } result.default = mod; return result; } function __importDefault$1(mod) { return mod && mod.__esModule ? mod : { default: mod }; } function __classPrivateFieldGet$1(receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); } function __classPrivateFieldSet$1(receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; } const tslib_es6$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, get __assign() { return __assign$1; }, __asyncDelegator: __asyncDelegator$1, __asyncGenerator: __asyncGenerator$1, __asyncValues: __asyncValues$1, __await: __await$1, __awaiter: __awaiter$1, __classPrivateFieldGet: __classPrivateFieldGet$1, __classPrivateFieldSet: __classPrivateFieldSet$1, __createBinding: __createBinding$1, __decorate: __decorate$1, __exportStar: __exportStar$1, __extends: __extends$1, __generator: __generator$1, __importDefault: __importDefault$1, __importStar: __importStar$1, __makeTemplateObject: __makeTemplateObject$1, __metadata: __metadata$1, __param: __param$1, __read: __read$1, __rest: __rest$1, __spread: __spread$1, __spreadArrays: __spreadArrays$1, __values: __values$1 }, Symbol.toStringTag, { value: "Module" })); const require$$0$1 = /* @__PURE__ */ getAugmentedNamespace(tslib_es6$1); var utils = {}; var delay = {}; var hasRequiredDelay; function requireDelay() { if (hasRequiredDelay) return delay; hasRequiredDelay = 1; Object.defineProperty(delay, "__esModule", { value: true }); delay.delay = void 0; function delay$1(timeout) { return new Promise((resolve) => { setTimeout(() => { resolve(true); }, timeout); }); } delay.delay = delay$1; return delay; } var convert = {}; var constants = {}; var misc = {}; var hasRequiredMisc; function requireMisc() { if (hasRequiredMisc) return misc; hasRequiredMisc = 1; Object.defineProperty(misc, "__esModule", { value: true }); misc.ONE_THOUSAND = misc.ONE_HUNDRED = void 0; misc.ONE_HUNDRED = 100; misc.ONE_THOUSAND = 1e3; return misc; } var time = {}; var hasRequiredTime; function requireTime() { if (hasRequiredTime) return time; hasRequiredTime = 1; (function(exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.ONE_YEAR = exports.FOUR_WEEKS = exports.THREE_WEEKS = exports.TWO_WEEKS = exports.ONE_WEEK = exports.THIRTY_DAYS = exports.SEVEN_DAYS = exports.FIVE_DAYS = exports.THREE_DAYS = exports.ONE_DAY = exports.TWENTY_FOUR_HOURS = exports.TWELVE_HOURS = exports.SIX_HOURS = exports.THREE_HOURS = exports.ONE_HOUR = exports.SIXTY_MINUTES = exports.THIRTY_MINUTES = exports.TEN_MINUTES = exports.FIVE_MINUTES = exports.ONE_MINUTE = exports.SIXTY_SECONDS = exports.THIRTY_SECONDS = exports.TEN_SECONDS = exports.FIVE_SECONDS = exports.ONE_SECOND = void 0; exports.ONE_SECOND = 1; exports.FIVE_SECONDS = 5; exports.TEN_SECONDS = 10; exports.THIRTY_SECONDS = 30; exports.SIXTY_SECONDS = 60; exports.ONE_MINUTE = exports.SIXTY_SECONDS; exports.FIVE_MINUTES = exports.ONE_MINUTE * 5; exports.TEN_MINUTES = exports.ONE_MINUTE * 10; exports.THIRTY_MINUTES = exports.ONE_MINUTE * 30; exports.SIXTY_MINUTES = exports.ONE_MINUTE * 60; exports.ONE_HOUR = exports.SIXTY_MINUTES; exports.THREE_HOURS = exports.ONE_HOUR * 3; exports.SIX_HOURS = exports.ONE_HOUR * 6; exports.TWELVE_HOURS = exports.ONE_HOUR * 12; exports.TWENTY_FOUR_HOURS = exports.ONE_HOUR * 24; exports.ONE_DAY = exports.TWENTY_FOUR_HOURS; exports.THREE_DAYS = exports.ONE_DAY * 3; exports.FIVE_DAYS = exports.ONE_DAY * 5; exports.SEVEN_DAYS = exports.ONE_DAY * 7; exports.THIRTY_DAYS = exports.ONE_DAY * 30; exports.ONE_WEEK = exports.SEVEN_DAYS; exports.TWO_WEEKS = exports.ONE_WEEK * 2; exports.THREE_WEEKS = exports.ONE_WEEK * 3; exports.FOUR_WEEKS = exports.ONE_WEEK * 4; exports.ONE_YEAR = exports.ONE_DAY * 365; })(time); return time; } var hasRequiredConstants; function requireConstants() { if (hasRequiredConstants) return constants; hasRequiredConstants = 1; (function(exports) { Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require$$0$1; tslib_1.__exportStar(requireMisc(), exports); tslib_1.__exportStar(requireTime(), exports); })(constants); return constants; } var hasRequiredConvert; function requireConvert() { if (hasRequiredConvert) return convert; hasRequiredConvert = 1; Object.defineProperty(convert, "__esModule", { value: true }); convert.fromMiliseconds = convert.toMiliseconds = void 0; const constants_1 = requireConstants(); function toMiliseconds(seconds) { return seconds * constants_1.ONE_THOUSAND; } convert.toMiliseconds = toMiliseconds; function fromMiliseconds(miliseconds) { return Math.floor(miliseconds / constants_1.ONE_THOUSAND); } convert.fromMiliseconds = fromMiliseconds; return convert; } var hasRequiredUtils; function requireUtils() { if (hasRequiredUtils) return utils; hasRequiredUtils = 1; (function(exports) { Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require$$0$1; tslib_1.__exportStar(requireDelay(), exports); tslib_1.__exportStar(requireConvert(), exports); })(utils); return utils; } var watch$2 = {}; var hasRequiredWatch$1; function requireWatch$1() { if (hasRequiredWatch$1) return watch$2; hasRequiredWatch$1 = 1; Object.defineProperty(watch$2, "__esModule", { value: true }); watch$2.Watch = void 0; class Watch { constructor() { this.timestamps = /* @__PURE__ */ new Map(); } start(label) { if (this.timestamps.has(label)) { throw new Error(`Watch already started for label: ${label}`); } this.timestamps.set(label, { started: Date.now() }); } stop(label) { const timestamp = this.get(label); if (typeof timestamp.elapsed !== "undefined") { throw new Error(`Watch already stopped for label: ${label}`); } const elapsed = Date.now() - timestamp.started; this.timestamps.set(label, { started: timestamp.started, elapsed }); } get(label) { const timestamp = this.timestamps.get(label); if (typeof timestamp === "undefined") { throw new Error(`No timestamp found for label: ${label}`); } return timestamp; } elapsed(label) { const timestamp = this.get(label); const elapsed = timestamp.elapsed || Date.now() - timestamp.started; return elapsed; } } watch$2.Watch = Watch; watch$2.default = Watch; return watch$2; } var types = {}; var watch$1 = {}; var hasRequiredWatch; function requireWatch() { if (hasRequiredWatch) return watch$1; hasRequiredWatch = 1; Object.defineProperty(watch$1, "__esModule", { value: true }); watch$1.IWatch = void 0; class IWatch { } watch$1.IWatch = IWatch; return watch$1; } var hasRequiredTypes; function requireTypes() { if (hasRequiredTypes) return types; hasRequiredTypes = 1; (function(exports) { Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require$$0$1; tslib_1.__exportStar(requireWatch(), exports); })(types); return types; } (function(exports) { Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require$$0$1; tslib_1.__exportStar(requireUtils(), exports); tslib_1.__exportStar(requireWatch$1(), exports); tslib_1.__exportStar(requireTypes(), exports); tslib_1.__exportStar(requireConstants(), exports); })(cjs$3); var cjs$2 = {}; Object.defineProperty(cjs$2, "__esModule", { value: true }); cjs$2.getLocalStorage = cjs$2.getLocalStorageOrThrow = cjs$2.getCrypto = cjs$2.getCryptoOrThrow = getLocation_1 = cjs$2.getLocation = cjs$2.getLocationOrThrow = getNavigator_1 = cjs$2.getNavigator = cjs$2.getNavigatorOrThrow = getDocument_1 = cjs$2.getDocument = cjs$2.getDocumentOrThrow = cjs$2.getFromWindowOrThrow = cjs$2.getFromWindow = void 0; function getFromWindow(name) { let res = void 0; if (typeof window !== "undefined" && typeof window[name] !== "undefined") { res = window[name]; } return res; } cjs$2.getFromWindow = getFromWindow; function getFromWindowOrThrow(name) { const res = getFromWindow(name); if (!res) { throw new Error(`${name} is not defined in Window`); } return res; } cjs$2.getFromWindowOrThrow = getFromWindowOrThrow; function getDocumentOrThrow() { return getFromWindowOrThrow("document"); } cjs$2.getDocumentOrThrow = getDocumentOrThrow; function getDocument() { return getFromWindow("document"); } var getDocument_1 = cjs$2.getDocument = getDocument; function getNavigatorOrThrow() { return getFromWindowOrThrow("navigator"); } cjs$2.getNavigatorOrThrow = getNavigatorOrThrow; function getNavigator() { return getFromWindow("navigator"); } var getNavigator_1 = cjs$2.getNavigator = getNavigator; function getLocationOrThrow() { return getFromWindowOrThrow("location"); } cjs$2.getLocationOrThrow = getLocationOrThrow; function getLocation() { return getFromWindow("location"); } var getLocation_1 = cjs$2.getLocation = getLocation; function getCryptoOrThrow() { return getFromWindowOrThrow("crypto"); } cjs$2.getCryptoOrThrow = getCryptoOrThrow; function getCrypto() { return getFromWindow("crypto"); } cjs$2.getCrypto = getCrypto; function getLocalStorageOrThrow() { return getFromWindowOrThrow("localStorage"); } cjs$2.getLocalStorageOrThrow = getLocalStorageOrThrow; function getLocalStorage() { return getFromWindow("localStorage"); } cjs$2.getLocalStorage = getLocalStorage; var cjs$1 = {}; Object.defineProperty(cjs$1, "__esModule", { value: true }); var getWindowMetadata_1 = cjs$1.getWindowMetadata = void 0; const window_getters_1 = cjs$2; function getWindowMetadata() { let doc; let loc; try { doc = window_getters_1.getDocumentOrThrow(); loc = window_getters_1.getLocationOrThrow(); } catch (e2) { return null; } function getIcons() { const links = doc.getElementsByTagName("link"); const icons2 = []; for (let i3 = 0; i3 < links.length; i3++) { const link = links[i3]; const rel = link.getAttribute("rel"); if (rel) { if (rel.toLowerCase().indexOf("icon") > -1) { const href = link.getAttribute("href"); if (href) { if (href.toLowerCase().indexOf("https:") === -1 && href.toLowerCase().indexOf("http:") === -1 && href.indexOf("//") !== 0) { let absoluteHref = loc.protocol + "//" + loc.host; if (href.indexOf("/") === 0) { absoluteHref += href; } else { const path = loc.pathname.split("/"); path.pop(); const finalPath = path.join("/"); absoluteHref += finalPath + "/" + href; } icons2.push(absoluteHref); } else if (href.indexOf("//") === 0) { const absoluteUrl = loc.protocol + href; icons2.push(absoluteUrl); } else { icons2.push(href); } } } } } return icons2; } function getWindowMetadataOfAny(...args) { const metaTags = doc.getElementsByTagName("meta"); for (let i3 = 0; i3 < metaTags.length; i3++) { const tag = metaTags[i3]; const attributes = ["itemprop", "property", "name"].map((target) => tag.getAttribute(target)).filter((attr) => { if (attr) { return args.includes(attr); } return false; }); if (attributes.length && attributes) { const content = tag.getAttribute("content"); if (content) { return content; } } } return ""; } function getName() { let name2 = getWindowMetadataOfAny("name", "og:site_name", "og:title", "twitter:title"); if (!name2) { name2 = doc.title; } return name2; } function getDescription() { const description2 = getWindowMetadataOfAny("description", "og:description", "twitter:description", "keywords"); return description2; } const name = getName(); const description = getDescription(); const url = loc.origin; const icons = getIcons(); const meta = { description, url, icons, name }; return meta; } getWindowMetadata_1 = cjs$1.getWindowMetadata = getWindowMetadata; function isHex(value, { strict = true } = {}) { if (!value) return false; if (typeof value !== "string") return false; return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x"); } function size(value) { if (isHex(value, { strict: false })) return Math.ceil((value.length - 2) / 2); return value.length; } const version = "2.23.2"; let errorConfig = { getDocsUrl: ({ docsBaseUrl, docsPath = "", docsSlug }) => docsPath ? `${docsBaseUrl ?? "https://viem.sh"}${docsPath}${docsSlug ? `#${docsSlug}` : ""}` : void 0, version: `viem@${version}` }; class BaseError extends Error { constructor(shortMessage, args = {}) { const details = (() => { if (args.cause instanceof BaseError) return args.cause.details; if (args.cause?.message) return args.cause.message; return args.details; })(); const docsPath = (() => { if (args.cause instanceof BaseError) return args.cause.docsPath || args.docsPath; return args.docsPath; })(); const docsUrl = errorConfig.getDocsUrl?.({ ...args, docsPath }); const message = [ shortMessage || "An error occurred.", "", ...args.metaMessages ? [...args.metaMessages, ""] : [], ...docsUrl ? [`Docs: ${docsUrl}`] : [], ...details ? [`Details: ${details}`] : [], ...errorConfig.version ? [`Version: ${errorConfig.version}`] : [] ].join("\n"); super(message, args.cause ? { cause: args.cause } : void 0); Object.defineProperty(this, "details", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "docsPath", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "metaMessages", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "shortMessage", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "version", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "BaseError" }); this.details = details; this.docsPath = docsPath; this.metaMessages = args.metaMessages; this.name = args.name ?? this.name; this.shortMessage = shortMessage; this.version = version; } walk(fn2) { return walk(this, fn2); } } function walk(err, fn2) { if (fn2?.(err)) return err; if (err && typeof err === "object" && "cause" in err && err.cause !== void 0) return walk(err.cause, fn2); return fn2 ? null : err; } class SizeExceedsPaddingSizeError extends BaseError { constructor({ size: size2, targetSize, type }) { super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" }); } } function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) { if (typeof hexOrBytes === "string") return padHex(hexOrBytes, { dir, size: size2 }); return padBytes(hexOrBytes, { dir, size: size2 }); } function padHex(hex_, { dir, size: size2 = 32 } = {}) { if (size2 === null) return hex_; const hex = hex_.replace("0x", ""); if (hex.length > size2 * 2) throw new SizeExceedsPaddingSizeError({ size: Math.ceil(hex.length / 2), targetSize: size2, type: "hex" }); return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size2 * 2, "0")}`; } function padBytes(bytes, { dir, size: size2 = 32 } = {}) { if (size2 === null) return bytes; if (bytes.length > size2) throw new SizeExceedsPaddingSizeError({ size: bytes.length, targetSize: size2, type: "bytes" }); const paddedBytes = new Uint8Array(size2); for (let i3 = 0; i3 < size2; i3++) { const padEnd = dir === "right"; paddedBytes[padEnd ? i3 : size2 - i3 - 1] = bytes[padEnd ? i3 : bytes.length - i3 - 1]; } return paddedBytes; } class IntegerOutOfRangeError extends BaseError { constructor({ max, min, signed, size: size2, value }) { super(`Number "${value}" is not in safe ${size2 ? `${size2 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" }); } } class SizeOverflowError extends BaseError { constructor({ givenSize, maxSize }) { super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" }); } } function assertSize(hexOrBytes, { size: size$1 }) { if (size(hexOrBytes) > size$1) throw new SizeOverflowError({ givenSize: size(hexOrBytes), maxSize: size$1 }); } function hexToBigInt(hex, opts = {}) { const { signed } = opts; if (opts.size) assertSize(hex, { size: opts.size }); const value = BigInt(hex); if (!signed) return value; const size2 = (hex.length - 2) / 2; const max = (1n << BigInt(size2) * 8n - 1n) - 1n; if (value <= max) return value; return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n; } function hexToNumber(hex, opts = {}) { return Number(hexToBigInt(hex, opts)); } const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i3) => i3.toString(16).padStart(2, "0")); function toHex(value, opts = {}) { if (typeof value === "number" || typeof value === "bigint") return numberToHex(value, opts); if (typeof value === "string") { return stringToHex(value, opts); } if (typeof value === "boolean") return boolToHex(value, opts); return bytesToHex(value, opts); } function boolToHex(value, opts = {}) { const hex = `0x${Number(value)}`; if (typeof opts.size === "number") { assertSize(hex, { size: opts.size }); return pad(hex, { size: opts.size }); } return hex; } function bytesToHex(value, opts = {}) { let string2 = ""; for (let i3 = 0; i3 < value.length; i3++) { string2 += hexes[value[i3]]; } const hex = `0x${string2}`; if (typeof opts.size === "number") { assertSize(hex, { size: opts.size }); return pad(hex, { dir: "right", size: opts.size }); } return hex; } function numberToHex(value_, opts = {}) { const { signed, size: size2 } = opts; const value = BigInt(value_); let maxValue; if (size2) { if (signed) maxValue = (1n << BigInt(size2) * 8n - 1n) - 1n; else maxValue = 2n ** (BigInt(size2) * 8n) - 1n; } else if (typeof value_ === "number") { maxValue = BigInt(Number.MAX_SAFE_INTEGER); } const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0; if (maxValue && value > maxValue || value < minValue) { const suffix = typeof value_ === "bigint" ? "n" : ""; throw new IntegerOutOfRangeError({ max: maxValue ? `${maxValue}${suffix}` : void 0, min: `${minValue}${suffix}`, signed, size: size2, value: `${value_}${suffix}` }); } const hex = `0x${(signed && value < 0 ? (1n << BigInt(size2 * 8)) + BigInt(value) : value).toString(16)}`; if (size2) return pad(hex, { size: size2 }); return hex; } const encoder$1 = /* @__PURE__ */ new TextEncoder(); function stringToHex(value_, opts = {}) { const value = encoder$1.encode(value_); return bytesToHex(value, opts); } const encoder = /* @__PURE__ */ new TextEncoder(); function toBytes$1(value, opts = {}) { if (typeof value === "number" || typeof value === "bigint") return numberToBytes(value, opts); if (typeof value === "boolean") return boolToBytes(value, opts); if (isHex(value)) return hexToBytes(value, opts); return stringToBytes(value, opts); } function boolToBytes(value, opts = {}) { const bytes = new Uint8Array(1); bytes[0] = Number(value); if (typeof opts.size === "number") { assertSize(bytes, { size: opts.size }); return pad(bytes, { size: opts.size }); } return bytes; } const charCodeMap = { zero: 48, nine: 57, A: 65, F: 70, a: 97, f: 102 }; function charCodeToBase16(char) { if (char >= charCodeMap.zero && char <= charCodeMap.nine) return char - charCodeMap.zero; if (char >= charCodeMap.A && char <= charCodeMap.F) return char - (charCodeMap.A - 10); if (char >= charCodeMap.a && char <= charCodeMap.f) return char - (charCodeMap.a - 10); return void 0; } function hexToBytes(hex_, opts = {}) { let hex = hex_; if (opts.size) { assertSize(hex, { size: opts.size }); hex = pad(hex, { dir: "right", size: opts.size }); } let hexString = hex.slice(2); if (hexString.length % 2) hexString = `0${hexString}`; const length = hexString.length / 2; const bytes = new Uint8Array(length); for (let index = 0, j2 = 0; index < length; index++) { const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j2++)); const nibbleRight = charCodeToBase16(hexString.charCodeAt(j2++)); if (nibbleLeft === void 0 || nibbleRight === void 0) { throw new BaseError(`Invalid byte sequence ("${hexString[j2 - 2]}${hexString[j2 - 1]}" in "${hexString}").`); } bytes[index] = nibbleLeft * 16 + nibbleRight; } return bytes; } function numberToBytes(value, opts) { const hex = numberToHex(value, opts); return hexToBytes(hex); } function stringToBytes(value, opts = {}) { const bytes = encoder.encode(value); if (typeof opts.size === "number") { assertSize(bytes, { size: opts.size }); return pad(bytes, { dir: "right", size: opts.size }); } return bytes; } function anumber(n3) { if (!Number.isSafeInteger(n3) || n3 < 0) throw new Error("positive integer expected, got " + n3); } function isBytes(a2) { return a2 instanceof Uint8Array || ArrayBuffer.isView(a2) && a2.constructor.name === "Uint8Array"; } function abytes(b2, ...lengths) { if (!isBytes(b2)) throw new Error("Uint8Array expected"); if (lengths.length > 0 && !lengths.includes(b2.length)) throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b2.length); } function ahash(h4) { if (typeof h4 !== "function" || typeof h4.create !== "function") throw new Error("Hash should be wrapped by utils.wrapConstructor"); anumber(h4.outputLen); anumber(h4.blockLen); } function aexists(instance, checkFinished = true) { if (instance.destroyed) throw new Error("Hash instance has been destroyed"); if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called"); } function aoutput(out, instance) { abytes(out); const min = instance.outputLen; if (out.length < min) { throw new Error("digestInto() expects output buffer of length at least " + min); } } const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); const _32n = /* @__PURE__ */ BigInt(32); function fromBig(n3, le2 = false) { if (le2) return { h: Number(n3 & U32_MASK64), l: Number(n3 >> _32n & U32_MASK64) }; return { h: Number(n3 >> _32n & U32_MASK64) | 0, l: Number(n3 & U32_MASK64) | 0 }; } function split(lst, le2 = false) { let Ah = new Uint32Array(lst.length); let Al = new Uint32Array(lst.length); for (let i3 = 0; i3 < lst.length; i3++) { const { h: h4, l: l2 } = fromBig(lst[i3], le2); [Ah[i3], Al[i3]] = [h4, l2]; } return [Ah, Al]; } const rotlSH = (h4, l2, s2) => h4 << s2 | l2 >>> 32 - s2; const rotlSL = (h4, l2, s2) => l2 << s2 | h4 >>> 32 - s2; const rotlBH = (h4, l2, s2) => l2 << s2 - 32 | h4 >>> 64 - s2; const rotlBL = (h4, l2, s2) => h4 << s2 - 32 | l2 >>> 64 - s2; const crypto$2 = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0; /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ function u32(arr) { return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); } function createView(arr) { return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); } function rotr(word, shift) { return word << 32 - shift | word >>> shift; } const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)(); function byteSwap(word) { return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255; } function byteSwap32(arr) { for (let i3 = 0; i3 < arr.length; i3++) { arr[i3] = byteSwap(arr[i3]); } } function utf8ToBytes(str) { if (typeof str !== "string") throw new Error("utf8ToBytes expected string, got " + typeof str); return new Uint8Array(new TextEncoder().encode(str)); } function toBytes(data) { if (typeof data === "string") data = utf8ToBytes(data); abytes(data); return data; } function concatBytes(...arrays) { let sum = 0; for (let i3 = 0; i3 < arrays.length; i3++) { const a2 = arrays[i3]; abytes(a2); sum += a2.length; } const res = new Uint8Array(sum); for (let i3 = 0, pad2 = 0; i3 < arrays.length; i3++) { const a2 = arrays[i3]; res.set(a2, pad2); pad2 += a2.length; } return res; } class Hash { // Safe version that clones internal state clone() { return this._cloneInto(); } } function wrapConstructor(hashCons) { const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); const tmp = hashCons(); hashC.outputLen = tmp.outputLen; hashC.blockLen = tmp.blockLen; hashC.create = () => hashCons(); return hashC; } function randomBytes(bytesLength = 32) { if (crypto$2 && typeof crypto$2.getRandomValues === "function") { return crypto$2.getRandomValues(new Uint8Array(bytesLength)); } if (crypto$2 && typeof crypto$2.randomBytes === "function") { return crypto$2.randomBytes(bytesLength); } throw new Error("crypto.getRandomValues must be defined"); } const SHA3_PI = []; const SHA3_ROTL = []; const _SHA3_IOTA = []; const _0n = /* @__PURE__ */ BigInt(0); const _1n = /* @__PURE__ */ BigInt(1); const _2n = /* @__PURE__ */ BigInt(2); const _7n = /* @__PURE__ */ BigInt(7); const _256n = /* @__PURE__ */ BigInt(256); const _0x71n = /* @__PURE__ */ BigInt(113); for (let round = 0, R3 = _1n, x2 = 1, y3 = 0; round < 24; round++) { [x2, y3] = [y3, (2 * x2 + 3 * y3) % 5]; SHA3_PI.push(2 * (5 * y3 + x2)); SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64); let t = _0n; for (let j2 = 0; j2 < 7; j2++) { R3 = (R3 << _1n ^ (R3 >> _7n) * _0x71n) % _256n; if (R3 & _2n) t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j2)) - _1n; } _SHA3_IOTA.push(t); } const [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true); const rotlH = (h4, l2, s2) => s2 > 32 ? rotlBH(h4, l2, s2) : rotlSH(h4, l2, s2); const rotlL = (h4, l2, s2) => s2 > 32 ? rotlBL(h4, l2, s2) : rotlSL(h4, l2, s2); function keccakP(s2, rounds = 24) { const B4 = new Uint32Array(5 * 2); for (let round = 24 - rounds; round < 24; round++) { for (let x2 = 0; x2 < 10; x2++) B4[x2] = s2[x2] ^ s2[x2 + 10] ^ s2[x2 + 20] ^ s2[x2 + 30] ^ s2[x2 + 40]; for (let x2 = 0; x2 < 10; x2 += 2) { const idx1 = (x2 + 8) % 10; const idx0 = (x2 + 2) % 10; const B0 = B4[idx0]; const B1 = B4[idx0 + 1]; const Th = rotlH(B0, B1, 1) ^ B4[idx1]; const Tl = rotlL(B0, B1, 1) ^ B4[idx1 + 1]; for (let y3 = 0; y3 < 50; y3 += 10) { s2[x2 + y3] ^= Th; s2[x2 + y3 + 1] ^= Tl; } } let curH = s2[2]; let curL = s2[3]; for (let t = 0; t < 24; t++) { const shift = SHA3_ROTL[t]; const Th = rotlH(curH, curL, shift); const Tl = rotlL(curH, curL, shift); const PI = SHA3_PI[t]; curH = s2[PI]; curL = s2[PI + 1]; s2[PI] = Th; s2[PI + 1] = Tl; } for (let y3 = 0; y3 < 50; y3 += 10) { for (let x2 = 0; x2 < 10; x2++) B4[x2] = s2[y3 + x2]; for (let x2 = 0; x2 < 10; x2++) s2[y3 + x2] ^= ~B4[(x2 + 2) % 10] & B4[(x2 + 4) % 10]; } s2[0] ^= SHA3_IOTA_H[round]; s2[1] ^= SHA3_IOTA_L[round]; } B4.fill(0); } class Keccak extends Hash { // NOTE: we accept arguments in bytes instead of bits here. constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { super(); this.blockLen = blockLen; this.suffix = suffix; this.outputLen = outputLen; this.enableXOF = enableXOF; this.rounds = rounds; this.pos = 0; this.posOut = 0; this.finished = false; this.destroyed = false; anumber(outputLen); if (0 >= this.blockLen || this.blockLen >= 200) throw new Error("Sha3 supports only keccak-f1600 function"); this.state = new Uint8Array(200); this.state32 = u32(this.state); } keccak() { if (!isLE) byteSwap32(this.state32); keccakP(this.state32, this.rounds); if (!isLE) byteSwap32(this.state32); this.posOut = 0; this.pos = 0; } update(data) { aexists(this); const { blockLen, state } = this; data = toBytes(data); const len = data.length; for (let pos = 0; pos < len; ) { const take = Math.min(blockLen - this.pos, len - pos); for (let i3 = 0; i3 < take; i3++) state[this.pos++] ^= data[pos++]; if (this.pos === blockLen) this.keccak(); } return this; } finish() { if (this.finished) return; this.finished = true; const { state, suffix, pos, blockLen } = this; state[pos] ^= suffix; if ((suffix & 128) !== 0 && pos === blockLen - 1) this.keccak(); state[blockLen - 1] ^= 128; this.keccak(); } writeInto(out) { aexists(this, false); abytes(out); this.finish(); const bufferOut = this.state; const { blockLen } = this; for (let pos = 0, len = out.length; pos < len; ) { if (this.posOut >= blockLen) this.keccak(); const take = Math.min(blockLen - this.posOut, len - pos); out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); this.posOut += take; pos += take; } return out; } xofInto(out) { if (!this.enableXOF) throw new Error("XOF is not possible for this instance"); return this.writeInto(out); } xof(bytes) { anumber(bytes); return this.xofInto(new Uint8Array(bytes)); } digestInto(out) { aoutput(out, this); if (this.finished) throw new Error("digest() was already called"); this.writeInto(out); this.destroy(); return out; } digest() { return this.digestInto(new Uint8Array(this.outputLen)); } destroy() { this.destroyed = true; this.state.fill(0); } _cloneInto(to2) { const { blockLen, suffix, outputLen, rounds, enableXOF } = this; to2 || (to2 = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds)); to2.state32.set(this.state32); to2.pos = this.pos; to2.posOut = this.posOut; to2.finished = this.finished; to2.rounds = rounds; to2.suffix = suffix; to2.outputLen = outputLen; to2.enableXOF = enableXOF; to2.destroyed = this.destroyed; return to2; } } const gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen)); const keccak_256 = /* @__PURE__ */ gen(1, 136, 256 / 8); function keccak256(value, to_) { const to2 = to_ || "hex"; const bytes = keccak_256(isHex(value, { strict: false }) ? toBytes$1(value) : value); if (to2 === "bytes") return bytes; return toHex(bytes); } class LruMap extends Map { constructor(size2) { super(); Object.defineProperty(this, "maxSize", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.maxSize = size2; } get(key) { const value = super.get(key); if (super.has(key) && value !== void 0) { this.delete(key); super.set(key, value); } return value; } set(key, value) { super.set(key, value); if (this.maxSize && this.size > this.maxSize) { const