@imtbl/sdk 1.71.2 → 1.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{blockchain_data-Bhqm0if8.js → blockchain_data-BhKkcXKA.js} +2 -2
- package/dist/blockchain_data.js +3 -3
- package/dist/browser/checkout/{AddTokensWidget-DKzImmC-.js → AddTokensWidget-H9uRs_pu.js} +20 -38
- package/dist/browser/checkout/{BridgeWidget-CzVsQchC.js → BridgeWidget-DBlVbfR0.js} +9 -9
- package/dist/browser/checkout/{CommerceWidget-CUasC3oE.js → CommerceWidget-BLbJSgWC.js} +17 -17
- package/dist/browser/checkout/{CryptoFiatProvider-DKXCDDGn.js → CryptoFiatProvider-BSRVFRoD.js} +1 -1
- package/dist/browser/checkout/{EllipsizedText-UC6tKNEL.js → EllipsizedText-4rf2JtZP.js} +1 -1
- package/dist/browser/checkout/{FeesBreakdown-BfPztUaH.js → FeesBreakdown-BQak-_iI.js} +1 -1
- package/dist/browser/checkout/{HandoverContent-B3LLoEOB.js → HandoverContent-FPHu2HkR.js} +1 -1
- package/dist/browser/checkout/{OnRampWidget-ByivbO-g.js → OnRampWidget-CEQJezLx.js} +3 -3
- package/dist/browser/checkout/{SaleWidget-Dk7eHdEM.js → SaleWidget-DvoH4z6w.js} +14 -14
- package/dist/browser/checkout/{SpendingCapHero-LcUg19at.js → SpendingCapHero-v3WRS9c2.js} +1 -1
- package/dist/browser/checkout/{SwapWidget-B5I4qbQ2.js → SwapWidget-C_9cjLEV.js} +9 -9
- package/dist/browser/checkout/{TokenImage-BV7fW6TT.js → TokenImage-C22RrN2b.js} +1 -1
- package/dist/browser/checkout/{TopUpView--9kYu60j.js → TopUpView-DwImDKAn.js} +3 -3
- package/dist/browser/checkout/{WalletApproveHero-CzkeZMMr.js → WalletApproveHero-BceSDZx_.js} +3 -3
- package/dist/browser/checkout/{WalletWidget-72Q5gtXg.js → WalletWidget-CZ_lw4_E.js} +4 -4
- package/dist/browser/checkout/{auto-track-BvpUU2wR.js → auto-track-CW8Ech72.js} +1 -1
- package/dist/browser/checkout/{index-bkapV3e8.js → index-B5NVM-4U.js} +1 -1
- package/dist/browser/checkout/{index-Ck7ANhMH.js → index-BceUl1li.js} +1 -1
- package/dist/browser/checkout/{index-Bct905Kz.js → index-BxckLE4O.js} +1 -1
- package/dist/browser/checkout/{index-OdSoW-FV.js → index-C8kOoOd-.js} +1 -1
- package/dist/browser/checkout/{index-B_P1u-VM.js → index-CXWnaooi.js} +1 -1
- package/dist/browser/checkout/{index-BAnpeiGZ.js → index-CkZRB4el.js} +2 -2
- package/dist/browser/checkout/{index-CIzNTZ1B.js → index-QbI5he3_.js} +1 -1
- package/dist/browser/checkout/{index-79qqSOkN.js → index-_RJ0jfOR.js} +1 -1
- package/dist/browser/checkout/{index-Crwefhg1.js → index-v748oxe1.js} +19 -19
- package/dist/browser/checkout/{index.umd-nRJL7rJq.js → index.umd-DJ42SoRS.js} +1 -1
- package/dist/browser/checkout/sdk.js +4 -4
- package/dist/browser/checkout/{useInterval-DutEDQ90.js → useInterval-BBIIMGa6.js} +1 -1
- package/dist/browser/checkout/widgets-esm.js +1 -1
- package/dist/browser/checkout/widgets.js +809 -882
- package/dist/{checkout-DasYybUZ.js → checkout-Bbw4lMvu.js} +40 -9
- package/dist/checkout.js +5 -5
- package/dist/{config-DCVDc3v8.js → config-Bx5cZVwN.js} +1 -1
- package/dist/config.js +1 -1
- package/dist/{index-TFa0owz-.js → index-2-9CaV4G.js} +1 -1
- package/dist/{index-COICsNsE.js → index-BCzTpky5.js} +1 -1
- package/dist/{index-BmVyhpJX.js → index-B_tA2AB3.js} +1 -1
- package/dist/{index-NtppN-aK.js → index-BjKQNmKU.js} +1 -1
- package/dist/{index-o5dSv0jt.js → index-DgAAcKgb.js} +4 -4
- package/dist/{index-L_TcRmaA.js → index-DgPFc11T.js} +3 -3
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +42 -11
- package/dist/index.js +14 -14
- package/dist/{minting_backend-Bg5AfM_R.js → minting_backend-DCIEgk4Y.js} +3 -3
- package/dist/minting_backend.js +5 -5
- package/dist/{orderbook-CEguKubj.js → orderbook-C99VLAwP.js} +1 -1
- package/dist/orderbook.js +2 -2
- package/dist/{passport-vGE_K8Y1.js → passport--cxG4DFA.js} +3 -3
- package/dist/passport.js +4 -4
- package/dist/{webhook-BCQEMed_.js → webhook-KbzH4ZI4.js} +1 -1
- package/dist/webhook.js +2 -2
- package/dist/{x-SjcnDDz3.js → x-D5yMtJYf.js} +3 -3
- package/dist/x.js +4 -4
- package/package.json +1 -1
|
@@ -61488,11 +61488,11 @@
|
|
|
61488
61488
|
|
|
61489
61489
|
var utf8$7 = {};
|
|
61490
61490
|
|
|
61491
|
-
var hasRequiredUtf8$
|
|
61491
|
+
var hasRequiredUtf8$2;
|
|
61492
61492
|
|
|
61493
|
-
function requireUtf8$
|
|
61494
|
-
if (hasRequiredUtf8$
|
|
61495
|
-
hasRequiredUtf8$
|
|
61493
|
+
function requireUtf8$2 () {
|
|
61494
|
+
if (hasRequiredUtf8$2) return utf8$7;
|
|
61495
|
+
hasRequiredUtf8$2 = 1;
|
|
61496
61496
|
(function (exports) {
|
|
61497
61497
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61498
61498
|
exports.toUtf8CodePoints = exports.toUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = void 0;
|
|
@@ -61811,7 +61811,7 @@
|
|
|
61811
61811
|
const data_js_1 = requireData$2();
|
|
61812
61812
|
const errors_js_1 = requireErrors$2();
|
|
61813
61813
|
const properties_js_1 = requireProperties$2();
|
|
61814
|
-
const utf8_js_1 = requireUtf8$
|
|
61814
|
+
const utf8_js_1 = requireUtf8$2();
|
|
61815
61815
|
const geturl_js_1 = requireGeturlBrowser$2();
|
|
61816
61816
|
const MAX_ATTEMPTS = 12;
|
|
61817
61817
|
const SLOT_INTERVAL = 250;
|
|
@@ -63550,7 +63550,7 @@
|
|
|
63550
63550
|
Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return units_js_1.parseEther; } });
|
|
63551
63551
|
Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return units_js_1.formatUnits; } });
|
|
63552
63552
|
Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return units_js_1.parseUnits; } });
|
|
63553
|
-
var utf8_js_1 = requireUtf8$
|
|
63553
|
+
var utf8_js_1 = requireUtf8$2();
|
|
63554
63554
|
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return utf8_js_1.toUtf8Bytes; } });
|
|
63555
63555
|
Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return utf8_js_1.toUtf8CodePoints; } });
|
|
63556
63556
|
Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return utf8_js_1.toUtf8String; } });
|
|
@@ -71433,7 +71433,7 @@
|
|
|
71433
71433
|
hasRequiredString$2 = 1;
|
|
71434
71434
|
Object.defineProperty(string$3, "__esModule", { value: true });
|
|
71435
71435
|
string$3.StringCoder = void 0;
|
|
71436
|
-
const utf8_js_1 = requireUtf8$
|
|
71436
|
+
const utf8_js_1 = requireUtf8$2();
|
|
71437
71437
|
const typed_js_1 = requireTyped$2();
|
|
71438
71438
|
const bytes_js_1 = requireBytes$2();
|
|
71439
71439
|
/**
|
|
@@ -79895,15 +79895,15 @@
|
|
|
79895
79895
|
return contract$4;
|
|
79896
79896
|
}
|
|
79897
79897
|
|
|
79898
|
-
var factory$
|
|
79898
|
+
var factory$3 = {};
|
|
79899
79899
|
|
|
79900
79900
|
var hasRequiredFactory$2;
|
|
79901
79901
|
|
|
79902
79902
|
function requireFactory$2 () {
|
|
79903
|
-
if (hasRequiredFactory$2) return factory$
|
|
79903
|
+
if (hasRequiredFactory$2) return factory$3;
|
|
79904
79904
|
hasRequiredFactory$2 = 1;
|
|
79905
|
-
Object.defineProperty(factory$
|
|
79906
|
-
factory$
|
|
79905
|
+
Object.defineProperty(factory$3, "__esModule", { value: true });
|
|
79906
|
+
factory$3.ContractFactory = void 0;
|
|
79907
79907
|
const index_js_1 = requireAbi$2();
|
|
79908
79908
|
const index_js_2 = requireAddress$a();
|
|
79909
79909
|
const index_js_3 = requireUtils$c();
|
|
@@ -80015,9 +80015,9 @@
|
|
|
80015
80015
|
return new this(abi, bytecode, runner);
|
|
80016
80016
|
}
|
|
80017
80017
|
}
|
|
80018
|
-
factory$
|
|
80018
|
+
factory$3.ContractFactory = ContractFactory;
|
|
80019
80019
|
|
|
80020
|
-
return factory$
|
|
80020
|
+
return factory$3;
|
|
80021
80021
|
}
|
|
80022
80022
|
|
|
80023
80023
|
var hasRequiredContract$4;
|
|
@@ -128640,7 +128640,7 @@
|
|
|
128640
128640
|
}
|
|
128641
128641
|
var baseLogger = new Logger();
|
|
128642
128642
|
|
|
128643
|
-
let EventEmitter$
|
|
128643
|
+
let EventEmitter$3 = class EventEmitter {
|
|
128644
128644
|
constructor() {
|
|
128645
128645
|
this.observers = {};
|
|
128646
128646
|
}
|
|
@@ -128840,7 +128840,7 @@
|
|
|
128840
128840
|
return code;
|
|
128841
128841
|
}
|
|
128842
128842
|
|
|
128843
|
-
class ResourceStore extends EventEmitter$
|
|
128843
|
+
class ResourceStore extends EventEmitter$3 {
|
|
128844
128844
|
constructor(data) {
|
|
128845
128845
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
128846
128846
|
ns: ['translation'],
|
|
@@ -128977,7 +128977,7 @@
|
|
|
128977
128977
|
};
|
|
128978
128978
|
|
|
128979
128979
|
const checkedLoadedFor = {};
|
|
128980
|
-
class Translator extends EventEmitter$
|
|
128980
|
+
class Translator extends EventEmitter$3 {
|
|
128981
128981
|
constructor(services) {
|
|
128982
128982
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
128983
128983
|
super();
|
|
@@ -130085,7 +130085,7 @@
|
|
|
130085
130085
|
q.pendingCount--;
|
|
130086
130086
|
}
|
|
130087
130087
|
}
|
|
130088
|
-
class Connector extends EventEmitter$
|
|
130088
|
+
class Connector extends EventEmitter$3 {
|
|
130089
130089
|
constructor(backend, store, services) {
|
|
130090
130090
|
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
130091
130091
|
super();
|
|
@@ -130384,7 +130384,7 @@
|
|
|
130384
130384
|
}
|
|
130385
130385
|
});
|
|
130386
130386
|
}
|
|
130387
|
-
class I18n extends EventEmitter$
|
|
130387
|
+
class I18n extends EventEmitter$3 {
|
|
130388
130388
|
constructor() {
|
|
130389
130389
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
130390
130390
|
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -136393,27 +136393,27 @@
|
|
|
136393
136393
|
function EventHandlers() {}
|
|
136394
136394
|
EventHandlers.prototype = Object.create(null);
|
|
136395
136395
|
|
|
136396
|
-
function EventEmitter$
|
|
136397
|
-
EventEmitter$
|
|
136396
|
+
function EventEmitter$2() {
|
|
136397
|
+
EventEmitter$2.init.call(this);
|
|
136398
136398
|
}
|
|
136399
136399
|
|
|
136400
136400
|
// nodejs oddity
|
|
136401
136401
|
// require('events') === require('events').EventEmitter
|
|
136402
|
-
EventEmitter$
|
|
136402
|
+
EventEmitter$2.EventEmitter = EventEmitter$2;
|
|
136403
136403
|
|
|
136404
|
-
EventEmitter$
|
|
136404
|
+
EventEmitter$2.usingDomains = false;
|
|
136405
136405
|
|
|
136406
|
-
EventEmitter$
|
|
136407
|
-
EventEmitter$
|
|
136408
|
-
EventEmitter$
|
|
136406
|
+
EventEmitter$2.prototype.domain = undefined;
|
|
136407
|
+
EventEmitter$2.prototype._events = undefined;
|
|
136408
|
+
EventEmitter$2.prototype._maxListeners = undefined;
|
|
136409
136409
|
|
|
136410
136410
|
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
136411
136411
|
// added to it. This is a useful default which helps finding memory leaks.
|
|
136412
|
-
EventEmitter$
|
|
136412
|
+
EventEmitter$2.defaultMaxListeners = 10;
|
|
136413
136413
|
|
|
136414
|
-
EventEmitter$
|
|
136414
|
+
EventEmitter$2.init = function() {
|
|
136415
136415
|
this.domain = null;
|
|
136416
|
-
if (EventEmitter$
|
|
136416
|
+
if (EventEmitter$2.usingDomains) {
|
|
136417
136417
|
// if there is an active domain, then attach to it.
|
|
136418
136418
|
if (domain.active) ;
|
|
136419
136419
|
}
|
|
@@ -136428,7 +136428,7 @@
|
|
|
136428
136428
|
|
|
136429
136429
|
// Obviously not all Emitters should be limited to 10. This function allows
|
|
136430
136430
|
// that to be increased. Set to zero for unlimited.
|
|
136431
|
-
EventEmitter$
|
|
136431
|
+
EventEmitter$2.prototype.setMaxListeners = function setMaxListeners(n) {
|
|
136432
136432
|
if (typeof n !== 'number' || n < 0 || isNaN(n))
|
|
136433
136433
|
throw new TypeError('"n" argument must be a positive number');
|
|
136434
136434
|
this._maxListeners = n;
|
|
@@ -136437,11 +136437,11 @@
|
|
|
136437
136437
|
|
|
136438
136438
|
function $getMaxListeners(that) {
|
|
136439
136439
|
if (that._maxListeners === undefined)
|
|
136440
|
-
return EventEmitter$
|
|
136440
|
+
return EventEmitter$2.defaultMaxListeners;
|
|
136441
136441
|
return that._maxListeners;
|
|
136442
136442
|
}
|
|
136443
136443
|
|
|
136444
|
-
EventEmitter$
|
|
136444
|
+
EventEmitter$2.prototype.getMaxListeners = function getMaxListeners() {
|
|
136445
136445
|
return $getMaxListeners(this);
|
|
136446
136446
|
};
|
|
136447
136447
|
|
|
@@ -136502,7 +136502,7 @@
|
|
|
136502
136502
|
}
|
|
136503
136503
|
}
|
|
136504
136504
|
|
|
136505
|
-
EventEmitter$
|
|
136505
|
+
EventEmitter$2.prototype.emit = function emit(type) {
|
|
136506
136506
|
var er, handler, len, args, i, events, domain;
|
|
136507
136507
|
var doError = (type === 'error');
|
|
136508
136508
|
|
|
@@ -136633,13 +136633,13 @@
|
|
|
136633
136633
|
function emitWarning(e) {
|
|
136634
136634
|
typeof console.warn === 'function' ? console.warn(e) : console.log(e);
|
|
136635
136635
|
}
|
|
136636
|
-
EventEmitter$
|
|
136636
|
+
EventEmitter$2.prototype.addListener = function addListener(type, listener) {
|
|
136637
136637
|
return _addListener(this, type, listener, false);
|
|
136638
136638
|
};
|
|
136639
136639
|
|
|
136640
|
-
EventEmitter$
|
|
136640
|
+
EventEmitter$2.prototype.on = EventEmitter$2.prototype.addListener;
|
|
136641
136641
|
|
|
136642
|
-
EventEmitter$
|
|
136642
|
+
EventEmitter$2.prototype.prependListener =
|
|
136643
136643
|
function prependListener(type, listener) {
|
|
136644
136644
|
return _addListener(this, type, listener, true);
|
|
136645
136645
|
};
|
|
@@ -136657,14 +136657,14 @@
|
|
|
136657
136657
|
return g;
|
|
136658
136658
|
}
|
|
136659
136659
|
|
|
136660
|
-
EventEmitter$
|
|
136660
|
+
EventEmitter$2.prototype.once = function once(type, listener) {
|
|
136661
136661
|
if (typeof listener !== 'function')
|
|
136662
136662
|
throw new TypeError('"listener" argument must be a function');
|
|
136663
136663
|
this.on(type, _onceWrap(this, type, listener));
|
|
136664
136664
|
return this;
|
|
136665
136665
|
};
|
|
136666
136666
|
|
|
136667
|
-
EventEmitter$
|
|
136667
|
+
EventEmitter$2.prototype.prependOnceListener =
|
|
136668
136668
|
function prependOnceListener(type, listener) {
|
|
136669
136669
|
if (typeof listener !== 'function')
|
|
136670
136670
|
throw new TypeError('"listener" argument must be a function');
|
|
@@ -136673,7 +136673,7 @@
|
|
|
136673
136673
|
};
|
|
136674
136674
|
|
|
136675
136675
|
// emits a 'removeListener' event iff the listener was removed
|
|
136676
|
-
EventEmitter$
|
|
136676
|
+
EventEmitter$2.prototype.removeListener =
|
|
136677
136677
|
function removeListener(type, listener) {
|
|
136678
136678
|
var list, events, position, i, originalListener;
|
|
136679
136679
|
|
|
@@ -136732,11 +136732,11 @@
|
|
|
136732
136732
|
|
|
136733
136733
|
// Alias for removeListener added in NodeJS 10.0
|
|
136734
136734
|
// https://nodejs.org/api/events.html#events_emitter_off_eventname_listener
|
|
136735
|
-
EventEmitter$
|
|
136735
|
+
EventEmitter$2.prototype.off = function(type, listener){
|
|
136736
136736
|
return this.removeListener(type, listener);
|
|
136737
136737
|
};
|
|
136738
136738
|
|
|
136739
|
-
EventEmitter$
|
|
136739
|
+
EventEmitter$2.prototype.removeAllListeners =
|
|
136740
136740
|
function removeAllListeners(type) {
|
|
136741
136741
|
var listeners, events;
|
|
136742
136742
|
|
|
@@ -136786,7 +136786,7 @@
|
|
|
136786
136786
|
return this;
|
|
136787
136787
|
};
|
|
136788
136788
|
|
|
136789
|
-
EventEmitter$
|
|
136789
|
+
EventEmitter$2.prototype.listeners = function listeners(type) {
|
|
136790
136790
|
var evlistener;
|
|
136791
136791
|
var ret;
|
|
136792
136792
|
var events = this._events;
|
|
@@ -136806,7 +136806,7 @@
|
|
|
136806
136806
|
return ret;
|
|
136807
136807
|
};
|
|
136808
136808
|
|
|
136809
|
-
EventEmitter$
|
|
136809
|
+
EventEmitter$2.listenerCount = function(emitter, type) {
|
|
136810
136810
|
if (typeof emitter.listenerCount === 'function') {
|
|
136811
136811
|
return emitter.listenerCount(type);
|
|
136812
136812
|
} else {
|
|
@@ -136814,7 +136814,7 @@
|
|
|
136814
136814
|
}
|
|
136815
136815
|
};
|
|
136816
136816
|
|
|
136817
|
-
EventEmitter$
|
|
136817
|
+
EventEmitter$2.prototype.listenerCount = listenerCount;
|
|
136818
136818
|
function listenerCount(type) {
|
|
136819
136819
|
var events = this._events;
|
|
136820
136820
|
|
|
@@ -136831,7 +136831,7 @@
|
|
|
136831
136831
|
return 0;
|
|
136832
136832
|
}
|
|
136833
136833
|
|
|
136834
|
-
EventEmitter$
|
|
136834
|
+
EventEmitter$2.prototype.eventNames = function eventNames() {
|
|
136835
136835
|
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
|
136836
136836
|
};
|
|
136837
136837
|
|
|
@@ -136859,8 +136859,8 @@
|
|
|
136859
136859
|
|
|
136860
136860
|
var _polyfillNode_events = /*#__PURE__*/Object.freeze({
|
|
136861
136861
|
__proto__: null,
|
|
136862
|
-
EventEmitter: EventEmitter$
|
|
136863
|
-
default: EventEmitter$
|
|
136862
|
+
EventEmitter: EventEmitter$2,
|
|
136863
|
+
default: EventEmitter$2
|
|
136864
136864
|
});
|
|
136865
136865
|
|
|
136866
136866
|
var chacha20poly1305 = {};
|
|
@@ -137200,7 +137200,7 @@
|
|
|
137200
137200
|
*
|
|
137201
137201
|
* Supports bit lengths divisible by 8, up to 48.
|
|
137202
137202
|
*/
|
|
137203
|
-
function readUintBE(bitLength, array, offset) {
|
|
137203
|
+
function readUintBE$1(bitLength, array, offset) {
|
|
137204
137204
|
if (offset === void 0) { offset = 0; }
|
|
137205
137205
|
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
137206
137206
|
if (bitLength % 8 !== 0) {
|
|
@@ -137217,14 +137217,14 @@
|
|
|
137217
137217
|
}
|
|
137218
137218
|
return result;
|
|
137219
137219
|
}
|
|
137220
|
-
binary$1.readUintBE = readUintBE;
|
|
137220
|
+
binary$1.readUintBE = readUintBE$1;
|
|
137221
137221
|
/**
|
|
137222
137222
|
* Reads bytes from array starting at offset as little-endian
|
|
137223
137223
|
* unsigned bitLen-bit integer and returns it.
|
|
137224
137224
|
*
|
|
137225
137225
|
* Supports bit lengths divisible by 8, up to 48.
|
|
137226
137226
|
*/
|
|
137227
|
-
function readUintLE(bitLength, array, offset) {
|
|
137227
|
+
function readUintLE$1(bitLength, array, offset) {
|
|
137228
137228
|
if (offset === void 0) { offset = 0; }
|
|
137229
137229
|
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
137230
137230
|
if (bitLength % 8 !== 0) {
|
|
@@ -137241,7 +137241,7 @@
|
|
|
137241
137241
|
}
|
|
137242
137242
|
return result;
|
|
137243
137243
|
}
|
|
137244
|
-
binary$1.readUintLE = readUintLE;
|
|
137244
|
+
binary$1.readUintLE = readUintLE$1;
|
|
137245
137245
|
/**
|
|
137246
137246
|
* Writes a big-endian representation of bitLen-bit unsigned
|
|
137247
137247
|
* value to array starting at offset.
|
|
@@ -137252,7 +137252,7 @@
|
|
|
137252
137252
|
*
|
|
137253
137253
|
* Returns the output byte array.
|
|
137254
137254
|
*/
|
|
137255
|
-
function writeUintBE(bitLength, value, out, offset) {
|
|
137255
|
+
function writeUintBE$1(bitLength, value, out, offset) {
|
|
137256
137256
|
if (out === void 0) { out = new Uint8Array(bitLength / 8); }
|
|
137257
137257
|
if (offset === void 0) { offset = 0; }
|
|
137258
137258
|
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
@@ -137269,7 +137269,7 @@
|
|
|
137269
137269
|
}
|
|
137270
137270
|
return out;
|
|
137271
137271
|
}
|
|
137272
|
-
binary$1.writeUintBE = writeUintBE;
|
|
137272
|
+
binary$1.writeUintBE = writeUintBE$1;
|
|
137273
137273
|
/**
|
|
137274
137274
|
* Writes a little-endian representation of bitLen-bit unsigned
|
|
137275
137275
|
* value to array starting at offset.
|
|
@@ -137280,7 +137280,7 @@
|
|
|
137280
137280
|
*
|
|
137281
137281
|
* Returns the output byte array.
|
|
137282
137282
|
*/
|
|
137283
|
-
function writeUintLE(bitLength, value, out, offset) {
|
|
137283
|
+
function writeUintLE$1(bitLength, value, out, offset) {
|
|
137284
137284
|
if (out === void 0) { out = new Uint8Array(bitLength / 8); }
|
|
137285
137285
|
if (offset === void 0) { offset = 0; }
|
|
137286
137286
|
// TODO(dchest): implement support for bitLengths non-divisible by 8
|
|
@@ -137297,7 +137297,7 @@
|
|
|
137297
137297
|
}
|
|
137298
137298
|
return out;
|
|
137299
137299
|
}
|
|
137300
|
-
binary$1.writeUintLE = writeUintLE;
|
|
137300
|
+
binary$1.writeUintLE = writeUintLE$1;
|
|
137301
137301
|
/**
|
|
137302
137302
|
* Reads 4 bytes from array starting at offset as big-endian
|
|
137303
137303
|
* 32-bit floating-point number and returns it.
|
|
@@ -144686,7 +144686,7 @@
|
|
|
144686
144686
|
class JsonRpcProvider extends IJsonRpcProvider {
|
|
144687
144687
|
constructor(connection) {
|
|
144688
144688
|
super(connection);
|
|
144689
|
-
this.events = new EventEmitter$
|
|
144689
|
+
this.events = new EventEmitter$2();
|
|
144690
144690
|
this.hasRegisteredEventListeners = false;
|
|
144691
144691
|
this.connection = this.setConnection(connection);
|
|
144692
144692
|
if (this.connection.connected) {
|
|
@@ -144789,7 +144789,7 @@
|
|
|
144789
144789
|
}
|
|
144790
144790
|
}
|
|
144791
144791
|
|
|
144792
|
-
const w$3=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),b$2=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",a$4=c=>c.split("?")[0],h$5=10,S$5=w$3();let f$8 = class f{constructor(e){if(this.url=e,this.events=new EventEmitter$
|
|
144792
|
+
const w$3=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),b$2=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",a$4=c=>c.split("?")[0],h$5=10,S$5=w$3();let f$8 = class f{constructor(e){if(this.url=e,this.events=new EventEmitter$2,this.registering=!1,!isWsUrl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e;}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t);}once(e,t){this.events.once(e,t);}off(e,t){this.events.off(e,t);}removeListener(e,t){this.events.removeListener(e,t);}async open(e=this.url){await this.register(e);}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),e();},this.socket.close();})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(safeJsonStringify(e));}catch(t){this.onError(e.id,t);}}register(e=this.url){if(!isWsUrl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return (this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((n,o)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),o(s);}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return o(new Error("WebSocket connection is missing or invalid"));n(this.socket);});})}return this.url=e,this.registering=!0,new Promise((t,n)=>{const o=new URLSearchParams(e).get("origin"),s=cjs.isReactNative()?{headers:{origin:o}}:{rejectUnauthorized:!isLocalhostUrl(e)},i=new S$5(e,[],s);b$2()?i.onerror=r=>{const l=r;n(this.emitError(l.error));}:i.on("error",r=>{n(this.emitError(r));}),i.onopen=()=>{this.onOpen(i),t(i);};})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open");}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e);}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?safeJsonParse(e.data):e.data;this.events.emit("payload",t);}onError(e,t){const n=this.parseError(t),o=n.message||n.toString(),s=formatJsonRpcError(e,o);this.events.emit("payload",s);}parseError(e,t=this.url){return parseConnectionError(e,a$4(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>h$5&&this.events.setMaxListeners(h$5);}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${a$4(this.url)}`));return this.events.emit("register_error",t),t}};
|
|
144793
144793
|
|
|
144794
144794
|
var lodash_isequal$1 = {exports: {}};
|
|
144795
144795
|
|
|
@@ -146661,9 +146661,9 @@
|
|
|
146661
146661
|
|
|
146662
146662
|
var Yi$1 = /*@__PURE__*/getDefaultExportFromCjs$3(browser$2);
|
|
146663
146663
|
|
|
146664
|
-
function Hi$1(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var s=0;s<n.length;s++){var r=n.charAt(s),o=r.charCodeAt(0);if(t[o]!==255)throw new TypeError(r+" is ambiguous");t[o]=s;}var a=n.length,h=n.charAt(0),l=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function p(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var m=0,z=0,I=0,_=u.length;I!==_&&u[I]===0;)I++,m++;for(var T=(_-I)*d+1>>>0,f=new Uint8Array(T);I!==_;){for(var S=u[I],A=0,C=T-1;(S!==0||A<z)&&C!==-1;C--,A++)S+=256*f[C]>>>0,f[C]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");z=A,I++;}for(var x=T-z;x!==T&&f[x]===0;)x++;for(var j=h.repeat(m);x<T;++x)j+=n.charAt(f[x]);return j}function y(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var m=0;if(u[m]!==" "){for(var z=0,I=0;u[m]===h;)z++,m++;for(var _=(u.length-m)*l+1>>>0,T=new Uint8Array(_);u[m];){var f=t[u.charCodeAt(m)];if(f===255)return;for(var S=0,A=_-1;(f!==0||S<I)&&A!==-1;A--,S++)f+=a*T[A]>>>0,T[A]=f%256>>>0,f=f/256>>>0;if(f!==0)throw new Error("Non-zero carry");I=S,m++;}if(u[m]!==" "){for(var C=_-I;C!==_&&T[C]===0;)C++;for(var x=new Uint8Array(z+(_-C)),j=z;C!==_;)x[j++]=T[C++];return x}}}function M(u){var m=y(u);if(m)return m;throw new Error(`Non-${e} character`)}return {encode:p,decodeUnsafe:y,decode:M}}var Ji$1=Hi$1,Xi$1=Ji$1;const Ne$2=n=>{if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")},Wi$2=n=>new TextEncoder().encode(n),Qi$1=n=>new TextDecoder().decode(n);let Zi$1 = class Zi{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i;}encode(e){if(e instanceof Uint8Array)return `${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};class es{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i;}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ue$2(this,e)}}class ts{constructor(e){this.decoders=e;}or(e){return Ue$2(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Ue$2=(n,e)=>new ts({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class is{constructor(e,t,i,s){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=s,this.encoder=new Zi$1(e,t,i),this.decoder=new es(e,t,s);}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const W$2=({name:n,prefix:e,encode:t,decode:i})=>new is(n,e,t,i),B$4=({prefix:n,name:e,alphabet:t})=>{const{encode:i,decode:s}=Xi$1(t,e);return W$2({prefix:n,name:e,encode:i,decode:r=>Ne$2(s(r))})},ss=(n,e,t,i)=>{const s={};for(let d=0;d<e.length;++d)s[e[d]]=d;let r=n.length;for(;n[r-1]==="=";)--r;const o=new Uint8Array(r*t/8|0);let a=0,h=0,l=0;for(let d=0;d<r;++d){const p=s[n[d]];if(p===void 0)throw new SyntaxError(`Non-${i} character`);h=h<<t|p,a+=t,a>=8&&(a-=8,o[l++]=255&h>>a);}if(a>=t||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o},rs=(n,e,t)=>{const i=e[e.length-1]==="=",s=(1<<t)-1;let r="",o=0,a=0;for(let h=0;h<n.length;++h)for(a=a<<8|n[h],o+=8;o>t;)o-=t,r+=e[s&a>>o];if(o&&(r+=e[s&a<<t-o]),i)for(;r.length*t&7;)r+="=";return r},g$6=({name:n,prefix:e,bitsPerChar:t,alphabet:i})=>W$2({prefix:e,name:n,encode(s){return rs(s,i,t)},decode(s){return ss(s,i,t,n)}}),ns=W$2({prefix:"\0",name:"identity",encode:n=>Qi$1(n),decode:n=>Wi$2(n)});var os=Object.freeze({__proto__:null,identity:ns});const as$1=g$6({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hs$1=Object.freeze({__proto__:null,base2:as$1});const cs$1=g$6({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var us$1=Object.freeze({__proto__:null,base8:cs$1});const ls$1=B$4({prefix:"9",name:"base10",alphabet:"0123456789"});var ds$1=Object.freeze({__proto__:null,base10:ls$1});const gs$1=g$6({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ps$1=g$6({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ds=Object.freeze({__proto__:null,base16:gs$1,base16upper:ps$1});const ys=g$6({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ms=g$6({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bs=g$6({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fs=g$6({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Es=g$6({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ws$1=g$6({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vs=g$6({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Is=g$6({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cs=g$6({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rs=Object.freeze({__proto__:null,base32:ys,base32upper:ms,base32pad:bs,base32padupper:fs,base32hex:Es,base32hexupper:ws$1,base32hexpad:vs,base32hexpadupper:Is,base32z:Cs});const _s=B$4({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ts=B$4({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ss=Object.freeze({__proto__:null,base36:_s,base36upper:Ts});const Ps=B$4({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xs$1=B$4({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Os=Object.freeze({__proto__:null,base58btc:Ps,base58flickr:xs$1});const As=g$6({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zs=g$6({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ns=g$6({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Us=g$6({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ls=Object.freeze({__proto__:null,base64:As,base64pad:zs,base64url:Ns,base64urlpad:Us});const Le$2=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),$s=Le$2.reduce((n,e,t)=>(n[t]=e,n),[]),Fs=Le$2.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]);function Ms(n){return n.reduce((e,t)=>(e+=$s[t],e),"")}function ks(n){const e=[];for(const t of n){const i=Fs[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i);}return new Uint8Array(e)}const Ks=W$2({prefix:"\u{1F680}",name:"base256emoji",encode:Ms,decode:ks});var Bs=Object.freeze({__proto__:null,base256emoji:Ks}),Vs=Fe$3,$e$3=128,qs=127,js=~qs,Gs=Math.pow(2,31);function Fe$3(n,e,t){e=e||[],t=t||0;for(var i=t;n>=Gs;)e[t++]=n&255|$e$3,n/=128;for(;n&js;)e[t++]=n&255|$e$3,n>>>=7;return e[t]=n|0,Fe$3.bytes=t-i+1,e}var Ys=he$4,Hs=128,Me$3=127;function he$4(n,i){var t=0,i=i||0,s=0,r=i,o,a=n.length;do{if(r>=a)throw he$4.bytes=0,new RangeError("Could not decode varint");o=n[r++],t+=s<28?(o&Me$3)<<s:(o&Me$3)*Math.pow(2,s),s+=7;}while(o>=Hs);return he$4.bytes=r-i,t}var Js=Math.pow(2,7),Xs=Math.pow(2,14),Ws=Math.pow(2,21),Qs=Math.pow(2,28),Zs=Math.pow(2,35),er$2=Math.pow(2,42),tr$1=Math.pow(2,49),ir$2=Math.pow(2,56),sr$2=Math.pow(2,63),rr$2=function(n){return n<Js?1:n<Xs?2:n<Ws?3:n<Qs?4:n<Zs?5:n<er$2?6:n<tr$1?7:n<ir$2?8:n<sr$2?9:10},nr$2={encode:Vs,decode:Ys,encodingLength:rr$2},ke$2=nr$2;const Ke$2=(n,e,t=0)=>(ke$2.encode(n,e,t),e),Be$3=n=>ke$2.encodingLength(n),ce$4=(n,e)=>{const t=e.byteLength,i=Be$3(n),s=i+Be$3(t),r=new Uint8Array(s+t);return Ke$2(n,r,0),Ke$2(t,r,i),r.set(e,s),new or(n,t,e,r)};class or{constructor(e,t,i,s){this.code=e,this.size=t,this.digest=i,this.bytes=s;}}const Ve$3=({name:n,code:e,encode:t})=>new ar$1(n,e,t);let ar$1 = class ar{constructor(e,t,i){this.name=e,this.code=t,this.encode=i;}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ce$4(this.code,t):t.then(i=>ce$4(this.code,i))}else throw Error("Unknown type, must be binary type")}};const qe$2=n=>async e=>new Uint8Array(await crypto.subtle.digest(n,e)),hr$3=Ve$3({name:"sha2-256",code:18,encode:qe$2("SHA-256")}),cr$2=Ve$3({name:"sha2-512",code:19,encode:qe$2("SHA-512")});var ur$1=Object.freeze({__proto__:null,sha256:hr$3,sha512:cr$2});const je$2=0,lr$2="identity",Ge$2=Ne$2,dr$2=n=>ce$4(je$2,Ge$2(n)),gr={code:je$2,name:lr$2,encode:Ge$2,digest:dr$2};var pr$1=Object.freeze({__proto__:null,identity:gr});new TextEncoder,new TextDecoder;const Ye$2={...os,...hs$1,...us$1,...ds$1,...Ds,...Rs,...Ss,...Os,...Ls,...Bs};({...ur$1,...pr$1});function He$2(n){return globalThis.Buffer!=null?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n}function Dr(n=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?He$2(globalThis.Buffer.allocUnsafe(n)):new Uint8Array(n)}function Je$2(n,e,t,i){return {name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:i}}}const Xe$2=Je$2("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),ue$4=Je$2("ascii","a",n=>{let e="a";for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return e},n=>{n=n.substring(1);const e=Dr(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e}),yr$1={utf8:Xe$2,"utf-8":Xe$2,hex:Ye$2.base16,latin1:ue$4,ascii:ue$4,binary:ue$4,...Ye$2};function mr$2(n,e="utf8"){const t=yr$1[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?He$2(globalThis.Buffer.from(n,"utf-8")):t.decoder.decode(`${t.prefix}${n}`)}const le$4="wc",We$2=2,Q$5="core",O$3=`${le$4}@2:${Q$5}:`,Qe$3={name:Q$5,logger:"error"},Ze$2={database:":memory:"},et$1="crypto",de$4="client_ed25519_seed",tt$1=cjs$5.ONE_DAY,it$1="keychain",st$1="0.3",rt$1="messages",nt$1="0.3",ot$1=cjs$5.SIX_HOURS,at$1="publisher",ht="irn",ct$1="error",ge$4="wss://relay.walletconnect.com",pe$3="wss://relay.walletconnect.org",ut$1="relayer",D$6={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},lt$1="_subscription",P$4={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},dt$1=cjs$5.ONE_SECOND,gt="2.11.1",pt$1=1e4,Dt$1="0.3",yt$1="WALLETCONNECT_CLIENT_ID",w$2={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},mt="subscription",bt$1="0.3",ft$1=cjs$5.FIVE_SECONDS*1e3,Et$1="pairing",wt$1="0.3",$$2={wc_pairingDelete:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:0},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:0}}},V$3={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},R$4={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},vt="history",It$1="0.3",Ct$1="expirer",v$5={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Rt$1="0.3",Z$4="verify-api",F$4="https://verify.walletconnect.com",ee$3="https://verify.walletconnect.org",_t$1=[F$4,ee$3],Tt$1="echo",St$1="https://echo.walletconnect.com";let Pt$1 = class Pt{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=it$1,this.version=st$1,this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0;}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist();},this.get=i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:r}=N$4("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(r)}return s},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist();},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,rt$2(e));}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ot$2(e):void 0}async persist(){await this.setKeyChain(this.keychain);}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};class xt{constructor(e,t,i){this.core=e,this.logger=t,this.name=et$1,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0);},this.hasKeys=s=>(this.isInitialized(),this.keychain.has(s)),this.getClientId=async()=>{this.isInitialized();const s=await this.getClientSeed(),r=generateKeyPair(s);return encodeIss(r.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const s=kn();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();const r=await this.getClientSeed(),o=generateKeyPair(r),a=Vn$1(),h=tt$1;return await signJWT(a,s,h,o)},this.generateSharedKey=(s,r,o)=>{this.isInitialized();const a=this.getPrivateKey(s),h=Mn(a,r);return this.setSymKey(h,o)},this.setSymKey=async(s,r)=>{this.isInitialized();const o=r||Kn(s);return await this.keychain.set(o,s),o},this.deleteKeyPair=async s=>{this.isInitialized(),await this.keychain.del(s);},this.deleteSymKey=async s=>{this.isInitialized(),await this.keychain.del(s);},this.encode=async(s,r,o)=>{this.isInitialized();const a=Ae$3(o),h=safeJsonStringify(r);if(qn(a)){const y=a.senderPublicKey,M=a.receiverPublicKey;s=await this.generateSharedKey(y,M);}const l=this.getSymKey(s),{type:d,senderPublicKey:p}=a;return xn({type:d,symKey:l,message:h,senderPublicKey:p})},this.decode=async(s,r,o)=>{this.isInitialized();const a=Hn(r,o);if(qn(a)){const h=a.receiverPublicKey,l=a.senderPublicKey;s=await this.generateSharedKey(h,l);}try{const h=this.getSymKey(s),l=Fn({symKey:h,encoded:r});return safeJsonParse(l)}catch(h){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(h);}},this.getPayloadType=s=>{const r=ee$4(s);return j$4(r.type)},this.getPayloadSenderPublicKey=s=>{const r=ee$4(s);return r.senderPublicKey?toString$4(r.senderPublicKey,p$9):void 0},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.keychain=i||new Pt$1(this.core,this.logger);}get context(){return cjs$1.getLoggerContext(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(de$4);}catch{e=Vn$1(),await this.keychain.set(de$4,e);}return mr$2(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}}let Ot$1 = class Ot extends a$5{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=rt$1,this.version=nt$1,this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size});}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i);}finally{this.initialized=!0;}}},this.set=async(i,s)=>{this.isInitialized();const r=Ln(s);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[r]<"u"||(o[r]=s,this.messages.set(i,o),await this.persist()),r},this.get=i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s},this.has=(i,s)=>{this.isInitialized();const r=this.get(i),o=Ln(s);return typeof r[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist();},this.logger=cjs$1.generateChildLogger(e,this.name),this.core=t;}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,rt$2(e));}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ot$2(e):void 0}async persist(){await this.setRelayerMessages(this.messages);}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let vr$1 = class vr extends u$4{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new EventEmitter$1,this.name=at$1,this.queue=new Map,this.publishTimeout=cjs$5.toMiliseconds(cjs$5.TEN_SECONDS*2),this.needsTransportRestart=!1,this.publish=async(i,s,r)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:r}});try{const a=r?.ttl||ot$1,h=vt$1(r),l=r?.prompt||!1,d=r?.tag||0,p=r?.id||getBigIntRpcId().toString(),y={topic:i,message:s,opts:{ttl:a,relay:h,prompt:l,tag:d,id:p}},M=setTimeout(()=>this.queue.set(p,y),this.publishTimeout);try{await await ut$2(this.rpcPublish(i,s,a,h,l,d,p),this.publishTimeout,`Failed to publish payload, please try again. id:${p} tag:${d}`),this.removeRequestFromQueue(p),this.relayer.events.emit(D$6.publish,y);}catch(u){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(o=r?.internal)!=null&&o.throwOnFailedPublish)throw this.removeRequestFromQueue(p),u;return}finally{clearTimeout(M);}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:r}});}catch(a){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(a),a}},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.relayer=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.registerEventListeners();}get context(){return cjs$1.getLoggerContext(this.logger)}rpcPublish(e,t,i,s,r,o,a){var h,l,d,p;const y={method:Et$2(s.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:r,tag:o},id:a};return w$5((h=y.params)==null?void 0:h.prompt)&&((l=y.params)==null||delete l.prompt),w$5((d=y.params)==null?void 0:d.tag)&&((p=y.params)==null||delete p.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:y}),this.relayer.request(y)}removeRequestFromQueue(e){this.queue.delete(e);}checkQueue(){this.queue.forEach(async e=>{const{topic:t,message:i,opts:s}=e;await this.publish(t,i,s);});}registerEventListeners(){this.relayer.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(D$6.connection_stalled);return}this.checkQueue();}),this.relayer.on(D$6.message_ack,e=>{this.removeRequestFromQueue(e.id.toString());});}};class Ir{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t]);},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const s=i.filter(r=>r!==t);if(!s.length){this.map.delete(e);return}this.map.set(e,s);},this.clear=()=>{this.map.clear();};}get topics(){return Array.from(this.map.keys())}}var Cr=Object.defineProperty,Rr=Object.defineProperties,_r$1=Object.getOwnPropertyDescriptors,At$1=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Sr$1=Object.prototype.propertyIsEnumerable,zt$1=(n,e,t)=>e in n?Cr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,q$5=(n,e)=>{for(var t in e||(e={}))Tr.call(e,t)&&zt$1(n,t,e[t]);if(At$1)for(var t of At$1(e))Sr$1.call(e,t)&&zt$1(n,t,e[t]);return n},De$3=(n,e)=>Rr(n,_r$1(e));let Nt$1 = class Nt extends d$4{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Ir,this.events=new EventEmitter$1,this.name=mt,this.version=bt$1,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=O$3,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId());},this.subscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const r=vt$1(s),o={topic:i,relay:r};this.pending.set(i,o);const a=await this.rpcSubscribe(i,r);return this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}}),a}catch(r){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(r),r}},this.unsubscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s);},this.isSubscribed=async i=>{if(this.topics.includes(i))return !0;const s=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((r,o)=>{const a=new cjs$5.Watch;a.start(s);const h=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(h),a.stop(s),r(!0)),a.elapsed(s)>=ft$1&&(clearInterval(h),a.stop(s),o(new Error("Subscription resolution timeout")));},this.pollingInterval);}).catch(()=>!1)},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1;},this.relayer=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.clientId="";}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t;}catch{}return i}onEnable(){this.cached=[],this.initialized=!0;}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear();}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async s=>await this.unsubscribeById(e,s,t)));}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const s=vt$1(i);await this.rpcUnsubscribe(e,t,s);const r=U$5("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,t){const i={method:Et$2(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await ut$2(this.relayer.request(i),this.subscribeTimeout);}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(D$6.connection_stalled);}return Ln(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:Et$2(t.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await ut$2(this.relayer.request(i),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(D$6.connection_stalled);}}rpcUnsubscribe(e,t,i){const s={method:Et$2(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,De$3(q$5({},t),{id:e})),this.pending.delete(t.topic);}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,q$5({},t)),this.pending.delete(t.topic);});}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e);}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e);}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t));}addSubscription(e,t){this.subscriptions.set(e,q$5({},t)),this.topicMap.set(t.topic,e),this.events.emit(w$2.created,t);}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(w$2.deleted,De$3(q$5({},i),{reason:t}));}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(w$2.sync);}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i);}}this.events.emit(w$2.resubscribed);}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values});}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e);}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);k$5(t)&&this.onBatchSubscribe(t.map((i,s)=>De$3(q$5({},e[s]),{id:i})));}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable());}onDisconnect(){this.onDisable();}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach(t=>{e.push(t);}),await this.batchSubscribe(e);}registerEventListeners(){this.relayer.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending();}),this.relayer.on(D$6.connect,async()=>{await this.onConnect();}),this.relayer.on(D$6.disconnect,()=>{this.onDisconnect();}),this.events.on(w$2.created,async e=>{const t=w$2.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist();}),this.events.on(w$2.deleted,async e=>{const t=w$2.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e());},this.pollingInterval);});}};var Pr=Object.defineProperty,Ut$1=Object.getOwnPropertySymbols,xr$1=Object.prototype.hasOwnProperty,Or$1=Object.prototype.propertyIsEnumerable,Lt$1=(n,e,t)=>e in n?Pr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ar=(n,e)=>{for(var t in e||(e={}))xr$1.call(e,t)&&Lt$1(n,t,e[t]);if(Ut$1)for(var t of Ut$1(e))Or$1.call(e,t)&&Lt$1(n,t,e[t]);return n};let $t$1 = class $t extends g$7{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new EventEmitter$1,this.name=ut$1,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.request=async t=>{this.logger.debug("Publishing Request Payload");const i=t.id,s=this.provider.request(t);this.requestsInFlight.set(i,{promise:s,request:t});try{return await this.toEstablishConnection(),await s}catch(r){throw this.logger.debug("Failed to Publish Request"),this.logger.error(r),r}finally{this.requestsInFlight.delete(i);}},this.onPayloadHandler=t=>{this.onProviderPayload(t);},this.onConnectHandler=()=>{this.events.emit(D$6.connect);},this.onDisconnectHandler=()=>{this.onProviderDisconnect();},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(D$6.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose();},this.registerProviderListeners=()=>{this.provider.on(P$4.payload,this.onPayloadHandler),this.provider.on(P$4.connect,this.onConnectHandler),this.provider.on(P$4.disconnect,this.onDisconnectHandler),this.provider.on(P$4.error,this.onProviderErrorHandler);},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?cjs$1.generateChildLogger(e.logger,this.name):cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:e.logger||ct$1})),this.messages=new Ot$1(this.logger,e.core),this.subscriber=new Nt$1(this,this.logger),this.publisher=new vr$1(this,this.logger),this.relayUrl=e?.relayUrl||ge$4,this.projectId=e.projectId,this.bundleId=Jn(),this.provider={};}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen();}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$3}...`),await this.restartTransport(pe$3);}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1);},pt$1);}get context(){return cjs$1.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()});}async subscribe(e,t){var i;this.isInitialized();let s=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"";if(s)return s;let r;const o=a=>{a.topic===e&&(this.subscriber.off(w$2.created,o),r());};return await Promise.all([new Promise(a=>{r=a,this.subscriber.on(w$2.created,o);}),new Promise(async a=>{s=await this.subscriber.subscribe(e,t),a();})]),s}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t);}on(e,t){this.events.on(e,t);}once(e,t){this.events.once(e,t);}off(e,t){this.events.off(e,t);}removeListener(e,t){this.events.removeListener(e,t);}async transportClose(){this.requestsInFlight.size>0&&(this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."),this.requestsInFlight.forEach(async e=>{await e.promise;})),this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await ut$2(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect();}async transportOpen(e){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(t=>{if(!this.initialized)return t();this.subscriber.once(w$2.resubscribed,()=>{t();});}),new Promise(async(t,i)=>{try{await ut$2(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`);}catch(s){i(s);return}t();})]);}catch(t){this.logger.error(t);const i=t;if(!this.isConnectionStalled(i.message))throw t;this.provider.events.emit(P$4.disconnect);}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1;}}}async restartTransport(e){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen());}async confirmOnlineStateOrThrow(){if(!await rr$3())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new JsonRpcProvider(new f$8(Xn({sdkVersion:gt,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners();}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i);}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const s=this.messages.has(t,i);return s&&this.logger.debug(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),isJsonRpcRequest(e)){if(!e.method.endsWith(lt$1))return;const t=e.params,{topic:i,message:s,publishedAt:r}=t.data,o={topic:i,message:s,publishedAt:r};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Ar({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o);}else isJsonRpcResponse(e)&&this.events.emit(D$6.message_ack,e);}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(D$6.message,e),await this.recordMessageEvent(e));}async acknowledgePayload(e){const t=formatJsonRpcResult(e.id,!0);await this.provider.connection.send(t);}unregisterProviderListeners(){this.provider.off(P$4.payload,this.onPayloadHandler),this.provider.off(P$4.connect,this.onConnectHandler),this.provider.off(P$4.disconnect,this.onDisconnectHandler),this.provider.off(P$4.error,this.onProviderErrorHandler);}async registerEventListeners(){this.events.on(D$6.connection_stalled,()=>{this.restartTransport().catch(t=>this.logger.error(t));});let e=await rr$3();or$1(async t=>{this.initialized&&e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(i=>this.logger.error(i))));});}onProviderDisconnect(){this.events.emit(D$6.disconnect),this.attemptToReconnect();}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(e=>this.logger.error(e));},cjs$5.toMiliseconds(dt$1)));}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(e=>{const t=setInterval(()=>{this.connected&&(clearInterval(t),e());},this.connectionStatusPollingInterval);});await this.restartTransport();}}};var zr=Object.defineProperty,Ft=Object.getOwnPropertySymbols,Nr$1=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,Mt$1=(n,e,t)=>e in n?zr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,kt=(n,e)=>{for(var t in e||(e={}))Nr$1.call(e,t)&&Mt$1(n,t,e[t]);if(Ft)for(var t of Ft(e))Ur.call(e,t)&&Mt$1(n,t,e[t]);return n};let Kt$1 = class Kt extends p$8{constructor(e,t,i,s=O$3,r=void 0){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=Dt$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!w$5(o)?this.map.set(this.getKey(o),o):Lt$2(o)?this.map.set(o.id,o):xt$1(o)&&this.map.set(o.topic,o);}),this.cached=[],this.initialized=!0);},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist());},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(h=>Gi$1(a[h],o[h]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const h=kt(kt({},this.getData(o)),a);this.map.set(o,h),await this.persist();},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),await this.persist());},this.logger=cjs$1.generateChildLogger(t,this.name),this.storagePrefix=s,this.getKey=r;}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e);}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values);}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values});}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e);}}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let Bt$1 = class Bt{constructor(e,t){this.core=e,this.logger=t,this.name=Et$1,this.version=wt$1,this.events=new EventEmitter$1,this.initialized=!1,this.storagePrefix=O$3,this.ignoredPayloadTypes=[_$4],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"));},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])];},this.create=async()=>{this.isInitialized();const i=Vn$1(),s=await this.core.crypto.setSymKey(i),r=pt$2(cjs$5.FIVE_MINUTES),o={protocol:ht},a={topic:s,expiry:r,relay:o,active:!1},h=Rt$2({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:i,relay:o,expiryTimestamp:r});return await this.pairings.set(s,a),await this.core.relayer.subscribe(s),this.core.expirer.set(s,r),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized(),this.isValidPair(i);const{topic:s,symKey:r,relay:o,expiryTimestamp:a}=Pt$2(i.uri);let h;if(this.pairings.keys.includes(s)&&(h=this.pairings.get(s),h.active))throw new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);const l=a||pt$2(cjs$5.FIVE_MINUTES),d={topic:s,relay:o,expiry:l,active:!1};return await this.pairings.set(s,d),this.core.expirer.set(s,l),i.activatePairing&&await this.activate({topic:s}),this.events.emit(V$3.create,d),this.core.crypto.keychain.has(s)||(await this.core.crypto.setSymKey(r,s),await this.core.relayer.subscribe(s,{relay:o})),d},this.activate=async({topic:i})=>{this.isInitialized();const s=pt$2(cjs$5.THIRTY_DAYS);await this.pairings.update(i,{active:!0,expiry:s}),this.core.expirer.set(i,s);},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:s}=i;if(this.pairings.keys.includes(s)){const r=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:h}=at$2();this.events.once(yt$2("pairing_ping",r),({error:l})=>{l?h(l):a();}),await o();}},this.updateExpiry=async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s});},this.updateMetadata=async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s});},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",U$5("USER_DISCONNECTED")),await this.deletePairing(s));},this.sendRequest=async(i,s,r)=>{const o=formatJsonRpcRequest(s,r),a=await this.core.crypto.encode(i,o),h=$$2[s].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,h),o.id},this.sendResult=async(i,s,r)=>{const o=formatJsonRpcResult(i,r),a=await this.core.crypto.encode(s,o),h=await this.core.history.get(s,i),l=$$2[h.request.method].res;await this.core.relayer.publish(s,a,l),await this.core.history.resolve(o);},this.sendError=async(i,s,r)=>{const o=formatJsonRpcError(i,r),a=await this.core.crypto.encode(s,o),h=await this.core.history.get(s,i),l=$$2[h.request.method]?$$2[h.request.method].res:$$2.unregistered_method.res;await this.core.relayer.publish(s,a,l),await this.core.history.resolve(o);},this.deletePairing=async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,U$5("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)]);},this.cleanup=async()=>{const i=this.pairings.getAll().filter(s=>mt$1(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)));},this.onRelayEventRequest=i=>{const{topic:s,payload:r}=i;switch(r.method){case"wc_pairingPing":return this.onPairingPingRequest(s,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,r);default:return this.onUnknownRpcMethodRequest(s,r)}},this.onRelayEventResponse=async i=>{const{topic:s,payload:r}=i,o=(await this.core.history.get(s,r.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(s,r);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,s)=>{const{id:r}=s;try{this.isValidPing({topic:i}),await this.sendResult(r,i,!0),this.events.emit(V$3.ping,{id:r,topic:i});}catch(o){await this.sendError(r,i,o),this.logger.error(o);}},this.onPairingPingResponse=(i,s)=>{const{id:r}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(yt$2("pairing_ping",r),{}):isJsonRpcError(s)&&this.events.emit(yt$2("pairing_ping",r),{error:s.error});},500);},this.onPairingDeleteRequest=async(i,s)=>{const{id:r}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(V$3.delete,{id:r,topic:i});}catch(o){await this.sendError(r,i,o),this.logger.error(o);}},this.onUnknownRpcMethodRequest=async(i,s)=>{const{id:r,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=U$5("WC_METHOD_UNSUPPORTED",o);await this.sendError(r,i,a),this.logger.error(a);}catch(a){await this.sendError(r,i,a),this.logger.error(a);}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(U$5("WC_METHOD_UNSUPPORTED",i));},this.isValidPair=i=>{var s;if(!Gt$2(i)){const{message:o}=N$4("MISSING_OR_INVALID",`pair() params: ${i}`);throw new Error(o)}if(!Kt$2(i.uri)){const{message:o}=N$4("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw new Error(o)}const r=Pt$2(i.uri);if(!((s=r?.relay)!=null&&s.protocol)){const{message:o}=N$4("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(o)}if(!(r!=null&&r.symKey)){const{message:o}=N$4("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(o)}if(r!=null&&r.expiryTimestamp&&cjs$5.toMiliseconds(r?.expiryTimestamp)<Date.now()){const{message:o}=N$4("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(o)}},this.isValidPing=async i=>{if(!Gt$2(i)){const{message:r}=N$4("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(r)}const{topic:s}=i;await this.isValidPairingTopic(s);},this.isValidDisconnect=async i=>{if(!Gt$2(i)){const{message:r}=N$4("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(r)}const{topic:s}=i;await this.isValidPairingTopic(s);},this.isValidPairingTopic=async i=>{if(!g$8(i,!1)){const{message:s}=N$4("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=N$4("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(mt$1(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=N$4("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.pairings=new Kt$1(this.core,this.logger,this.name,this.storagePrefix);}get context(){return cjs$1.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(D$6.message,async e=>{const{topic:t,message:i}=e;if(!this.pairings.keys.includes(t)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{isJsonRpcRequest(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):isJsonRpcResponse(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id));}catch(r){this.logger.error(r);}});}registerExpirerEvents(){this.core.expirer.on(v$5.expired,async e=>{const{topic:t}=ft$2(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(V$3.expire,{topic:t}));});}};class Vt extends h$6{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new EventEmitter$1,this.name=vt,this.version=It$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0);},this.set=(i,s,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:r}),this.records.has(s.id))return;const o={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:r,expiry:pt$2(cjs$5.THIRTY_DAYS)};this.records.set(o.id,o),this.events.emit(R$4.created,o);},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=isJsonRpcError(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.events.emit(R$4.updated,s));},this.get=async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s)),this.delete=(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(r=>{if(r.topic===i){if(typeof s<"u"&&r.id!==s)return;this.records.delete(r.id),this.events.emit(R$4.deleted,r);}});},this.exists=async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:!1),this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:formatJsonRpcRequest(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e);}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(R$4.sync);}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values});}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e);}}registerEventListeners(){this.events.on(R$4.created,e=>{const t=R$4.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.events.on(R$4.updated,e=>{const t=R$4.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.events.on(R$4.deleted,e=>{const t=R$4.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup();});}cleanup(){try{this.records.forEach(e=>{cjs$5.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id));});}catch(e){this.logger.warn(e);}}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}}let qt$1 = class qt extends E$3{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new EventEmitter$1,this.name=Ct$1,this.version=Rt$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0);},this.has=i=>{try{const s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return !1}},this.set=(i,s)=>{this.isInitialized();const r=this.formatTarget(i),o={target:r,expiry:s};this.expirations.set(r,o),this.checkExpiry(r,o),this.events.emit(v$5.created,{target:r,expiration:o});},this.get=i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)},this.del=i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),r=this.getExpiration(s);this.expirations.delete(s),this.events.emit(v$5.deleted,{target:s,expiration:r});}},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return lt$2(e);if(typeof e=="number")return dt$2(e);const{message:t}=N$4("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e);}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(v$5.sync);}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values});}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e);}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;cjs$5.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t);}expire(e,t){this.expirations.delete(e),this.events.emit(v$5.expired,{target:e,expiration:t});}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e));}registerEventListeners(){this.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(v$5.created,e=>{const t=v$5.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(v$5.expired,e=>{const t=v$5.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(v$5.deleted,e=>{const t=v$5.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let jt$1 = class jt extends y$5{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=Z$4,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async i=>{if(this.verifyDisabled||$$3()||!D$8())return;const s=this.getVerifyUrl(i?.verifyUrl);this.verifyUrl!==s&&this.removeIframe(),this.verifyUrl=s;try{await this.createIframe();}catch(r){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(r);}if(!this.initialized){this.removeIframe(),this.verifyUrl=ee$3;try{await this.createIframe();}catch(r){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(r),this.verifyDisabled=!0;}}},this.register=async i=>{this.initialized?this.sendPost(i.attestationId):(this.addToQueue(i.attestationId),await this.init());},this.resolve=async i=>{if(this.isDevEnv)return "";const s=this.getVerifyUrl(i?.verifyUrl);let r;try{r=await this.fetchAttestation(i.attestationId,s);}catch(o){this.logger.info(`failed to resolve attestation: ${i.attestationId} from url: ${s}`),this.logger.info(o),r=await this.fetchAttestation(i.attestationId,ee$3);}return r},this.fetchAttestation=async(i,s)=>{this.logger.info(`resolving attestation: ${i} from url: ${s}`);const r=this.startAbortTimer(cjs$5.ONE_SECOND*2),o=await fetch(`${s}/attestation/${i}`,{signal:this.abortController.signal});return clearTimeout(r),o.status===200?await o.json():void 0},this.addToQueue=i=>{this.queue.push(i);},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(i=>this.sendPost(i)),this.queue=[]);},this.sendPost=i=>{var s;try{if(!this.iframe)return;(s=this.iframe.contentWindow)==null||s.postMessage(i,"*"),this.logger.info(`postMessage sent: ${i} ${this.verifyUrl}`);}catch{}},this.createIframe=async()=>{let i;const s=r=>{r.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",s),i());};await Promise.race([new Promise(r=>{if(document.getElementById(Z$4))return r();window.addEventListener("message",s);const o=document.createElement("iframe");o.id=Z$4,o.src=`${this.verifyUrl}/${this.projectId}`,o.style.display="none",document.body.append(o),this.iframe=o,i=r;}),new Promise((r,o)=>setTimeout(()=>{window.removeEventListener("message",s),o("verify iframe load timeout");},cjs$5.toMiliseconds(cjs$5.FIVE_SECONDS)))]);},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1);},this.getVerifyUrl=i=>{let s=i||F$4;return _t$1.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${F$4}`),s=F$4),s},this.logger=cjs$1.generateChildLogger(t,this.name),this.verifyUrl=F$4,this.abortController=new AbortController,this.isDevEnv=te$4()&&process.env.IS_VITEST;}get context(){return cjs$1.getLoggerContext(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),cjs$5.toMiliseconds(e))}};let Gt$1 = class Gt extends v$6{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=Tt$1,this.registerDeviceToken=async i=>{const{clientId:s,token:r,notificationType:o,enableEncrypted:a=!1}=i,h=`${St$1}/${this.projectId}/clients`;await Yi$1(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:r,always_raw:a})});},this.logger=cjs$1.generateChildLogger(t,this.context);}};var Lr=Object.defineProperty,Yt$1=Object.getOwnPropertySymbols,$r$1=Object.prototype.hasOwnProperty,Fr=Object.prototype.propertyIsEnumerable,Ht$1=(n,e,t)=>e in n?Lr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Jt$1=(n,e)=>{for(var t in e||(e={}))$r$1.call(e,t)&&Ht$1(n,t,e[t]);if(Yt$1)for(var t of Yt$1(e))Fr.call(e,t)&&Ht$1(n,t,e[t]);return n};let te$3 = class te extends n$a{constructor(e){super(e),this.protocol=le$4,this.version=We$2,this.name=Q$5,this.events=new EventEmitter$1,this.initialized=!1,this.on=(i,s)=>this.events.on(i,s),this.once=(i,s)=>this.events.once(i,s),this.off=(i,s)=>this.events.off(i,s),this.removeListener=(i,s)=>this.events.removeListener(i,s),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||ge$4,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:e?.logger||Qe$3.logger}));this.logger=cjs$1.generateChildLogger(t,this.name),this.heartbeat=new cjs$2.HeartBeat,this.crypto=new xt(this,this.logger,e?.keychain),this.history=new Vt(this,this.logger),this.expirer=new qt$1(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new h$7(Jt$1(Jt$1({},Ze$2),e?.storageOptions)),this.relayer=new $t$1({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Bt$1(this,this.logger),this.verify=new jt$1(this.projectId||"",this.logger),this.echoClient=new Gt$1(this.projectId||"",this.logger);}static async init(e){const t=new te(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(yt$1,i),t}get context(){return cjs$1.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize();}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success");}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}};const Mr=te$3;
|
|
146664
|
+
function Hi$1(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var s=0;s<n.length;s++){var r=n.charAt(s),o=r.charCodeAt(0);if(t[o]!==255)throw new TypeError(r+" is ambiguous");t[o]=s;}var a=n.length,h=n.charAt(0),l=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function p(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var m=0,z=0,I=0,_=u.length;I!==_&&u[I]===0;)I++,m++;for(var T=(_-I)*d+1>>>0,f=new Uint8Array(T);I!==_;){for(var S=u[I],A=0,C=T-1;(S!==0||A<z)&&C!==-1;C--,A++)S+=256*f[C]>>>0,f[C]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");z=A,I++;}for(var x=T-z;x!==T&&f[x]===0;)x++;for(var j=h.repeat(m);x<T;++x)j+=n.charAt(f[x]);return j}function y(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var m=0;if(u[m]!==" "){for(var z=0,I=0;u[m]===h;)z++,m++;for(var _=(u.length-m)*l+1>>>0,T=new Uint8Array(_);u[m];){var f=t[u.charCodeAt(m)];if(f===255)return;for(var S=0,A=_-1;(f!==0||S<I)&&A!==-1;A--,S++)f+=a*T[A]>>>0,T[A]=f%256>>>0,f=f/256>>>0;if(f!==0)throw new Error("Non-zero carry");I=S,m++;}if(u[m]!==" "){for(var C=_-I;C!==_&&T[C]===0;)C++;for(var x=new Uint8Array(z+(_-C)),j=z;C!==_;)x[j++]=T[C++];return x}}}function M(u){var m=y(u);if(m)return m;throw new Error(`Non-${e} character`)}return {encode:p,decodeUnsafe:y,decode:M}}var Ji$1=Hi$1,Xi$1=Ji$1;const Ne$2=n=>{if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")},Wi$2=n=>new TextEncoder().encode(n),Qi$1=n=>new TextDecoder().decode(n);let Zi$1 = class Zi{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i;}encode(e){if(e instanceof Uint8Array)return `${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}};class es{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i;}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ue$2(this,e)}}class ts{constructor(e){this.decoders=e;}or(e){return Ue$2(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Ue$2=(n,e)=>new ts({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class is{constructor(e,t,i,s){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=s,this.encoder=new Zi$1(e,t,i),this.decoder=new es(e,t,s);}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const W$2=({name:n,prefix:e,encode:t,decode:i})=>new is(n,e,t,i),B$4=({prefix:n,name:e,alphabet:t})=>{const{encode:i,decode:s}=Xi$1(t,e);return W$2({prefix:n,name:e,encode:i,decode:r=>Ne$2(s(r))})},ss=(n,e,t,i)=>{const s={};for(let d=0;d<e.length;++d)s[e[d]]=d;let r=n.length;for(;n[r-1]==="=";)--r;const o=new Uint8Array(r*t/8|0);let a=0,h=0,l=0;for(let d=0;d<r;++d){const p=s[n[d]];if(p===void 0)throw new SyntaxError(`Non-${i} character`);h=h<<t|p,a+=t,a>=8&&(a-=8,o[l++]=255&h>>a);}if(a>=t||255&h<<8-a)throw new SyntaxError("Unexpected end of data");return o},rs=(n,e,t)=>{const i=e[e.length-1]==="=",s=(1<<t)-1;let r="",o=0,a=0;for(let h=0;h<n.length;++h)for(a=a<<8|n[h],o+=8;o>t;)o-=t,r+=e[s&a>>o];if(o&&(r+=e[s&a<<t-o]),i)for(;r.length*t&7;)r+="=";return r},g$6=({name:n,prefix:e,bitsPerChar:t,alphabet:i})=>W$2({prefix:e,name:n,encode(s){return rs(s,i,t)},decode(s){return ss(s,i,t,n)}}),ns=W$2({prefix:"\0",name:"identity",encode:n=>Qi$1(n),decode:n=>Wi$2(n)});var os=Object.freeze({__proto__:null,identity:ns});const as$1=g$6({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hs$1=Object.freeze({__proto__:null,base2:as$1});const cs$1=g$6({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var us$1=Object.freeze({__proto__:null,base8:cs$1});const ls$1=B$4({prefix:"9",name:"base10",alphabet:"0123456789"});var ds$1=Object.freeze({__proto__:null,base10:ls$1});const gs$1=g$6({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ps$1=g$6({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ds=Object.freeze({__proto__:null,base16:gs$1,base16upper:ps$1});const ys=g$6({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ms=g$6({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bs=g$6({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fs=g$6({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Es=g$6({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ws$1=g$6({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vs=g$6({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Is=g$6({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cs=g$6({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rs=Object.freeze({__proto__:null,base32:ys,base32upper:ms,base32pad:bs,base32padupper:fs,base32hex:Es,base32hexupper:ws$1,base32hexpad:vs,base32hexpadupper:Is,base32z:Cs});const _s=B$4({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ts=B$4({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ss=Object.freeze({__proto__:null,base36:_s,base36upper:Ts});const Ps=B$4({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xs$1=B$4({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Os=Object.freeze({__proto__:null,base58btc:Ps,base58flickr:xs$1});const As=g$6({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zs=g$6({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ns=g$6({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Us=g$6({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ls=Object.freeze({__proto__:null,base64:As,base64pad:zs,base64url:Ns,base64urlpad:Us});const Le$2=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),$s=Le$2.reduce((n,e,t)=>(n[t]=e,n),[]),Fs=Le$2.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]);function Ms(n){return n.reduce((e,t)=>(e+=$s[t],e),"")}function ks(n){const e=[];for(const t of n){const i=Fs[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i);}return new Uint8Array(e)}const Ks=W$2({prefix:"\u{1F680}",name:"base256emoji",encode:Ms,decode:ks});var Bs=Object.freeze({__proto__:null,base256emoji:Ks}),Vs=Fe$3,$e$3=128,qs=127,js=~qs,Gs=Math.pow(2,31);function Fe$3(n,e,t){e=e||[],t=t||0;for(var i=t;n>=Gs;)e[t++]=n&255|$e$3,n/=128;for(;n&js;)e[t++]=n&255|$e$3,n>>>=7;return e[t]=n|0,Fe$3.bytes=t-i+1,e}var Ys=he$4,Hs=128,Me$3=127;function he$4(n,i){var t=0,i=i||0,s=0,r=i,o,a=n.length;do{if(r>=a)throw he$4.bytes=0,new RangeError("Could not decode varint");o=n[r++],t+=s<28?(o&Me$3)<<s:(o&Me$3)*Math.pow(2,s),s+=7;}while(o>=Hs);return he$4.bytes=r-i,t}var Js=Math.pow(2,7),Xs=Math.pow(2,14),Ws=Math.pow(2,21),Qs=Math.pow(2,28),Zs=Math.pow(2,35),er$2=Math.pow(2,42),tr$1=Math.pow(2,49),ir$2=Math.pow(2,56),sr$2=Math.pow(2,63),rr$2=function(n){return n<Js?1:n<Xs?2:n<Ws?3:n<Qs?4:n<Zs?5:n<er$2?6:n<tr$1?7:n<ir$2?8:n<sr$2?9:10},nr$2={encode:Vs,decode:Ys,encodingLength:rr$2},ke$2=nr$2;const Ke$2=(n,e,t=0)=>(ke$2.encode(n,e,t),e),Be$3=n=>ke$2.encodingLength(n),ce$4=(n,e)=>{const t=e.byteLength,i=Be$3(n),s=i+Be$3(t),r=new Uint8Array(s+t);return Ke$2(n,r,0),Ke$2(t,r,i),r.set(e,s),new or(n,t,e,r)};class or{constructor(e,t,i,s){this.code=e,this.size=t,this.digest=i,this.bytes=s;}}const Ve$3=({name:n,code:e,encode:t})=>new ar$1(n,e,t);let ar$1 = class ar{constructor(e,t,i){this.name=e,this.code=t,this.encode=i;}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ce$4(this.code,t):t.then(i=>ce$4(this.code,i))}else throw Error("Unknown type, must be binary type")}};const qe$2=n=>async e=>new Uint8Array(await crypto.subtle.digest(n,e)),hr$3=Ve$3({name:"sha2-256",code:18,encode:qe$2("SHA-256")}),cr$2=Ve$3({name:"sha2-512",code:19,encode:qe$2("SHA-512")});var ur$1=Object.freeze({__proto__:null,sha256:hr$3,sha512:cr$2});const je$2=0,lr$2="identity",Ge$2=Ne$2,dr$2=n=>ce$4(je$2,Ge$2(n)),gr={code:je$2,name:lr$2,encode:Ge$2,digest:dr$2};var pr$1=Object.freeze({__proto__:null,identity:gr});new TextEncoder,new TextDecoder;const Ye$2={...os,...hs$1,...us$1,...ds$1,...Ds,...Rs,...Ss,...Os,...Ls,...Bs};({...ur$1,...pr$1});function He$2(n){return globalThis.Buffer!=null?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n}function Dr(n=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?He$2(globalThis.Buffer.allocUnsafe(n)):new Uint8Array(n)}function Je$2(n,e,t,i){return {name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:i}}}const Xe$2=Je$2("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),ue$4=Je$2("ascii","a",n=>{let e="a";for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return e},n=>{n=n.substring(1);const e=Dr(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e}),yr$1={utf8:Xe$2,"utf-8":Xe$2,hex:Ye$2.base16,latin1:ue$4,ascii:ue$4,binary:ue$4,...Ye$2};function mr$2(n,e="utf8"){const t=yr$1[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return (e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?He$2(globalThis.Buffer.from(n,"utf-8")):t.decoder.decode(`${t.prefix}${n}`)}const le$4="wc",We$2=2,Q$5="core",O$3=`${le$4}@2:${Q$5}:`,Qe$3={name:Q$5,logger:"error"},Ze$2={database:":memory:"},et$1="crypto",de$4="client_ed25519_seed",tt$1=cjs$5.ONE_DAY,it$1="keychain",st$1="0.3",rt$1="messages",nt$1="0.3",ot$1=cjs$5.SIX_HOURS,at$1="publisher",ht="irn",ct$1="error",ge$4="wss://relay.walletconnect.com",pe$3="wss://relay.walletconnect.org",ut$1="relayer",D$6={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},lt$1="_subscription",P$4={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},dt$1=cjs$5.ONE_SECOND,gt="2.11.1",pt$1=1e4,Dt$1="0.3",yt$1="WALLETCONNECT_CLIENT_ID",w$2={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},mt="subscription",bt$1="0.3",ft$1=cjs$5.FIVE_SECONDS*1e3,Et$1="pairing",wt$1="0.3",$$2={wc_pairingDelete:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:0},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:0}}},V$3={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},R$4={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},vt="history",It$1="0.3",Ct$1="expirer",v$5={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Rt$1="0.3",Z$4="verify-api",F$4="https://verify.walletconnect.com",ee$3="https://verify.walletconnect.org",_t$1=[F$4,ee$3],Tt$1="echo",St$1="https://echo.walletconnect.com";let Pt$1 = class Pt{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name=it$1,this.version=st$1,this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0;}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,s)=>{this.isInitialized(),this.keychain.set(i,s),await this.persist();},this.get=i=>{this.isInitialized();const s=this.keychain.get(i);if(typeof s>"u"){const{message:r}=N$4("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(r)}return s},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist();},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,rt$2(e));}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ot$2(e):void 0}async persist(){await this.setKeyChain(this.keychain);}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};class xt{constructor(e,t,i){this.core=e,this.logger=t,this.name=et$1,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0);},this.hasKeys=s=>(this.isInitialized(),this.keychain.has(s)),this.getClientId=async()=>{this.isInitialized();const s=await this.getClientSeed(),r=generateKeyPair(s);return encodeIss(r.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const s=kn();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();const r=await this.getClientSeed(),o=generateKeyPair(r),a=Vn$1(),h=tt$1;return await signJWT(a,s,h,o)},this.generateSharedKey=(s,r,o)=>{this.isInitialized();const a=this.getPrivateKey(s),h=Mn(a,r);return this.setSymKey(h,o)},this.setSymKey=async(s,r)=>{this.isInitialized();const o=r||Kn(s);return await this.keychain.set(o,s),o},this.deleteKeyPair=async s=>{this.isInitialized(),await this.keychain.del(s);},this.deleteSymKey=async s=>{this.isInitialized(),await this.keychain.del(s);},this.encode=async(s,r,o)=>{this.isInitialized();const a=Ae$3(o),h=safeJsonStringify(r);if(qn(a)){const y=a.senderPublicKey,M=a.receiverPublicKey;s=await this.generateSharedKey(y,M);}const l=this.getSymKey(s),{type:d,senderPublicKey:p}=a;return xn({type:d,symKey:l,message:h,senderPublicKey:p})},this.decode=async(s,r,o)=>{this.isInitialized();const a=Hn(r,o);if(qn(a)){const h=a.receiverPublicKey,l=a.senderPublicKey;s=await this.generateSharedKey(h,l);}try{const h=this.getSymKey(s),l=Fn({symKey:h,encoded:r});return safeJsonParse(l)}catch(h){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(h);}},this.getPayloadType=s=>{const r=ee$4(s);return j$4(r.type)},this.getPayloadSenderPublicKey=s=>{const r=ee$4(s);return r.senderPublicKey?toString$4(r.senderPublicKey,p$9):void 0},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.keychain=i||new Pt$1(this.core,this.logger);}get context(){return cjs$1.getLoggerContext(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(de$4);}catch{e=Vn$1(),await this.keychain.set(de$4,e);}return mr$2(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}}let Ot$1 = class Ot extends a$5{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=rt$1,this.version=nt$1,this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size});}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i);}finally{this.initialized=!0;}}},this.set=async(i,s)=>{this.isInitialized();const r=Ln(s);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[r]<"u"||(o[r]=s,this.messages.set(i,o),await this.persist()),r},this.get=i=>{this.isInitialized();let s=this.messages.get(i);return typeof s>"u"&&(s={}),s},this.has=(i,s)=>{this.isInitialized();const r=this.get(i),o=Ln(s);return typeof r[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist();},this.logger=cjs$1.generateChildLogger(e,this.name),this.core=t;}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,rt$2(e));}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?ot$2(e):void 0}async persist(){await this.setRelayerMessages(this.messages);}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let vr$1 = class vr extends u$4{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new EventEmitter$2,this.name=at$1,this.queue=new Map,this.publishTimeout=cjs$5.toMiliseconds(cjs$5.TEN_SECONDS*2),this.needsTransportRestart=!1,this.publish=async(i,s,r)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:r}});try{const a=r?.ttl||ot$1,h=vt$1(r),l=r?.prompt||!1,d=r?.tag||0,p=r?.id||getBigIntRpcId().toString(),y={topic:i,message:s,opts:{ttl:a,relay:h,prompt:l,tag:d,id:p}},M=setTimeout(()=>this.queue.set(p,y),this.publishTimeout);try{await await ut$2(this.rpcPublish(i,s,a,h,l,d,p),this.publishTimeout,`Failed to publish payload, please try again. id:${p} tag:${d}`),this.removeRequestFromQueue(p),this.relayer.events.emit(D$6.publish,y);}catch(u){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(o=r?.internal)!=null&&o.throwOnFailedPublish)throw this.removeRequestFromQueue(p),u;return}finally{clearTimeout(M);}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:s,opts:r}});}catch(a){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(a),a}},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.relayer=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.registerEventListeners();}get context(){return cjs$1.getLoggerContext(this.logger)}rpcPublish(e,t,i,s,r,o,a){var h,l,d,p;const y={method:Et$2(s.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:r,tag:o},id:a};return w$5((h=y.params)==null?void 0:h.prompt)&&((l=y.params)==null||delete l.prompt),w$5((d=y.params)==null?void 0:d.tag)&&((p=y.params)==null||delete p.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:y}),this.relayer.request(y)}removeRequestFromQueue(e){this.queue.delete(e);}checkQueue(){this.queue.forEach(async e=>{const{topic:t,message:i,opts:s}=e;await this.publish(t,i,s);});}registerEventListeners(){this.relayer.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(D$6.connection_stalled);return}this.checkQueue();}),this.relayer.on(D$6.message_ack,e=>{this.removeRequestFromQueue(e.id.toString());});}};class Ir{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t]);},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const s=i.filter(r=>r!==t);if(!s.length){this.map.delete(e);return}this.map.set(e,s);},this.clear=()=>{this.map.clear();};}get topics(){return Array.from(this.map.keys())}}var Cr=Object.defineProperty,Rr=Object.defineProperties,_r$1=Object.getOwnPropertyDescriptors,At$1=Object.getOwnPropertySymbols,Tr=Object.prototype.hasOwnProperty,Sr$1=Object.prototype.propertyIsEnumerable,zt$1=(n,e,t)=>e in n?Cr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,q$5=(n,e)=>{for(var t in e||(e={}))Tr.call(e,t)&&zt$1(n,t,e[t]);if(At$1)for(var t of At$1(e))Sr$1.call(e,t)&&zt$1(n,t,e[t]);return n},De$3=(n,e)=>Rr(n,_r$1(e));let Nt$1 = class Nt extends d$4{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Ir,this.events=new EventEmitter$2,this.name=mt,this.version=bt$1,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=O$3,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId());},this.subscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}});try{const r=vt$1(s),o={topic:i,relay:r};this.pending.set(i,o);const a=await this.rpcSubscribe(i,r);return this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:s}}),a}catch(r){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(r),r}},this.unsubscribe=async(i,s)=>{await this.restartToComplete(),this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(i,s.id,s):await this.unsubscribeByTopic(i,s);},this.isSubscribed=async i=>{if(this.topics.includes(i))return !0;const s=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((r,o)=>{const a=new cjs$5.Watch;a.start(s);const h=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(h),a.stop(s),r(!0)),a.elapsed(s)>=ft$1&&(clearInterval(h),a.stop(s),o(new Error("Subscription resolution timeout")));},this.pollingInterval);}).catch(()=>!1)},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1;},this.relayer=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.clientId="";}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t;}catch{}return i}onEnable(){this.cached=[],this.initialized=!0;}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear();}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async s=>await this.unsubscribeById(e,s,t)));}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const s=vt$1(i);await this.rpcUnsubscribe(e,t,s);const r=U$5("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,t){const i={method:Et$2(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await ut$2(this.relayer.request(i),this.subscribeTimeout);}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(D$6.connection_stalled);}return Ln(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:Et$2(t.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await ut$2(this.relayer.request(i),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(D$6.connection_stalled);}}rpcUnsubscribe(e,t,i){const s={method:Et$2(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,De$3(q$5({},t),{id:e})),this.pending.delete(t.topic);}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,q$5({},t)),this.pending.delete(t.topic);});}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e);}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e);}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t));}addSubscription(e,t){this.subscriptions.set(e,q$5({},t)),this.topicMap.set(t.topic,e),this.events.emit(w$2.created,t);}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(w$2.deleted,De$3(q$5({},i),{reason:t}));}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(w$2.sync);}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const i=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i);}}this.events.emit(w$2.resubscribed);}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values});}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e);}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);k$5(t)&&this.onBatchSubscribe(t.map((i,s)=>De$3(q$5({},e[s]),{id:i})));}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable());}onDisconnect(){this.onDisable();}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach(t=>{e.push(t);}),await this.batchSubscribe(e);}registerEventListeners(){this.relayer.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending();}),this.relayer.on(D$6.connect,async()=>{await this.onConnect();}),this.relayer.on(D$6.disconnect,()=>{this.onDisconnect();}),this.events.on(w$2.created,async e=>{const t=w$2.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist();}),this.events.on(w$2.deleted,async e=>{const t=w$2.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise(e=>{const t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e());},this.pollingInterval);});}};var Pr=Object.defineProperty,Ut$1=Object.getOwnPropertySymbols,xr$1=Object.prototype.hasOwnProperty,Or$1=Object.prototype.propertyIsEnumerable,Lt$1=(n,e,t)=>e in n?Pr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ar=(n,e)=>{for(var t in e||(e={}))xr$1.call(e,t)&&Lt$1(n,t,e[t]);if(Ut$1)for(var t of Ut$1(e))Or$1.call(e,t)&&Lt$1(n,t,e[t]);return n};let $t$1 = class $t extends g$7{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new EventEmitter$2,this.name=ut$1,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.request=async t=>{this.logger.debug("Publishing Request Payload");const i=t.id,s=this.provider.request(t);this.requestsInFlight.set(i,{promise:s,request:t});try{return await this.toEstablishConnection(),await s}catch(r){throw this.logger.debug("Failed to Publish Request"),this.logger.error(r),r}finally{this.requestsInFlight.delete(i);}},this.onPayloadHandler=t=>{this.onProviderPayload(t);},this.onConnectHandler=()=>{this.events.emit(D$6.connect);},this.onDisconnectHandler=()=>{this.onProviderDisconnect();},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(D$6.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose();},this.registerProviderListeners=()=>{this.provider.on(P$4.payload,this.onPayloadHandler),this.provider.on(P$4.connect,this.onConnectHandler),this.provider.on(P$4.disconnect,this.onDisconnectHandler),this.provider.on(P$4.error,this.onProviderErrorHandler);},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?cjs$1.generateChildLogger(e.logger,this.name):cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:e.logger||ct$1})),this.messages=new Ot$1(this.logger,e.core),this.subscriber=new Nt$1(this,this.logger),this.publisher=new vr$1(this,this.logger),this.relayUrl=e?.relayUrl||ge$4,this.projectId=e.projectId,this.bundleId=Jn(),this.provider={};}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen();}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${pe$3}...`),await this.restartTransport(pe$3);}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1);},pt$1);}get context(){return cjs$1.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()});}async subscribe(e,t){var i;this.isInitialized();let s=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"";if(s)return s;let r;const o=a=>{a.topic===e&&(this.subscriber.off(w$2.created,o),r());};return await Promise.all([new Promise(a=>{r=a,this.subscriber.on(w$2.created,o);}),new Promise(async a=>{s=await this.subscriber.subscribe(e,t),a();})]),s}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t);}on(e,t){this.events.on(e,t);}once(e,t){this.events.once(e,t);}off(e,t){this.events.off(e,t);}removeListener(e,t){this.events.removeListener(e,t);}async transportClose(){this.requestsInFlight.size>0&&(this.logger.debug("Waiting for all in-flight requests to finish before closing transport..."),this.requestsInFlight.forEach(async e=>{await e.promise;})),this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await ut$2(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect();}async transportOpen(e){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(t=>{if(!this.initialized)return t();this.subscriber.once(w$2.resubscribed,()=>{t();});}),new Promise(async(t,i)=>{try{await ut$2(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`);}catch(s){i(s);return}t();})]);}catch(t){this.logger.error(t);const i=t;if(!this.isConnectionStalled(i.message))throw t;this.provider.events.emit(P$4.disconnect);}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1;}}}async restartTransport(e){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen());}async confirmOnlineStateOrThrow(){if(!await rr$3())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new JsonRpcProvider(new f$8(Xn({sdkVersion:gt,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners();}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i);}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;const s=this.messages.has(t,i);return s&&this.logger.debug(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),isJsonRpcRequest(e)){if(!e.method.endsWith(lt$1))return;const t=e.params,{topic:i,message:s,publishedAt:r}=t.data,o={topic:i,message:s,publishedAt:r};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Ar({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o);}else isJsonRpcResponse(e)&&this.events.emit(D$6.message_ack,e);}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(D$6.message,e),await this.recordMessageEvent(e));}async acknowledgePayload(e){const t=formatJsonRpcResult(e.id,!0);await this.provider.connection.send(t);}unregisterProviderListeners(){this.provider.off(P$4.payload,this.onPayloadHandler),this.provider.off(P$4.connect,this.onConnectHandler),this.provider.off(P$4.disconnect,this.onDisconnectHandler),this.provider.off(P$4.error,this.onProviderErrorHandler);}async registerEventListeners(){this.events.on(D$6.connection_stalled,()=>{this.restartTransport().catch(t=>this.logger.error(t));});let e=await rr$3();or$1(async t=>{this.initialized&&e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(i=>this.logger.error(i))));});}onProviderDisconnect(){this.events.emit(D$6.disconnect),this.attemptToReconnect();}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(e=>this.logger.error(e));},cjs$5.toMiliseconds(dt$1)));}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(e=>{const t=setInterval(()=>{this.connected&&(clearInterval(t),e());},this.connectionStatusPollingInterval);});await this.restartTransport();}}};var zr=Object.defineProperty,Ft=Object.getOwnPropertySymbols,Nr$1=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,Mt$1=(n,e,t)=>e in n?zr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,kt=(n,e)=>{for(var t in e||(e={}))Nr$1.call(e,t)&&Mt$1(n,t,e[t]);if(Ft)for(var t of Ft(e))Ur.call(e,t)&&Mt$1(n,t,e[t]);return n};let Kt$1 = class Kt extends p$8{constructor(e,t,i,s=O$3,r=void 0){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=Dt$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!w$5(o)?this.map.set(this.getKey(o),o):Lt$2(o)?this.map.set(o.id,o):xt$1(o)&&this.map.set(o.topic,o);}),this.cached=[],this.initialized=!0);},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist());},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(h=>Gi$1(a[h],o[h]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const h=kt(kt({},this.getData(o)),a);this.map.set(o,h),await this.persist();},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),await this.persist());},this.logger=cjs$1.generateChildLogger(t,this.name),this.storagePrefix=s,this.getKey=r;}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e);}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values);}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values});}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e);}}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let Bt$1 = class Bt{constructor(e,t){this.core=e,this.logger=t,this.name=Et$1,this.version=wt$1,this.events=new EventEmitter$2,this.initialized=!1,this.storagePrefix=O$3,this.ignoredPayloadTypes=[_$4],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"));},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])];},this.create=async()=>{this.isInitialized();const i=Vn$1(),s=await this.core.crypto.setSymKey(i),r=pt$2(cjs$5.FIVE_MINUTES),o={protocol:ht},a={topic:s,expiry:r,relay:o,active:!1},h=Rt$2({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:i,relay:o,expiryTimestamp:r});return await this.pairings.set(s,a),await this.core.relayer.subscribe(s),this.core.expirer.set(s,r),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized(),this.isValidPair(i);const{topic:s,symKey:r,relay:o,expiryTimestamp:a}=Pt$2(i.uri);let h;if(this.pairings.keys.includes(s)&&(h=this.pairings.get(s),h.active))throw new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);const l=a||pt$2(cjs$5.FIVE_MINUTES),d={topic:s,relay:o,expiry:l,active:!1};return await this.pairings.set(s,d),this.core.expirer.set(s,l),i.activatePairing&&await this.activate({topic:s}),this.events.emit(V$3.create,d),this.core.crypto.keychain.has(s)||(await this.core.crypto.setSymKey(r,s),await this.core.relayer.subscribe(s,{relay:o})),d},this.activate=async({topic:i})=>{this.isInitialized();const s=pt$2(cjs$5.THIRTY_DAYS);await this.pairings.update(i,{active:!0,expiry:s}),this.core.expirer.set(i,s);},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);const{topic:s}=i;if(this.pairings.keys.includes(s)){const r=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:h}=at$2();this.events.once(yt$2("pairing_ping",r),({error:l})=>{l?h(l):a();}),await o();}},this.updateExpiry=async({topic:i,expiry:s})=>{this.isInitialized(),await this.pairings.update(i,{expiry:s});},this.updateMetadata=async({topic:i,metadata:s})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:s});},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:s}=i;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",U$5("USER_DISCONNECTED")),await this.deletePairing(s));},this.sendRequest=async(i,s,r)=>{const o=formatJsonRpcRequest(s,r),a=await this.core.crypto.encode(i,o),h=$$2[s].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,h),o.id},this.sendResult=async(i,s,r)=>{const o=formatJsonRpcResult(i,r),a=await this.core.crypto.encode(s,o),h=await this.core.history.get(s,i),l=$$2[h.request.method].res;await this.core.relayer.publish(s,a,l),await this.core.history.resolve(o);},this.sendError=async(i,s,r)=>{const o=formatJsonRpcError(i,r),a=await this.core.crypto.encode(s,o),h=await this.core.history.get(s,i),l=$$2[h.request.method]?$$2[h.request.method].res:$$2.unregistered_method.res;await this.core.relayer.publish(s,a,l),await this.core.history.resolve(o);},this.deletePairing=async(i,s)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,U$5("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),s?Promise.resolve():this.core.expirer.del(i)]);},this.cleanup=async()=>{const i=this.pairings.getAll().filter(s=>mt$1(s.expiry));await Promise.all(i.map(s=>this.deletePairing(s.topic)));},this.onRelayEventRequest=i=>{const{topic:s,payload:r}=i;switch(r.method){case"wc_pairingPing":return this.onPairingPingRequest(s,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,r);default:return this.onUnknownRpcMethodRequest(s,r)}},this.onRelayEventResponse=async i=>{const{topic:s,payload:r}=i,o=(await this.core.history.get(s,r.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(s,r);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,s)=>{const{id:r}=s;try{this.isValidPing({topic:i}),await this.sendResult(r,i,!0),this.events.emit(V$3.ping,{id:r,topic:i});}catch(o){await this.sendError(r,i,o),this.logger.error(o);}},this.onPairingPingResponse=(i,s)=>{const{id:r}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(yt$2("pairing_ping",r),{}):isJsonRpcError(s)&&this.events.emit(yt$2("pairing_ping",r),{error:s.error});},500);},this.onPairingDeleteRequest=async(i,s)=>{const{id:r}=s;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(V$3.delete,{id:r,topic:i});}catch(o){await this.sendError(r,i,o),this.logger.error(o);}},this.onUnknownRpcMethodRequest=async(i,s)=>{const{id:r,method:o}=s;try{if(this.registeredMethods.includes(o))return;const a=U$5("WC_METHOD_UNSUPPORTED",o);await this.sendError(r,i,a),this.logger.error(a);}catch(a){await this.sendError(r,i,a),this.logger.error(a);}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(U$5("WC_METHOD_UNSUPPORTED",i));},this.isValidPair=i=>{var s;if(!Gt$2(i)){const{message:o}=N$4("MISSING_OR_INVALID",`pair() params: ${i}`);throw new Error(o)}if(!Kt$2(i.uri)){const{message:o}=N$4("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw new Error(o)}const r=Pt$2(i.uri);if(!((s=r?.relay)!=null&&s.protocol)){const{message:o}=N$4("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(o)}if(!(r!=null&&r.symKey)){const{message:o}=N$4("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(o)}if(r!=null&&r.expiryTimestamp&&cjs$5.toMiliseconds(r?.expiryTimestamp)<Date.now()){const{message:o}=N$4("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(o)}},this.isValidPing=async i=>{if(!Gt$2(i)){const{message:r}=N$4("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(r)}const{topic:s}=i;await this.isValidPairingTopic(s);},this.isValidDisconnect=async i=>{if(!Gt$2(i)){const{message:r}=N$4("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(r)}const{topic:s}=i;await this.isValidPairingTopic(s);},this.isValidPairingTopic=async i=>{if(!g$8(i,!1)){const{message:s}=N$4("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(s)}if(!this.pairings.keys.includes(i)){const{message:s}=N$4("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(s)}if(mt$1(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:s}=N$4("EXPIRED",`pairing topic: ${i}`);throw new Error(s)}},this.core=e,this.logger=cjs$1.generateChildLogger(t,this.name),this.pairings=new Kt$1(this.core,this.logger,this.name,this.storagePrefix);}get context(){return cjs$1.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(D$6.message,async e=>{const{topic:t,message:i}=e;if(!this.pairings.keys.includes(t)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const s=await this.core.crypto.decode(t,i);try{isJsonRpcRequest(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):isJsonRpcResponse(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id));}catch(r){this.logger.error(r);}});}registerExpirerEvents(){this.core.expirer.on(v$5.expired,async e=>{const{topic:t}=ft$2(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(V$3.expire,{topic:t}));});}};class Vt extends h$6{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new EventEmitter$2,this.name=vt,this.version=It$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0);},this.set=(i,s,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:s,chainId:r}),this.records.has(s.id))return;const o={id:s.id,topic:i,request:{method:s.method,params:s.params||null},chainId:r,expiry:pt$2(cjs$5.THIRTY_DAYS)};this.records.set(o.id,o),this.events.emit(R$4.created,o);},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const s=await this.getRecord(i.id);typeof s.response>"u"&&(s.response=isJsonRpcError(i)?{error:i.error}:{result:i.result},this.records.set(s.id,s),this.events.emit(R$4.updated,s));},this.get=async(i,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:s}),await this.getRecord(s)),this.delete=(i,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(r=>{if(r.topic===i){if(typeof s<"u"&&r.id!==s)return;this.records.delete(r.id),this.events.emit(R$4.deleted,r);}});},this.exists=async(i,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===i:!1),this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:formatJsonRpcRequest(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e);}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(R$4.sync);}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values});}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e);}}registerEventListeners(){this.events.on(R$4.created,e=>{const t=R$4.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.events.on(R$4.updated,e=>{const t=R$4.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.events.on(R$4.deleted,e=>{const t=R$4.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist();}),this.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup();});}cleanup(){try{this.records.forEach(e=>{cjs$5.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id));});}catch(e){this.logger.warn(e);}}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}}let qt$1 = class qt extends E$3{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new EventEmitter$2,this.name=Ct$1,this.version=Rt$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$3,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0);},this.has=i=>{try{const s=this.formatTarget(i);return typeof this.getExpiration(s)<"u"}catch{return !1}},this.set=(i,s)=>{this.isInitialized();const r=this.formatTarget(i),o={target:r,expiry:s};this.expirations.set(r,o),this.checkExpiry(r,o),this.events.emit(v$5.created,{target:r,expiration:o});},this.get=i=>{this.isInitialized();const s=this.formatTarget(i);return this.getExpiration(s)},this.del=i=>{if(this.isInitialized(),this.has(i)){const s=this.formatTarget(i),r=this.getExpiration(s);this.expirations.delete(s),this.events.emit(v$5.deleted,{target:s,expiration:r});}},this.on=(i,s)=>{this.events.on(i,s);},this.once=(i,s)=>{this.events.once(i,s);},this.off=(i,s)=>{this.events.off(i,s);},this.removeListener=(i,s)=>{this.events.removeListener(i,s);},this.logger=cjs$1.generateChildLogger(t,this.name);}get context(){return cjs$1.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return lt$2(e);if(typeof e=="number")return dt$2(e);const{message:t}=N$4("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e);}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(v$5.sync);}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=N$4("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values});}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e);}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=N$4("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;cjs$5.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t);}expire(e,t){this.expirations.delete(e),this.events.emit(v$5.expired,{target:e,expiration:t});}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e));}registerEventListeners(){this.core.heartbeat.on(cjs$2.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(v$5.created,e=>{const t=v$5.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(v$5.expired,e=>{const t=v$5.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();}),this.events.on(v$5.deleted,e=>{const t=v$5.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist();});}isInitialized(){if(!this.initialized){const{message:e}=N$4("NOT_INITIALIZED",this.name);throw new Error(e)}}};let jt$1 = class jt extends y$5{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=Z$4,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async i=>{if(this.verifyDisabled||$$3()||!D$8())return;const s=this.getVerifyUrl(i?.verifyUrl);this.verifyUrl!==s&&this.removeIframe(),this.verifyUrl=s;try{await this.createIframe();}catch(r){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(r);}if(!this.initialized){this.removeIframe(),this.verifyUrl=ee$3;try{await this.createIframe();}catch(r){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(r),this.verifyDisabled=!0;}}},this.register=async i=>{this.initialized?this.sendPost(i.attestationId):(this.addToQueue(i.attestationId),await this.init());},this.resolve=async i=>{if(this.isDevEnv)return "";const s=this.getVerifyUrl(i?.verifyUrl);let r;try{r=await this.fetchAttestation(i.attestationId,s);}catch(o){this.logger.info(`failed to resolve attestation: ${i.attestationId} from url: ${s}`),this.logger.info(o),r=await this.fetchAttestation(i.attestationId,ee$3);}return r},this.fetchAttestation=async(i,s)=>{this.logger.info(`resolving attestation: ${i} from url: ${s}`);const r=this.startAbortTimer(cjs$5.ONE_SECOND*2),o=await fetch(`${s}/attestation/${i}`,{signal:this.abortController.signal});return clearTimeout(r),o.status===200?await o.json():void 0},this.addToQueue=i=>{this.queue.push(i);},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(i=>this.sendPost(i)),this.queue=[]);},this.sendPost=i=>{var s;try{if(!this.iframe)return;(s=this.iframe.contentWindow)==null||s.postMessage(i,"*"),this.logger.info(`postMessage sent: ${i} ${this.verifyUrl}`);}catch{}},this.createIframe=async()=>{let i;const s=r=>{r.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",s),i());};await Promise.race([new Promise(r=>{if(document.getElementById(Z$4))return r();window.addEventListener("message",s);const o=document.createElement("iframe");o.id=Z$4,o.src=`${this.verifyUrl}/${this.projectId}`,o.style.display="none",document.body.append(o),this.iframe=o,i=r;}),new Promise((r,o)=>setTimeout(()=>{window.removeEventListener("message",s),o("verify iframe load timeout");},cjs$5.toMiliseconds(cjs$5.FIVE_SECONDS)))]);},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1);},this.getVerifyUrl=i=>{let s=i||F$4;return _t$1.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${F$4}`),s=F$4),s},this.logger=cjs$1.generateChildLogger(t,this.name),this.verifyUrl=F$4,this.abortController=new AbortController,this.isDevEnv=te$4()&&process.env.IS_VITEST;}get context(){return cjs$1.getLoggerContext(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),cjs$5.toMiliseconds(e))}};let Gt$1 = class Gt extends v$6{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=Tt$1,this.registerDeviceToken=async i=>{const{clientId:s,token:r,notificationType:o,enableEncrypted:a=!1}=i,h=`${St$1}/${this.projectId}/clients`;await Yi$1(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:r,always_raw:a})});},this.logger=cjs$1.generateChildLogger(t,this.context);}};var Lr=Object.defineProperty,Yt$1=Object.getOwnPropertySymbols,$r$1=Object.prototype.hasOwnProperty,Fr=Object.prototype.propertyIsEnumerable,Ht$1=(n,e,t)=>e in n?Lr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Jt$1=(n,e)=>{for(var t in e||(e={}))$r$1.call(e,t)&&Ht$1(n,t,e[t]);if(Yt$1)for(var t of Yt$1(e))Fr.call(e,t)&&Ht$1(n,t,e[t]);return n};let te$3 = class te extends n$a{constructor(e){super(e),this.protocol=le$4,this.version=We$2,this.name=Q$5,this.events=new EventEmitter$2,this.initialized=!1,this.on=(i,s)=>this.events.on(i,s),this.once=(i,s)=>this.events.once(i,s),this.off=(i,s)=>this.events.off(i,s),this.removeListener=(i,s)=>this.events.removeListener(i,s),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||ge$4,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:e?.logger||Qe$3.logger}));this.logger=cjs$1.generateChildLogger(t,this.name),this.heartbeat=new cjs$2.HeartBeat,this.crypto=new xt(this,this.logger,e?.keychain),this.history=new Vt(this,this.logger),this.expirer=new qt$1(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new h$7(Jt$1(Jt$1({},Ze$2),e?.storageOptions)),this.relayer=new $t$1({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Bt$1(this,this.logger),this.verify=new jt$1(this.projectId||"",this.logger),this.echoClient=new Gt$1(this.projectId||"",this.logger);}static async init(e){const t=new te(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(yt$1,i),t}get context(){return cjs$1.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize();}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success");}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}};const Mr=te$3;
|
|
146665
146665
|
|
|
146666
|
-
const J$1="wc",F$3=2,X$2="client",G$3=`${J$1}@${F$3}:${X$2}:`,M$4={name:X$2,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},H$3="WALLETCONNECT_DEEPLINK_CHOICE",oe$3="proposal",ae$3="Proposal expired",ce$3="session",L$5=cjs$5.SEVEN_DAYS,le$3="engine",R$3={wc_sessionPropose:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1104},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1106},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1112},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1115}}},U$4={min:cjs$5.FIVE_MINUTES,max:cjs$5.SEVEN_DAYS},I$3={idle:"IDLE",active:"ACTIVE"},pe$2="request",he$3=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var as=Object.defineProperty,cs=Object.defineProperties,ls=Object.getOwnPropertyDescriptors,de$3=Object.getOwnPropertySymbols,ps=Object.prototype.hasOwnProperty,hs=Object.prototype.propertyIsEnumerable,ue$3=(w,r,e)=>r in w?as(w,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[r]=e,g$5=(w,r)=>{for(var e in r||(r={}))ps.call(r,e)&&ue$3(w,e,r[e]);if(de$3)for(var e of de$3(r))hs.call(r,e)&&ue$3(w,e,r[e]);return w},D$5=(w,r)=>cs(w,ls(r));class ds extends w$4{constructor(r){super(r),this.name=le$3,this.events=new EventEmitter$1,this.initialized=!1,this.ignoredPayloadTypes=[_$4],this.requestQueue={state:I$3.idle,queue:[]},this.sessionRequestQueue={state:I$3.idle,queue:[]},this.requestQueueDelay=cjs$5.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(R$3)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue();},cjs$5.toMiliseconds(this.requestQueueDelay)));},this.connect=async e=>{await this.isInitialized();const s=D$5(g$5({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(s);const{pairingTopic:t,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:o,relays:a}=s;let c=t,p,d=!1;if(c&&(d=this.client.core.pairing.pairings.get(c).active),!c||!d){const{topic:T,uri:_}=await this.client.core.pairing.create();c=T,p=_;}const h=await this.client.core.crypto.generateKeyPair(),N=R$3.wc_sessionPropose.req.ttl||cjs$5.FIVE_MINUTES,m=pt$2(N),f=g$5({requiredNamespaces:i,optionalNamespaces:n,relays:a??[{protocol:ht}],proposer:{publicKey:h,metadata:this.client.metadata},expiryTimestamp:m},o&&{sessionProperties:o}),{reject:k,resolve:O,done:we}=at$2(N,ae$3);if(this.events.once(yt$2("session_connect"),async({error:T,session:_})=>{if(T)k(T);else if(_){_.self.publicKey=h;const B=D$5(g$5({},_),{requiredNamespaces:f.requiredNamespaces,optionalNamespaces:f.optionalNamespaces});await this.client.session.set(_.topic,B),await this.setExpiry(_.topic,_.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:_.peer.metadata}),O(B);}}),!c){const{message:T}=N$4("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(T)}const W=await this.sendRequest({topic:c,method:"wc_sessionPropose",params:f,throwOnFailedPublish:!0});return await this.setProposal(W,g$5({id:W},f)),{uri:p,approval:we}},this.pair=async e=>(await this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{await this.isInitialized(),await this.isValidApprove(e);const{id:s,relayProtocol:t,namespaces:i,sessionProperties:n}=e,o=this.client.proposal.get(s);let{pairingTopic:a,proposer:c,requiredNamespaces:p,optionalNamespaces:d}=o;a=a||"";const h=await this.client.core.crypto.generateKeyPair(),N=c.publicKey,m=await this.client.core.crypto.generateSharedKey(h,N);a&&s&&(await this.client.core.pairing.updateMetadata({topic:a,metadata:c.metadata}),await this.sendResult({id:s,topic:a,result:{relay:{protocol:t??"irn"},responderPublicKey:h}}),await this.client.proposal.delete(s,U$5("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:a}));const f=g$5({relay:{protocol:t??"irn"},namespaces:i,pairingTopic:a,controller:{publicKey:h,metadata:this.client.metadata},expiry:pt$2(L$5)},n&&{sessionProperties:n});await this.client.core.relayer.subscribe(m);const k=D$5(g$5({},f),{topic:m,requiredNamespaces:p,optionalNamespaces:d,pairingTopic:a,acknowledged:!1,self:f.controller,peer:{publicKey:c.publicKey,metadata:c.metadata},controller:h});await this.client.session.set(m,k);try{await this.sendRequest({topic:m,method:"wc_sessionSettle",params:f,throwOnFailedPublish:!0});}catch(O){throw this.client.logger.error(O),this.client.session.delete(m,U$5("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(m),O}return await this.setExpiry(m,pt$2(L$5)),{topic:m,acknowledged:()=>new Promise(O=>setTimeout(()=>O(this.client.session.get(m)),500))}},this.reject=async e=>{await this.isInitialized(),await this.isValidReject(e);const{id:s,reason:t}=e,{pairingTopic:i}=this.client.proposal.get(s);i&&(await this.sendError(s,i,t),await this.client.proposal.delete(s,U$5("USER_DISCONNECTED")));},this.update=async e=>{await this.isInitialized(),await this.isValidUpdate(e);const{topic:s,namespaces:t}=e,i=await this.sendRequest({topic:s,method:"wc_sessionUpdate",params:{namespaces:t}}),{done:n,resolve:o,reject:a}=at$2();return this.events.once(yt$2("session_update",i),({error:c})=>{c?a(c):o();}),await this.client.session.update(s,{namespaces:t}),{acknowledged:n}},this.extend=async e=>{await this.isInitialized(),await this.isValidExtend(e);const{topic:s}=e,t=await this.sendRequest({topic:s,method:"wc_sessionExtend",params:{}}),{done:i,resolve:n,reject:o}=at$2();return this.events.once(yt$2("session_extend",t),({error:a})=>{a?o(a):n();}),await this.setExpiry(s,pt$2(L$5)),{acknowledged:i}},this.request=async e=>{await this.isInitialized(),await this.isValidRequest(e);const{chainId:s,request:t,topic:i,expiry:n=R$3.wc_sessionRequest.req.ttl}=e,o=payloadId(),{done:a,resolve:c,reject:p}=at$2(n,"Request expired. Please try again.");return this.events.once(yt$2("session_request",o),({error:d,result:h})=>{d?p(d):c(h);}),await Promise.all([new Promise(async d=>{await this.sendRequest({clientRpcId:o,topic:i,method:"wc_sessionRequest",params:{request:D$5(g$5({},t),{expiryTimestamp:pt$2(n)}),chainId:s},expiry:n,throwOnFailedPublish:!0}).catch(h=>p(h)),this.client.events.emit("session_request_sent",{topic:i,request:t,chainId:s,id:o}),d();}),new Promise(async d=>{const h=await ht$1(this.client.core.storage,H$3);gt$1({id:o,topic:i,wcDeepLink:h}),d();}),a()]).then(d=>d[2])},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:s,response:t}=e,{id:i}=t;isJsonRpcResult(t)?await this.sendResult({id:i,topic:s,result:t.result,throwOnFailedPublish:!0}):isJsonRpcError(t)&&await this.sendError(i,s,t.error),this.cleanupAfterResponse(e);},this.ping=async e=>{await this.isInitialized(),await this.isValidPing(e);const{topic:s}=e;if(this.client.session.keys.includes(s)){const t=await this.sendRequest({topic:s,method:"wc_sessionPing",params:{}}),{done:i,resolve:n,reject:o}=at$2();this.events.once(yt$2("session_ping",t),({error:a})=>{a?o(a):n();}),await i();}else this.client.core.pairing.pairings.keys.includes(s)&&await this.client.core.pairing.ping({topic:s});},this.emit=async e=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:s,event:t,chainId:i}=e;await this.sendRequest({topic:s,method:"wc_sessionEvent",params:{event:t,chainId:i}});},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:s}=e;if(this.client.session.keys.includes(s))await this.sendRequest({topic:s,method:"wc_sessionDelete",params:U$5("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:s,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(s))await this.client.core.pairing.disconnect({topic:s});else {const{message:t}=N$4("MISMATCHED_TOPIC",`Session or pairing topic not found: ${s}`);throw new Error(t)}},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter(s=>Mt$2(s,e))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const s=this.client.core.pairing.pairings.get(e.pairingTopic),t=this.client.core.pairing.pairings.getAll().filter(i=>{var n,o;return ((n=i.peerMetadata)==null?void 0:n.url)&&((o=i.peerMetadata)==null?void 0:o.url)===e.peer.metadata.url&&i.topic&&i.topic!==s.topic});if(t.length===0)return;this.client.logger.info(`Cleaning up ${t.length} duplicate pairing(s)`),await Promise.all(t.map(i=>this.client.core.pairing.disconnect({topic:i.topic}))),this.client.logger.info("Duplicate pairings clean up finished");}catch(s){this.client.logger.error(s);}},this.deleteSession=async e=>{const{topic:s,expirerHasDeleted:t=!1,emitEvent:i=!0,id:n=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,U$5("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),t||this.client.core.expirer.del(s),this.client.core.storage.removeItem(H$3).catch(a=>this.client.logger.warn(a)),this.getPendingSessionRequests().forEach(a=>{a.topic===s&&this.deletePendingSessionRequest(a.id,U$5("USER_DISCONNECTED"));}),i&&this.client.events.emit("session_delete",{id:n,topic:s});},this.deleteProposal=async(e,s)=>{await Promise.all([this.client.proposal.delete(e,U$5("USER_DISCONNECTED")),s?Promise.resolve():this.client.core.expirer.del(e)]);},this.deletePendingSessionRequest=async(e,s,t=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,s),t?Promise.resolve():this.client.core.expirer.del(e)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(i=>i.id!==e),t&&(this.sessionRequestQueue.state=I$3.idle,this.client.events.emit("session_request_expire",{id:e}));},this.setExpiry=async(e,s)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:s}),this.client.core.expirer.set(e,s);},this.setProposal=async(e,s)=>{await this.client.proposal.set(e,s),this.client.core.expirer.set(e,pt$2(R$3.wc_sessionPropose.req.ttl));},this.setPendingSessionRequest=async e=>{const{id:s,topic:t,params:i,verifyContext:n}=e,o=i.request.expiryTimestamp||pt$2(R$3.wc_sessionRequest.req.ttl);await this.client.pendingRequest.set(s,{id:s,topic:t,params:i,verifyContext:n}),o&&this.client.core.expirer.set(s,o);},this.sendRequest=async e=>{const{topic:s,method:t,params:i,expiry:n,relayRpcId:o,clientRpcId:a,throwOnFailedPublish:c}=e,p=formatJsonRpcRequest(t,i,a);if(D$8()&&he$3.includes(t)){const N=Ln(JSON.stringify(p));this.client.core.verify.register({attestationId:N});}const d=await this.client.core.crypto.encode(s,p),h=R$3[t].req;return n&&(h.ttl=n),o&&(h.id=o),this.client.core.history.set(s,p),c?(h.internal=D$5(g$5({},h.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,d,h)):this.client.core.relayer.publish(s,d,h).catch(N=>this.client.logger.error(N)),p.id},this.sendResult=async e=>{const{id:s,topic:t,result:i,throwOnFailedPublish:n}=e,o=formatJsonRpcResult(s,i),a=await this.client.core.crypto.encode(t,o),c=await this.client.core.history.get(t,s),p=R$3[c.request.method].res;n?(p.internal=D$5(g$5({},p.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,a,p)):this.client.core.relayer.publish(t,a,p).catch(d=>this.client.logger.error(d)),await this.client.core.history.resolve(o);},this.sendError=async(e,s,t)=>{const i=formatJsonRpcError(e,t),n=await this.client.core.crypto.encode(s,i),o=await this.client.core.history.get(s,e),a=R$3[o.request.method].res;this.client.core.relayer.publish(s,n,a),await this.client.core.history.resolve(i);},this.cleanup=async()=>{const e=[],s=[];this.client.session.getAll().forEach(t=>{let i=!1;mt$1(t.expiry)&&(i=!0),this.client.core.crypto.keychain.has(t.topic)||(i=!0),i&&e.push(t.topic);}),this.client.proposal.getAll().forEach(t=>{mt$1(t.expiryTimestamp)&&s.push(t.id);}),await Promise.all([...e.map(t=>this.deleteSession({topic:t})),...s.map(t=>this.deleteProposal(t))]);},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue();},this.processRequestsQueue=async()=>{if(this.requestQueue.state===I$3.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=I$3.active;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise(s=>setTimeout(s,300));}catch(s){this.client.logger.warn(s);}}this.requestQueue.state=I$3.idle;},this.processRequest=e=>{const{topic:s,payload:t}=e,i=t.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeRequest(s,t);case"wc_sessionSettle":return this.onSessionSettleRequest(s,t);case"wc_sessionUpdate":return this.onSessionUpdateRequest(s,t);case"wc_sessionExtend":return this.onSessionExtendRequest(s,t);case"wc_sessionPing":return this.onSessionPingRequest(s,t);case"wc_sessionDelete":return this.onSessionDeleteRequest(s,t);case"wc_sessionRequest":return this.onSessionRequest(s,t);case"wc_sessionEvent":return this.onSessionEventRequest(s,t);default:return this.client.logger.info(`Unsupported request method ${i}`)}},this.onRelayEventResponse=async e=>{const{topic:s,payload:t}=e,i=(await this.client.core.history.get(s,t.id)).request.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeResponse(s,t);case"wc_sessionSettle":return this.onSessionSettleResponse(s,t);case"wc_sessionUpdate":return this.onSessionUpdateResponse(s,t);case"wc_sessionExtend":return this.onSessionExtendResponse(s,t);case"wc_sessionPing":return this.onSessionPingResponse(s,t);case"wc_sessionRequest":return this.onSessionRequestResponse(s,t);default:return this.client.logger.info(`Unsupported response method ${i}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:s}=e,{message:t}=N$4("MISSING_OR_INVALID",`Decoded payload on topic ${s} is not identifiable as a JSON-RPC request or a response.`);throw new Error(t)},this.onSessionProposeRequest=async(e,s)=>{const{params:t,id:i}=s;try{this.isValidConnect(g$5({},s.params));const n=t.expiryTimestamp||pt$2(R$3.wc_sessionPropose.req.ttl),o=g$5({id:i,pairingTopic:e,expiryTimestamp:n},t);await this.setProposal(i,o);const a=Ln(JSON.stringify(s)),c=await this.getVerifyContext(a,o.proposer.metadata);this.client.events.emit("session_proposal",{id:i,params:o,verifyContext:c});}catch(n){await this.sendError(i,e,n),this.client.logger.error(n);}},this.onSessionProposeResponse=async(e,s)=>{const{id:t}=s;if(isJsonRpcResult(s)){const{result:i}=s;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:i});const n=this.client.proposal.get(t);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=i.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:c});const p=await this.client.core.relayer.subscribe(c);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:p}),await this.client.core.pairing.activate({topic:e});}else isJsonRpcError(s)&&(await this.client.proposal.delete(t,U$5("USER_DISCONNECTED")),this.events.emit(yt$2("session_connect"),{error:s.error}));},this.onSessionSettleRequest=async(e,s)=>{const{id:t,params:i}=s;try{this.isValidSessionSettleRequest(i);const{relay:n,controller:o,expiry:a,namespaces:c,sessionProperties:p,pairingTopic:d}=s.params,h=g$5({topic:e,relay:n,expiry:a,namespaces:c,acknowledged:!0,pairingTopic:d,requiredNamespaces:{},optionalNamespaces:{},controller:o.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:o.publicKey,metadata:o.metadata}},p&&{sessionProperties:p});await this.sendResult({id:s.id,topic:e,result:!0}),this.events.emit(yt$2("session_connect"),{session:h}),this.cleanupDuplicatePairings(h);}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.onSessionSettleResponse=async(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(yt$2("session_approve",t),{})):isJsonRpcError(s)&&(await this.client.session.delete(e,U$5("USER_DISCONNECTED")),this.events.emit(yt$2("session_approve",t),{error:s.error}));},this.onSessionUpdateRequest=async(e,s)=>{const{params:t,id:i}=s;try{const n=`${e}_session_update`,o=sr$3.get(n);if(o&&this.isRequestOutOfSync(o,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidUpdate(g$5({topic:e},t)),await this.client.session.update(e,{namespaces:t.namespaces}),await this.sendResult({id:i,topic:e,result:!0}),this.client.events.emit("session_update",{id:i,topic:e,params:t}),sr$3.set(n,i);}catch(n){await this.sendError(i,e,n),this.client.logger.error(n);}},this.isRequestOutOfSync=(e,s)=>parseInt(s.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_update",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_update",t),{error:s.error});},this.onSessionExtendRequest=async(e,s)=>{const{id:t}=s;try{this.isValidExtend({topic:e}),await this.setExpiry(e,pt$2(L$5)),await this.sendResult({id:t,topic:e,result:!0}),this.client.events.emit("session_extend",{id:t,topic:e});}catch(i){await this.sendError(t,e,i),this.client.logger.error(i);}},this.onSessionExtendResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_extend",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_extend",t),{error:s.error});},this.onSessionPingRequest=async(e,s)=>{const{id:t}=s;try{this.isValidPing({topic:e}),await this.sendResult({id:t,topic:e,result:!0}),this.client.events.emit("session_ping",{id:t,topic:e});}catch(i){await this.sendError(t,e,i),this.client.logger.error(i);}},this.onSessionPingResponse=(e,s)=>{const{id:t}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(yt$2("session_ping",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_ping",t),{error:s.error});},500);},this.onSessionDeleteRequest=async(e,s)=>{const{id:t}=s;try{this.isValidDisconnect({topic:e,reason:s.params}),await Promise.all([new Promise(i=>{this.client.core.relayer.once(D$6.publish,async()=>{i(await this.deleteSession({topic:e,id:t}));});}),this.sendResult({id:t,topic:e,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:U$5("USER_DISCONNECTED")})]);}catch(i){this.client.logger.error(i);}},this.onSessionRequest=async(e,s)=>{const{id:t,params:i}=s;try{this.isValidRequest(g$5({topic:e},i));const n=Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest",i,t))),o=this.client.session.get(e),a=await this.getVerifyContext(n,o.peer.metadata),c={id:t,topic:e,params:i,verifyContext:a};await this.setPendingSessionRequest(c),this.addSessionRequestToSessionRequestQueue(c),this.processSessionRequestQueue();}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.onSessionRequestResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_request",t),{result:s.result}):isJsonRpcError(s)&&this.events.emit(yt$2("session_request",t),{error:s.error});},this.onSessionEventRequest=async(e,s)=>{const{id:t,params:i}=s;try{const n=`${e}_session_event_${i.event.name}`,o=sr$3.get(n);if(o&&this.isRequestOutOfSync(o,t)){this.client.logger.info(`Discarding out of sync request - ${t}`);return}this.isValidEmit(g$5({topic:e},i)),this.client.events.emit("session_event",{id:t,topic:e,params:i}),sr$3.set(n,t);}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e);},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=I$3.idle,this.processSessionRequestQueue();},cjs$5.toMiliseconds(this.requestQueueDelay));},this.cleanupPendingSentRequestsForTopic=({topic:e,error:s})=>{const t=this.client.core.history.pending;t.length>0&&t.filter(i=>i.topic===e&&i.request.method==="wc_sessionRequest").forEach(i=>{this.events.emit(yt$2("session_request",i.request.id),{error:s});});},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===I$3.active){this.client.logger.info("session request queue is already active.");return}const e=this.sessionRequestQueue.queue[0];if(!e){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=I$3.active,this.client.events.emit("session_request",e);}catch(s){this.client.logger.error(s);}},this.onPairingCreated=e=>{if(e.active)return;const s=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);s&&this.onSessionProposeRequest(e.topic,formatJsonRpcRequest("wc_sessionPropose",{requiredNamespaces:s.requiredNamespaces,optionalNamespaces:s.optionalNamespaces,relays:s.relays,proposer:s.proposer,sessionProperties:s.sessionProperties},s.id));},this.isValidConnect=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(a)}const{pairingTopic:s,requiredNamespaces:t,optionalNamespaces:i,sessionProperties:n,relays:o}=e;if(w$5(s)||await this.isValidPairingTopic(s),!qt$2(o)){const{message:a}=N$4("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(a)}!w$5(t)&&B$5(t)!==0&&this.validateNamespaces(t,"requiredNamespaces"),!w$5(i)&&B$5(i)!==0&&this.validateNamespaces(i,"optionalNamespaces"),w$5(n)||this.validateSessionProps(n,"sessionProperties");},this.validateNamespaces=(e,s)=>{const t=Ht$2(e,"connect()",s);if(t)throw new Error(t.message)},this.isValidApprove=async e=>{if(!Gt$2(e))throw new Error(N$4("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:s,namespaces:t,relayProtocol:i,sessionProperties:n}=e;await this.isValidProposalId(s);const o=this.client.proposal.get(s),a=ln(t,"approve()");if(a)throw new Error(a.message);const c=fn(o.requiredNamespaces,t,"approve()");if(c)throw new Error(c.message);if(!g$8(i,!0)){const{message:p}=N$4("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(p)}w$5(n)||this.validateSessionProps(n,"sessionProperties");},this.isValidReject=async e=>{if(!Gt$2(e)){const{message:i}=N$4("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(i)}const{id:s,reason:t}=e;if(await this.isValidProposalId(s),!Wt$1(t)){const{message:i}=N$4("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(t)}`);throw new Error(i)}},this.isValidSessionSettleRequest=e=>{if(!Gt$2(e)){const{message:c}=N$4("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(c)}const{relay:s,controller:t,namespaces:i,expiry:n}=e;if(!dn(s)){const{message:c}=N$4("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}const o=Ft$1(t,"onSessionSettleRequest()");if(o)throw new Error(o.message);const a=ln(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);if(mt$1(n)){const{message:c}=N$4("EXPIRED","onSessionSettleRequest()");throw new Error(c)}},this.isValidUpdate=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(a)}const{topic:s,namespaces:t}=e;await this.isValidSessionTopic(s);const i=this.client.session.get(s),n=ln(t,"update()");if(n)throw new Error(n.message);const o=fn(i.requiredNamespaces,t,"update()");if(o)throw new Error(o.message)},this.isValidExtend=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionTopic(s);},this.isValidRequest=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(a)}const{topic:s,request:t,chainId:i,expiry:n}=e;await this.isValidSessionTopic(s);const{namespaces:o}=this.client.session.get(s);if(!Qt$1(o,i)){const{message:a}=N$4("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(a)}if(!zt$2(t)){const{message:a}=N$4("MISSING_OR_INVALID",`request() ${JSON.stringify(t)}`);throw new Error(a)}if(!Zt$1(o,i,t.method)){const{message:a}=N$4("MISSING_OR_INVALID",`request() method: ${t.method}`);throw new Error(a)}if(n&&!tr$2(n,U$4)){const{message:a}=N$4("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${U$4.min} and ${U$4.max}`);throw new Error(a)}},this.isValidRespond=async e=>{var s;if(!Gt$2(e)){const{message:n}=N$4("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(n)}const{topic:t,response:i}=e;try{await this.isValidSessionTopic(t);}catch(n){throw (s=e?.response)!=null&&s.id&&this.cleanupAfterResponse(e),n}if(!Yt$2(i)){const{message:n}=N$4("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(n)}},this.isValidPing=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionOrPairingTopic(s);},this.isValidEmit=async e=>{if(!Gt$2(e)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(o)}const{topic:s,event:t,chainId:i}=e;await this.isValidSessionTopic(s);const{namespaces:n}=this.client.session.get(s);if(!Qt$1(n,i)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(o)}if(!Jt$2(t)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(t)}`);throw new Error(o)}if(!Xt$1(n,i,t.name)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(t)}`);throw new Error(o)}},this.isValidDisconnect=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionOrPairingTopic(s);},this.getVerifyContext=async(e,s)=>{const t={verified:{verifyUrl:s.verifyUrl||F$4,validation:"UNKNOWN",origin:s.url||""}};try{const i=await this.client.core.verify.resolve({attestationId:e,verifyUrl:s.verifyUrl});i&&(t.verified.origin=i.origin,t.verified.isScam=i.isScam,t.verified.validation=i.origin===new URL(s.url).origin?"VALID":"INVALID");}catch(i){this.client.logger.info(i);}return this.client.logger.info(`Verify context: ${JSON.stringify(t)}`),t},this.validateSessionProps=(e,s)=>{Object.values(e).forEach(t=>{if(!g$8(t,!1)){const{message:i}=N$4("MISSING_OR_INVALID",`${s} must be in Record<string, string> format. Received: ${JSON.stringify(t)}`);throw new Error(i)}});};}async isInitialized(){if(!this.initialized){const{message:r}=N$4("NOT_INITIALIZED",this.name);throw new Error(r)}await this.client.core.relayer.confirmOnlineStateOrThrow();}registerRelayerEvents(){this.client.core.relayer.on(D$6.message,async r=>{const{topic:e,message:s}=r;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s)))return;const t=await this.client.core.crypto.decode(e,s);try{isJsonRpcRequest(t)?(this.client.core.history.set(e,t),this.onRelayEventRequest({topic:e,payload:t})):isJsonRpcResponse(t)?(await this.client.core.history.resolve(t),await this.onRelayEventResponse({topic:e,payload:t}),this.client.core.history.delete(e,t.id)):this.onRelayEventUnknownPayload({topic:e,payload:t});}catch(i){this.client.logger.error(i);}});}registerExpirerEvents(){this.client.core.expirer.on(v$5.expired,async r=>{const{topic:e,id:s}=ft$2(r.target);if(s&&this.client.pendingRequest.keys.includes(s))return await this.deletePendingSessionRequest(s,N$4("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession({topic:e,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:e})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s}));});}registerPairingEvents(){this.client.core.pairing.events.on(V$3.create,r=>this.onPairingCreated(r));}isValidPairingTopic(r){if(!g$8(r,!1)){const{message:e}=N$4("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.core.pairing.pairings.get(r).expiry)){const{message:e}=N$4("EXPIRED",`pairing topic: ${r}`);throw new Error(e)}}async isValidSessionTopic(r){if(!g$8(r,!1)){const{message:e}=N$4("MISSING_OR_INVALID",`session topic should be a string: ${r}`);throw new Error(e)}if(!this.client.session.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`session topic doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.session.get(r).expiry)){await this.deleteSession({topic:r});const{message:e}=N$4("EXPIRED",`session topic: ${r}`);throw new Error(e)}if(!this.client.core.crypto.keychain.has(r)){const{message:e}=N$4("MISSING_OR_INVALID",`session topic does not exist in keychain: ${r}`);throw await this.deleteSession({topic:r}),new Error(e)}}async isValidSessionOrPairingTopic(r){if(this.client.session.keys.includes(r))await this.isValidSessionTopic(r);else if(this.client.core.pairing.pairings.keys.includes(r))this.isValidPairingTopic(r);else if(g$8(r,!1)){const{message:e}=N$4("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${r}`);throw new Error(e)}else {const{message:e}=N$4("MISSING_OR_INVALID",`session or pairing topic should be a string: ${r}`);throw new Error(e)}}async isValidProposalId(r){if(!Bt$2(r)){const{message:e}=N$4("MISSING_OR_INVALID",`proposal id should be a number: ${r}`);throw new Error(e)}if(!this.client.proposal.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`proposal id doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.proposal.get(r).expiryTimestamp)){await this.deleteProposal(r);const{message:e}=N$4("EXPIRED",`proposal id: ${r}`);throw new Error(e)}}}class us extends Kt$1{constructor(r,e){super(r,e,oe$3,G$3),this.core=r,this.logger=e;}}let ge$3 = class ge extends Kt$1{constructor(r,e){super(r,e,ce$3,G$3),this.core=r,this.logger=e;}};class gs extends Kt$1{constructor(r,e){super(r,e,pe$2,G$3,s=>s.id),this.core=r,this.logger=e;}}let Q$4 = class Q extends b$3{constructor(r){super(r),this.protocol=J$1,this.version=F$3,this.name=M$4.name,this.events=new EventEmitter$1,this.on=(s,t)=>this.events.on(s,t),this.once=(s,t)=>this.events.once(s,t),this.off=(s,t)=>this.events.off(s,t),this.removeListener=(s,t)=>this.events.removeListener(s,t),this.removeAllListeners=s=>this.events.removeAllListeners(s),this.connect=async s=>{try{return await this.engine.connect(s)}catch(t){throw this.logger.error(t.message),t}},this.pair=async s=>{try{return await this.engine.pair(s)}catch(t){throw this.logger.error(t.message),t}},this.approve=async s=>{try{return await this.engine.approve(s)}catch(t){throw this.logger.error(t.message),t}},this.reject=async s=>{try{return await this.engine.reject(s)}catch(t){throw this.logger.error(t.message),t}},this.update=async s=>{try{return await this.engine.update(s)}catch(t){throw this.logger.error(t.message),t}},this.extend=async s=>{try{return await this.engine.extend(s)}catch(t){throw this.logger.error(t.message),t}},this.request=async s=>{try{return await this.engine.request(s)}catch(t){throw this.logger.error(t.message),t}},this.respond=async s=>{try{return await this.engine.respond(s)}catch(t){throw this.logger.error(t.message),t}},this.ping=async s=>{try{return await this.engine.ping(s)}catch(t){throw this.logger.error(t.message),t}},this.emit=async s=>{try{return await this.engine.emit(s)}catch(t){throw this.logger.error(t.message),t}},this.disconnect=async s=>{try{return await this.engine.disconnect(s)}catch(t){throw this.logger.error(t.message),t}},this.find=s=>{try{return this.engine.find(s)}catch(t){throw this.logger.error(t.message),t}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(s){throw this.logger.error(s.message),s}},this.name=r?.name||M$4.name,this.metadata=r?.metadata||Qn();const e=typeof r?.logger<"u"&&typeof r?.logger!="string"?r.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:r?.logger||M$4.logger}));this.core=r?.core||new Mr(r),this.logger=cjs$1.generateChildLogger(e,this.name),this.session=new ge$3(this.core,this.logger),this.proposal=new us(this.core,this.logger),this.pendingRequest=new gs(this.core,this.logger),this.engine=new ds(this);}static async init(r){const e=new Q(r);return await e.initialize(),e}get context(){return cjs$1.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success");}catch(r){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(r.message),r}}};
|
|
146666
|
+
const J$1="wc",F$3=2,X$2="client",G$3=`${J$1}@${F$3}:${X$2}:`,M$4={name:X$2,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},H$3="WALLETCONNECT_DEEPLINK_CHOICE",oe$3="proposal",ae$3="Proposal expired",ce$3="session",L$5=cjs$5.SEVEN_DAYS,le$3="engine",R$3={wc_sessionPropose:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1104},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1106},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:cjs$5.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:cjs$5.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1112},res:{ttl:cjs$5.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:cjs$5.THIRTY_SECONDS,prompt:!1,tag:1115}}},U$4={min:cjs$5.FIVE_MINUTES,max:cjs$5.SEVEN_DAYS},I$3={idle:"IDLE",active:"ACTIVE"},pe$2="request",he$3=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var as=Object.defineProperty,cs=Object.defineProperties,ls=Object.getOwnPropertyDescriptors,de$3=Object.getOwnPropertySymbols,ps=Object.prototype.hasOwnProperty,hs=Object.prototype.propertyIsEnumerable,ue$3=(w,r,e)=>r in w?as(w,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[r]=e,g$5=(w,r)=>{for(var e in r||(r={}))ps.call(r,e)&&ue$3(w,e,r[e]);if(de$3)for(var e of de$3(r))hs.call(r,e)&&ue$3(w,e,r[e]);return w},D$5=(w,r)=>cs(w,ls(r));class ds extends w$4{constructor(r){super(r),this.name=le$3,this.events=new EventEmitter$2,this.initialized=!1,this.ignoredPayloadTypes=[_$4],this.requestQueue={state:I$3.idle,queue:[]},this.sessionRequestQueue={state:I$3.idle,queue:[]},this.requestQueueDelay=cjs$5.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(R$3)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue();},cjs$5.toMiliseconds(this.requestQueueDelay)));},this.connect=async e=>{await this.isInitialized();const s=D$5(g$5({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(s);const{pairingTopic:t,requiredNamespaces:i,optionalNamespaces:n,sessionProperties:o,relays:a}=s;let c=t,p,d=!1;if(c&&(d=this.client.core.pairing.pairings.get(c).active),!c||!d){const{topic:T,uri:_}=await this.client.core.pairing.create();c=T,p=_;}const h=await this.client.core.crypto.generateKeyPair(),N=R$3.wc_sessionPropose.req.ttl||cjs$5.FIVE_MINUTES,m=pt$2(N),f=g$5({requiredNamespaces:i,optionalNamespaces:n,relays:a??[{protocol:ht}],proposer:{publicKey:h,metadata:this.client.metadata},expiryTimestamp:m},o&&{sessionProperties:o}),{reject:k,resolve:O,done:we}=at$2(N,ae$3);if(this.events.once(yt$2("session_connect"),async({error:T,session:_})=>{if(T)k(T);else if(_){_.self.publicKey=h;const B=D$5(g$5({},_),{requiredNamespaces:f.requiredNamespaces,optionalNamespaces:f.optionalNamespaces});await this.client.session.set(_.topic,B),await this.setExpiry(_.topic,_.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:_.peer.metadata}),O(B);}}),!c){const{message:T}=N$4("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(T)}const W=await this.sendRequest({topic:c,method:"wc_sessionPropose",params:f,throwOnFailedPublish:!0});return await this.setProposal(W,g$5({id:W},f)),{uri:p,approval:we}},this.pair=async e=>(await this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{await this.isInitialized(),await this.isValidApprove(e);const{id:s,relayProtocol:t,namespaces:i,sessionProperties:n}=e,o=this.client.proposal.get(s);let{pairingTopic:a,proposer:c,requiredNamespaces:p,optionalNamespaces:d}=o;a=a||"";const h=await this.client.core.crypto.generateKeyPair(),N=c.publicKey,m=await this.client.core.crypto.generateSharedKey(h,N);a&&s&&(await this.client.core.pairing.updateMetadata({topic:a,metadata:c.metadata}),await this.sendResult({id:s,topic:a,result:{relay:{protocol:t??"irn"},responderPublicKey:h}}),await this.client.proposal.delete(s,U$5("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:a}));const f=g$5({relay:{protocol:t??"irn"},namespaces:i,pairingTopic:a,controller:{publicKey:h,metadata:this.client.metadata},expiry:pt$2(L$5)},n&&{sessionProperties:n});await this.client.core.relayer.subscribe(m);const k=D$5(g$5({},f),{topic:m,requiredNamespaces:p,optionalNamespaces:d,pairingTopic:a,acknowledged:!1,self:f.controller,peer:{publicKey:c.publicKey,metadata:c.metadata},controller:h});await this.client.session.set(m,k);try{await this.sendRequest({topic:m,method:"wc_sessionSettle",params:f,throwOnFailedPublish:!0});}catch(O){throw this.client.logger.error(O),this.client.session.delete(m,U$5("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(m),O}return await this.setExpiry(m,pt$2(L$5)),{topic:m,acknowledged:()=>new Promise(O=>setTimeout(()=>O(this.client.session.get(m)),500))}},this.reject=async e=>{await this.isInitialized(),await this.isValidReject(e);const{id:s,reason:t}=e,{pairingTopic:i}=this.client.proposal.get(s);i&&(await this.sendError(s,i,t),await this.client.proposal.delete(s,U$5("USER_DISCONNECTED")));},this.update=async e=>{await this.isInitialized(),await this.isValidUpdate(e);const{topic:s,namespaces:t}=e,i=await this.sendRequest({topic:s,method:"wc_sessionUpdate",params:{namespaces:t}}),{done:n,resolve:o,reject:a}=at$2();return this.events.once(yt$2("session_update",i),({error:c})=>{c?a(c):o();}),await this.client.session.update(s,{namespaces:t}),{acknowledged:n}},this.extend=async e=>{await this.isInitialized(),await this.isValidExtend(e);const{topic:s}=e,t=await this.sendRequest({topic:s,method:"wc_sessionExtend",params:{}}),{done:i,resolve:n,reject:o}=at$2();return this.events.once(yt$2("session_extend",t),({error:a})=>{a?o(a):n();}),await this.setExpiry(s,pt$2(L$5)),{acknowledged:i}},this.request=async e=>{await this.isInitialized(),await this.isValidRequest(e);const{chainId:s,request:t,topic:i,expiry:n=R$3.wc_sessionRequest.req.ttl}=e,o=payloadId(),{done:a,resolve:c,reject:p}=at$2(n,"Request expired. Please try again.");return this.events.once(yt$2("session_request",o),({error:d,result:h})=>{d?p(d):c(h);}),await Promise.all([new Promise(async d=>{await this.sendRequest({clientRpcId:o,topic:i,method:"wc_sessionRequest",params:{request:D$5(g$5({},t),{expiryTimestamp:pt$2(n)}),chainId:s},expiry:n,throwOnFailedPublish:!0}).catch(h=>p(h)),this.client.events.emit("session_request_sent",{topic:i,request:t,chainId:s,id:o}),d();}),new Promise(async d=>{const h=await ht$1(this.client.core.storage,H$3);gt$1({id:o,topic:i,wcDeepLink:h}),d();}),a()]).then(d=>d[2])},this.respond=async e=>{await this.isInitialized(),await this.isValidRespond(e);const{topic:s,response:t}=e,{id:i}=t;isJsonRpcResult(t)?await this.sendResult({id:i,topic:s,result:t.result,throwOnFailedPublish:!0}):isJsonRpcError(t)&&await this.sendError(i,s,t.error),this.cleanupAfterResponse(e);},this.ping=async e=>{await this.isInitialized(),await this.isValidPing(e);const{topic:s}=e;if(this.client.session.keys.includes(s)){const t=await this.sendRequest({topic:s,method:"wc_sessionPing",params:{}}),{done:i,resolve:n,reject:o}=at$2();this.events.once(yt$2("session_ping",t),({error:a})=>{a?o(a):n();}),await i();}else this.client.core.pairing.pairings.keys.includes(s)&&await this.client.core.pairing.ping({topic:s});},this.emit=async e=>{await this.isInitialized(),await this.isValidEmit(e);const{topic:s,event:t,chainId:i}=e;await this.sendRequest({topic:s,method:"wc_sessionEvent",params:{event:t,chainId:i}});},this.disconnect=async e=>{await this.isInitialized(),await this.isValidDisconnect(e);const{topic:s}=e;if(this.client.session.keys.includes(s))await this.sendRequest({topic:s,method:"wc_sessionDelete",params:U$5("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:s,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(s))await this.client.core.pairing.disconnect({topic:s});else {const{message:t}=N$4("MISMATCHED_TOPIC",`Session or pairing topic not found: ${s}`);throw new Error(t)}},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter(s=>Mt$2(s,e))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const s=this.client.core.pairing.pairings.get(e.pairingTopic),t=this.client.core.pairing.pairings.getAll().filter(i=>{var n,o;return ((n=i.peerMetadata)==null?void 0:n.url)&&((o=i.peerMetadata)==null?void 0:o.url)===e.peer.metadata.url&&i.topic&&i.topic!==s.topic});if(t.length===0)return;this.client.logger.info(`Cleaning up ${t.length} duplicate pairing(s)`),await Promise.all(t.map(i=>this.client.core.pairing.disconnect({topic:i.topic}))),this.client.logger.info("Duplicate pairings clean up finished");}catch(s){this.client.logger.error(s);}},this.deleteSession=async e=>{const{topic:s,expirerHasDeleted:t=!1,emitEvent:i=!0,id:n=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,U$5("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),t||this.client.core.expirer.del(s),this.client.core.storage.removeItem(H$3).catch(a=>this.client.logger.warn(a)),this.getPendingSessionRequests().forEach(a=>{a.topic===s&&this.deletePendingSessionRequest(a.id,U$5("USER_DISCONNECTED"));}),i&&this.client.events.emit("session_delete",{id:n,topic:s});},this.deleteProposal=async(e,s)=>{await Promise.all([this.client.proposal.delete(e,U$5("USER_DISCONNECTED")),s?Promise.resolve():this.client.core.expirer.del(e)]);},this.deletePendingSessionRequest=async(e,s,t=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,s),t?Promise.resolve():this.client.core.expirer.del(e)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(i=>i.id!==e),t&&(this.sessionRequestQueue.state=I$3.idle,this.client.events.emit("session_request_expire",{id:e}));},this.setExpiry=async(e,s)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:s}),this.client.core.expirer.set(e,s);},this.setProposal=async(e,s)=>{await this.client.proposal.set(e,s),this.client.core.expirer.set(e,pt$2(R$3.wc_sessionPropose.req.ttl));},this.setPendingSessionRequest=async e=>{const{id:s,topic:t,params:i,verifyContext:n}=e,o=i.request.expiryTimestamp||pt$2(R$3.wc_sessionRequest.req.ttl);await this.client.pendingRequest.set(s,{id:s,topic:t,params:i,verifyContext:n}),o&&this.client.core.expirer.set(s,o);},this.sendRequest=async e=>{const{topic:s,method:t,params:i,expiry:n,relayRpcId:o,clientRpcId:a,throwOnFailedPublish:c}=e,p=formatJsonRpcRequest(t,i,a);if(D$8()&&he$3.includes(t)){const N=Ln(JSON.stringify(p));this.client.core.verify.register({attestationId:N});}const d=await this.client.core.crypto.encode(s,p),h=R$3[t].req;return n&&(h.ttl=n),o&&(h.id=o),this.client.core.history.set(s,p),c?(h.internal=D$5(g$5({},h.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,d,h)):this.client.core.relayer.publish(s,d,h).catch(N=>this.client.logger.error(N)),p.id},this.sendResult=async e=>{const{id:s,topic:t,result:i,throwOnFailedPublish:n}=e,o=formatJsonRpcResult(s,i),a=await this.client.core.crypto.encode(t,o),c=await this.client.core.history.get(t,s),p=R$3[c.request.method].res;n?(p.internal=D$5(g$5({},p.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,a,p)):this.client.core.relayer.publish(t,a,p).catch(d=>this.client.logger.error(d)),await this.client.core.history.resolve(o);},this.sendError=async(e,s,t)=>{const i=formatJsonRpcError(e,t),n=await this.client.core.crypto.encode(s,i),o=await this.client.core.history.get(s,e),a=R$3[o.request.method].res;this.client.core.relayer.publish(s,n,a),await this.client.core.history.resolve(i);},this.cleanup=async()=>{const e=[],s=[];this.client.session.getAll().forEach(t=>{let i=!1;mt$1(t.expiry)&&(i=!0),this.client.core.crypto.keychain.has(t.topic)||(i=!0),i&&e.push(t.topic);}),this.client.proposal.getAll().forEach(t=>{mt$1(t.expiryTimestamp)&&s.push(t.id);}),await Promise.all([...e.map(t=>this.deleteSession({topic:t})),...s.map(t=>this.deleteProposal(t))]);},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue();},this.processRequestsQueue=async()=>{if(this.requestQueue.state===I$3.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=I$3.active;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise(s=>setTimeout(s,300));}catch(s){this.client.logger.warn(s);}}this.requestQueue.state=I$3.idle;},this.processRequest=e=>{const{topic:s,payload:t}=e,i=t.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeRequest(s,t);case"wc_sessionSettle":return this.onSessionSettleRequest(s,t);case"wc_sessionUpdate":return this.onSessionUpdateRequest(s,t);case"wc_sessionExtend":return this.onSessionExtendRequest(s,t);case"wc_sessionPing":return this.onSessionPingRequest(s,t);case"wc_sessionDelete":return this.onSessionDeleteRequest(s,t);case"wc_sessionRequest":return this.onSessionRequest(s,t);case"wc_sessionEvent":return this.onSessionEventRequest(s,t);default:return this.client.logger.info(`Unsupported request method ${i}`)}},this.onRelayEventResponse=async e=>{const{topic:s,payload:t}=e,i=(await this.client.core.history.get(s,t.id)).request.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeResponse(s,t);case"wc_sessionSettle":return this.onSessionSettleResponse(s,t);case"wc_sessionUpdate":return this.onSessionUpdateResponse(s,t);case"wc_sessionExtend":return this.onSessionExtendResponse(s,t);case"wc_sessionPing":return this.onSessionPingResponse(s,t);case"wc_sessionRequest":return this.onSessionRequestResponse(s,t);default:return this.client.logger.info(`Unsupported response method ${i}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:s}=e,{message:t}=N$4("MISSING_OR_INVALID",`Decoded payload on topic ${s} is not identifiable as a JSON-RPC request or a response.`);throw new Error(t)},this.onSessionProposeRequest=async(e,s)=>{const{params:t,id:i}=s;try{this.isValidConnect(g$5({},s.params));const n=t.expiryTimestamp||pt$2(R$3.wc_sessionPropose.req.ttl),o=g$5({id:i,pairingTopic:e,expiryTimestamp:n},t);await this.setProposal(i,o);const a=Ln(JSON.stringify(s)),c=await this.getVerifyContext(a,o.proposer.metadata);this.client.events.emit("session_proposal",{id:i,params:o,verifyContext:c});}catch(n){await this.sendError(i,e,n),this.client.logger.error(n);}},this.onSessionProposeResponse=async(e,s)=>{const{id:t}=s;if(isJsonRpcResult(s)){const{result:i}=s;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:i});const n=this.client.proposal.get(t);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=i.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:c});const p=await this.client.core.relayer.subscribe(c);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:p}),await this.client.core.pairing.activate({topic:e});}else isJsonRpcError(s)&&(await this.client.proposal.delete(t,U$5("USER_DISCONNECTED")),this.events.emit(yt$2("session_connect"),{error:s.error}));},this.onSessionSettleRequest=async(e,s)=>{const{id:t,params:i}=s;try{this.isValidSessionSettleRequest(i);const{relay:n,controller:o,expiry:a,namespaces:c,sessionProperties:p,pairingTopic:d}=s.params,h=g$5({topic:e,relay:n,expiry:a,namespaces:c,acknowledged:!0,pairingTopic:d,requiredNamespaces:{},optionalNamespaces:{},controller:o.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:o.publicKey,metadata:o.metadata}},p&&{sessionProperties:p});await this.sendResult({id:s.id,topic:e,result:!0}),this.events.emit(yt$2("session_connect"),{session:h}),this.cleanupDuplicatePairings(h);}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.onSessionSettleResponse=async(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(yt$2("session_approve",t),{})):isJsonRpcError(s)&&(await this.client.session.delete(e,U$5("USER_DISCONNECTED")),this.events.emit(yt$2("session_approve",t),{error:s.error}));},this.onSessionUpdateRequest=async(e,s)=>{const{params:t,id:i}=s;try{const n=`${e}_session_update`,o=sr$3.get(n);if(o&&this.isRequestOutOfSync(o,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidUpdate(g$5({topic:e},t)),await this.client.session.update(e,{namespaces:t.namespaces}),await this.sendResult({id:i,topic:e,result:!0}),this.client.events.emit("session_update",{id:i,topic:e,params:t}),sr$3.set(n,i);}catch(n){await this.sendError(i,e,n),this.client.logger.error(n);}},this.isRequestOutOfSync=(e,s)=>parseInt(s.toString().slice(0,-3))<=parseInt(e.toString().slice(0,-3)),this.onSessionUpdateResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_update",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_update",t),{error:s.error});},this.onSessionExtendRequest=async(e,s)=>{const{id:t}=s;try{this.isValidExtend({topic:e}),await this.setExpiry(e,pt$2(L$5)),await this.sendResult({id:t,topic:e,result:!0}),this.client.events.emit("session_extend",{id:t,topic:e});}catch(i){await this.sendError(t,e,i),this.client.logger.error(i);}},this.onSessionExtendResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_extend",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_extend",t),{error:s.error});},this.onSessionPingRequest=async(e,s)=>{const{id:t}=s;try{this.isValidPing({topic:e}),await this.sendResult({id:t,topic:e,result:!0}),this.client.events.emit("session_ping",{id:t,topic:e});}catch(i){await this.sendError(t,e,i),this.client.logger.error(i);}},this.onSessionPingResponse=(e,s)=>{const{id:t}=s;setTimeout(()=>{isJsonRpcResult(s)?this.events.emit(yt$2("session_ping",t),{}):isJsonRpcError(s)&&this.events.emit(yt$2("session_ping",t),{error:s.error});},500);},this.onSessionDeleteRequest=async(e,s)=>{const{id:t}=s;try{this.isValidDisconnect({topic:e,reason:s.params}),await Promise.all([new Promise(i=>{this.client.core.relayer.once(D$6.publish,async()=>{i(await this.deleteSession({topic:e,id:t}));});}),this.sendResult({id:t,topic:e,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:U$5("USER_DISCONNECTED")})]);}catch(i){this.client.logger.error(i);}},this.onSessionRequest=async(e,s)=>{const{id:t,params:i}=s;try{this.isValidRequest(g$5({topic:e},i));const n=Ln(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest",i,t))),o=this.client.session.get(e),a=await this.getVerifyContext(n,o.peer.metadata),c={id:t,topic:e,params:i,verifyContext:a};await this.setPendingSessionRequest(c),this.addSessionRequestToSessionRequestQueue(c),this.processSessionRequestQueue();}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.onSessionRequestResponse=(e,s)=>{const{id:t}=s;isJsonRpcResult(s)?this.events.emit(yt$2("session_request",t),{result:s.result}):isJsonRpcError(s)&&this.events.emit(yt$2("session_request",t),{error:s.error});},this.onSessionEventRequest=async(e,s)=>{const{id:t,params:i}=s;try{const n=`${e}_session_event_${i.event.name}`,o=sr$3.get(n);if(o&&this.isRequestOutOfSync(o,t)){this.client.logger.info(`Discarding out of sync request - ${t}`);return}this.isValidEmit(g$5({topic:e},i)),this.client.events.emit("session_event",{id:t,topic:e,params:i}),sr$3.set(n,t);}catch(n){await this.sendError(t,e,n),this.client.logger.error(n);}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e);},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=I$3.idle,this.processSessionRequestQueue();},cjs$5.toMiliseconds(this.requestQueueDelay));},this.cleanupPendingSentRequestsForTopic=({topic:e,error:s})=>{const t=this.client.core.history.pending;t.length>0&&t.filter(i=>i.topic===e&&i.request.method==="wc_sessionRequest").forEach(i=>{this.events.emit(yt$2("session_request",i.request.id),{error:s});});},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===I$3.active){this.client.logger.info("session request queue is already active.");return}const e=this.sessionRequestQueue.queue[0];if(!e){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=I$3.active,this.client.events.emit("session_request",e);}catch(s){this.client.logger.error(s);}},this.onPairingCreated=e=>{if(e.active)return;const s=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);s&&this.onSessionProposeRequest(e.topic,formatJsonRpcRequest("wc_sessionPropose",{requiredNamespaces:s.requiredNamespaces,optionalNamespaces:s.optionalNamespaces,relays:s.relays,proposer:s.proposer,sessionProperties:s.sessionProperties},s.id));},this.isValidConnect=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(a)}const{pairingTopic:s,requiredNamespaces:t,optionalNamespaces:i,sessionProperties:n,relays:o}=e;if(w$5(s)||await this.isValidPairingTopic(s),!qt$2(o)){const{message:a}=N$4("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(a)}!w$5(t)&&B$5(t)!==0&&this.validateNamespaces(t,"requiredNamespaces"),!w$5(i)&&B$5(i)!==0&&this.validateNamespaces(i,"optionalNamespaces"),w$5(n)||this.validateSessionProps(n,"sessionProperties");},this.validateNamespaces=(e,s)=>{const t=Ht$2(e,"connect()",s);if(t)throw new Error(t.message)},this.isValidApprove=async e=>{if(!Gt$2(e))throw new Error(N$4("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:s,namespaces:t,relayProtocol:i,sessionProperties:n}=e;await this.isValidProposalId(s);const o=this.client.proposal.get(s),a=ln(t,"approve()");if(a)throw new Error(a.message);const c=fn(o.requiredNamespaces,t,"approve()");if(c)throw new Error(c.message);if(!g$8(i,!0)){const{message:p}=N$4("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(p)}w$5(n)||this.validateSessionProps(n,"sessionProperties");},this.isValidReject=async e=>{if(!Gt$2(e)){const{message:i}=N$4("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(i)}const{id:s,reason:t}=e;if(await this.isValidProposalId(s),!Wt$1(t)){const{message:i}=N$4("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(t)}`);throw new Error(i)}},this.isValidSessionSettleRequest=e=>{if(!Gt$2(e)){const{message:c}=N$4("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(c)}const{relay:s,controller:t,namespaces:i,expiry:n}=e;if(!dn(s)){const{message:c}=N$4("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}const o=Ft$1(t,"onSessionSettleRequest()");if(o)throw new Error(o.message);const a=ln(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);if(mt$1(n)){const{message:c}=N$4("EXPIRED","onSessionSettleRequest()");throw new Error(c)}},this.isValidUpdate=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(a)}const{topic:s,namespaces:t}=e;await this.isValidSessionTopic(s);const i=this.client.session.get(s),n=ln(t,"update()");if(n)throw new Error(n.message);const o=fn(i.requiredNamespaces,t,"update()");if(o)throw new Error(o.message)},this.isValidExtend=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionTopic(s);},this.isValidRequest=async e=>{if(!Gt$2(e)){const{message:a}=N$4("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(a)}const{topic:s,request:t,chainId:i,expiry:n}=e;await this.isValidSessionTopic(s);const{namespaces:o}=this.client.session.get(s);if(!Qt$1(o,i)){const{message:a}=N$4("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(a)}if(!zt$2(t)){const{message:a}=N$4("MISSING_OR_INVALID",`request() ${JSON.stringify(t)}`);throw new Error(a)}if(!Zt$1(o,i,t.method)){const{message:a}=N$4("MISSING_OR_INVALID",`request() method: ${t.method}`);throw new Error(a)}if(n&&!tr$2(n,U$4)){const{message:a}=N$4("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${U$4.min} and ${U$4.max}`);throw new Error(a)}},this.isValidRespond=async e=>{var s;if(!Gt$2(e)){const{message:n}=N$4("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(n)}const{topic:t,response:i}=e;try{await this.isValidSessionTopic(t);}catch(n){throw (s=e?.response)!=null&&s.id&&this.cleanupAfterResponse(e),n}if(!Yt$2(i)){const{message:n}=N$4("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(n)}},this.isValidPing=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionOrPairingTopic(s);},this.isValidEmit=async e=>{if(!Gt$2(e)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(o)}const{topic:s,event:t,chainId:i}=e;await this.isValidSessionTopic(s);const{namespaces:n}=this.client.session.get(s);if(!Qt$1(n,i)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(o)}if(!Jt$2(t)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(t)}`);throw new Error(o)}if(!Xt$1(n,i,t.name)){const{message:o}=N$4("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(t)}`);throw new Error(o)}},this.isValidDisconnect=async e=>{if(!Gt$2(e)){const{message:t}=N$4("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:s}=e;await this.isValidSessionOrPairingTopic(s);},this.getVerifyContext=async(e,s)=>{const t={verified:{verifyUrl:s.verifyUrl||F$4,validation:"UNKNOWN",origin:s.url||""}};try{const i=await this.client.core.verify.resolve({attestationId:e,verifyUrl:s.verifyUrl});i&&(t.verified.origin=i.origin,t.verified.isScam=i.isScam,t.verified.validation=i.origin===new URL(s.url).origin?"VALID":"INVALID");}catch(i){this.client.logger.info(i);}return this.client.logger.info(`Verify context: ${JSON.stringify(t)}`),t},this.validateSessionProps=(e,s)=>{Object.values(e).forEach(t=>{if(!g$8(t,!1)){const{message:i}=N$4("MISSING_OR_INVALID",`${s} must be in Record<string, string> format. Received: ${JSON.stringify(t)}`);throw new Error(i)}});};}async isInitialized(){if(!this.initialized){const{message:r}=N$4("NOT_INITIALIZED",this.name);throw new Error(r)}await this.client.core.relayer.confirmOnlineStateOrThrow();}registerRelayerEvents(){this.client.core.relayer.on(D$6.message,async r=>{const{topic:e,message:s}=r;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s)))return;const t=await this.client.core.crypto.decode(e,s);try{isJsonRpcRequest(t)?(this.client.core.history.set(e,t),this.onRelayEventRequest({topic:e,payload:t})):isJsonRpcResponse(t)?(await this.client.core.history.resolve(t),await this.onRelayEventResponse({topic:e,payload:t}),this.client.core.history.delete(e,t.id)):this.onRelayEventUnknownPayload({topic:e,payload:t});}catch(i){this.client.logger.error(i);}});}registerExpirerEvents(){this.client.core.expirer.on(v$5.expired,async r=>{const{topic:e,id:s}=ft$2(r.target);if(s&&this.client.pendingRequest.keys.includes(s))return await this.deletePendingSessionRequest(s,N$4("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession({topic:e,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:e})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s}));});}registerPairingEvents(){this.client.core.pairing.events.on(V$3.create,r=>this.onPairingCreated(r));}isValidPairingTopic(r){if(!g$8(r,!1)){const{message:e}=N$4("MISSING_OR_INVALID",`pairing topic should be a string: ${r}`);throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`pairing topic doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.core.pairing.pairings.get(r).expiry)){const{message:e}=N$4("EXPIRED",`pairing topic: ${r}`);throw new Error(e)}}async isValidSessionTopic(r){if(!g$8(r,!1)){const{message:e}=N$4("MISSING_OR_INVALID",`session topic should be a string: ${r}`);throw new Error(e)}if(!this.client.session.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`session topic doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.session.get(r).expiry)){await this.deleteSession({topic:r});const{message:e}=N$4("EXPIRED",`session topic: ${r}`);throw new Error(e)}if(!this.client.core.crypto.keychain.has(r)){const{message:e}=N$4("MISSING_OR_INVALID",`session topic does not exist in keychain: ${r}`);throw await this.deleteSession({topic:r}),new Error(e)}}async isValidSessionOrPairingTopic(r){if(this.client.session.keys.includes(r))await this.isValidSessionTopic(r);else if(this.client.core.pairing.pairings.keys.includes(r))this.isValidPairingTopic(r);else if(g$8(r,!1)){const{message:e}=N$4("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${r}`);throw new Error(e)}else {const{message:e}=N$4("MISSING_OR_INVALID",`session or pairing topic should be a string: ${r}`);throw new Error(e)}}async isValidProposalId(r){if(!Bt$2(r)){const{message:e}=N$4("MISSING_OR_INVALID",`proposal id should be a number: ${r}`);throw new Error(e)}if(!this.client.proposal.keys.includes(r)){const{message:e}=N$4("NO_MATCHING_KEY",`proposal id doesn't exist: ${r}`);throw new Error(e)}if(mt$1(this.client.proposal.get(r).expiryTimestamp)){await this.deleteProposal(r);const{message:e}=N$4("EXPIRED",`proposal id: ${r}`);throw new Error(e)}}}class us extends Kt$1{constructor(r,e){super(r,e,oe$3,G$3),this.core=r,this.logger=e;}}let ge$3 = class ge extends Kt$1{constructor(r,e){super(r,e,ce$3,G$3),this.core=r,this.logger=e;}};class gs extends Kt$1{constructor(r,e){super(r,e,pe$2,G$3,s=>s.id),this.core=r,this.logger=e;}}let Q$4 = class Q extends b$3{constructor(r){super(r),this.protocol=J$1,this.version=F$3,this.name=M$4.name,this.events=new EventEmitter$2,this.on=(s,t)=>this.events.on(s,t),this.once=(s,t)=>this.events.once(s,t),this.off=(s,t)=>this.events.off(s,t),this.removeListener=(s,t)=>this.events.removeListener(s,t),this.removeAllListeners=s=>this.events.removeAllListeners(s),this.connect=async s=>{try{return await this.engine.connect(s)}catch(t){throw this.logger.error(t.message),t}},this.pair=async s=>{try{return await this.engine.pair(s)}catch(t){throw this.logger.error(t.message),t}},this.approve=async s=>{try{return await this.engine.approve(s)}catch(t){throw this.logger.error(t.message),t}},this.reject=async s=>{try{return await this.engine.reject(s)}catch(t){throw this.logger.error(t.message),t}},this.update=async s=>{try{return await this.engine.update(s)}catch(t){throw this.logger.error(t.message),t}},this.extend=async s=>{try{return await this.engine.extend(s)}catch(t){throw this.logger.error(t.message),t}},this.request=async s=>{try{return await this.engine.request(s)}catch(t){throw this.logger.error(t.message),t}},this.respond=async s=>{try{return await this.engine.respond(s)}catch(t){throw this.logger.error(t.message),t}},this.ping=async s=>{try{return await this.engine.ping(s)}catch(t){throw this.logger.error(t.message),t}},this.emit=async s=>{try{return await this.engine.emit(s)}catch(t){throw this.logger.error(t.message),t}},this.disconnect=async s=>{try{return await this.engine.disconnect(s)}catch(t){throw this.logger.error(t.message),t}},this.find=s=>{try{return this.engine.find(s)}catch(t){throw this.logger.error(t.message),t}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(s){throw this.logger.error(s.message),s}},this.name=r?.name||M$4.name,this.metadata=r?.metadata||Qn();const e=typeof r?.logger<"u"&&typeof r?.logger!="string"?r.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:r?.logger||M$4.logger}));this.core=r?.core||new Mr(r),this.logger=cjs$1.generateChildLogger(e,this.name),this.session=new ge$3(this.core,this.logger),this.proposal=new us(this.core,this.logger),this.pendingRequest=new gs(this.core,this.logger),this.engine=new ds(this);}static async init(r){const e=new Q(r);return await e.initialize(),e}get context(){return cjs$1.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success");}catch(r){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(r.message),r}}};
|
|
146667
146667
|
|
|
146668
146668
|
var browserPonyfill = {exports: {}};
|
|
146669
146669
|
|
|
@@ -147241,7 +147241,7 @@
|
|
|
147241
147241
|
constructor(url, disableProviderPing = false) {
|
|
147242
147242
|
this.url = url;
|
|
147243
147243
|
this.disableProviderPing = disableProviderPing;
|
|
147244
|
-
this.events = new EventEmitter$
|
|
147244
|
+
this.events = new EventEmitter$2();
|
|
147245
147245
|
this.isAvailable = false;
|
|
147246
147246
|
this.registering = false;
|
|
147247
147247
|
if (!isHttpUrl(url)) {
|
|
@@ -147389,9 +147389,9 @@ __p += '`),$&&(m+=`' +
|
|
|
147389
147389
|
function print() { __p += __j.call(arguments, '') }
|
|
147390
147390
|
`:`;
|
|
147391
147391
|
`)+m+`return __p
|
|
147392
|
-
}`;var b=_a(function(){return U(o,I+"return "+m).apply(i,f)});if(b.source=m,Ei(b))throw b;return b}function Ud(n){return W(n).toLowerCase()}function Wd(n){return W(n).toUpperCase()}function Fd(n,t,e){if(n=W(n),n&&(e||t===i))return ys(n);if(!n||!(t=ln(t)))return n;var r=On(n),s=On(t),o=Ss(r,s),f=Os(r,s)+1;return ut(r,o,f).join("")}function Md(n,t,e){if(n=W(n),n&&(e||t===i))return n.slice(0,bs(n)+1);if(!n||!(t=ln(t)))return n;var r=On(n),s=Os(r,On(t))+1;return ut(r,0,s).join("")}function qd(n,t,e){if(n=W(n),n&&(e||t===i))return n.replace(Er,"");if(!n||!(t=ln(t)))return n;var r=On(n),s=Ss(r,On(t));return ut(r,s).join("")}function Bd(n,t){var e=Da,r=Ha;if(K(t)){var s="separator"in t?t.separator:s;e="length"in t?R(t.length):e,r="omission"in t?ln(t.omission):r;}n=W(n);var o=n.length;if(Lt(n)){var f=On(n);o=f.length;}if(e>=o)return n;var c=e-Dt(r);if(c<1)return r;var l=f?ut(f,0,c).join(""):n.slice(0,c);if(s===i)return l+r;if(f&&(c+=l.length-c),yi(s)){if(n.slice(c).search(s)){var v,_=l;for(s.global||(s=Br(s.source,W(Ji.exec(s))+"g")),s.lastIndex=0;v=s.exec(_);)var m=v.index;l=l.slice(0,m===i?c:m);}}else if(n.indexOf(ln(s),c)!=c){var P=l.lastIndexOf(s);P>-1&&(l=l.slice(0,P));}return l+r}function Gd(n){return n=W(n),n&&ka.test(n)?n.replace(Ki,mf):n}var zd=Mt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Ri=mu("toUpperCase");function va(n,t,e){return n=W(n),t=e?i:t,t===i?pf(n)?Af(n):rf(n):n.match(t)||[]}var _a=T(function(n,t){try{return cn(n,i,t)}catch(e){return Ei(e)?e:new S(e)}}),Kd=Yn(function(n,t){return mn(t,function(e){e=Wn(e),zn(n,e,Ii(n[e],n));}),n});function Yd(n){var t=n==null?0:n.length,e=x();return n=t?G(n,function(r){if(typeof r[1]!="function")throw new wn(D);return [e(r[0]),r[1]]}):[],T(function(r){for(var s=-1;++s<t;){var o=n[s];if(cn(o[0],this,r))return cn(o[1],this,r)}})}function Zd(n){return mc(An(n,Ln))}function bi(n){return function(){return n}}function Jd(n,t){return n==null||n!==n?t:n}var Xd=Pu(),Qd=Pu(!0);function fn(n){return n}function Ti(n){return Qs(typeof n=="function"?n:An(n,Ln))}function Vd(n){return ks(An(n,Ln))}function kd(n,t){return js(n,An(t,Ln))}var jd=T(function(n,t){return function(e){return ae(e,n,t)}}),ng=T(function(n,t){return function(e){return ae(n,e,t)}});function Li(n,t,e){var r=V(t),s=ze(t,r);e==null&&!(K(t)&&(s.length||!r.length))&&(e=t,t=n,n=this,s=ze(t,V(t)));var o=!(K(e)&&"chain"in e)||!!e.chain,f=Jn(n);return mn(s,function(c){var l=t[c];n[c]=l,f&&(n.prototype[c]=function(){var v=this.__chain__;if(o||v){var _=n(this.__wrapped__),m=_.__actions__=un(this.__actions__);return m.push({func:l,args:arguments,thisArg:n}),_.__chain__=v,_}return l.apply(n,nt([this.value()],arguments))});}),n}function tg(){return k._===this&&(k._=Sf),this}function Di(){}function eg(n){return n=R(n),T(function(t){return nu(t,n)})}var rg=ci(G),ig=ci(As),sg=ci(Nr);function ma(n){return _i(n)?$r(Wn(n)):Nc(n)}function ug(n){return function(t){return n==null?i:_t(n,t)}}var ag=Cu(),og=Cu(!0);function Hi(){return []}function Ni(){return !1}function fg(){return {}}function cg(){return ""}function hg(){return !0}function lg(n,t){if(n=R(n),n<1||n>kn)return [];var e=Nn,r=nn(n,Nn);t=x(t),n-=Nn;for(var s=Fr(r,t);++e<n;)t(e);return s}function pg(n){return O(n)?G(n,Wn):pn(n)?[n]:un(Wu(W(n)))}function dg(n){var t=++Ef;return W(n)+t}var gg=Qe(function(n,t){return n+t},0),vg=hi("ceil"),_g=Qe(function(n,t){return n/t},1),mg=hi("floor");function wg(n){return n&&n.length?Ge(n,fn,Qr):i}function Pg(n,t){return n&&n.length?Ge(n,x(t,2),Qr):i}function Ag(n){return xs(n,fn)}function Cg(n,t){return xs(n,x(t,2))}function Ig(n){return n&&n.length?Ge(n,fn,ni):i}function xg(n,t){return n&&n.length?Ge(n,x(t,2),ni):i}var Eg=Qe(function(n,t){return n*t},1),yg=hi("round"),Sg=Qe(function(n,t){return n-t},0);function Og(n){return n&&n.length?Wr(n,fn):0}function Rg(n,t){return n&&n.length?Wr(n,x(t,2)):0}return a.after=Vl,a.ary=Xu,a.assign=Wp,a.assignIn=fa,a.assignInWith=fr,a.assignWith=Fp,a.at=Mp,a.before=Qu,a.bind=Ii,a.bindAll=Kd,a.bindKey=Vu,a.castArray=fp,a.chain=Yu,a.chunk=mh,a.compact=wh,a.concat=Ph,a.cond=Yd,a.conforms=Zd,a.constant=bi,a.countBy=Ol,a.create=qp,a.curry=ku,a.curryRight=ju,a.debounce=na,a.defaults=Bp,a.defaultsDeep=Gp,a.defer=kl,a.delay=jl,a.difference=Ah,a.differenceBy=Ch,a.differenceWith=Ih,a.drop=xh,a.dropRight=Eh,a.dropRightWhile=yh,a.dropWhile=Sh,a.fill=Oh,a.filter=bl,a.flatMap=Dl,a.flatMapDeep=Hl,a.flatMapDepth=Nl,a.flatten=Bu,a.flattenDeep=Rh,a.flattenDepth=bh,a.flip=np,a.flow=Xd,a.flowRight=Qd,a.fromPairs=Th,a.functions=Qp,a.functionsIn=Vp,a.groupBy=$l,a.initial=Dh,a.intersection=Hh,a.intersectionBy=Nh,a.intersectionWith=$h,a.invert=jp,a.invertBy=nd,a.invokeMap=Wl,a.iteratee=Ti,a.keyBy=Fl,a.keys=V,a.keysIn=on,a.map=rr,a.mapKeys=ed,a.mapValues=rd,a.matches=Vd,a.matchesProperty=kd,a.memoize=sr,a.merge=id,a.mergeWith=ca,a.method=jd,a.methodOf=ng,a.mixin=Li,a.negate=ur,a.nthArg=eg,a.omit=sd,a.omitBy=ud,a.once=tp,a.orderBy=Ml,a.over=rg,a.overArgs=ep,a.overEvery=ig,a.overSome=sg,a.partial=xi,a.partialRight=ta,a.partition=ql,a.pick=ad,a.pickBy=ha,a.property=ma,a.propertyOf=ug,a.pull=Mh,a.pullAll=zu,a.pullAllBy=qh,a.pullAllWith=Bh,a.pullAt=Gh,a.range=ag,a.rangeRight=og,a.rearg=rp,a.reject=zl,a.remove=zh,a.rest=ip,a.reverse=Ai,a.sampleSize=Yl,a.set=fd,a.setWith=cd,a.shuffle=Zl,a.slice=Kh,a.sortBy=Ql,a.sortedUniq=kh,a.sortedUniqBy=jh,a.split=Dd,a.spread=sp,a.tail=nl,a.take=tl,a.takeRight=el,a.takeRightWhile=rl,a.takeWhile=il,a.tap=wl,a.throttle=up,a.thru=er,a.toArray=ua,a.toPairs=la,a.toPairsIn=pa,a.toPath=pg,a.toPlainObject=oa,a.transform=hd,a.unary=ap,a.union=sl,a.unionBy=ul,a.unionWith=al,a.uniq=ol,a.uniqBy=fl,a.uniqWith=cl,a.unset=ld,a.unzip=Ci,a.unzipWith=Ku,a.update=pd,a.updateWith=dd,a.values=Gt,a.valuesIn=gd,a.without=hl,a.words=va,a.wrap=op,a.xor=ll,a.xorBy=pl,a.xorWith=dl,a.zip=gl,a.zipObject=vl,a.zipObjectDeep=_l,a.zipWith=ml,a.entries=la,a.entriesIn=pa,a.extend=fa,a.extendWith=fr,Li(a,a),a.add=gg,a.attempt=_a,a.camelCase=wd,a.capitalize=da,a.ceil=vg,a.clamp=vd,a.clone=cp,a.cloneDeep=lp,a.cloneDeepWith=pp,a.cloneWith=hp,a.conformsTo=dp,a.deburr=ga,a.defaultTo=Jd,a.divide=_g,a.endsWith=Pd,a.eq=bn,a.escape=Ad,a.escapeRegExp=Cd,a.every=Rl,a.find=Tl,a.findIndex=Mu,a.findKey=zp,a.findLast=Ll,a.findLastIndex=qu,a.findLastKey=Kp,a.floor=mg,a.forEach=Zu,a.forEachRight=Ju,a.forIn=Yp,a.forInRight=Zp,a.forOwn=Jp,a.forOwnRight=Xp,a.get=Si,a.gt=gp,a.gte=vp,a.has=kp,a.hasIn=Oi,a.head=Gu,a.identity=fn,a.includes=Ul,a.indexOf=Lh,a.inRange=_d,a.invoke=td,a.isArguments=Pt,a.isArray=O,a.isArrayBuffer=_p,a.isArrayLike=an,a.isArrayLikeObject=Z,a.isBoolean=mp,a.isBuffer=at,a.isDate=wp,a.isElement=Pp,a.isEmpty=Ap,a.isEqual=Cp,a.isEqualWith=Ip,a.isError=Ei,a.isFinite=xp,a.isFunction=Jn,a.isInteger=ea,a.isLength=ar,a.isMap=ra,a.isMatch=Ep,a.isMatchWith=yp,a.isNaN=Sp,a.isNative=Op,a.isNil=bp,a.isNull=Rp,a.isNumber=ia,a.isObject=K,a.isObjectLike=Y,a.isPlainObject=pe,a.isRegExp=yi,a.isSafeInteger=Tp,a.isSet=sa,a.isString=or,a.isSymbol=pn,a.isTypedArray=Bt,a.isUndefined=Lp,a.isWeakMap=Dp,a.isWeakSet=Hp,a.join=Uh,a.kebabCase=Id,a.last=In,a.lastIndexOf=Wh,a.lowerCase=xd,a.lowerFirst=Ed,a.lt=Np,a.lte=$p,a.max=wg,a.maxBy=Pg,a.mean=Ag,a.meanBy=Cg,a.min=Ig,a.minBy=xg,a.stubArray=Hi,a.stubFalse=Ni,a.stubObject=fg,a.stubString=cg,a.stubTrue=hg,a.multiply=Eg,a.nth=Fh,a.noConflict=tg,a.noop=Di,a.now=ir,a.pad=yd,a.padEnd=Sd,a.padStart=Od,a.parseInt=Rd,a.random=md,a.reduce=Bl,a.reduceRight=Gl,a.repeat=bd,a.replace=Td,a.result=od,a.round=yg,a.runInContext=h,a.sample=Kl,a.size=Jl,a.snakeCase=Ld,a.some=Xl,a.sortedIndex=Yh,a.sortedIndexBy=Zh,a.sortedIndexOf=Jh,a.sortedLastIndex=Xh,a.sortedLastIndexBy=Qh,a.sortedLastIndexOf=Vh,a.startCase=Hd,a.startsWith=Nd,a.subtract=Sg,a.sum=Og,a.sumBy=Rg,a.template=$d,a.times=lg,a.toFinite=Xn,a.toInteger=R,a.toLength=aa,a.toLower=Ud,a.toNumber=xn,a.toSafeInteger=Up,a.toString=W,a.toUpper=Wd,a.trim=Fd,a.trimEnd=Md,a.trimStart=qd,a.truncate=Bd,a.unescape=Gd,a.uniqueId=dg,a.upperCase=zd,a.upperFirst=Ri,a.each=Zu,a.eachRight=Ju,a.first=Gu,Li(a,function(){var n={};return $n(a,function(t,e){F.call(a.prototype,e)||(n[e]=t);}),n}(),{chain:!1}),a.VERSION=d,mn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a;}),mn(["drop","take"],function(n,t){N.prototype[n]=function(e){e=e===i?1:Q(R(e),0);var r=this.__filtered__&&!t?new N(this):this.clone();return r.__filtered__?r.__takeCount__=nn(e,r.__takeCount__):r.__views__.push({size:nn(e,Nn),type:n+(r.__dir__<0?"Right":"")}),r},N.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()};}),mn(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==Bi||e==Wa;N.prototype[n]=function(s){var o=this.clone();return o.__iteratees__.push({iteratee:x(s,3),type:e}),o.__filtered__=o.__filtered__||r,o};}),mn(["head","last"],function(n,t){var e="take"+(t?"Right":"");N.prototype[n]=function(){return this[e](1).value()[0]};}),mn(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");N.prototype[n]=function(){return this.__filtered__?new N(this):this[e](1)};}),N.prototype.compact=function(){return this.filter(fn)},N.prototype.find=function(n){return this.filter(n).head()},N.prototype.findLast=function(n){return this.reverse().find(n)},N.prototype.invokeMap=T(function(n,t){return typeof n=="function"?new N(this):this.map(function(e){return ae(e,n,t)})}),N.prototype.reject=function(n){return this.filter(ur(x(n)))},N.prototype.slice=function(n,t){n=R(n);var e=this;return e.__filtered__&&(n>0||t<0)?new N(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=R(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},N.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},N.prototype.toArray=function(){return this.take(Nn)},$n(N.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),s=a[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);s&&(a.prototype[t]=function(){var f=this.__wrapped__,c=r?[1]:arguments,l=f instanceof N,v=c[0],_=l||O(f),m=function(H){var $=s.apply(a,nt([H],c));return r&&P?$[0]:$};_&&e&&typeof v=="function"&&v.length!=1&&(l=_=!1);var P=this.__chain__,I=!!this.__actions__.length,E=o&&!P,b=l&&!I;if(!o&&_){f=b?f:new N(this);var y=n.apply(f,c);return y.__actions__.push({func:er,args:[m],thisArg:i}),new Pn(y,P)}return E&&b?n.apply(this,c):(y=this.thru(m),E?r?y.value()[0]:y.value():y)});}),mn(["pop","push","shift","sort","splice","unshift"],function(n){var t=Oe[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var s=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(O(o)?o:[],s)}return this[e](function(f){return t.apply(O(f)?f:[],s)})};}),$n(N.prototype,function(n,t){var e=a[t];if(e){var r=e.name+"";F.call(Ut,r)||(Ut[r]=[]),Ut[r].push({name:t,func:e});}}),Ut[Xe(i,ct).name]=[{name:"wrapper",func:i}],N.prototype.clone=Gf,N.prototype.reverse=zf,N.prototype.value=Kf,a.prototype.at=Pl,a.prototype.chain=Al,a.prototype.commit=Cl,a.prototype.next=Il,a.prototype.plant=El,a.prototype.reverse=yl,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Sl,a.prototype.first=a.prototype.head,ne&&(a.prototype[ne]=xl),a},Ht=Cf();lt?((lt.exports=Ht)._=Ht,Tr._=Ht):k._=Ht;}).call(ge$2);})(Ui$1,Ui$1.exports);var Gg$1=Object.defineProperty,zg$1=Object.defineProperties,Kg$1=Object.getOwnPropertyDescriptors,Ea$1=Object.getOwnPropertySymbols,Yg$1=Object.prototype.hasOwnProperty,Zg$1=Object.prototype.propertyIsEnumerable,ya$1=(A,u,i)=>u in A?Gg$1(A,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):A[u]=i,cr$1=(A,u)=>{for(var i in u||(u={}))Yg$1.call(u,i)&&ya$1(A,i,u[i]);if(Ea$1)for(var i of Ea$1(u))Zg$1.call(u,i)&&ya$1(A,i,u[i]);return A},Jg$1=(A,u)=>zg$1(A,Kg$1(u));function ft(A,u,i){var d;const w=ve$3(A);return ((d=u.rpcMap)==null?void 0:d[w.reference])||`${Bg$1}?chainId=${w.namespace}:${w.reference}&projectId=${i}`}function Ct(A){return A.includes(":")?A.split(":")[1]:A}function Sa$1(A){return A.map(u=>`${u.split(":")[0]}:${u.split(":")[1]}`)}function Xg$1(A,u){const i=Object.keys(u.namespaces).filter(w=>w.includes(A));if(!i.length)return [];const d=[];return i.forEach(w=>{const L=u.namespaces[w].accounts;d.push(...L);}),d}function Oa$1(A={},u={}){const i=Ra$1(A),d=Ra$1(u);return Ui$1.exports.merge(i,d)}function Ra$1(A){var u,i,d,w;const L={};if(!B$5(A))return L;for(const[D,En]of Object.entries(A)){const zt=oe$4(D)?[D]:En.chains,pr=En.methods||[],It=En.events||[],Ln=En.rpcMap||{},Fn=en(D);L[Fn]=Jg$1(cr$1(cr$1({},L[Fn]),En),{chains:S$6(zt,(u=L[Fn])==null?void 0:u.chains),methods:S$6(pr,(i=L[Fn])==null?void 0:i.methods),events:S$6(It,(d=L[Fn])==null?void 0:d.events),rpcMap:cr$1(cr$1({},Ln),(w=L[Fn])==null?void 0:w.rpcMap)});}return L}function Qg$1(A){return A.includes(":")?A.split(":")[2]:A}function Vg$1(A){const u={};for(const[i,d]of Object.entries(A)){const w=d.methods||[],L=d.events||[],D=d.accounts||[],En=oe$4(i)?[i]:d.chains?d.chains:Sa$1(d.accounts);u[i]={chains:En,methods:w,events:L,accounts:D};}return u}function Wi$1(A){return typeof A=="number"?A:A.includes("0x")?parseInt(A,16):(A=A.includes(":")?A.split(":")[1]:A,isNaN(Number(A))?A:Number(A))}const ba={},z$4=A=>ba[A],Fi$1=(A,u)=>{ba[A]=u;};let kg$1 = class kg{constructor(u){this.name="polkadot",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getAccounts(){const u=this.namespace.accounts;return u?u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}};let jg$1 = class jg{constructor(u){this.name="eip155",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain());}async request(u){switch(u.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(u);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(u.request.method)?await this.client.request(u):this.getHttpProvider().request(u.request)}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(parseInt(u),i),this.chainId=parseInt(u),this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}createHttpProvider(u,i){const d=i||ft(`${this.name}:${u}`,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=parseInt(Ct(i));u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}getHttpProvider(){const u=this.chainId,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}async handleSwitchChain(u){var i,d;let w=u.request.params?(i=u.request.params[0])==null?void 0:i.chainId:"0x0";w=w.startsWith("0x")?w:`0x${w}`;const L=parseInt(w,16);if(this.isChainApproved(L))this.setDefaultChain(`${L}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:u.topic,request:{method:u.request.method,params:[{chainId:w}]},chainId:(d=this.namespace.chains)==null?void 0:d[0]}),this.setDefaultChain(`${L}`);else throw new Error(`Failed to switch to chain 'eip155:${L}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(u){return this.namespace.chains.includes(`${this.name}:${u}`)}};class nv{constructor(u){this.name="solana",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class tv{constructor(u){this.name="cosmos",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class ev{constructor(u){this.name="cip34",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{const d=this.getCardanoRPCUrl(i),w=Ct(i);u[w]=this.createHttpProvider(w,d);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}getCardanoRPCUrl(u){const i=this.namespace.rpcMap;if(i)return i[u]}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||this.getCardanoRPCUrl(u);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class rv{constructor(u){this.name="elrond",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class iv{constructor(u){this.name="multiversx",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class sv{constructor(u){this.name="near",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){if(this.chainId=u,!this.httpProviders[u]){const d=i||ft(`${this.name}:${u}`,this.namespace);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);this.setHttpProvider(u,d);}this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;u[i]=this.createHttpProvider(i,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace);return typeof d>"u"?void 0:new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}var uv=Object.defineProperty,av=Object.defineProperties,ov=Object.getOwnPropertyDescriptors,Ta$1=Object.getOwnPropertySymbols,fv=Object.prototype.hasOwnProperty,cv=Object.prototype.propertyIsEnumerable,La$1=(A,u,i)=>u in A?uv(A,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):A[u]=i,hr$2=(A,u)=>{for(var i in u||(u={}))fv.call(u,i)&&La$1(A,i,u[i]);if(Ta$1)for(var i of Ta$1(u))cv.call(u,i)&&La$1(A,i,u[i]);return A},Mi$1=(A,u)=>av(A,ov(u));let lr$1 = class lr{constructor(u){this.events=new EventEmitter$1,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=u,this.logger=typeof u?.logger<"u"&&typeof u?.logger!="string"?u.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:u?.logger||Ia$1})),this.disableProviderPing=u?.disableProviderPing||!1;}static async init(u){const i=new lr(u);return await i.initialize(),i}async request(u,i,d){const[w,L]=this.validateChain(i);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(w).request({request:hr$2({},u),chainId:`${w}:${L}`,topic:this.session.topic,expiry:d})}sendAsync(u,i,d,w){const L=new Date().getTime();this.request(u,d,w).then(D=>i(null,formatJsonRpcResult(L,D))).catch(D=>i(D,void 0));}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var u;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(u=this.session)==null?void 0:u.topic,reason:U$5("USER_DISCONNECTED")}),await this.cleanup();}async connect(u){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(u),await this.cleanupPendingPairings(),!u.skipPairing)return await this.pair(u.pairingTopic)}on(u,i){this.events.on(u,i);}once(u,i){this.events.once(u,i);}removeListener(u,i){this.events.removeListener(u,i);}off(u,i){this.events.off(u,i);}get isWalletConnect(){return !0}async pair(u){this.shouldAbortPairingAttempt=!1;let i=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(i>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:d,approval:w}=await this.client.connect({pairingTopic:u,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});d&&(this.uri=d,this.events.emit("display_uri",d)),await w().then(L=>{this.session=L;const D=Vg$1(L.namespaces);this.namespaces=Oa$1(this.namespaces,D),this.persist("namespaces",this.namespaces);}).catch(L=>{if(L.message!==ae$3)throw L;i++;});}while(!this.session);return this.onConnect(),this.session}setDefaultChain(u,i){try{if(!this.session)return;const[d,w]=this.validateChain(u);this.getProvider(d).setDefaultChain(w,i);}catch(d){if(!/Please call connect/.test(d.message))throw d}}async cleanupPendingPairings(u={}){this.logger.info("Cleaning up inactive pairings...");const i=this.client.pairing.getAll();if(k$5(i)){for(const d of i)u.deletePairings?this.client.core.expirer.set(d.topic,0):await this.client.core.relayer.subscriber.unsubscribe(d.topic);this.logger.info(`Inactive pairings cleared: ${i.length}`);}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0;}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const u=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[u]),this.createProviders();}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners();}async createClient(){this.client=this.providerOpts.client||await Q$4.init({logger:this.providerOpts.logger||Ia$1,relayUrl:this.providerOpts.relayUrl||Fg$1,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized");}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const u=[...new Set(Object.keys(this.session.namespaces).map(i=>en(i)))];Fi$1("client",this.client),Fi$1("events",this.events),Fi$1("disableProviderPing",this.disableProviderPing),u.forEach(i=>{if(!this.session)return;const d=Xg$1(i,this.session),w=Sa$1(d),L=Oa$1(this.namespaces,this.optionalNamespaces),D=Mi$1(hr$2({},L[i]),{accounts:d,chains:w});switch(i){case"eip155":this.rpcProviders[i]=new jg$1({namespace:D});break;case"solana":this.rpcProviders[i]=new nv({namespace:D});break;case"cosmos":this.rpcProviders[i]=new tv({namespace:D});break;case"polkadot":this.rpcProviders[i]=new kg$1({namespace:D});break;case"cip34":this.rpcProviders[i]=new ev({namespace:D});break;case"elrond":this.rpcProviders[i]=new rv({namespace:D});break;case"multiversx":this.rpcProviders[i]=new iv({namespace:D});break;case"near":this.rpcProviders[i]=new sv({namespace:D});break}});}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",u=>{this.events.emit("session_ping",u);}),this.client.on("session_event",u=>{const{params:i}=u,{event:d}=i;if(d.name==="accountsChanged"){const w=d.data;w&&k$5(w)&&this.events.emit("accountsChanged",w.map(Qg$1));}else if(d.name==="chainChanged"){const w=i.chainId,L=i.event.data,D=en(w),En=Wi$1(w)!==Wi$1(L)?`${D}:${Wi$1(L)}`:w;this.onChainChanged(En);}else this.events.emit(d.name,d.data);this.events.emit("session_event",u);}),this.client.on("session_update",({topic:u,params:i})=>{var d;const{namespaces:w}=i,L=(d=this.client)==null?void 0:d.session.get(u);this.session=Mi$1(hr$2({},L),{namespaces:w}),this.onSessionUpdate(),this.events.emit("session_update",{topic:u,params:i});}),this.client.on("session_delete",async u=>{await this.cleanup(),this.events.emit("session_delete",u),this.events.emit("disconnect",Mi$1(hr$2({},U$5("USER_DISCONNECTED")),{data:u.topic}));}),this.on(Vn.DEFAULT_CHAIN_CHANGED,u=>{this.onChainChanged(u,!0);});}getProvider(u){if(!this.rpcProviders[u])throw new Error(`Provider not found: ${u}`);return this.rpcProviders[u]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(u=>{var i;this.getProvider(u).updateNamespace((i=this.session)==null?void 0:i.namespaces[u]);});}setNamespaces(u){const{namespaces:i,optionalNamespaces:d,sessionProperties:w}=u;i&&Object.keys(i).length&&(this.namespaces=i),d&&Object.keys(d).length&&(this.optionalNamespaces=d),this.sessionProperties=w,this.persist("namespaces",i),this.persist("optionalNamespaces",d);}validateChain(u){const[i,d]=u?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return [i,d];if(i&&!Object.keys(this.namespaces||{}).map(D=>en(D)).includes(i))throw new Error(`Namespace '${i}' is not configured. Please call connect() first with namespace config.`);if(i&&d)return [i,d];const w=en(Object.keys(this.namespaces)[0]),L=this.rpcProviders[w].getDefaultChain();return [w,L]}async requestAccounts(){const[u]=this.validateChain();return await this.getProvider(u).requestAccounts()}onChainChanged(u,i=!1){if(!this.namespaces)return;const[d,w]=this.validateChain(u);w&&(i||this.getProvider(d).setDefaultChain(w),this.namespaces[d]?this.namespaces[d].defaultChain=w:this.namespaces[`${d}:${w}`]?this.namespaces[`${d}:${w}`].defaultChain=w:this.namespaces[`${d}:${w}`]={defaultChain:w},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",w));}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session});}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0});}persist(u,i){this.client.core.storage.setItem(`${xa}/${u}`,i);}async getFromStore(u){return await this.client.core.storage.getItem(`${xa}/${u}`)}};const hv=lr$1;
|
|
147392
|
+
}`;var b=_a(function(){return U(o,I+"return "+m).apply(i,f)});if(b.source=m,Ei(b))throw b;return b}function Ud(n){return W(n).toLowerCase()}function Wd(n){return W(n).toUpperCase()}function Fd(n,t,e){if(n=W(n),n&&(e||t===i))return ys(n);if(!n||!(t=ln(t)))return n;var r=On(n),s=On(t),o=Ss(r,s),f=Os(r,s)+1;return ut(r,o,f).join("")}function Md(n,t,e){if(n=W(n),n&&(e||t===i))return n.slice(0,bs(n)+1);if(!n||!(t=ln(t)))return n;var r=On(n),s=Os(r,On(t))+1;return ut(r,0,s).join("")}function qd(n,t,e){if(n=W(n),n&&(e||t===i))return n.replace(Er,"");if(!n||!(t=ln(t)))return n;var r=On(n),s=Ss(r,On(t));return ut(r,s).join("")}function Bd(n,t){var e=Da,r=Ha;if(K(t)){var s="separator"in t?t.separator:s;e="length"in t?R(t.length):e,r="omission"in t?ln(t.omission):r;}n=W(n);var o=n.length;if(Lt(n)){var f=On(n);o=f.length;}if(e>=o)return n;var c=e-Dt(r);if(c<1)return r;var l=f?ut(f,0,c).join(""):n.slice(0,c);if(s===i)return l+r;if(f&&(c+=l.length-c),yi(s)){if(n.slice(c).search(s)){var v,_=l;for(s.global||(s=Br(s.source,W(Ji.exec(s))+"g")),s.lastIndex=0;v=s.exec(_);)var m=v.index;l=l.slice(0,m===i?c:m);}}else if(n.indexOf(ln(s),c)!=c){var P=l.lastIndexOf(s);P>-1&&(l=l.slice(0,P));}return l+r}function Gd(n){return n=W(n),n&&ka.test(n)?n.replace(Ki,mf):n}var zd=Mt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Ri=mu("toUpperCase");function va(n,t,e){return n=W(n),t=e?i:t,t===i?pf(n)?Af(n):rf(n):n.match(t)||[]}var _a=T(function(n,t){try{return cn(n,i,t)}catch(e){return Ei(e)?e:new S(e)}}),Kd=Yn(function(n,t){return mn(t,function(e){e=Wn(e),zn(n,e,Ii(n[e],n));}),n});function Yd(n){var t=n==null?0:n.length,e=x();return n=t?G(n,function(r){if(typeof r[1]!="function")throw new wn(D);return [e(r[0]),r[1]]}):[],T(function(r){for(var s=-1;++s<t;){var o=n[s];if(cn(o[0],this,r))return cn(o[1],this,r)}})}function Zd(n){return mc(An(n,Ln))}function bi(n){return function(){return n}}function Jd(n,t){return n==null||n!==n?t:n}var Xd=Pu(),Qd=Pu(!0);function fn(n){return n}function Ti(n){return Qs(typeof n=="function"?n:An(n,Ln))}function Vd(n){return ks(An(n,Ln))}function kd(n,t){return js(n,An(t,Ln))}var jd=T(function(n,t){return function(e){return ae(e,n,t)}}),ng=T(function(n,t){return function(e){return ae(n,e,t)}});function Li(n,t,e){var r=V(t),s=ze(t,r);e==null&&!(K(t)&&(s.length||!r.length))&&(e=t,t=n,n=this,s=ze(t,V(t)));var o=!(K(e)&&"chain"in e)||!!e.chain,f=Jn(n);return mn(s,function(c){var l=t[c];n[c]=l,f&&(n.prototype[c]=function(){var v=this.__chain__;if(o||v){var _=n(this.__wrapped__),m=_.__actions__=un(this.__actions__);return m.push({func:l,args:arguments,thisArg:n}),_.__chain__=v,_}return l.apply(n,nt([this.value()],arguments))});}),n}function tg(){return k._===this&&(k._=Sf),this}function Di(){}function eg(n){return n=R(n),T(function(t){return nu(t,n)})}var rg=ci(G),ig=ci(As),sg=ci(Nr);function ma(n){return _i(n)?$r(Wn(n)):Nc(n)}function ug(n){return function(t){return n==null?i:_t(n,t)}}var ag=Cu(),og=Cu(!0);function Hi(){return []}function Ni(){return !1}function fg(){return {}}function cg(){return ""}function hg(){return !0}function lg(n,t){if(n=R(n),n<1||n>kn)return [];var e=Nn,r=nn(n,Nn);t=x(t),n-=Nn;for(var s=Fr(r,t);++e<n;)t(e);return s}function pg(n){return O(n)?G(n,Wn):pn(n)?[n]:un(Wu(W(n)))}function dg(n){var t=++Ef;return W(n)+t}var gg=Qe(function(n,t){return n+t},0),vg=hi("ceil"),_g=Qe(function(n,t){return n/t},1),mg=hi("floor");function wg(n){return n&&n.length?Ge(n,fn,Qr):i}function Pg(n,t){return n&&n.length?Ge(n,x(t,2),Qr):i}function Ag(n){return xs(n,fn)}function Cg(n,t){return xs(n,x(t,2))}function Ig(n){return n&&n.length?Ge(n,fn,ni):i}function xg(n,t){return n&&n.length?Ge(n,x(t,2),ni):i}var Eg=Qe(function(n,t){return n*t},1),yg=hi("round"),Sg=Qe(function(n,t){return n-t},0);function Og(n){return n&&n.length?Wr(n,fn):0}function Rg(n,t){return n&&n.length?Wr(n,x(t,2)):0}return a.after=Vl,a.ary=Xu,a.assign=Wp,a.assignIn=fa,a.assignInWith=fr,a.assignWith=Fp,a.at=Mp,a.before=Qu,a.bind=Ii,a.bindAll=Kd,a.bindKey=Vu,a.castArray=fp,a.chain=Yu,a.chunk=mh,a.compact=wh,a.concat=Ph,a.cond=Yd,a.conforms=Zd,a.constant=bi,a.countBy=Ol,a.create=qp,a.curry=ku,a.curryRight=ju,a.debounce=na,a.defaults=Bp,a.defaultsDeep=Gp,a.defer=kl,a.delay=jl,a.difference=Ah,a.differenceBy=Ch,a.differenceWith=Ih,a.drop=xh,a.dropRight=Eh,a.dropRightWhile=yh,a.dropWhile=Sh,a.fill=Oh,a.filter=bl,a.flatMap=Dl,a.flatMapDeep=Hl,a.flatMapDepth=Nl,a.flatten=Bu,a.flattenDeep=Rh,a.flattenDepth=bh,a.flip=np,a.flow=Xd,a.flowRight=Qd,a.fromPairs=Th,a.functions=Qp,a.functionsIn=Vp,a.groupBy=$l,a.initial=Dh,a.intersection=Hh,a.intersectionBy=Nh,a.intersectionWith=$h,a.invert=jp,a.invertBy=nd,a.invokeMap=Wl,a.iteratee=Ti,a.keyBy=Fl,a.keys=V,a.keysIn=on,a.map=rr,a.mapKeys=ed,a.mapValues=rd,a.matches=Vd,a.matchesProperty=kd,a.memoize=sr,a.merge=id,a.mergeWith=ca,a.method=jd,a.methodOf=ng,a.mixin=Li,a.negate=ur,a.nthArg=eg,a.omit=sd,a.omitBy=ud,a.once=tp,a.orderBy=Ml,a.over=rg,a.overArgs=ep,a.overEvery=ig,a.overSome=sg,a.partial=xi,a.partialRight=ta,a.partition=ql,a.pick=ad,a.pickBy=ha,a.property=ma,a.propertyOf=ug,a.pull=Mh,a.pullAll=zu,a.pullAllBy=qh,a.pullAllWith=Bh,a.pullAt=Gh,a.range=ag,a.rangeRight=og,a.rearg=rp,a.reject=zl,a.remove=zh,a.rest=ip,a.reverse=Ai,a.sampleSize=Yl,a.set=fd,a.setWith=cd,a.shuffle=Zl,a.slice=Kh,a.sortBy=Ql,a.sortedUniq=kh,a.sortedUniqBy=jh,a.split=Dd,a.spread=sp,a.tail=nl,a.take=tl,a.takeRight=el,a.takeRightWhile=rl,a.takeWhile=il,a.tap=wl,a.throttle=up,a.thru=er,a.toArray=ua,a.toPairs=la,a.toPairsIn=pa,a.toPath=pg,a.toPlainObject=oa,a.transform=hd,a.unary=ap,a.union=sl,a.unionBy=ul,a.unionWith=al,a.uniq=ol,a.uniqBy=fl,a.uniqWith=cl,a.unset=ld,a.unzip=Ci,a.unzipWith=Ku,a.update=pd,a.updateWith=dd,a.values=Gt,a.valuesIn=gd,a.without=hl,a.words=va,a.wrap=op,a.xor=ll,a.xorBy=pl,a.xorWith=dl,a.zip=gl,a.zipObject=vl,a.zipObjectDeep=_l,a.zipWith=ml,a.entries=la,a.entriesIn=pa,a.extend=fa,a.extendWith=fr,Li(a,a),a.add=gg,a.attempt=_a,a.camelCase=wd,a.capitalize=da,a.ceil=vg,a.clamp=vd,a.clone=cp,a.cloneDeep=lp,a.cloneDeepWith=pp,a.cloneWith=hp,a.conformsTo=dp,a.deburr=ga,a.defaultTo=Jd,a.divide=_g,a.endsWith=Pd,a.eq=bn,a.escape=Ad,a.escapeRegExp=Cd,a.every=Rl,a.find=Tl,a.findIndex=Mu,a.findKey=zp,a.findLast=Ll,a.findLastIndex=qu,a.findLastKey=Kp,a.floor=mg,a.forEach=Zu,a.forEachRight=Ju,a.forIn=Yp,a.forInRight=Zp,a.forOwn=Jp,a.forOwnRight=Xp,a.get=Si,a.gt=gp,a.gte=vp,a.has=kp,a.hasIn=Oi,a.head=Gu,a.identity=fn,a.includes=Ul,a.indexOf=Lh,a.inRange=_d,a.invoke=td,a.isArguments=Pt,a.isArray=O,a.isArrayBuffer=_p,a.isArrayLike=an,a.isArrayLikeObject=Z,a.isBoolean=mp,a.isBuffer=at,a.isDate=wp,a.isElement=Pp,a.isEmpty=Ap,a.isEqual=Cp,a.isEqualWith=Ip,a.isError=Ei,a.isFinite=xp,a.isFunction=Jn,a.isInteger=ea,a.isLength=ar,a.isMap=ra,a.isMatch=Ep,a.isMatchWith=yp,a.isNaN=Sp,a.isNative=Op,a.isNil=bp,a.isNull=Rp,a.isNumber=ia,a.isObject=K,a.isObjectLike=Y,a.isPlainObject=pe,a.isRegExp=yi,a.isSafeInteger=Tp,a.isSet=sa,a.isString=or,a.isSymbol=pn,a.isTypedArray=Bt,a.isUndefined=Lp,a.isWeakMap=Dp,a.isWeakSet=Hp,a.join=Uh,a.kebabCase=Id,a.last=In,a.lastIndexOf=Wh,a.lowerCase=xd,a.lowerFirst=Ed,a.lt=Np,a.lte=$p,a.max=wg,a.maxBy=Pg,a.mean=Ag,a.meanBy=Cg,a.min=Ig,a.minBy=xg,a.stubArray=Hi,a.stubFalse=Ni,a.stubObject=fg,a.stubString=cg,a.stubTrue=hg,a.multiply=Eg,a.nth=Fh,a.noConflict=tg,a.noop=Di,a.now=ir,a.pad=yd,a.padEnd=Sd,a.padStart=Od,a.parseInt=Rd,a.random=md,a.reduce=Bl,a.reduceRight=Gl,a.repeat=bd,a.replace=Td,a.result=od,a.round=yg,a.runInContext=h,a.sample=Kl,a.size=Jl,a.snakeCase=Ld,a.some=Xl,a.sortedIndex=Yh,a.sortedIndexBy=Zh,a.sortedIndexOf=Jh,a.sortedLastIndex=Xh,a.sortedLastIndexBy=Qh,a.sortedLastIndexOf=Vh,a.startCase=Hd,a.startsWith=Nd,a.subtract=Sg,a.sum=Og,a.sumBy=Rg,a.template=$d,a.times=lg,a.toFinite=Xn,a.toInteger=R,a.toLength=aa,a.toLower=Ud,a.toNumber=xn,a.toSafeInteger=Up,a.toString=W,a.toUpper=Wd,a.trim=Fd,a.trimEnd=Md,a.trimStart=qd,a.truncate=Bd,a.unescape=Gd,a.uniqueId=dg,a.upperCase=zd,a.upperFirst=Ri,a.each=Zu,a.eachRight=Ju,a.first=Gu,Li(a,function(){var n={};return $n(a,function(t,e){F.call(a.prototype,e)||(n[e]=t);}),n}(),{chain:!1}),a.VERSION=d,mn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){a[n].placeholder=a;}),mn(["drop","take"],function(n,t){N.prototype[n]=function(e){e=e===i?1:Q(R(e),0);var r=this.__filtered__&&!t?new N(this):this.clone();return r.__filtered__?r.__takeCount__=nn(e,r.__takeCount__):r.__views__.push({size:nn(e,Nn),type:n+(r.__dir__<0?"Right":"")}),r},N.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()};}),mn(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==Bi||e==Wa;N.prototype[n]=function(s){var o=this.clone();return o.__iteratees__.push({iteratee:x(s,3),type:e}),o.__filtered__=o.__filtered__||r,o};}),mn(["head","last"],function(n,t){var e="take"+(t?"Right":"");N.prototype[n]=function(){return this[e](1).value()[0]};}),mn(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");N.prototype[n]=function(){return this.__filtered__?new N(this):this[e](1)};}),N.prototype.compact=function(){return this.filter(fn)},N.prototype.find=function(n){return this.filter(n).head()},N.prototype.findLast=function(n){return this.reverse().find(n)},N.prototype.invokeMap=T(function(n,t){return typeof n=="function"?new N(this):this.map(function(e){return ae(e,n,t)})}),N.prototype.reject=function(n){return this.filter(ur(x(n)))},N.prototype.slice=function(n,t){n=R(n);var e=this;return e.__filtered__&&(n>0||t<0)?new N(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=R(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},N.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},N.prototype.toArray=function(){return this.take(Nn)},$n(N.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),s=a[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);s&&(a.prototype[t]=function(){var f=this.__wrapped__,c=r?[1]:arguments,l=f instanceof N,v=c[0],_=l||O(f),m=function(H){var $=s.apply(a,nt([H],c));return r&&P?$[0]:$};_&&e&&typeof v=="function"&&v.length!=1&&(l=_=!1);var P=this.__chain__,I=!!this.__actions__.length,E=o&&!P,b=l&&!I;if(!o&&_){f=b?f:new N(this);var y=n.apply(f,c);return y.__actions__.push({func:er,args:[m],thisArg:i}),new Pn(y,P)}return E&&b?n.apply(this,c):(y=this.thru(m),E?r?y.value()[0]:y.value():y)});}),mn(["pop","push","shift","sort","splice","unshift"],function(n){var t=Oe[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);a.prototype[n]=function(){var s=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(O(o)?o:[],s)}return this[e](function(f){return t.apply(O(f)?f:[],s)})};}),$n(N.prototype,function(n,t){var e=a[t];if(e){var r=e.name+"";F.call(Ut,r)||(Ut[r]=[]),Ut[r].push({name:t,func:e});}}),Ut[Xe(i,ct).name]=[{name:"wrapper",func:i}],N.prototype.clone=Gf,N.prototype.reverse=zf,N.prototype.value=Kf,a.prototype.at=Pl,a.prototype.chain=Al,a.prototype.commit=Cl,a.prototype.next=Il,a.prototype.plant=El,a.prototype.reverse=yl,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=Sl,a.prototype.first=a.prototype.head,ne&&(a.prototype[ne]=xl),a},Ht=Cf();lt?((lt.exports=Ht)._=Ht,Tr._=Ht):k._=Ht;}).call(ge$2);})(Ui$1,Ui$1.exports);var Gg$1=Object.defineProperty,zg$1=Object.defineProperties,Kg$1=Object.getOwnPropertyDescriptors,Ea$1=Object.getOwnPropertySymbols,Yg$1=Object.prototype.hasOwnProperty,Zg$1=Object.prototype.propertyIsEnumerable,ya$1=(A,u,i)=>u in A?Gg$1(A,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):A[u]=i,cr$1=(A,u)=>{for(var i in u||(u={}))Yg$1.call(u,i)&&ya$1(A,i,u[i]);if(Ea$1)for(var i of Ea$1(u))Zg$1.call(u,i)&&ya$1(A,i,u[i]);return A},Jg$1=(A,u)=>zg$1(A,Kg$1(u));function ft(A,u,i){var d;const w=ve$3(A);return ((d=u.rpcMap)==null?void 0:d[w.reference])||`${Bg$1}?chainId=${w.namespace}:${w.reference}&projectId=${i}`}function Ct(A){return A.includes(":")?A.split(":")[1]:A}function Sa$1(A){return A.map(u=>`${u.split(":")[0]}:${u.split(":")[1]}`)}function Xg$1(A,u){const i=Object.keys(u.namespaces).filter(w=>w.includes(A));if(!i.length)return [];const d=[];return i.forEach(w=>{const L=u.namespaces[w].accounts;d.push(...L);}),d}function Oa$1(A={},u={}){const i=Ra$1(A),d=Ra$1(u);return Ui$1.exports.merge(i,d)}function Ra$1(A){var u,i,d,w;const L={};if(!B$5(A))return L;for(const[D,En]of Object.entries(A)){const zt=oe$4(D)?[D]:En.chains,pr=En.methods||[],It=En.events||[],Ln=En.rpcMap||{},Fn=en(D);L[Fn]=Jg$1(cr$1(cr$1({},L[Fn]),En),{chains:S$6(zt,(u=L[Fn])==null?void 0:u.chains),methods:S$6(pr,(i=L[Fn])==null?void 0:i.methods),events:S$6(It,(d=L[Fn])==null?void 0:d.events),rpcMap:cr$1(cr$1({},Ln),(w=L[Fn])==null?void 0:w.rpcMap)});}return L}function Qg$1(A){return A.includes(":")?A.split(":")[2]:A}function Vg$1(A){const u={};for(const[i,d]of Object.entries(A)){const w=d.methods||[],L=d.events||[],D=d.accounts||[],En=oe$4(i)?[i]:d.chains?d.chains:Sa$1(d.accounts);u[i]={chains:En,methods:w,events:L,accounts:D};}return u}function Wi$1(A){return typeof A=="number"?A:A.includes("0x")?parseInt(A,16):(A=A.includes(":")?A.split(":")[1]:A,isNaN(Number(A))?A:Number(A))}const ba={},z$4=A=>ba[A],Fi$1=(A,u)=>{ba[A]=u;};let kg$1 = class kg{constructor(u){this.name="polkadot",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getAccounts(){const u=this.namespace.accounts;return u?u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}};let jg$1 = class jg{constructor(u){this.name="eip155",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain());}async request(u){switch(u.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(u);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(u.request.method)?await this.client.request(u):this.getHttpProvider().request(u.request)}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(parseInt(u),i),this.chainId=parseInt(u),this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}createHttpProvider(u,i){const d=i||ft(`${this.name}:${u}`,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=parseInt(Ct(i));u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}getHttpProvider(){const u=this.chainId,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}async handleSwitchChain(u){var i,d;let w=u.request.params?(i=u.request.params[0])==null?void 0:i.chainId:"0x0";w=w.startsWith("0x")?w:`0x${w}`;const L=parseInt(w,16);if(this.isChainApproved(L))this.setDefaultChain(`${L}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:u.topic,request:{method:u.request.method,params:[{chainId:w}]},chainId:(d=this.namespace.chains)==null?void 0:d[0]}),this.setDefaultChain(`${L}`);else throw new Error(`Failed to switch to chain 'eip155:${L}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(u){return this.namespace.chains.includes(`${this.name}:${u}`)}};class nv{constructor(u){this.name="solana",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class tv{constructor(u){this.name="cosmos",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class ev{constructor(u){this.name="cip34",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{const d=this.getCardanoRPCUrl(i),w=Ct(i);u[w]=this.createHttpProvider(w,d);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}getCardanoRPCUrl(u){const i=this.namespace.rpcMap;if(i)return i[u]}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||this.getCardanoRPCUrl(u);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class rv{constructor(u){this.name="elrond",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class iv{constructor(u){this.name="multiversx",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){this.httpProviders[u]||this.setHttpProvider(u,i),this.chainId=u,this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${u}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}getAccounts(){const u=this.namespace.accounts;return u?[...new Set(u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2]))]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;const w=Ct(i);u[w]=this.createHttpProvider(w,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace,this.client.core.projectId);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);return new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}class sv{constructor(u){this.name="near",this.namespace=u.namespace,this.events=z$4("events"),this.client=z$4("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(u){this.namespace=Object.assign(this.namespace,u);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const u=this.namespace.chains[0];if(!u)throw new Error("ChainId not found");return u.split(":")[1]}request(u){return this.namespace.methods.includes(u.request.method)?this.client.request(u):this.getHttpProvider().request(u.request)}setDefaultChain(u,i){if(this.chainId=u,!this.httpProviders[u]){const d=i||ft(`${this.name}:${u}`,this.namespace);if(!d)throw new Error(`No RPC url provided for chainId: ${u}`);this.setHttpProvider(u,d);}this.events.emit(Vn.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const u=this.namespace.accounts;return u?u.filter(i=>i.split(":")[1]===this.chainId.toString()).map(i=>i.split(":")[2])||[]:[]}createHttpProviders(){const u={};return this.namespace.chains.forEach(i=>{var d;u[i]=this.createHttpProvider(i,(d=this.namespace.rpcMap)==null?void 0:d[i]);}),u}getHttpProvider(){const u=`${this.name}:${this.chainId}`,i=this.httpProviders[u];if(typeof i>"u")throw new Error(`JSON-RPC provider for ${u} not found`);return i}setHttpProvider(u,i){const d=this.createHttpProvider(u,i);d&&(this.httpProviders[u]=d);}createHttpProvider(u,i){const d=i||ft(u,this.namespace);return typeof d>"u"?void 0:new JsonRpcProvider(new HttpConnection(d,z$4("disableProviderPing")))}}var uv=Object.defineProperty,av=Object.defineProperties,ov=Object.getOwnPropertyDescriptors,Ta$1=Object.getOwnPropertySymbols,fv=Object.prototype.hasOwnProperty,cv=Object.prototype.propertyIsEnumerable,La$1=(A,u,i)=>u in A?uv(A,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):A[u]=i,hr$2=(A,u)=>{for(var i in u||(u={}))fv.call(u,i)&&La$1(A,i,u[i]);if(Ta$1)for(var i of Ta$1(u))cv.call(u,i)&&La$1(A,i,u[i]);return A},Mi$1=(A,u)=>av(A,ov(u));let lr$1 = class lr{constructor(u){this.events=new EventEmitter$2,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=u,this.logger=typeof u?.logger<"u"&&typeof u?.logger!="string"?u.logger:cjs$1.pino(cjs$1.getDefaultLoggerOptions({level:u?.logger||Ia$1})),this.disableProviderPing=u?.disableProviderPing||!1;}static async init(u){const i=new lr(u);return await i.initialize(),i}async request(u,i,d){const[w,L]=this.validateChain(i);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(w).request({request:hr$2({},u),chainId:`${w}:${L}`,topic:this.session.topic,expiry:d})}sendAsync(u,i,d,w){const L=new Date().getTime();this.request(u,d,w).then(D=>i(null,formatJsonRpcResult(L,D))).catch(D=>i(D,void 0));}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var u;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(u=this.session)==null?void 0:u.topic,reason:U$5("USER_DISCONNECTED")}),await this.cleanup();}async connect(u){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(u),await this.cleanupPendingPairings(),!u.skipPairing)return await this.pair(u.pairingTopic)}on(u,i){this.events.on(u,i);}once(u,i){this.events.once(u,i);}removeListener(u,i){this.events.removeListener(u,i);}off(u,i){this.events.off(u,i);}get isWalletConnect(){return !0}async pair(u){this.shouldAbortPairingAttempt=!1;let i=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(i>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:d,approval:w}=await this.client.connect({pairingTopic:u,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});d&&(this.uri=d,this.events.emit("display_uri",d)),await w().then(L=>{this.session=L;const D=Vg$1(L.namespaces);this.namespaces=Oa$1(this.namespaces,D),this.persist("namespaces",this.namespaces);}).catch(L=>{if(L.message!==ae$3)throw L;i++;});}while(!this.session);return this.onConnect(),this.session}setDefaultChain(u,i){try{if(!this.session)return;const[d,w]=this.validateChain(u);this.getProvider(d).setDefaultChain(w,i);}catch(d){if(!/Please call connect/.test(d.message))throw d}}async cleanupPendingPairings(u={}){this.logger.info("Cleaning up inactive pairings...");const i=this.client.pairing.getAll();if(k$5(i)){for(const d of i)u.deletePairings?this.client.core.expirer.set(d.topic,0):await this.client.core.relayer.subscriber.unsubscribe(d.topic);this.logger.info(`Inactive pairings cleared: ${i.length}`);}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0;}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const u=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[u]),this.createProviders();}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners();}async createClient(){this.client=this.providerOpts.client||await Q$4.init({logger:this.providerOpts.logger||Ia$1,relayUrl:this.providerOpts.relayUrl||Fg$1,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized");}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const u=[...new Set(Object.keys(this.session.namespaces).map(i=>en(i)))];Fi$1("client",this.client),Fi$1("events",this.events),Fi$1("disableProviderPing",this.disableProviderPing),u.forEach(i=>{if(!this.session)return;const d=Xg$1(i,this.session),w=Sa$1(d),L=Oa$1(this.namespaces,this.optionalNamespaces),D=Mi$1(hr$2({},L[i]),{accounts:d,chains:w});switch(i){case"eip155":this.rpcProviders[i]=new jg$1({namespace:D});break;case"solana":this.rpcProviders[i]=new nv({namespace:D});break;case"cosmos":this.rpcProviders[i]=new tv({namespace:D});break;case"polkadot":this.rpcProviders[i]=new kg$1({namespace:D});break;case"cip34":this.rpcProviders[i]=new ev({namespace:D});break;case"elrond":this.rpcProviders[i]=new rv({namespace:D});break;case"multiversx":this.rpcProviders[i]=new iv({namespace:D});break;case"near":this.rpcProviders[i]=new sv({namespace:D});break}});}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",u=>{this.events.emit("session_ping",u);}),this.client.on("session_event",u=>{const{params:i}=u,{event:d}=i;if(d.name==="accountsChanged"){const w=d.data;w&&k$5(w)&&this.events.emit("accountsChanged",w.map(Qg$1));}else if(d.name==="chainChanged"){const w=i.chainId,L=i.event.data,D=en(w),En=Wi$1(w)!==Wi$1(L)?`${D}:${Wi$1(L)}`:w;this.onChainChanged(En);}else this.events.emit(d.name,d.data);this.events.emit("session_event",u);}),this.client.on("session_update",({topic:u,params:i})=>{var d;const{namespaces:w}=i,L=(d=this.client)==null?void 0:d.session.get(u);this.session=Mi$1(hr$2({},L),{namespaces:w}),this.onSessionUpdate(),this.events.emit("session_update",{topic:u,params:i});}),this.client.on("session_delete",async u=>{await this.cleanup(),this.events.emit("session_delete",u),this.events.emit("disconnect",Mi$1(hr$2({},U$5("USER_DISCONNECTED")),{data:u.topic}));}),this.on(Vn.DEFAULT_CHAIN_CHANGED,u=>{this.onChainChanged(u,!0);});}getProvider(u){if(!this.rpcProviders[u])throw new Error(`Provider not found: ${u}`);return this.rpcProviders[u]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(u=>{var i;this.getProvider(u).updateNamespace((i=this.session)==null?void 0:i.namespaces[u]);});}setNamespaces(u){const{namespaces:i,optionalNamespaces:d,sessionProperties:w}=u;i&&Object.keys(i).length&&(this.namespaces=i),d&&Object.keys(d).length&&(this.optionalNamespaces=d),this.sessionProperties=w,this.persist("namespaces",i),this.persist("optionalNamespaces",d);}validateChain(u){const[i,d]=u?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return [i,d];if(i&&!Object.keys(this.namespaces||{}).map(D=>en(D)).includes(i))throw new Error(`Namespace '${i}' is not configured. Please call connect() first with namespace config.`);if(i&&d)return [i,d];const w=en(Object.keys(this.namespaces)[0]),L=this.rpcProviders[w].getDefaultChain();return [w,L]}async requestAccounts(){const[u]=this.validateChain();return await this.getProvider(u).requestAccounts()}onChainChanged(u,i=!1){if(!this.namespaces)return;const[d,w]=this.validateChain(u);w&&(i||this.getProvider(d).setDefaultChain(w),this.namespaces[d]?this.namespaces[d].defaultChain=w:this.namespaces[`${d}:${w}`]?this.namespaces[`${d}:${w}`].defaultChain=w:this.namespaces[`${d}:${w}`]={defaultChain:w},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",w));}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session});}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0});}persist(u,i){this.client.core.storage.setItem(`${xa}/${u}`,i);}async getFromStore(u){return await this.client.core.storage.getItem(`${xa}/${u}`)}};const hv=lr$1;
|
|
147393
147393
|
|
|
147394
|
-
const P$3="wc",S$4="ethereum_provider",$$1=`${P$3}@2:${S$4}:`,j$2="https://rpc.walletconnect.com/v1/",u$3=["eth_sendTransaction","personal_sign"],E$2=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],m$5=["chainChanged","accountsChanged"],_$2=["chainChanged","accountsChanged","message","disconnect","connect"];var N$2=Object.defineProperty,q$4=Object.defineProperties,D$4=Object.getOwnPropertyDescriptors,y$4=Object.getOwnPropertySymbols,U$3=Object.prototype.hasOwnProperty,Q$3=Object.prototype.propertyIsEnumerable,O$2=(a,t,s)=>t in a?N$2(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,p$7=(a,t)=>{for(var s in t||(t={}))U$3.call(t,s)&&O$2(a,s,t[s]);if(y$4)for(var s of y$4(t))Q$3.call(t,s)&&O$2(a,s,t[s]);return a},M$3=(a,t)=>q$4(a,D$4(t));function g$4(a){return Number(a[0].split(":")[1])}function f$7(a){return `0x${a.toString(16)}`}function L$4(a){const{chains:t,optionalChains:s,methods:i,optionalMethods:n,events:e,optionalEvents:h,rpcMap:c}=a;if(!k$5(t))throw new Error("Invalid chains");const o={chains:t,methods:i||u$3,events:e||m$5,rpcMap:p$7({},t.length?{[g$4(t)]:c[g$4(t)]}:{})},r=e?.filter(l=>!m$5.includes(l)),d=i?.filter(l=>!u$3.includes(l));if(!s&&!h&&!n&&!(r!=null&&r.length)&&!(d!=null&&d.length))return {required:t.length?o:void 0};const C=r?.length&&d?.length||!s,I={chains:[...new Set(C?o.chains.concat(s||[]):s)],methods:[...new Set(o.methods.concat(n!=null&&n.length?n:E$2))],events:[...new Set(o.events.concat(h!=null&&h.length?h:_$2))],rpcMap:c};return {required:t.length?o:void 0,optional:s.length?I:void 0}}let v$4 = class v{constructor(){this.events=new EventEmitter$
|
|
147394
|
+
const P$3="wc",S$4="ethereum_provider",$$1=`${P$3}@2:${S$4}:`,j$2="https://rpc.walletconnect.com/v1/",u$3=["eth_sendTransaction","personal_sign"],E$2=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],m$5=["chainChanged","accountsChanged"],_$2=["chainChanged","accountsChanged","message","disconnect","connect"];var N$2=Object.defineProperty,q$4=Object.defineProperties,D$4=Object.getOwnPropertyDescriptors,y$4=Object.getOwnPropertySymbols,U$3=Object.prototype.hasOwnProperty,Q$3=Object.prototype.propertyIsEnumerable,O$2=(a,t,s)=>t in a?N$2(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,p$7=(a,t)=>{for(var s in t||(t={}))U$3.call(t,s)&&O$2(a,s,t[s]);if(y$4)for(var s of y$4(t))Q$3.call(t,s)&&O$2(a,s,t[s]);return a},M$3=(a,t)=>q$4(a,D$4(t));function g$4(a){return Number(a[0].split(":")[1])}function f$7(a){return `0x${a.toString(16)}`}function L$4(a){const{chains:t,optionalChains:s,methods:i,optionalMethods:n,events:e,optionalEvents:h,rpcMap:c}=a;if(!k$5(t))throw new Error("Invalid chains");const o={chains:t,methods:i||u$3,events:e||m$5,rpcMap:p$7({},t.length?{[g$4(t)]:c[g$4(t)]}:{})},r=e?.filter(l=>!m$5.includes(l)),d=i?.filter(l=>!u$3.includes(l));if(!s&&!h&&!n&&!(r!=null&&r.length)&&!(d!=null&&d.length))return {required:t.length?o:void 0};const C=r?.length&&d?.length||!s,I={chains:[...new Set(C?o.chains.concat(s||[]):s)],methods:[...new Set(o.methods.concat(n!=null&&n.length?n:E$2))],events:[...new Set(o.events.concat(h!=null&&h.length?h:_$2))],rpcMap:c};return {required:t.length?o:void 0,optional:s.length?I:void 0}}let v$4 = class v{constructor(){this.events=new EventEmitter$2,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=$$1,this.on=(t,s)=>(this.events.on(t,s),this),this.once=(t,s)=>(this.events.once(t,s),this),this.removeListener=(t,s)=>(this.events.removeListener(t,s),this),this.off=(t,s)=>(this.events.off(t,s),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={};}static async init(t){const s=new v;return await s.initialize(t),s}async request(t,s){return await this.signer.request(t,this.formatChainId(this.chainId),s)}sendAsync(t,s,i){this.signer.sendAsync(t,s,this.formatChainId(this.chainId),i);}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:s,optional:i}=L$4(this.rpc);try{const n=await new Promise(async(h,c)=>{var o;this.rpc.showQrModal&&((o=this.modal)==null||o.subscribeModal(r=>{!r.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")));})),await this.signer.connect(M$3(p$7({namespaces:p$7({},s&&{[this.namespace]:s})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:t?.pairingTopic})).then(r=>{h(r);}).catch(r=>{c(new Error(r.message));});});if(!n)return;const e=Un(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:e),this.setAccounts(e),this.events.emit("connect",{chainId:f$7(this.chainId)});}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal();}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset();}get isWalletConnect(){return !0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:s}=t,{event:i}=s;i.name==="accountsChanged"?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):i.name==="chainChanged"?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",t);}),this.signer.on("chainChanged",t=>{const s=parseInt(t);this.chainId=s,this.events.emit("chainChanged",f$7(this.chainId)),this.persist();}),this.signer.on("session_update",t=>{this.events.emit("session_update",t);}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",M$3(p$7({},U$5("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}));}),this.signer.on("display_uri",t=>{var s,i;this.rpc.showQrModal&&((s=this.modal)==null||s.closeModal(),(i=this.modal)==null||i.openModal({uri:t})),this.events.emit("display_uri",t);});}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]});}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return `${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const s=t.filter(i=>this.isCompatibleChainId(i)).map(i=>this.parseChainId(i));s.length&&(this.chainId=s[0],this.events.emit("chainChanged",f$7(this.chainId)),this.persist());}setChainId(t){if(this.isCompatibleChainId(t)){const s=this.parseChainId(t);this.chainId=s,this.switchEthereumChain(s);}}parseAccountId(t){const[s,i,n]=t.split(":");return {chainId:`${s}:${i}`,address:n}}setAccounts(t){this.accounts=t.filter(s=>this.parseChainId(this.parseAccountId(s).chainId)===this.chainId).map(s=>this.parseAccountId(s).address),this.events.emit("accountsChanged",this.accounts);}getRpcConfig(t){var s,i;const n=(s=t?.chains)!=null?s:[],e=(i=t?.optionalChains)!=null?i:[],h=n.concat(e);if(!h.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const c=n.length?t?.methods||u$3:[],o=n.length?t?.events||m$5:[],r=t?.optionalMethods||[],d=t?.optionalEvents||[],C=t?.rpcMap||this.buildRpcMap(h,t.projectId),I=t?.qrModalOptions||void 0;return {chains:n?.map(l=>this.formatChainId(l)),optionalChains:e.map(l=>this.formatChainId(l)),methods:c,events:o,optionalMethods:r,optionalEvents:d,rpcMap:C,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:I,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,s){const i={};return t.forEach(n=>{i[n]=this.getRpcUrl(n,s);}),i}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?g$4(this.rpc.chains):g$4(this.rpc.optionalChains),this.signer=await hv.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let s;try{const{WalletConnectModal:i}=await Promise.resolve().then(function () { return index$9; });s=i;}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(s)try{this.modal=new s(p$7({projectId:this.rpc.projectId},this.rpc.qrModalOptions));}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:s,optionalChains:i,rpcMap:n}=t;s&&k$5(s)&&(this.rpc.chains=s.map(e=>this.formatChainId(e)),s.forEach(e=>{this.rpc.rpcMap[e]=n?.[e]||this.getRpcUrl(e);})),i&&k$5(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i?.map(e=>this.formatChainId(e)),i.forEach(e=>{this.rpc.rpcMap[e]=n?.[e]||this.getRpcUrl(e);}));}getRpcUrl(t,s){var i;return ((i=this.rpc.rpcMap)==null?void 0:i[t])||`${j$2}?chainId=eip155:${t}&projectId=${s||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),s=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:s?.accounts),this.setAccounts(s?.accounts);}reset(){this.chainId=1,this.accounts=[];}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId);}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(s=>this.parseAccount(s))}};
|
|
147395
147395
|
|
|
147396
147396
|
const walletConnectProviderInfo = {
|
|
147397
147397
|
name: 'Other',
|
|
@@ -192604,7 +192604,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
192604
192604
|
} (eventemitter3));
|
|
192605
192605
|
|
|
192606
192606
|
var eventemitter3Exports = eventemitter3.exports;
|
|
192607
|
-
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
|
192607
|
+
var EventEmitter$1 = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
|
192608
192608
|
|
|
192609
192609
|
class TransmuxerInterface {
|
|
192610
192610
|
constructor(hls, id, onTransmuxComplete, onFlush) {
|
|
@@ -192637,7 +192637,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
192637
192637
|
};
|
|
192638
192638
|
|
|
192639
192639
|
// forward events to main thread
|
|
192640
|
-
this.observer = new EventEmitter();
|
|
192640
|
+
this.observer = new EventEmitter$1();
|
|
192641
192641
|
this.observer.on(Events.FRAG_DECRYPTED, forwardMessage);
|
|
192642
192642
|
this.observer.on(Events.ERROR, forwardMessage);
|
|
192643
192643
|
const MediaSource = getMediaSource(config.preferManagedMediaSource) || {
|
|
@@ -199646,7 +199646,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
199646
199646
|
}
|
|
199647
199647
|
const keyId = this.getKeyIdString(context.decryptdata);
|
|
199648
199648
|
this.log(`Generating key-session request for "${reason}": ${keyId} (init data type: ${initDataType} length: ${initData ? initData.byteLength : null})`);
|
|
199649
|
-
const licenseStatus = new EventEmitter();
|
|
199649
|
+
const licenseStatus = new EventEmitter$1();
|
|
199650
199650
|
const onmessage = context._onmessage = event => {
|
|
199651
199651
|
const keySession = context.mediaKeysSession;
|
|
199652
199652
|
if (!keySession) {
|
|
@@ -205062,7 +205062,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
205062
205062
|
this.coreComponents = void 0;
|
|
205063
205063
|
this.networkControllers = void 0;
|
|
205064
205064
|
this.started = false;
|
|
205065
|
-
this._emitter = new EventEmitter();
|
|
205065
|
+
this._emitter = new EventEmitter$1();
|
|
205066
205066
|
this._autoLevelCapping = -1;
|
|
205067
205067
|
this._maxHdcpLevel = null;
|
|
205068
205068
|
this.abrController = void 0;
|
|
@@ -243516,29 +243516,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
243516
243516
|
&& tokenChoiceOptions.map((token) => (jsxs(MenuItem, { size: "medium", onClick: () => handleTokenChange(token), selected: isSelected(token), emphasized: true, children: [jsx$1(MenuItem.FramedImage, { circularFrame: true, use: (jsx$1(TokenImage, { src: token.icon, name: token.name, defaultImage: defaultTokenImage })), emphasized: false }), jsx$1(MenuItem.Label, { children: token.symbol }), token.symbol !== token.name && (jsx$1(MenuItem.Caption, { children: token.name }))] }, token.name))) })] })] }));
|
|
243517
243517
|
}
|
|
243518
243518
|
|
|
243519
|
-
const
|
|
243520
|
-
const
|
|
243521
|
-
|
|
243522
|
-
reactExports.useEffect(() => {
|
|
243523
|
-
if (!checkout) {
|
|
243524
|
-
return;
|
|
243525
|
-
}
|
|
243526
|
-
(async () => {
|
|
243527
|
-
const addresses = [];
|
|
243528
|
-
if (fromAddress) {
|
|
243529
|
-
addresses.push(fromAddress);
|
|
243530
|
-
}
|
|
243531
|
-
if (toAddress && toAddress !== fromAddress) {
|
|
243532
|
-
addresses.push(toAddress);
|
|
243533
|
-
}
|
|
243534
|
-
if (addresses.length === 0) {
|
|
243535
|
-
return;
|
|
243536
|
-
}
|
|
243537
|
-
const assessment = await fetchRiskAssessment(addresses, checkout.config);
|
|
243538
|
-
setRiskAssessment(assessment);
|
|
243539
|
-
})();
|
|
243540
|
-
}, [checkout, fromAddress, toAddress]);
|
|
243541
|
-
return { riskAssessment };
|
|
243519
|
+
const checkSanctionedAddresses = async (addresses, config) => {
|
|
243520
|
+
const result = await fetchRiskAssessment(addresses, config);
|
|
243521
|
+
return isAddressSanctioned(result);
|
|
243542
243522
|
};
|
|
243543
243523
|
|
|
243544
243524
|
function AddTokens({ checkout, toAmount, config, toTokenAddress, showOnrampOption = true, showSwapOption = true, showBridgeOption = true, onCloseButtonClick, showBackButton, onBackButtonClick, }) {
|
|
@@ -243558,7 +243538,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
243558
243538
|
const [inputValue, setInputValue] = reactExports.useState(selectedAmount || toAmount || '');
|
|
243559
243539
|
const [fetchingRoutes, setFetchingRoutes] = reactExports.useState(false);
|
|
243560
243540
|
const [insufficientBalance, setInsufficientBalance] = reactExports.useState(false);
|
|
243561
|
-
const { riskAssessment } = useRiskAssessment();
|
|
243562
243541
|
const selectedAmountUsd = reactExports.useMemo(() => convertToUsd(tokens, inputValue, selectedToken), [tokens, inputValue, selectedToken]);
|
|
243563
243542
|
const setSelectedAmount = reactExports.useMemo(() => debounce$2((value) => {
|
|
243564
243543
|
addTokensDispatch({
|
|
@@ -243697,8 +243676,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
243697
243676
|
};
|
|
243698
243677
|
fetchOnRampTokens();
|
|
243699
243678
|
}, [checkout]);
|
|
243700
|
-
const sendRequestOnRampEvent = () => {
|
|
243701
|
-
if (
|
|
243679
|
+
const sendRequestOnRampEvent = async () => {
|
|
243680
|
+
if (toAddress
|
|
243681
|
+
&& (await checkSanctionedAddresses([toAddress], checkout.config))) {
|
|
243702
243682
|
viewDispatch({
|
|
243703
243683
|
payload: {
|
|
243704
243684
|
type: ViewActions.UPDATE_VIEW,
|
|
@@ -243737,10 +243717,10 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
243737
243717
|
sendRequestOnRampEvent();
|
|
243738
243718
|
};
|
|
243739
243719
|
reactExports.useEffect(() => {
|
|
243740
|
-
if (toProvider &&
|
|
243720
|
+
if (toProvider && payWithCardClicked) {
|
|
243741
243721
|
sendRequestOnRampEvent();
|
|
243742
243722
|
}
|
|
243743
|
-
}, [toProvider,
|
|
243723
|
+
}, [toProvider, payWithCardClicked]);
|
|
243744
243724
|
const handleRouteClick = (route) => {
|
|
243745
243725
|
setShowOptionsDrawer(false);
|
|
243746
243726
|
setShowPayWithDrawer(false);
|
|
@@ -243753,10 +243733,12 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
243753
243733
|
}
|
|
243754
243734
|
setShowDeliverToDrawer(false);
|
|
243755
243735
|
};
|
|
243756
|
-
const handleReviewClick = () => {
|
|
243736
|
+
const handleReviewClick = async () => {
|
|
243757
243737
|
if (!selectedRouteData || !selectedToken?.address)
|
|
243758
243738
|
return;
|
|
243759
|
-
if (
|
|
243739
|
+
if (fromAddress
|
|
243740
|
+
&& toAddress
|
|
243741
|
+
&& (await checkSanctionedAddresses([fromAddress, toAddress], checkout.config))) {
|
|
243760
243742
|
viewDispatch({
|
|
243761
243743
|
payload: {
|
|
243762
243744
|
type: ViewActions.UPDATE_VIEW,
|
|
@@ -243818,7 +243800,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
243818
243800
|
&& validateToAmount$1(inputValue).isValid;
|
|
243819
243801
|
const loading = (routeInputsReady || fetchingRoutes)
|
|
243820
243802
|
&& !(selectedRouteData || insufficientBalance);
|
|
243821
|
-
const readyToReview = routeInputsReady && !!toAddress && !!selectedRouteData && !loading
|
|
243803
|
+
const readyToReview = routeInputsReady && !!toAddress && !!selectedRouteData && !loading;
|
|
243822
243804
|
const handleWalletConnected = (providerType, provider, providerInfo) => {
|
|
243823
243805
|
track({
|
|
243824
243806
|
userJourney: UserJourney.ADD_TOKENS,
|
|
@@ -243876,7 +243858,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
243876
243858
|
: {}, label: t('views.ADD_TOKENS.walletSelection.toText'), providerInfo: {
|
|
243877
243859
|
...toProviderInfo,
|
|
243878
243860
|
address: toAddress,
|
|
243879
|
-
}, onClick: () => setShowDeliverToDrawer(true), disabled: lockedToProvider })] }), jsx$1(Button, { testId: "add-tokens-button", size: "large", variant: readyToReview ? 'primary' : 'secondary', disabled: !readyToReview, onClick: handleReviewClick, sx: { opacity: readyToReview ? 1 : 0.5 }, children: t('views.ADD_TOKENS.review.buttonText') }), jsx$1(SquidFooter, {}), jsx$1(PayWithWalletDrawer, { visible: showPayWithDrawer, walletOptions: walletOptions, onClose: () => setShowPayWithDrawer(false), onPayWithCard: handleCardClick, onConnect: handleWalletConnected, insufficientBalance: insufficientBalance, showOnRampOption: shouldShowOnRampOption }), jsx$1(OptionsDrawer, { checkout: checkout, routes: routes, showOnrampOption: shouldShowOnRampOption, showSwapOption: showSwapOption, showBridgeOption: showBridgeOption, visible: showOptionsDrawer, onClose: () => setShowOptionsDrawer(false), onCardClick: handleCardClick, onRouteClick: handleRouteClick, insufficientBalance: insufficientBalance }), jsx$1(DeliverToWalletDrawer, { visible: showDeliverToDrawer, walletOptions: walletOptions, onClose: handleDeliverToClose, onConnect: handleWalletConnected }), jsx$1(OnboardingDrawer, { environment: checkout?.config.environment })] })] }) }));
|
|
243861
|
+
}, onClick: () => setShowDeliverToDrawer(true), disabled: lockedToProvider })] }), jsx$1(Button, { testId: "add-tokens-button", size: "large", variant: readyToReview ? 'primary' : 'secondary', disabled: !readyToReview, onClick: handleReviewClick, sx: { opacity: readyToReview ? 1 : 0.5 }, children: t('views.ADD_TOKENS.review.buttonText') }), jsx$1(SquidFooter, {}), jsx$1(PayWithWalletDrawer, { visible: showPayWithDrawer, walletOptions: walletOptions, onClose: () => setShowPayWithDrawer(false), onPayWithCard: handleCardClick, onConnect: handleWalletConnected, insufficientBalance: insufficientBalance, showOnRampOption: shouldShowOnRampOption || !selectedToken }), jsx$1(OptionsDrawer, { checkout: checkout, routes: routes, showOnrampOption: shouldShowOnRampOption, showSwapOption: showSwapOption, showBridgeOption: showBridgeOption, visible: showOptionsDrawer, onClose: () => setShowOptionsDrawer(false), onCardClick: handleCardClick, onRouteClick: handleRouteClick, insufficientBalance: insufficientBalance }), jsx$1(DeliverToWalletDrawer, { visible: showDeliverToDrawer, walletOptions: walletOptions, onClose: handleDeliverToClose, onConnect: handleWalletConnected }), jsx$1(OnboardingDrawer, { environment: checkout?.config.environment })] })] }) }));
|
|
243880
243862
|
}
|
|
243881
243863
|
|
|
243882
243864
|
var dist$2 = {};
|
|
@@ -265852,11 +265834,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
265852
265834
|
|
|
265853
265835
|
var utf8$6 = {};
|
|
265854
265836
|
|
|
265855
|
-
var hasRequiredUtf8$
|
|
265837
|
+
var hasRequiredUtf8$1;
|
|
265856
265838
|
|
|
265857
|
-
function requireUtf8$
|
|
265858
|
-
if (hasRequiredUtf8$
|
|
265859
|
-
hasRequiredUtf8$
|
|
265839
|
+
function requireUtf8$1 () {
|
|
265840
|
+
if (hasRequiredUtf8$1) return utf8$6;
|
|
265841
|
+
hasRequiredUtf8$1 = 1;
|
|
265860
265842
|
(function (exports) {
|
|
265861
265843
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
265862
265844
|
exports.toUtf8CodePoints = exports.toUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = void 0;
|
|
@@ -266174,7 +266156,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
266174
266156
|
const data_js_1 = requireData$1();
|
|
266175
266157
|
const errors_js_1 = requireErrors$1();
|
|
266176
266158
|
const properties_js_1 = requireProperties$1();
|
|
266177
|
-
const utf8_js_1 = requireUtf8$
|
|
266159
|
+
const utf8_js_1 = requireUtf8$1();
|
|
266178
266160
|
const geturl_js_1 = requireGeturlBrowser$1();
|
|
266179
266161
|
const MAX_ATTEMPTS = 12;
|
|
266180
266162
|
const SLOT_INTERVAL = 250;
|
|
@@ -267898,7 +267880,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
267898
267880
|
Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return units_js_1.parseEther; } });
|
|
267899
267881
|
Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return units_js_1.formatUnits; } });
|
|
267900
267882
|
Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return units_js_1.parseUnits; } });
|
|
267901
|
-
var utf8_js_1 = requireUtf8$
|
|
267883
|
+
var utf8_js_1 = requireUtf8$1();
|
|
267902
267884
|
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return utf8_js_1.toUtf8Bytes; } });
|
|
267903
267885
|
Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return utf8_js_1.toUtf8CodePoints; } });
|
|
267904
267886
|
Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return utf8_js_1.toUtf8String; } });
|
|
@@ -272692,7 +272674,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
272692
272674
|
hasRequiredString$1 = 1;
|
|
272693
272675
|
Object.defineProperty(string$1, "__esModule", { value: true });
|
|
272694
272676
|
string$1.StringCoder = void 0;
|
|
272695
|
-
const utf8_js_1 = requireUtf8$
|
|
272677
|
+
const utf8_js_1 = requireUtf8$1();
|
|
272696
272678
|
const typed_js_1 = requireTyped$1();
|
|
272697
272679
|
const bytes_js_1 = requireBytes$1();
|
|
272698
272680
|
/**
|
|
@@ -280897,15 +280879,15 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
280897
280879
|
return contract$2;
|
|
280898
280880
|
}
|
|
280899
280881
|
|
|
280900
|
-
var factory$
|
|
280882
|
+
var factory$2 = {};
|
|
280901
280883
|
|
|
280902
280884
|
var hasRequiredFactory$1;
|
|
280903
280885
|
|
|
280904
280886
|
function requireFactory$1 () {
|
|
280905
|
-
if (hasRequiredFactory$1) return factory$
|
|
280887
|
+
if (hasRequiredFactory$1) return factory$2;
|
|
280906
280888
|
hasRequiredFactory$1 = 1;
|
|
280907
|
-
Object.defineProperty(factory$
|
|
280908
|
-
factory$
|
|
280889
|
+
Object.defineProperty(factory$2, "__esModule", { value: true });
|
|
280890
|
+
factory$2.ContractFactory = void 0;
|
|
280909
280891
|
const index_js_1 = requireAbi$1();
|
|
280910
280892
|
const index_js_2 = requireAddress$6();
|
|
280911
280893
|
const index_js_3 = requireUtils$5();
|
|
@@ -281017,9 +280999,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
281017
280999
|
return new this(abi, bytecode, runner);
|
|
281018
281000
|
}
|
|
281019
281001
|
}
|
|
281020
|
-
factory$
|
|
281002
|
+
factory$2.ContractFactory = ContractFactory;
|
|
281021
281003
|
|
|
281022
|
-
return factory$
|
|
281004
|
+
return factory$2;
|
|
281023
281005
|
}
|
|
281024
281006
|
|
|
281025
281007
|
var hasRequiredContract$2;
|
|
@@ -292217,11 +292199,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
292217
292199
|
|
|
292218
292200
|
var utf8$5 = {};
|
|
292219
292201
|
|
|
292220
|
-
var hasRequiredUtf8
|
|
292202
|
+
var hasRequiredUtf8;
|
|
292221
292203
|
|
|
292222
|
-
function requireUtf8
|
|
292223
|
-
if (hasRequiredUtf8
|
|
292224
|
-
hasRequiredUtf8
|
|
292204
|
+
function requireUtf8 () {
|
|
292205
|
+
if (hasRequiredUtf8) return utf8$5;
|
|
292206
|
+
hasRequiredUtf8 = 1;
|
|
292225
292207
|
(function (exports) {
|
|
292226
292208
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
292227
292209
|
exports.toUtf8CodePoints = exports.toUtf8String = exports.toUtf8Bytes = exports.Utf8ErrorFuncs = void 0;
|
|
@@ -292557,7 +292539,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
292557
292539
|
const data_js_1 = requireData();
|
|
292558
292540
|
const errors_js_1 = requireErrors();
|
|
292559
292541
|
const properties_js_1 = requireProperties();
|
|
292560
|
-
const utf8_js_1 = requireUtf8
|
|
292542
|
+
const utf8_js_1 = requireUtf8();
|
|
292561
292543
|
const geturl_js_1 = requireGeturlBrowser();
|
|
292562
292544
|
const MAX_ATTEMPTS = 12;
|
|
292563
292545
|
const SLOT_INTERVAL = 250;
|
|
@@ -294297,7 +294279,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
294297
294279
|
Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return units_js_1.parseEther; } });
|
|
294298
294280
|
Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return units_js_1.formatUnits; } });
|
|
294299
294281
|
Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return units_js_1.parseUnits; } });
|
|
294300
|
-
var utf8_js_1 = requireUtf8
|
|
294282
|
+
var utf8_js_1 = requireUtf8();
|
|
294301
294283
|
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return utf8_js_1.toUtf8Bytes; } });
|
|
294302
294284
|
Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return utf8_js_1.toUtf8CodePoints; } });
|
|
294303
294285
|
Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return utf8_js_1.toUtf8String; } });
|
|
@@ -299156,7 +299138,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
299156
299138
|
hasRequiredString = 1;
|
|
299157
299139
|
Object.defineProperty(string, "__esModule", { value: true });
|
|
299158
299140
|
string.StringCoder = void 0;
|
|
299159
|
-
const utf8_js_1 = requireUtf8
|
|
299141
|
+
const utf8_js_1 = requireUtf8();
|
|
299160
299142
|
const typed_js_1 = requireTyped();
|
|
299161
299143
|
const bytes_js_1 = requireBytes();
|
|
299162
299144
|
/**
|
|
@@ -307777,15 +307759,15 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
307777
307759
|
return contract;
|
|
307778
307760
|
}
|
|
307779
307761
|
|
|
307780
|
-
var factory = {};
|
|
307762
|
+
var factory$1 = {};
|
|
307781
307763
|
|
|
307782
307764
|
var hasRequiredFactory;
|
|
307783
307765
|
|
|
307784
307766
|
function requireFactory () {
|
|
307785
|
-
if (hasRequiredFactory) return factory;
|
|
307767
|
+
if (hasRequiredFactory) return factory$1;
|
|
307786
307768
|
hasRequiredFactory = 1;
|
|
307787
|
-
Object.defineProperty(factory, "__esModule", { value: true });
|
|
307788
|
-
factory.ContractFactory = void 0;
|
|
307769
|
+
Object.defineProperty(factory$1, "__esModule", { value: true });
|
|
307770
|
+
factory$1.ContractFactory = void 0;
|
|
307789
307771
|
const index_js_1 = requireAbi();
|
|
307790
307772
|
const index_js_2 = requireAddress$2();
|
|
307791
307773
|
const index_js_3 = requireUtils$2();
|
|
@@ -307897,9 +307879,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
307897
307879
|
return new this(abi, bytecode, runner);
|
|
307898
307880
|
}
|
|
307899
307881
|
}
|
|
307900
|
-
factory.ContractFactory = ContractFactory;
|
|
307882
|
+
factory$1.ContractFactory = ContractFactory;
|
|
307901
307883
|
|
|
307902
|
-
return factory;
|
|
307884
|
+
return factory$1;
|
|
307903
307885
|
}
|
|
307904
307886
|
|
|
307905
307887
|
var hasRequiredContract;
|
|
@@ -319245,838 +319227,783 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
319245
319227
|
|
|
319246
319228
|
var minimal$1 = {};
|
|
319247
319229
|
|
|
319248
|
-
var aspromise;
|
|
319249
|
-
var hasRequiredAspromise;
|
|
319250
|
-
|
|
319251
|
-
function requireAspromise () {
|
|
319252
|
-
if (hasRequiredAspromise) return aspromise;
|
|
319253
|
-
hasRequiredAspromise = 1;
|
|
319254
|
-
aspromise = asPromise;
|
|
319230
|
+
var aspromise = asPromise;
|
|
319255
319231
|
|
|
319256
|
-
|
|
319257
|
-
|
|
319258
|
-
|
|
319259
|
-
|
|
319260
|
-
|
|
319261
|
-
|
|
319262
|
-
|
|
319263
|
-
|
|
319232
|
+
/**
|
|
319233
|
+
* Callback as used by {@link util.asPromise}.
|
|
319234
|
+
* @typedef asPromiseCallback
|
|
319235
|
+
* @type {function}
|
|
319236
|
+
* @param {Error|null} error Error, if any
|
|
319237
|
+
* @param {...*} params Additional arguments
|
|
319238
|
+
* @returns {undefined}
|
|
319239
|
+
*/
|
|
319264
319240
|
|
|
319265
|
-
|
|
319266
|
-
|
|
319267
|
-
|
|
319268
|
-
|
|
319269
|
-
|
|
319270
|
-
|
|
319271
|
-
|
|
319272
|
-
|
|
319273
|
-
|
|
319274
|
-
|
|
319275
|
-
|
|
319276
|
-
|
|
319277
|
-
|
|
319278
|
-
|
|
319279
|
-
|
|
319280
|
-
|
|
319281
|
-
|
|
319282
|
-
|
|
319283
|
-
|
|
319284
|
-
|
|
319285
|
-
|
|
319286
|
-
|
|
319287
|
-
|
|
319288
|
-
|
|
319289
|
-
|
|
319290
|
-
|
|
319291
|
-
|
|
319292
|
-
|
|
319293
|
-
|
|
319294
|
-
|
|
319295
|
-
|
|
319296
|
-
|
|
319297
|
-
|
|
319298
|
-
|
|
319299
|
-
|
|
319300
|
-
|
|
319301
|
-
|
|
319302
|
-
|
|
319303
|
-
|
|
319304
|
-
}
|
|
319305
|
-
return aspromise;
|
|
319241
|
+
/**
|
|
319242
|
+
* Returns a promise from a node-style callback function.
|
|
319243
|
+
* @memberof util
|
|
319244
|
+
* @param {asPromiseCallback} fn Function to call
|
|
319245
|
+
* @param {*} ctx Function context
|
|
319246
|
+
* @param {...*} params Function arguments
|
|
319247
|
+
* @returns {Promise<*>} Promisified function
|
|
319248
|
+
*/
|
|
319249
|
+
function asPromise(fn, ctx/*, varargs */) {
|
|
319250
|
+
var params = new Array(arguments.length - 1),
|
|
319251
|
+
offset = 0,
|
|
319252
|
+
index = 2,
|
|
319253
|
+
pending = true;
|
|
319254
|
+
while (index < arguments.length)
|
|
319255
|
+
params[offset++] = arguments[index++];
|
|
319256
|
+
return new Promise(function executor(resolve, reject) {
|
|
319257
|
+
params[offset] = function callback(err/*, varargs */) {
|
|
319258
|
+
if (pending) {
|
|
319259
|
+
pending = false;
|
|
319260
|
+
if (err)
|
|
319261
|
+
reject(err);
|
|
319262
|
+
else {
|
|
319263
|
+
var params = new Array(arguments.length - 1),
|
|
319264
|
+
offset = 0;
|
|
319265
|
+
while (offset < params.length)
|
|
319266
|
+
params[offset++] = arguments[offset];
|
|
319267
|
+
resolve.apply(null, params);
|
|
319268
|
+
}
|
|
319269
|
+
}
|
|
319270
|
+
};
|
|
319271
|
+
try {
|
|
319272
|
+
fn.apply(ctx || null, params);
|
|
319273
|
+
} catch (err) {
|
|
319274
|
+
if (pending) {
|
|
319275
|
+
pending = false;
|
|
319276
|
+
reject(err);
|
|
319277
|
+
}
|
|
319278
|
+
}
|
|
319279
|
+
});
|
|
319306
319280
|
}
|
|
319307
319281
|
|
|
319308
319282
|
var base64$2 = {};
|
|
319309
319283
|
|
|
319310
|
-
|
|
319311
|
-
|
|
319312
|
-
function requireBase64 () {
|
|
319313
|
-
if (hasRequiredBase64) return base64$2;
|
|
319314
|
-
hasRequiredBase64 = 1;
|
|
319315
|
-
(function (exports) {
|
|
319316
|
-
|
|
319317
|
-
/**
|
|
319318
|
-
* A minimal base64 implementation for number arrays.
|
|
319319
|
-
* @memberof util
|
|
319320
|
-
* @namespace
|
|
319321
|
-
*/
|
|
319322
|
-
var base64 = exports;
|
|
319323
|
-
|
|
319324
|
-
/**
|
|
319325
|
-
* Calculates the byte length of a base64 encoded string.
|
|
319326
|
-
* @param {string} string Base64 encoded string
|
|
319327
|
-
* @returns {number} Byte length
|
|
319328
|
-
*/
|
|
319329
|
-
base64.length = function length(string) {
|
|
319330
|
-
var p = string.length;
|
|
319331
|
-
if (!p)
|
|
319332
|
-
return 0;
|
|
319333
|
-
var n = 0;
|
|
319334
|
-
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
319335
|
-
++n;
|
|
319336
|
-
return Math.ceil(string.length * 3) / 4 - n;
|
|
319337
|
-
};
|
|
319338
|
-
|
|
319339
|
-
// Base64 encoding table
|
|
319340
|
-
var b64 = new Array(64);
|
|
319341
|
-
|
|
319342
|
-
// Base64 decoding table
|
|
319343
|
-
var s64 = new Array(123);
|
|
319344
|
-
|
|
319345
|
-
// 65..90, 97..122, 48..57, 43, 47
|
|
319346
|
-
for (var i = 0; i < 64;)
|
|
319347
|
-
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
|
|
319348
|
-
|
|
319349
|
-
/**
|
|
319350
|
-
* Encodes a buffer to a base64 encoded string.
|
|
319351
|
-
* @param {Uint8Array} buffer Source buffer
|
|
319352
|
-
* @param {number} start Source start
|
|
319353
|
-
* @param {number} end Source end
|
|
319354
|
-
* @returns {string} Base64 encoded string
|
|
319355
|
-
*/
|
|
319356
|
-
base64.encode = function encode(buffer, start, end) {
|
|
319357
|
-
var parts = null,
|
|
319358
|
-
chunk = [];
|
|
319359
|
-
var i = 0, // output index
|
|
319360
|
-
j = 0, // goto index
|
|
319361
|
-
t; // temporary
|
|
319362
|
-
while (start < end) {
|
|
319363
|
-
var b = buffer[start++];
|
|
319364
|
-
switch (j) {
|
|
319365
|
-
case 0:
|
|
319366
|
-
chunk[i++] = b64[b >> 2];
|
|
319367
|
-
t = (b & 3) << 4;
|
|
319368
|
-
j = 1;
|
|
319369
|
-
break;
|
|
319370
|
-
case 1:
|
|
319371
|
-
chunk[i++] = b64[t | b >> 4];
|
|
319372
|
-
t = (b & 15) << 2;
|
|
319373
|
-
j = 2;
|
|
319374
|
-
break;
|
|
319375
|
-
case 2:
|
|
319376
|
-
chunk[i++] = b64[t | b >> 6];
|
|
319377
|
-
chunk[i++] = b64[b & 63];
|
|
319378
|
-
j = 0;
|
|
319379
|
-
break;
|
|
319380
|
-
}
|
|
319381
|
-
if (i > 8191) {
|
|
319382
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
319383
|
-
i = 0;
|
|
319384
|
-
}
|
|
319385
|
-
}
|
|
319386
|
-
if (j) {
|
|
319387
|
-
chunk[i++] = b64[t];
|
|
319388
|
-
chunk[i++] = 61;
|
|
319389
|
-
if (j === 1)
|
|
319390
|
-
chunk[i++] = 61;
|
|
319391
|
-
}
|
|
319392
|
-
if (parts) {
|
|
319393
|
-
if (i)
|
|
319394
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
319395
|
-
return parts.join("");
|
|
319396
|
-
}
|
|
319397
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
319398
|
-
};
|
|
319399
|
-
|
|
319400
|
-
var invalidEncoding = "invalid encoding";
|
|
319401
|
-
|
|
319402
|
-
/**
|
|
319403
|
-
* Decodes a base64 encoded string to a buffer.
|
|
319404
|
-
* @param {string} string Source string
|
|
319405
|
-
* @param {Uint8Array} buffer Destination buffer
|
|
319406
|
-
* @param {number} offset Destination offset
|
|
319407
|
-
* @returns {number} Number of bytes written
|
|
319408
|
-
* @throws {Error} If encoding is invalid
|
|
319409
|
-
*/
|
|
319410
|
-
base64.decode = function decode(string, buffer, offset) {
|
|
319411
|
-
var start = offset;
|
|
319412
|
-
var j = 0, // goto index
|
|
319413
|
-
t; // temporary
|
|
319414
|
-
for (var i = 0; i < string.length;) {
|
|
319415
|
-
var c = string.charCodeAt(i++);
|
|
319416
|
-
if (c === 61 && j > 1)
|
|
319417
|
-
break;
|
|
319418
|
-
if ((c = s64[c]) === undefined)
|
|
319419
|
-
throw Error(invalidEncoding);
|
|
319420
|
-
switch (j) {
|
|
319421
|
-
case 0:
|
|
319422
|
-
t = c;
|
|
319423
|
-
j = 1;
|
|
319424
|
-
break;
|
|
319425
|
-
case 1:
|
|
319426
|
-
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
319427
|
-
t = c;
|
|
319428
|
-
j = 2;
|
|
319429
|
-
break;
|
|
319430
|
-
case 2:
|
|
319431
|
-
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
319432
|
-
t = c;
|
|
319433
|
-
j = 3;
|
|
319434
|
-
break;
|
|
319435
|
-
case 3:
|
|
319436
|
-
buffer[offset++] = (t & 3) << 6 | c;
|
|
319437
|
-
j = 0;
|
|
319438
|
-
break;
|
|
319439
|
-
}
|
|
319440
|
-
}
|
|
319441
|
-
if (j === 1)
|
|
319442
|
-
throw Error(invalidEncoding);
|
|
319443
|
-
return offset - start;
|
|
319444
|
-
};
|
|
319445
|
-
|
|
319446
|
-
/**
|
|
319447
|
-
* Tests if the specified string appears to be base64 encoded.
|
|
319448
|
-
* @param {string} string String to test
|
|
319449
|
-
* @returns {boolean} `true` if probably base64 encoded, otherwise false
|
|
319450
|
-
*/
|
|
319451
|
-
base64.test = function test(string) {
|
|
319452
|
-
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
|
|
319453
|
-
};
|
|
319454
|
-
} (base64$2));
|
|
319455
|
-
return base64$2;
|
|
319456
|
-
}
|
|
319457
|
-
|
|
319458
|
-
var eventemitter;
|
|
319459
|
-
var hasRequiredEventemitter;
|
|
319460
|
-
|
|
319461
|
-
function requireEventemitter () {
|
|
319462
|
-
if (hasRequiredEventemitter) return eventemitter;
|
|
319463
|
-
hasRequiredEventemitter = 1;
|
|
319464
|
-
eventemitter = EventEmitter;
|
|
319284
|
+
(function (exports) {
|
|
319465
319285
|
|
|
319466
319286
|
/**
|
|
319467
|
-
*
|
|
319468
|
-
* @classdesc A minimal event emitter.
|
|
319287
|
+
* A minimal base64 implementation for number arrays.
|
|
319469
319288
|
* @memberof util
|
|
319470
|
-
* @
|
|
319289
|
+
* @namespace
|
|
319471
319290
|
*/
|
|
319472
|
-
|
|
319473
|
-
|
|
319474
|
-
/**
|
|
319475
|
-
* Registered listeners.
|
|
319476
|
-
* @type {Object.<string,*>}
|
|
319477
|
-
* @private
|
|
319478
|
-
*/
|
|
319479
|
-
this._listeners = {};
|
|
319480
|
-
}
|
|
319291
|
+
var base64 = exports;
|
|
319481
319292
|
|
|
319482
319293
|
/**
|
|
319483
|
-
*
|
|
319484
|
-
* @param {string}
|
|
319485
|
-
* @
|
|
319486
|
-
* @param {*} [ctx] Listener context
|
|
319487
|
-
* @returns {util.EventEmitter} `this`
|
|
319294
|
+
* Calculates the byte length of a base64 encoded string.
|
|
319295
|
+
* @param {string} string Base64 encoded string
|
|
319296
|
+
* @returns {number} Byte length
|
|
319488
319297
|
*/
|
|
319489
|
-
|
|
319490
|
-
|
|
319491
|
-
|
|
319492
|
-
|
|
319493
|
-
|
|
319494
|
-
|
|
319298
|
+
base64.length = function length(string) {
|
|
319299
|
+
var p = string.length;
|
|
319300
|
+
if (!p)
|
|
319301
|
+
return 0;
|
|
319302
|
+
var n = 0;
|
|
319303
|
+
while (--p % 4 > 1 && string.charAt(p) === "=")
|
|
319304
|
+
++n;
|
|
319305
|
+
return Math.ceil(string.length * 3) / 4 - n;
|
|
319495
319306
|
};
|
|
319496
319307
|
|
|
319308
|
+
// Base64 encoding table
|
|
319309
|
+
var b64 = new Array(64);
|
|
319310
|
+
|
|
319311
|
+
// Base64 decoding table
|
|
319312
|
+
var s64 = new Array(123);
|
|
319313
|
+
|
|
319314
|
+
// 65..90, 97..122, 48..57, 43, 47
|
|
319315
|
+
for (var i = 0; i < 64;)
|
|
319316
|
+
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
|
|
319317
|
+
|
|
319497
319318
|
/**
|
|
319498
|
-
*
|
|
319499
|
-
* @param {
|
|
319500
|
-
* @param {
|
|
319501
|
-
* @
|
|
319319
|
+
* Encodes a buffer to a base64 encoded string.
|
|
319320
|
+
* @param {Uint8Array} buffer Source buffer
|
|
319321
|
+
* @param {number} start Source start
|
|
319322
|
+
* @param {number} end Source end
|
|
319323
|
+
* @returns {string} Base64 encoded string
|
|
319502
319324
|
*/
|
|
319503
|
-
|
|
319504
|
-
|
|
319505
|
-
|
|
319506
|
-
|
|
319507
|
-
|
|
319508
|
-
|
|
319509
|
-
|
|
319510
|
-
|
|
319511
|
-
|
|
319512
|
-
|
|
319513
|
-
|
|
319514
|
-
|
|
319515
|
-
|
|
319325
|
+
base64.encode = function encode(buffer, start, end) {
|
|
319326
|
+
var parts = null,
|
|
319327
|
+
chunk = [];
|
|
319328
|
+
var i = 0, // output index
|
|
319329
|
+
j = 0, // goto index
|
|
319330
|
+
t; // temporary
|
|
319331
|
+
while (start < end) {
|
|
319332
|
+
var b = buffer[start++];
|
|
319333
|
+
switch (j) {
|
|
319334
|
+
case 0:
|
|
319335
|
+
chunk[i++] = b64[b >> 2];
|
|
319336
|
+
t = (b & 3) << 4;
|
|
319337
|
+
j = 1;
|
|
319338
|
+
break;
|
|
319339
|
+
case 1:
|
|
319340
|
+
chunk[i++] = b64[t | b >> 4];
|
|
319341
|
+
t = (b & 15) << 2;
|
|
319342
|
+
j = 2;
|
|
319343
|
+
break;
|
|
319344
|
+
case 2:
|
|
319345
|
+
chunk[i++] = b64[t | b >> 6];
|
|
319346
|
+
chunk[i++] = b64[b & 63];
|
|
319347
|
+
j = 0;
|
|
319348
|
+
break;
|
|
319349
|
+
}
|
|
319350
|
+
if (i > 8191) {
|
|
319351
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
319352
|
+
i = 0;
|
|
319516
319353
|
}
|
|
319517
319354
|
}
|
|
319518
|
-
|
|
319355
|
+
if (j) {
|
|
319356
|
+
chunk[i++] = b64[t];
|
|
319357
|
+
chunk[i++] = 61;
|
|
319358
|
+
if (j === 1)
|
|
319359
|
+
chunk[i++] = 61;
|
|
319360
|
+
}
|
|
319361
|
+
if (parts) {
|
|
319362
|
+
if (i)
|
|
319363
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
319364
|
+
return parts.join("");
|
|
319365
|
+
}
|
|
319366
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
319519
319367
|
};
|
|
319520
319368
|
|
|
319369
|
+
var invalidEncoding = "invalid encoding";
|
|
319370
|
+
|
|
319521
319371
|
/**
|
|
319522
|
-
*
|
|
319523
|
-
* @param {string}
|
|
319524
|
-
* @param {
|
|
319525
|
-
* @
|
|
319372
|
+
* Decodes a base64 encoded string to a buffer.
|
|
319373
|
+
* @param {string} string Source string
|
|
319374
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
319375
|
+
* @param {number} offset Destination offset
|
|
319376
|
+
* @returns {number} Number of bytes written
|
|
319377
|
+
* @throws {Error} If encoding is invalid
|
|
319526
319378
|
*/
|
|
319527
|
-
|
|
319528
|
-
var
|
|
319529
|
-
|
|
319530
|
-
|
|
319531
|
-
|
|
319532
|
-
|
|
319533
|
-
|
|
319534
|
-
|
|
319535
|
-
|
|
319379
|
+
base64.decode = function decode(string, buffer, offset) {
|
|
319380
|
+
var start = offset;
|
|
319381
|
+
var j = 0, // goto index
|
|
319382
|
+
t; // temporary
|
|
319383
|
+
for (var i = 0; i < string.length;) {
|
|
319384
|
+
var c = string.charCodeAt(i++);
|
|
319385
|
+
if (c === 61 && j > 1)
|
|
319386
|
+
break;
|
|
319387
|
+
if ((c = s64[c]) === undefined)
|
|
319388
|
+
throw Error(invalidEncoding);
|
|
319389
|
+
switch (j) {
|
|
319390
|
+
case 0:
|
|
319391
|
+
t = c;
|
|
319392
|
+
j = 1;
|
|
319393
|
+
break;
|
|
319394
|
+
case 1:
|
|
319395
|
+
buffer[offset++] = t << 2 | (c & 48) >> 4;
|
|
319396
|
+
t = c;
|
|
319397
|
+
j = 2;
|
|
319398
|
+
break;
|
|
319399
|
+
case 2:
|
|
319400
|
+
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
|
|
319401
|
+
t = c;
|
|
319402
|
+
j = 3;
|
|
319403
|
+
break;
|
|
319404
|
+
case 3:
|
|
319405
|
+
buffer[offset++] = (t & 3) << 6 | c;
|
|
319406
|
+
j = 0;
|
|
319407
|
+
break;
|
|
319408
|
+
}
|
|
319536
319409
|
}
|
|
319537
|
-
|
|
319538
|
-
|
|
319539
|
-
|
|
319540
|
-
|
|
319541
|
-
|
|
319542
|
-
var float;
|
|
319543
|
-
var hasRequiredFloat;
|
|
319544
|
-
|
|
319545
|
-
function requireFloat () {
|
|
319546
|
-
if (hasRequiredFloat) return float;
|
|
319547
|
-
hasRequiredFloat = 1;
|
|
319548
|
-
|
|
319549
|
-
float = factory(factory);
|
|
319410
|
+
if (j === 1)
|
|
319411
|
+
throw Error(invalidEncoding);
|
|
319412
|
+
return offset - start;
|
|
319413
|
+
};
|
|
319550
319414
|
|
|
319551
319415
|
/**
|
|
319552
|
-
*
|
|
319553
|
-
* @
|
|
319554
|
-
* @
|
|
319416
|
+
* Tests if the specified string appears to be base64 encoded.
|
|
319417
|
+
* @param {string} string String to test
|
|
319418
|
+
* @returns {boolean} `true` if probably base64 encoded, otherwise false
|
|
319555
319419
|
*/
|
|
319420
|
+
base64.test = function test(string) {
|
|
319421
|
+
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
|
|
319422
|
+
};
|
|
319423
|
+
} (base64$2));
|
|
319424
|
+
|
|
319425
|
+
var eventemitter = EventEmitter;
|
|
319556
319426
|
|
|
319557
|
-
|
|
319558
|
-
|
|
319559
|
-
|
|
319560
|
-
|
|
319561
|
-
|
|
319562
|
-
|
|
319563
|
-
|
|
319564
|
-
* @returns {undefined}
|
|
319565
|
-
*/
|
|
319427
|
+
/**
|
|
319428
|
+
* Constructs a new event emitter instance.
|
|
319429
|
+
* @classdesc A minimal event emitter.
|
|
319430
|
+
* @memberof util
|
|
319431
|
+
* @constructor
|
|
319432
|
+
*/
|
|
319433
|
+
function EventEmitter() {
|
|
319566
319434
|
|
|
319567
|
-
|
|
319568
|
-
|
|
319569
|
-
|
|
319570
|
-
|
|
319571
|
-
|
|
319572
|
-
|
|
319573
|
-
|
|
319574
|
-
* @returns {undefined}
|
|
319575
|
-
*/
|
|
319435
|
+
/**
|
|
319436
|
+
* Registered listeners.
|
|
319437
|
+
* @type {Object.<string,*>}
|
|
319438
|
+
* @private
|
|
319439
|
+
*/
|
|
319440
|
+
this._listeners = {};
|
|
319441
|
+
}
|
|
319576
319442
|
|
|
319577
|
-
|
|
319578
|
-
|
|
319579
|
-
|
|
319580
|
-
|
|
319581
|
-
|
|
319582
|
-
|
|
319583
|
-
|
|
319584
|
-
|
|
319443
|
+
/**
|
|
319444
|
+
* Registers an event listener.
|
|
319445
|
+
* @param {string} evt Event name
|
|
319446
|
+
* @param {function} fn Listener
|
|
319447
|
+
* @param {*} [ctx] Listener context
|
|
319448
|
+
* @returns {util.EventEmitter} `this`
|
|
319449
|
+
*/
|
|
319450
|
+
EventEmitter.prototype.on = function on(evt, fn, ctx) {
|
|
319451
|
+
(this._listeners[evt] || (this._listeners[evt] = [])).push({
|
|
319452
|
+
fn : fn,
|
|
319453
|
+
ctx : ctx || this
|
|
319454
|
+
});
|
|
319455
|
+
return this;
|
|
319456
|
+
};
|
|
319585
319457
|
|
|
319586
|
-
|
|
319587
|
-
|
|
319588
|
-
|
|
319589
|
-
|
|
319590
|
-
|
|
319591
|
-
|
|
319592
|
-
|
|
319593
|
-
|
|
319458
|
+
/**
|
|
319459
|
+
* Removes an event listener or any matching listeners if arguments are omitted.
|
|
319460
|
+
* @param {string} [evt] Event name. Removes all listeners if omitted.
|
|
319461
|
+
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
|
|
319462
|
+
* @returns {util.EventEmitter} `this`
|
|
319463
|
+
*/
|
|
319464
|
+
EventEmitter.prototype.off = function off(evt, fn) {
|
|
319465
|
+
if (evt === undefined)
|
|
319466
|
+
this._listeners = {};
|
|
319467
|
+
else {
|
|
319468
|
+
if (fn === undefined)
|
|
319469
|
+
this._listeners[evt] = [];
|
|
319470
|
+
else {
|
|
319471
|
+
var listeners = this._listeners[evt];
|
|
319472
|
+
for (var i = 0; i < listeners.length;)
|
|
319473
|
+
if (listeners[i].fn === fn)
|
|
319474
|
+
listeners.splice(i, 1);
|
|
319475
|
+
else
|
|
319476
|
+
++i;
|
|
319477
|
+
}
|
|
319478
|
+
}
|
|
319479
|
+
return this;
|
|
319480
|
+
};
|
|
319594
319481
|
|
|
319595
|
-
|
|
319596
|
-
|
|
319597
|
-
|
|
319598
|
-
|
|
319599
|
-
|
|
319600
|
-
|
|
319601
|
-
|
|
319602
|
-
|
|
319603
|
-
|
|
319482
|
+
/**
|
|
319483
|
+
* Emits an event by calling its listeners with the specified arguments.
|
|
319484
|
+
* @param {string} evt Event name
|
|
319485
|
+
* @param {...*} args Arguments
|
|
319486
|
+
* @returns {util.EventEmitter} `this`
|
|
319487
|
+
*/
|
|
319488
|
+
EventEmitter.prototype.emit = function emit(evt) {
|
|
319489
|
+
var listeners = this._listeners[evt];
|
|
319490
|
+
if (listeners) {
|
|
319491
|
+
var args = [],
|
|
319492
|
+
i = 1;
|
|
319493
|
+
for (; i < arguments.length;)
|
|
319494
|
+
args.push(arguments[i++]);
|
|
319495
|
+
for (i = 0; i < listeners.length;)
|
|
319496
|
+
listeners[i].fn.apply(listeners[i++].ctx, args);
|
|
319497
|
+
}
|
|
319498
|
+
return this;
|
|
319499
|
+
};
|
|
319500
|
+
|
|
319501
|
+
var float = factory(factory);
|
|
319604
319502
|
|
|
319605
|
-
|
|
319606
|
-
|
|
319607
|
-
|
|
319608
|
-
|
|
319609
|
-
|
|
319610
|
-
* @param {Uint8Array} buf Target buffer
|
|
319611
|
-
* @param {number} pos Target buffer offset
|
|
319612
|
-
* @returns {undefined}
|
|
319613
|
-
*/
|
|
319503
|
+
/**
|
|
319504
|
+
* Reads / writes floats / doubles from / to buffers.
|
|
319505
|
+
* @name util.float
|
|
319506
|
+
* @namespace
|
|
319507
|
+
*/
|
|
319614
319508
|
|
|
319615
|
-
|
|
319616
|
-
|
|
319617
|
-
|
|
319618
|
-
|
|
319619
|
-
|
|
319620
|
-
|
|
319621
|
-
|
|
319622
|
-
|
|
319509
|
+
/**
|
|
319510
|
+
* Writes a 32 bit float to a buffer using little endian byte order.
|
|
319511
|
+
* @name util.float.writeFloatLE
|
|
319512
|
+
* @function
|
|
319513
|
+
* @param {number} val Value to write
|
|
319514
|
+
* @param {Uint8Array} buf Target buffer
|
|
319515
|
+
* @param {number} pos Target buffer offset
|
|
319516
|
+
* @returns {undefined}
|
|
319517
|
+
*/
|
|
319623
319518
|
|
|
319624
|
-
|
|
319625
|
-
|
|
319626
|
-
|
|
319627
|
-
|
|
319628
|
-
|
|
319629
|
-
|
|
319630
|
-
|
|
319631
|
-
|
|
319519
|
+
/**
|
|
319520
|
+
* Writes a 32 bit float to a buffer using big endian byte order.
|
|
319521
|
+
* @name util.float.writeFloatBE
|
|
319522
|
+
* @function
|
|
319523
|
+
* @param {number} val Value to write
|
|
319524
|
+
* @param {Uint8Array} buf Target buffer
|
|
319525
|
+
* @param {number} pos Target buffer offset
|
|
319526
|
+
* @returns {undefined}
|
|
319527
|
+
*/
|
|
319632
319528
|
|
|
319633
|
-
|
|
319634
|
-
|
|
319529
|
+
/**
|
|
319530
|
+
* Reads a 32 bit float from a buffer using little endian byte order.
|
|
319531
|
+
* @name util.float.readFloatLE
|
|
319532
|
+
* @function
|
|
319533
|
+
* @param {Uint8Array} buf Source buffer
|
|
319534
|
+
* @param {number} pos Source buffer offset
|
|
319535
|
+
* @returns {number} Value read
|
|
319536
|
+
*/
|
|
319635
319537
|
|
|
319636
|
-
|
|
319637
|
-
|
|
319538
|
+
/**
|
|
319539
|
+
* Reads a 32 bit float from a buffer using big endian byte order.
|
|
319540
|
+
* @name util.float.readFloatBE
|
|
319541
|
+
* @function
|
|
319542
|
+
* @param {Uint8Array} buf Source buffer
|
|
319543
|
+
* @param {number} pos Source buffer offset
|
|
319544
|
+
* @returns {number} Value read
|
|
319545
|
+
*/
|
|
319638
319546
|
|
|
319639
|
-
|
|
319640
|
-
|
|
319641
|
-
|
|
319547
|
+
/**
|
|
319548
|
+
* Writes a 64 bit double to a buffer using little endian byte order.
|
|
319549
|
+
* @name util.float.writeDoubleLE
|
|
319550
|
+
* @function
|
|
319551
|
+
* @param {number} val Value to write
|
|
319552
|
+
* @param {Uint8Array} buf Target buffer
|
|
319553
|
+
* @param {number} pos Target buffer offset
|
|
319554
|
+
* @returns {undefined}
|
|
319555
|
+
*/
|
|
319642
319556
|
|
|
319643
|
-
|
|
319644
|
-
|
|
319645
|
-
|
|
319646
|
-
|
|
319647
|
-
|
|
319648
|
-
|
|
319649
|
-
|
|
319557
|
+
/**
|
|
319558
|
+
* Writes a 64 bit double to a buffer using big endian byte order.
|
|
319559
|
+
* @name util.float.writeDoubleBE
|
|
319560
|
+
* @function
|
|
319561
|
+
* @param {number} val Value to write
|
|
319562
|
+
* @param {Uint8Array} buf Target buffer
|
|
319563
|
+
* @param {number} pos Target buffer offset
|
|
319564
|
+
* @returns {undefined}
|
|
319565
|
+
*/
|
|
319650
319566
|
|
|
319651
|
-
|
|
319652
|
-
|
|
319653
|
-
|
|
319654
|
-
|
|
319655
|
-
|
|
319656
|
-
|
|
319657
|
-
|
|
319567
|
+
/**
|
|
319568
|
+
* Reads a 64 bit double from a buffer using little endian byte order.
|
|
319569
|
+
* @name util.float.readDoubleLE
|
|
319570
|
+
* @function
|
|
319571
|
+
* @param {Uint8Array} buf Source buffer
|
|
319572
|
+
* @param {number} pos Source buffer offset
|
|
319573
|
+
* @returns {number} Value read
|
|
319574
|
+
*/
|
|
319658
319575
|
|
|
319659
|
-
|
|
319660
|
-
|
|
319661
|
-
|
|
319662
|
-
|
|
319663
|
-
|
|
319664
|
-
|
|
319665
|
-
|
|
319666
|
-
|
|
319667
|
-
f8b[2] = buf[pos + 2];
|
|
319668
|
-
f8b[3] = buf[pos + 3];
|
|
319669
|
-
return f32[0];
|
|
319670
|
-
}
|
|
319576
|
+
/**
|
|
319577
|
+
* Reads a 64 bit double from a buffer using big endian byte order.
|
|
319578
|
+
* @name util.float.readDoubleBE
|
|
319579
|
+
* @function
|
|
319580
|
+
* @param {Uint8Array} buf Source buffer
|
|
319581
|
+
* @param {number} pos Source buffer offset
|
|
319582
|
+
* @returns {number} Value read
|
|
319583
|
+
*/
|
|
319671
319584
|
|
|
319672
|
-
|
|
319673
|
-
|
|
319674
|
-
f8b[2] = buf[pos + 1];
|
|
319675
|
-
f8b[1] = buf[pos + 2];
|
|
319676
|
-
f8b[0] = buf[pos + 3];
|
|
319677
|
-
return f32[0];
|
|
319678
|
-
}
|
|
319585
|
+
// Factory function for the purpose of node-based testing in modified global environments
|
|
319586
|
+
function factory(exports) {
|
|
319679
319587
|
|
|
319680
|
-
|
|
319681
|
-
|
|
319682
|
-
/* istanbul ignore next */
|
|
319683
|
-
exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
|
|
319684
|
-
|
|
319685
|
-
// float: ieee754
|
|
319686
|
-
})(); else (function() {
|
|
319687
|
-
|
|
319688
|
-
function writeFloat_ieee754(writeUint, val, buf, pos) {
|
|
319689
|
-
var sign = val < 0 ? 1 : 0;
|
|
319690
|
-
if (sign)
|
|
319691
|
-
val = -val;
|
|
319692
|
-
if (val === 0)
|
|
319693
|
-
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
|
|
319694
|
-
else if (isNaN(val))
|
|
319695
|
-
writeUint(2143289344, buf, pos);
|
|
319696
|
-
else if (val > 3.4028234663852886e+38) // +-Infinity
|
|
319697
|
-
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
|
|
319698
|
-
else if (val < 1.1754943508222875e-38) // denormal
|
|
319699
|
-
writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
|
|
319700
|
-
else {
|
|
319701
|
-
var exponent = Math.floor(Math.log(val) / Math.LN2),
|
|
319702
|
-
mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
|
|
319703
|
-
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
|
|
319704
|
-
}
|
|
319705
|
-
}
|
|
319588
|
+
// float: typed array
|
|
319589
|
+
if (typeof Float32Array !== "undefined") (function() {
|
|
319706
319590
|
|
|
319707
|
-
|
|
319708
|
-
|
|
319709
|
-
|
|
319710
|
-
function readFloat_ieee754(readUint, buf, pos) {
|
|
319711
|
-
var uint = readUint(buf, pos),
|
|
319712
|
-
sign = (uint >> 31) * 2 + 1,
|
|
319713
|
-
exponent = uint >>> 23 & 255,
|
|
319714
|
-
mantissa = uint & 8388607;
|
|
319715
|
-
return exponent === 255
|
|
319716
|
-
? mantissa
|
|
319717
|
-
? NaN
|
|
319718
|
-
: sign * Infinity
|
|
319719
|
-
: exponent === 0 // denormal
|
|
319720
|
-
? sign * 1.401298464324817e-45 * mantissa
|
|
319721
|
-
: sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
|
|
319722
|
-
}
|
|
319591
|
+
var f32 = new Float32Array([ -0 ]),
|
|
319592
|
+
f8b = new Uint8Array(f32.buffer),
|
|
319593
|
+
le = f8b[3] === 128;
|
|
319723
319594
|
|
|
319724
|
-
|
|
319725
|
-
|
|
319595
|
+
function writeFloat_f32_cpy(val, buf, pos) {
|
|
319596
|
+
f32[0] = val;
|
|
319597
|
+
buf[pos ] = f8b[0];
|
|
319598
|
+
buf[pos + 1] = f8b[1];
|
|
319599
|
+
buf[pos + 2] = f8b[2];
|
|
319600
|
+
buf[pos + 3] = f8b[3];
|
|
319601
|
+
}
|
|
319726
319602
|
|
|
319727
|
-
|
|
319603
|
+
function writeFloat_f32_rev(val, buf, pos) {
|
|
319604
|
+
f32[0] = val;
|
|
319605
|
+
buf[pos ] = f8b[3];
|
|
319606
|
+
buf[pos + 1] = f8b[2];
|
|
319607
|
+
buf[pos + 2] = f8b[1];
|
|
319608
|
+
buf[pos + 3] = f8b[0];
|
|
319609
|
+
}
|
|
319728
319610
|
|
|
319729
|
-
|
|
319730
|
-
|
|
319611
|
+
/* istanbul ignore next */
|
|
319612
|
+
exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
|
|
319613
|
+
/* istanbul ignore next */
|
|
319614
|
+
exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
|
|
319615
|
+
|
|
319616
|
+
function readFloat_f32_cpy(buf, pos) {
|
|
319617
|
+
f8b[0] = buf[pos ];
|
|
319618
|
+
f8b[1] = buf[pos + 1];
|
|
319619
|
+
f8b[2] = buf[pos + 2];
|
|
319620
|
+
f8b[3] = buf[pos + 3];
|
|
319621
|
+
return f32[0];
|
|
319622
|
+
}
|
|
319731
319623
|
|
|
319732
|
-
|
|
319733
|
-
|
|
319734
|
-
|
|
319624
|
+
function readFloat_f32_rev(buf, pos) {
|
|
319625
|
+
f8b[3] = buf[pos ];
|
|
319626
|
+
f8b[2] = buf[pos + 1];
|
|
319627
|
+
f8b[1] = buf[pos + 2];
|
|
319628
|
+
f8b[0] = buf[pos + 3];
|
|
319629
|
+
return f32[0];
|
|
319630
|
+
}
|
|
319735
319631
|
|
|
319736
|
-
|
|
319737
|
-
|
|
319738
|
-
|
|
319739
|
-
|
|
319740
|
-
|
|
319741
|
-
|
|
319742
|
-
|
|
319743
|
-
|
|
319744
|
-
|
|
319745
|
-
|
|
319746
|
-
|
|
319632
|
+
/* istanbul ignore next */
|
|
319633
|
+
exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
|
|
319634
|
+
/* istanbul ignore next */
|
|
319635
|
+
exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
|
|
319636
|
+
|
|
319637
|
+
// float: ieee754
|
|
319638
|
+
})(); else (function() {
|
|
319639
|
+
|
|
319640
|
+
function writeFloat_ieee754(writeUint, val, buf, pos) {
|
|
319641
|
+
var sign = val < 0 ? 1 : 0;
|
|
319642
|
+
if (sign)
|
|
319643
|
+
val = -val;
|
|
319644
|
+
if (val === 0)
|
|
319645
|
+
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
|
|
319646
|
+
else if (isNaN(val))
|
|
319647
|
+
writeUint(2143289344, buf, pos);
|
|
319648
|
+
else if (val > 3.4028234663852886e+38) // +-Infinity
|
|
319649
|
+
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
|
|
319650
|
+
else if (val < 1.1754943508222875e-38) // denormal
|
|
319651
|
+
writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
|
|
319652
|
+
else {
|
|
319653
|
+
var exponent = Math.floor(Math.log(val) / Math.LN2),
|
|
319654
|
+
mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
|
|
319655
|
+
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
|
|
319656
|
+
}
|
|
319657
|
+
}
|
|
319747
319658
|
|
|
319748
|
-
|
|
319749
|
-
|
|
319750
|
-
|
|
319751
|
-
|
|
319752
|
-
|
|
319753
|
-
|
|
319754
|
-
|
|
319755
|
-
|
|
319756
|
-
|
|
319757
|
-
|
|
319758
|
-
|
|
319659
|
+
exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
|
|
319660
|
+
exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
|
|
319661
|
+
|
|
319662
|
+
function readFloat_ieee754(readUint, buf, pos) {
|
|
319663
|
+
var uint = readUint(buf, pos),
|
|
319664
|
+
sign = (uint >> 31) * 2 + 1,
|
|
319665
|
+
exponent = uint >>> 23 & 255,
|
|
319666
|
+
mantissa = uint & 8388607;
|
|
319667
|
+
return exponent === 255
|
|
319668
|
+
? mantissa
|
|
319669
|
+
? NaN
|
|
319670
|
+
: sign * Infinity
|
|
319671
|
+
: exponent === 0 // denormal
|
|
319672
|
+
? sign * 1.401298464324817e-45 * mantissa
|
|
319673
|
+
: sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
|
|
319674
|
+
}
|
|
319759
319675
|
|
|
319760
|
-
|
|
319761
|
-
|
|
319762
|
-
/* istanbul ignore next */
|
|
319763
|
-
exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
|
|
319764
|
-
|
|
319765
|
-
function readDouble_f64_cpy(buf, pos) {
|
|
319766
|
-
f8b[0] = buf[pos ];
|
|
319767
|
-
f8b[1] = buf[pos + 1];
|
|
319768
|
-
f8b[2] = buf[pos + 2];
|
|
319769
|
-
f8b[3] = buf[pos + 3];
|
|
319770
|
-
f8b[4] = buf[pos + 4];
|
|
319771
|
-
f8b[5] = buf[pos + 5];
|
|
319772
|
-
f8b[6] = buf[pos + 6];
|
|
319773
|
-
f8b[7] = buf[pos + 7];
|
|
319774
|
-
return f64[0];
|
|
319775
|
-
}
|
|
319676
|
+
exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
|
|
319677
|
+
exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
|
|
319776
319678
|
|
|
319777
|
-
|
|
319778
|
-
f8b[7] = buf[pos ];
|
|
319779
|
-
f8b[6] = buf[pos + 1];
|
|
319780
|
-
f8b[5] = buf[pos + 2];
|
|
319781
|
-
f8b[4] = buf[pos + 3];
|
|
319782
|
-
f8b[3] = buf[pos + 4];
|
|
319783
|
-
f8b[2] = buf[pos + 5];
|
|
319784
|
-
f8b[1] = buf[pos + 6];
|
|
319785
|
-
f8b[0] = buf[pos + 7];
|
|
319786
|
-
return f64[0];
|
|
319787
|
-
}
|
|
319679
|
+
})();
|
|
319788
319680
|
|
|
319789
|
-
|
|
319790
|
-
|
|
319791
|
-
/* istanbul ignore next */
|
|
319792
|
-
exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
|
|
319793
|
-
|
|
319794
|
-
// double: ieee754
|
|
319795
|
-
})(); else (function() {
|
|
319796
|
-
|
|
319797
|
-
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
|
|
319798
|
-
var sign = val < 0 ? 1 : 0;
|
|
319799
|
-
if (sign)
|
|
319800
|
-
val = -val;
|
|
319801
|
-
if (val === 0) {
|
|
319802
|
-
writeUint(0, buf, pos + off0);
|
|
319803
|
-
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
|
|
319804
|
-
} else if (isNaN(val)) {
|
|
319805
|
-
writeUint(0, buf, pos + off0);
|
|
319806
|
-
writeUint(2146959360, buf, pos + off1);
|
|
319807
|
-
} else if (val > 1.7976931348623157e+308) { // +-Infinity
|
|
319808
|
-
writeUint(0, buf, pos + off0);
|
|
319809
|
-
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
|
|
319810
|
-
} else {
|
|
319811
|
-
var mantissa;
|
|
319812
|
-
if (val < 2.2250738585072014e-308) { // denormal
|
|
319813
|
-
mantissa = val / 5e-324;
|
|
319814
|
-
writeUint(mantissa >>> 0, buf, pos + off0);
|
|
319815
|
-
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
|
|
319816
|
-
} else {
|
|
319817
|
-
var exponent = Math.floor(Math.log(val) / Math.LN2);
|
|
319818
|
-
if (exponent === 1024)
|
|
319819
|
-
exponent = 1023;
|
|
319820
|
-
mantissa = val * Math.pow(2, -exponent);
|
|
319821
|
-
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
|
|
319822
|
-
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
|
|
319823
|
-
}
|
|
319824
|
-
}
|
|
319825
|
-
}
|
|
319681
|
+
// double: typed array
|
|
319682
|
+
if (typeof Float64Array !== "undefined") (function() {
|
|
319826
319683
|
|
|
319827
|
-
|
|
319828
|
-
|
|
319829
|
-
|
|
319830
|
-
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
|
|
319831
|
-
var lo = readUint(buf, pos + off0),
|
|
319832
|
-
hi = readUint(buf, pos + off1);
|
|
319833
|
-
var sign = (hi >> 31) * 2 + 1,
|
|
319834
|
-
exponent = hi >>> 20 & 2047,
|
|
319835
|
-
mantissa = 4294967296 * (hi & 1048575) + lo;
|
|
319836
|
-
return exponent === 2047
|
|
319837
|
-
? mantissa
|
|
319838
|
-
? NaN
|
|
319839
|
-
: sign * Infinity
|
|
319840
|
-
: exponent === 0 // denormal
|
|
319841
|
-
? sign * 5e-324 * mantissa
|
|
319842
|
-
: sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
|
|
319843
|
-
}
|
|
319684
|
+
var f64 = new Float64Array([-0]),
|
|
319685
|
+
f8b = new Uint8Array(f64.buffer),
|
|
319686
|
+
le = f8b[7] === 128;
|
|
319844
319687
|
|
|
319845
|
-
|
|
319846
|
-
|
|
319688
|
+
function writeDouble_f64_cpy(val, buf, pos) {
|
|
319689
|
+
f64[0] = val;
|
|
319690
|
+
buf[pos ] = f8b[0];
|
|
319691
|
+
buf[pos + 1] = f8b[1];
|
|
319692
|
+
buf[pos + 2] = f8b[2];
|
|
319693
|
+
buf[pos + 3] = f8b[3];
|
|
319694
|
+
buf[pos + 4] = f8b[4];
|
|
319695
|
+
buf[pos + 5] = f8b[5];
|
|
319696
|
+
buf[pos + 6] = f8b[6];
|
|
319697
|
+
buf[pos + 7] = f8b[7];
|
|
319698
|
+
}
|
|
319847
319699
|
|
|
319848
|
-
|
|
319700
|
+
function writeDouble_f64_rev(val, buf, pos) {
|
|
319701
|
+
f64[0] = val;
|
|
319702
|
+
buf[pos ] = f8b[7];
|
|
319703
|
+
buf[pos + 1] = f8b[6];
|
|
319704
|
+
buf[pos + 2] = f8b[5];
|
|
319705
|
+
buf[pos + 3] = f8b[4];
|
|
319706
|
+
buf[pos + 4] = f8b[3];
|
|
319707
|
+
buf[pos + 5] = f8b[2];
|
|
319708
|
+
buf[pos + 6] = f8b[1];
|
|
319709
|
+
buf[pos + 7] = f8b[0];
|
|
319710
|
+
}
|
|
319849
319711
|
|
|
319850
|
-
|
|
319851
|
-
|
|
319712
|
+
/* istanbul ignore next */
|
|
319713
|
+
exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
|
|
319714
|
+
/* istanbul ignore next */
|
|
319715
|
+
exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
|
|
319716
|
+
|
|
319717
|
+
function readDouble_f64_cpy(buf, pos) {
|
|
319718
|
+
f8b[0] = buf[pos ];
|
|
319719
|
+
f8b[1] = buf[pos + 1];
|
|
319720
|
+
f8b[2] = buf[pos + 2];
|
|
319721
|
+
f8b[3] = buf[pos + 3];
|
|
319722
|
+
f8b[4] = buf[pos + 4];
|
|
319723
|
+
f8b[5] = buf[pos + 5];
|
|
319724
|
+
f8b[6] = buf[pos + 6];
|
|
319725
|
+
f8b[7] = buf[pos + 7];
|
|
319726
|
+
return f64[0];
|
|
319727
|
+
}
|
|
319852
319728
|
|
|
319853
|
-
|
|
319729
|
+
function readDouble_f64_rev(buf, pos) {
|
|
319730
|
+
f8b[7] = buf[pos ];
|
|
319731
|
+
f8b[6] = buf[pos + 1];
|
|
319732
|
+
f8b[5] = buf[pos + 2];
|
|
319733
|
+
f8b[4] = buf[pos + 3];
|
|
319734
|
+
f8b[3] = buf[pos + 4];
|
|
319735
|
+
f8b[2] = buf[pos + 5];
|
|
319736
|
+
f8b[1] = buf[pos + 6];
|
|
319737
|
+
f8b[0] = buf[pos + 7];
|
|
319738
|
+
return f64[0];
|
|
319739
|
+
}
|
|
319854
319740
|
|
|
319855
|
-
|
|
319856
|
-
|
|
319857
|
-
|
|
319858
|
-
|
|
319859
|
-
|
|
319860
|
-
|
|
319741
|
+
/* istanbul ignore next */
|
|
319742
|
+
exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
|
|
319743
|
+
/* istanbul ignore next */
|
|
319744
|
+
exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
|
|
319745
|
+
|
|
319746
|
+
// double: ieee754
|
|
319747
|
+
})(); else (function() {
|
|
319748
|
+
|
|
319749
|
+
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
|
|
319750
|
+
var sign = val < 0 ? 1 : 0;
|
|
319751
|
+
if (sign)
|
|
319752
|
+
val = -val;
|
|
319753
|
+
if (val === 0) {
|
|
319754
|
+
writeUint(0, buf, pos + off0);
|
|
319755
|
+
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
|
|
319756
|
+
} else if (isNaN(val)) {
|
|
319757
|
+
writeUint(0, buf, pos + off0);
|
|
319758
|
+
writeUint(2146959360, buf, pos + off1);
|
|
319759
|
+
} else if (val > 1.7976931348623157e+308) { // +-Infinity
|
|
319760
|
+
writeUint(0, buf, pos + off0);
|
|
319761
|
+
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
|
|
319762
|
+
} else {
|
|
319763
|
+
var mantissa;
|
|
319764
|
+
if (val < 2.2250738585072014e-308) { // denormal
|
|
319765
|
+
mantissa = val / 5e-324;
|
|
319766
|
+
writeUint(mantissa >>> 0, buf, pos + off0);
|
|
319767
|
+
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
|
|
319768
|
+
} else {
|
|
319769
|
+
var exponent = Math.floor(Math.log(val) / Math.LN2);
|
|
319770
|
+
if (exponent === 1024)
|
|
319771
|
+
exponent = 1023;
|
|
319772
|
+
mantissa = val * Math.pow(2, -exponent);
|
|
319773
|
+
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
|
|
319774
|
+
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
|
|
319775
|
+
}
|
|
319776
|
+
}
|
|
319777
|
+
}
|
|
319861
319778
|
|
|
319862
|
-
|
|
319863
|
-
|
|
319864
|
-
|
|
319865
|
-
|
|
319866
|
-
|
|
319867
|
-
|
|
319779
|
+
exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
|
|
319780
|
+
exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
|
|
319781
|
+
|
|
319782
|
+
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
|
|
319783
|
+
var lo = readUint(buf, pos + off0),
|
|
319784
|
+
hi = readUint(buf, pos + off1);
|
|
319785
|
+
var sign = (hi >> 31) * 2 + 1,
|
|
319786
|
+
exponent = hi >>> 20 & 2047,
|
|
319787
|
+
mantissa = 4294967296 * (hi & 1048575) + lo;
|
|
319788
|
+
return exponent === 2047
|
|
319789
|
+
? mantissa
|
|
319790
|
+
? NaN
|
|
319791
|
+
: sign * Infinity
|
|
319792
|
+
: exponent === 0 // denormal
|
|
319793
|
+
? sign * 5e-324 * mantissa
|
|
319794
|
+
: sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
|
|
319795
|
+
}
|
|
319868
319796
|
|
|
319869
|
-
|
|
319870
|
-
|
|
319871
|
-
| buf[pos + 1] << 8
|
|
319872
|
-
| buf[pos + 2] << 16
|
|
319873
|
-
| buf[pos + 3] << 24) >>> 0;
|
|
319874
|
-
}
|
|
319797
|
+
exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
|
|
319798
|
+
exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
|
|
319875
319799
|
|
|
319876
|
-
|
|
319877
|
-
|
|
319878
|
-
|
|
319879
|
-
|
|
319880
|
-
|
|
319881
|
-
|
|
319882
|
-
|
|
319800
|
+
})();
|
|
319801
|
+
|
|
319802
|
+
return exports;
|
|
319803
|
+
}
|
|
319804
|
+
|
|
319805
|
+
// uint helpers
|
|
319806
|
+
|
|
319807
|
+
function writeUintLE(val, buf, pos) {
|
|
319808
|
+
buf[pos ] = val & 255;
|
|
319809
|
+
buf[pos + 1] = val >>> 8 & 255;
|
|
319810
|
+
buf[pos + 2] = val >>> 16 & 255;
|
|
319811
|
+
buf[pos + 3] = val >>> 24;
|
|
319812
|
+
}
|
|
319813
|
+
|
|
319814
|
+
function writeUintBE(val, buf, pos) {
|
|
319815
|
+
buf[pos ] = val >>> 24;
|
|
319816
|
+
buf[pos + 1] = val >>> 16 & 255;
|
|
319817
|
+
buf[pos + 2] = val >>> 8 & 255;
|
|
319818
|
+
buf[pos + 3] = val & 255;
|
|
319819
|
+
}
|
|
319820
|
+
|
|
319821
|
+
function readUintLE(buf, pos) {
|
|
319822
|
+
return (buf[pos ]
|
|
319823
|
+
| buf[pos + 1] << 8
|
|
319824
|
+
| buf[pos + 2] << 16
|
|
319825
|
+
| buf[pos + 3] << 24) >>> 0;
|
|
319826
|
+
}
|
|
319827
|
+
|
|
319828
|
+
function readUintBE(buf, pos) {
|
|
319829
|
+
return (buf[pos ] << 24
|
|
319830
|
+
| buf[pos + 1] << 16
|
|
319831
|
+
| buf[pos + 2] << 8
|
|
319832
|
+
| buf[pos + 3]) >>> 0;
|
|
319883
319833
|
}
|
|
319884
319834
|
|
|
319885
|
-
var inquire_1;
|
|
319886
|
-
var hasRequiredInquire;
|
|
319887
|
-
|
|
319888
|
-
function requireInquire () {
|
|
319889
|
-
if (hasRequiredInquire) return inquire_1;
|
|
319890
|
-
hasRequiredInquire = 1;
|
|
319891
|
-
inquire_1 = inquire;
|
|
319835
|
+
var inquire_1 = inquire;
|
|
319892
319836
|
|
|
319893
|
-
|
|
319894
|
-
|
|
319895
|
-
|
|
319896
|
-
|
|
319897
|
-
|
|
319898
|
-
|
|
319899
|
-
|
|
319900
|
-
|
|
319901
|
-
|
|
319902
|
-
|
|
319903
|
-
|
|
319904
|
-
|
|
319905
|
-
|
|
319906
|
-
}
|
|
319907
|
-
return inquire_1;
|
|
319837
|
+
/**
|
|
319838
|
+
* Requires a module only if available.
|
|
319839
|
+
* @memberof util
|
|
319840
|
+
* @param {string} moduleName Module to require
|
|
319841
|
+
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
319842
|
+
*/
|
|
319843
|
+
function inquire(moduleName) {
|
|
319844
|
+
try {
|
|
319845
|
+
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
|
|
319846
|
+
if (mod && (mod.length || Object.keys(mod).length))
|
|
319847
|
+
return mod;
|
|
319848
|
+
} catch (e) {} // eslint-disable-line no-empty
|
|
319849
|
+
return null;
|
|
319908
319850
|
}
|
|
319909
319851
|
|
|
319910
319852
|
var utf8$4 = {};
|
|
319911
319853
|
|
|
319912
|
-
|
|
319913
|
-
|
|
319914
|
-
function requireUtf8 () {
|
|
319915
|
-
if (hasRequiredUtf8) return utf8$4;
|
|
319916
|
-
hasRequiredUtf8 = 1;
|
|
319917
|
-
(function (exports) {
|
|
319918
|
-
|
|
319919
|
-
/**
|
|
319920
|
-
* A minimal UTF8 implementation for number arrays.
|
|
319921
|
-
* @memberof util
|
|
319922
|
-
* @namespace
|
|
319923
|
-
*/
|
|
319924
|
-
var utf8 = exports;
|
|
319925
|
-
|
|
319926
|
-
/**
|
|
319927
|
-
* Calculates the UTF8 byte length of a string.
|
|
319928
|
-
* @param {string} string String
|
|
319929
|
-
* @returns {number} Byte length
|
|
319930
|
-
*/
|
|
319931
|
-
utf8.length = function utf8_length(string) {
|
|
319932
|
-
var len = 0,
|
|
319933
|
-
c = 0;
|
|
319934
|
-
for (var i = 0; i < string.length; ++i) {
|
|
319935
|
-
c = string.charCodeAt(i);
|
|
319936
|
-
if (c < 128)
|
|
319937
|
-
len += 1;
|
|
319938
|
-
else if (c < 2048)
|
|
319939
|
-
len += 2;
|
|
319940
|
-
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
319941
|
-
++i;
|
|
319942
|
-
len += 4;
|
|
319943
|
-
} else
|
|
319944
|
-
len += 3;
|
|
319945
|
-
}
|
|
319946
|
-
return len;
|
|
319947
|
-
};
|
|
319948
|
-
|
|
319949
|
-
/**
|
|
319950
|
-
* Reads UTF8 bytes as a string.
|
|
319951
|
-
* @param {Uint8Array} buffer Source buffer
|
|
319952
|
-
* @param {number} start Source start
|
|
319953
|
-
* @param {number} end Source end
|
|
319954
|
-
* @returns {string} String read
|
|
319955
|
-
*/
|
|
319956
|
-
utf8.read = function utf8_read(buffer, start, end) {
|
|
319957
|
-
var len = end - start;
|
|
319958
|
-
if (len < 1)
|
|
319959
|
-
return "";
|
|
319960
|
-
var parts = null,
|
|
319961
|
-
chunk = [],
|
|
319962
|
-
i = 0, // char offset
|
|
319963
|
-
t; // temporary
|
|
319964
|
-
while (start < end) {
|
|
319965
|
-
t = buffer[start++];
|
|
319966
|
-
if (t < 128)
|
|
319967
|
-
chunk[i++] = t;
|
|
319968
|
-
else if (t > 191 && t < 224)
|
|
319969
|
-
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
319970
|
-
else if (t > 239 && t < 365) {
|
|
319971
|
-
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
319972
|
-
chunk[i++] = 0xD800 + (t >> 10);
|
|
319973
|
-
chunk[i++] = 0xDC00 + (t & 1023);
|
|
319974
|
-
} else
|
|
319975
|
-
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
319976
|
-
if (i > 8191) {
|
|
319977
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
319978
|
-
i = 0;
|
|
319979
|
-
}
|
|
319980
|
-
}
|
|
319981
|
-
if (parts) {
|
|
319982
|
-
if (i)
|
|
319983
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
319984
|
-
return parts.join("");
|
|
319985
|
-
}
|
|
319986
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
319987
|
-
};
|
|
319854
|
+
(function (exports) {
|
|
319988
319855
|
|
|
319989
|
-
|
|
319990
|
-
|
|
319991
|
-
|
|
319992
|
-
|
|
319993
|
-
|
|
319994
|
-
|
|
319995
|
-
*/
|
|
319996
|
-
utf8.write = function utf8_write(string, buffer, offset) {
|
|
319997
|
-
var start = offset,
|
|
319998
|
-
c1, // character 1
|
|
319999
|
-
c2; // character 2
|
|
320000
|
-
for (var i = 0; i < string.length; ++i) {
|
|
320001
|
-
c1 = string.charCodeAt(i);
|
|
320002
|
-
if (c1 < 128) {
|
|
320003
|
-
buffer[offset++] = c1;
|
|
320004
|
-
} else if (c1 < 2048) {
|
|
320005
|
-
buffer[offset++] = c1 >> 6 | 192;
|
|
320006
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
320007
|
-
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
320008
|
-
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
320009
|
-
++i;
|
|
320010
|
-
buffer[offset++] = c1 >> 18 | 240;
|
|
320011
|
-
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
320012
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
320013
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
320014
|
-
} else {
|
|
320015
|
-
buffer[offset++] = c1 >> 12 | 224;
|
|
320016
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
320017
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
320018
|
-
}
|
|
320019
|
-
}
|
|
320020
|
-
return offset - start;
|
|
320021
|
-
};
|
|
320022
|
-
} (utf8$4));
|
|
320023
|
-
return utf8$4;
|
|
320024
|
-
}
|
|
320025
|
-
|
|
320026
|
-
var pool_1;
|
|
320027
|
-
var hasRequiredPool;
|
|
320028
|
-
|
|
320029
|
-
function requirePool () {
|
|
320030
|
-
if (hasRequiredPool) return pool_1;
|
|
320031
|
-
hasRequiredPool = 1;
|
|
320032
|
-
pool_1 = pool;
|
|
319856
|
+
/**
|
|
319857
|
+
* A minimal UTF8 implementation for number arrays.
|
|
319858
|
+
* @memberof util
|
|
319859
|
+
* @namespace
|
|
319860
|
+
*/
|
|
319861
|
+
var utf8 = exports;
|
|
320033
319862
|
|
|
320034
319863
|
/**
|
|
320035
|
-
*
|
|
320036
|
-
* @
|
|
320037
|
-
* @
|
|
320038
|
-
* @param {number} size Buffer size
|
|
320039
|
-
* @returns {Uint8Array} Buffer
|
|
319864
|
+
* Calculates the UTF8 byte length of a string.
|
|
319865
|
+
* @param {string} string String
|
|
319866
|
+
* @returns {number} Byte length
|
|
320040
319867
|
*/
|
|
319868
|
+
utf8.length = function utf8_length(string) {
|
|
319869
|
+
var len = 0,
|
|
319870
|
+
c = 0;
|
|
319871
|
+
for (var i = 0; i < string.length; ++i) {
|
|
319872
|
+
c = string.charCodeAt(i);
|
|
319873
|
+
if (c < 128)
|
|
319874
|
+
len += 1;
|
|
319875
|
+
else if (c < 2048)
|
|
319876
|
+
len += 2;
|
|
319877
|
+
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
319878
|
+
++i;
|
|
319879
|
+
len += 4;
|
|
319880
|
+
} else
|
|
319881
|
+
len += 3;
|
|
319882
|
+
}
|
|
319883
|
+
return len;
|
|
319884
|
+
};
|
|
320041
319885
|
|
|
320042
319886
|
/**
|
|
320043
|
-
*
|
|
320044
|
-
* @
|
|
320045
|
-
* @
|
|
320046
|
-
* @param {number}
|
|
320047
|
-
* @
|
|
320048
|
-
* @returns {Uint8Array} Buffer slice
|
|
320049
|
-
* @this {Uint8Array}
|
|
319887
|
+
* Reads UTF8 bytes as a string.
|
|
319888
|
+
* @param {Uint8Array} buffer Source buffer
|
|
319889
|
+
* @param {number} start Source start
|
|
319890
|
+
* @param {number} end Source end
|
|
319891
|
+
* @returns {string} String read
|
|
320050
319892
|
*/
|
|
319893
|
+
utf8.read = function utf8_read(buffer, start, end) {
|
|
319894
|
+
var len = end - start;
|
|
319895
|
+
if (len < 1)
|
|
319896
|
+
return "";
|
|
319897
|
+
var parts = null,
|
|
319898
|
+
chunk = [],
|
|
319899
|
+
i = 0, // char offset
|
|
319900
|
+
t; // temporary
|
|
319901
|
+
while (start < end) {
|
|
319902
|
+
t = buffer[start++];
|
|
319903
|
+
if (t < 128)
|
|
319904
|
+
chunk[i++] = t;
|
|
319905
|
+
else if (t > 191 && t < 224)
|
|
319906
|
+
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
319907
|
+
else if (t > 239 && t < 365) {
|
|
319908
|
+
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
|
|
319909
|
+
chunk[i++] = 0xD800 + (t >> 10);
|
|
319910
|
+
chunk[i++] = 0xDC00 + (t & 1023);
|
|
319911
|
+
} else
|
|
319912
|
+
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
319913
|
+
if (i > 8191) {
|
|
319914
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
319915
|
+
i = 0;
|
|
319916
|
+
}
|
|
319917
|
+
}
|
|
319918
|
+
if (parts) {
|
|
319919
|
+
if (i)
|
|
319920
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
319921
|
+
return parts.join("");
|
|
319922
|
+
}
|
|
319923
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
319924
|
+
};
|
|
320051
319925
|
|
|
320052
319926
|
/**
|
|
320053
|
-
*
|
|
320054
|
-
* @
|
|
320055
|
-
* @
|
|
320056
|
-
* @param {
|
|
320057
|
-
* @
|
|
320058
|
-
* @param {number} [size=8192] Slab size
|
|
320059
|
-
* @returns {PoolAllocator} Pooled allocator
|
|
319927
|
+
* Writes a string as UTF8 bytes.
|
|
319928
|
+
* @param {string} string Source string
|
|
319929
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
319930
|
+
* @param {number} offset Destination offset
|
|
319931
|
+
* @returns {number} Bytes written
|
|
320060
319932
|
*/
|
|
320061
|
-
function
|
|
320062
|
-
var
|
|
320063
|
-
|
|
320064
|
-
|
|
320065
|
-
var
|
|
320066
|
-
|
|
320067
|
-
if (
|
|
320068
|
-
|
|
320069
|
-
if (
|
|
320070
|
-
|
|
320071
|
-
offset =
|
|
319933
|
+
utf8.write = function utf8_write(string, buffer, offset) {
|
|
319934
|
+
var start = offset,
|
|
319935
|
+
c1, // character 1
|
|
319936
|
+
c2; // character 2
|
|
319937
|
+
for (var i = 0; i < string.length; ++i) {
|
|
319938
|
+
c1 = string.charCodeAt(i);
|
|
319939
|
+
if (c1 < 128) {
|
|
319940
|
+
buffer[offset++] = c1;
|
|
319941
|
+
} else if (c1 < 2048) {
|
|
319942
|
+
buffer[offset++] = c1 >> 6 | 192;
|
|
319943
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
319944
|
+
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
319945
|
+
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
319946
|
+
++i;
|
|
319947
|
+
buffer[offset++] = c1 >> 18 | 240;
|
|
319948
|
+
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
319949
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
319950
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
319951
|
+
} else {
|
|
319952
|
+
buffer[offset++] = c1 >> 12 | 224;
|
|
319953
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
319954
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
320072
319955
|
}
|
|
320073
|
-
|
|
320074
|
-
|
|
320075
|
-
|
|
320076
|
-
|
|
320077
|
-
|
|
320078
|
-
|
|
320079
|
-
|
|
319956
|
+
}
|
|
319957
|
+
return offset - start;
|
|
319958
|
+
};
|
|
319959
|
+
} (utf8$4));
|
|
319960
|
+
|
|
319961
|
+
var pool_1 = pool$1;
|
|
319962
|
+
|
|
319963
|
+
/**
|
|
319964
|
+
* An allocator as used by {@link util.pool}.
|
|
319965
|
+
* @typedef PoolAllocator
|
|
319966
|
+
* @type {function}
|
|
319967
|
+
* @param {number} size Buffer size
|
|
319968
|
+
* @returns {Uint8Array} Buffer
|
|
319969
|
+
*/
|
|
319970
|
+
|
|
319971
|
+
/**
|
|
319972
|
+
* A slicer as used by {@link util.pool}.
|
|
319973
|
+
* @typedef PoolSlicer
|
|
319974
|
+
* @type {function}
|
|
319975
|
+
* @param {number} start Start offset
|
|
319976
|
+
* @param {number} end End offset
|
|
319977
|
+
* @returns {Uint8Array} Buffer slice
|
|
319978
|
+
* @this {Uint8Array}
|
|
319979
|
+
*/
|
|
319980
|
+
|
|
319981
|
+
/**
|
|
319982
|
+
* A general purpose buffer pool.
|
|
319983
|
+
* @memberof util
|
|
319984
|
+
* @function
|
|
319985
|
+
* @param {PoolAllocator} alloc Allocator
|
|
319986
|
+
* @param {PoolSlicer} slice Slicer
|
|
319987
|
+
* @param {number} [size=8192] Slab size
|
|
319988
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
319989
|
+
*/
|
|
319990
|
+
function pool$1(alloc, slice, size) {
|
|
319991
|
+
var SIZE = size || 8192;
|
|
319992
|
+
var MAX = SIZE >>> 1;
|
|
319993
|
+
var slab = null;
|
|
319994
|
+
var offset = SIZE;
|
|
319995
|
+
return function pool_alloc(size) {
|
|
319996
|
+
if (size < 1 || size > MAX)
|
|
319997
|
+
return alloc(size);
|
|
319998
|
+
if (offset + size > SIZE) {
|
|
319999
|
+
slab = alloc(SIZE);
|
|
320000
|
+
offset = 0;
|
|
320001
|
+
}
|
|
320002
|
+
var buf = slice.call(slab, offset, offset += size);
|
|
320003
|
+
if (offset & 7) // align to 32 bit
|
|
320004
|
+
offset = (offset | 7) + 1;
|
|
320005
|
+
return buf;
|
|
320006
|
+
};
|
|
320080
320007
|
}
|
|
320081
320008
|
|
|
320082
320009
|
var longbits;
|
|
@@ -320296,25 +320223,25 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
320296
320223
|
var util = exports;
|
|
320297
320224
|
|
|
320298
320225
|
// used to return a Promise where callback is omitted
|
|
320299
|
-
util.asPromise =
|
|
320226
|
+
util.asPromise = aspromise;
|
|
320300
320227
|
|
|
320301
320228
|
// converts to / from base64 encoded strings
|
|
320302
|
-
util.base64 =
|
|
320229
|
+
util.base64 = base64$2;
|
|
320303
320230
|
|
|
320304
320231
|
// base class of rpc.Service
|
|
320305
|
-
util.EventEmitter =
|
|
320232
|
+
util.EventEmitter = eventemitter;
|
|
320306
320233
|
|
|
320307
320234
|
// float handling accross browsers
|
|
320308
|
-
util.float =
|
|
320235
|
+
util.float = float;
|
|
320309
320236
|
|
|
320310
320237
|
// requires modules optionally and hides the call from bundlers
|
|
320311
|
-
util.inquire =
|
|
320238
|
+
util.inquire = inquire_1;
|
|
320312
320239
|
|
|
320313
320240
|
// converts to / from utf8 encoded strings
|
|
320314
|
-
util.utf8 =
|
|
320241
|
+
util.utf8 = utf8$4;
|
|
320315
320242
|
|
|
320316
320243
|
// provides a node-like buffer pool in the browser
|
|
320317
|
-
util.pool =
|
|
320244
|
+
util.pool = pool_1;
|
|
320318
320245
|
|
|
320319
320246
|
// utility to work with the low and high bits of a 64 bit value
|
|
320320
320247
|
util.LongBits = requireLongbits();
|