Files
discord-decomp/_bundle/EventTarget.js
T
2026-11-01 12:12:55 +02:00

725 lines
21 KiB
JavaScript

// Metro module 229 (f230).
function $mk65823($env) {
return function get() {
const r7 = $env.$parent[0].get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return r7.event[$env[0]];
};
}
function $mk65824($env) {
return function set(a0) {
const r7 = $env.$parent[0].get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
r7.event[$env[0]] = a0;
};
}
function $mk101021($env) {
return function get() {
const r8 = $env.$parent[6].get(this);
if (r8 == null) {
throw new TypeError("'this' is expected an EventTarget object, but got another value.");
}
let r12 = r8.get($env[0]);
while (r12 != null) {
const listenerType = r12.listenerType;
const r14 = r12;
if (listenerType === 3) {
return r14.listener;
}
r12 = r14.next;
}
return null;
};
}
function $mk101022($env) {
return function set(a0) {
const listener = (typeof a0 !== "function" ? a0 !== null && typeof a0 === "object" : typeof a0 === "function") ? a0 : null;
const r7 = $env.$parent[6].get(this);
if (r7 == null) {
throw new TypeError("'this' is expected an EventTarget object, but got another value.");
}
const r22 = $env;
const r25 = r7.get(r22[0]);
const r26 = r25 != null;
let r9 = r25;
let r27 = null;
let r28 = null;
if (r26) {
do {
const listenerType = r9.listenerType;
const r10 = r9;
const r12 = r27;
let r11 = r10;
if (listenerType === 3) {
if (r12 !== null) {
r12.next = r10.next;
r11 = r12;
} else if (r10.next !== null) {
r7.set(r22[0], r10.next);
r11 = r12;
} else {
r7.delete(r22[0]);
r11 = r12;
}
}
r9 = r10.next;
r27 = r11;
r28 = r27;
} while (r9 != null);
}
if (listener !== null) {
const next = {
listener,
listenerType: 3,
passive: false,
once: false,
next: null
};
if (r28 === null) {
r7.set(r22[0], next);
} else {
r28.next = next;
}
}
};
}
let Event2, getWrapper, isStopped, setPassiveListener, getListeners, EventTarget, c252_0, c252_1, c252_6;
let $mk65826 = function() {
return function CustomEventTarget() {
EventTarget.call(this);
};
};
let env252 = {};
const value2 = function(a0, a1) {
c252_0.set(this, {
eventTarget: a0,
event: a1,
eventPhase: 2,
currentTarget: a0,
canceled: false,
stopped: false,
immediateStopped: false,
passiveListener: null,
timeStamp: a1.timeStamp || Date.now()
});
Object.defineProperty(this, "isTrusted", {
value: false,
enumerable: true
});
const r26 = Object.keys(a1);
const length = r26.length;
let r0 = 0;
if (0 < length) {
do {
const r28 = r26[r0];
const r29 = r28 in this;
const r1 = r0;
if (!r29) {
let env12213;
const r30 = Object;
const r11 = env12213 = {
$parent: env252
};
env12213[0] = r28;
r30.defineProperty(this, r28, {
get: $mk65823(r11),
set: $mk65824(r11),
configurable: true,
enumerable: true
});
}
r0 = r1 + 1;
} while (r0 < r26.length);
}
};
Event2 = value2;
getWrapper = function getWrapper(a0) {
let r46, length2;
if (a0 != null && a0 !== Object.prototype) {
let r22 = c252_1.get(a0);
if (r22 == null) {
const wrapper = getWrapper(Object.getPrototypeOf(a0));
let c12214_0 = wrapper;
const r11 = Object.keys(a0);
const length = r11.length;
let r28 = wrapper;
if (length !== 0) {
const value3 = function(a0, a1) {
c12214_0.call(this, a0, a1);
};
value3.prototype = Object.create(wrapper.prototype, {
constructor: {
value: value3,
configurable: true,
writable: true
}
});
const r33 = 0 < r11.length;
let r34 = 0;
r28 = value3;
if (r33) {
do {
const r35 = r11[r34];
const r37 = r35 in wrapper.prototype;
const r1 = r34;
if (!r37) {
const value2 = Object.getOwnPropertyDescriptor(a0, r35).value;
const r42 = Object;
const prototype = value3.prototype;
if (typeof value2 === "function") {
let c12216_0 = r35;
r46 = {
value: function value() {
const r11 = c252_0.get(this);
console.assert(r11 != null, "'this' is expected an Event object, but got", this);
const event = r11.event;
return event[c12216_0].apply(event, arguments);
},
configurable: true,
enumerable: true
};
} else {
let env12215;
const r18 = env12215 = {
$parent: env252
};
env12215[0] = r35;
r46 = {
get: $mk65823(r18),
set: $mk65824(r18),
configurable: true,
enumerable: true
};
}
r42.defineProperty(prototype, r35, r46);
}
r34 = r1 + 1;
length2 = r11.length;
r28 = value3;
} while (r34 < length2);
}
}
c252_1.set(a0, r28);
r22 = r28;
}
return r22;
}
return Event2;
};
isStopped = function isStopped(a0) {
const r7 = c252_0.get(a0);
console.assert(r7 != null, "'this' is expected an Event object, but got", a0);
return r7.immediateStopped;
};
setPassiveListener = function setPassiveListener(a0, a1) {
const r7 = c252_0.get(a0);
console.assert(r7 != null, "'this' is expected an Event object, but got", a0);
r7.passiveListener = a1;
};
getListeners = function getListeners(a0) {
const r7 = c252_6.get(a0);
if (r7 == null) {
throw new TypeError("'this' is expected an EventTarget object, but got another value.");
}
return r7;
};
EventTarget = function EventTarget() {
if (this instanceof EventTarget) {
c252_6.set(this, new Map());
return void 0;
}
if (arguments.length === 1 && Array.isArray(arguments[0])) {
const r68 = arguments[0];
const value3 = $mk65826();
value3.prototype = Object.create(EventTarget.prototype, {
constructor: {
value: value3,
configurable: true,
writable: true
}
});
const r77 = 0 < r68.length;
let r79 = 0;
if (r77) {
do {
let env12219;
const prototype2 = value3.prototype;
const r81 = r68[r79];
const r82 = Object;
const r86 = `on${r81}`;
const r87 = env12219 = {
$parent: env252
};
env12219[0] = r81;
r82.defineProperty(prototype2, r86, {
get: $mk101021(r87),
set: $mk101022(r87),
configurable: true,
enumerable: true
});
r79 = r79 + 1;
} while (r79 < r68.length);
}
return value3;
}
if (arguments.length > 0) {
const array = new Array(arguments.length);
const r45 = 0 < arguments.length;
let r2 = 0;
if (r45) {
do {
array[r2] = arguments[r2];
r2 = r2 + 1;
} while (r2 < arguments.length);
}
const value2 = $mk65826();
value2.prototype = Object.create(EventTarget.prototype, {
constructor: {
value: value2,
configurable: true,
writable: true
}
});
const r55 = 0 < array.length;
let r57 = 0;
if (r55) {
do {
let env12218;
const prototype = value2.prototype;
const r58 = array[r57];
const r59 = Object;
const r63 = `on${r58}`;
const r21 = env12218 = {
$parent: env252
};
env12218[0] = r58;
r59.defineProperty(prototype, r63, {
get: $mk101021(r21),
set: $mk101022(r21),
configurable: true,
enumerable: true
});
r57 = r57 + 1;
} while (r57 < array.length);
}
return value2;
}
throw new TypeError("Cannot call a class as a function");
};
c252_0 = new WeakMap();
c252_1 = new WeakMap();
const prototype = {};
Object.defineProperty(prototype, "type", {
get: function() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return r7.event.type;
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "target", {
get: function() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return r7.eventTarget;
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "currentTarget", {
get: function() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return r7.currentTarget;
},
set: void 0,
enumerable: true,
configurable: true
});
prototype.composedPath = function composedPath() {
const r8 = c252_0.get(this);
console.assert(r8 != null, "'this' is expected an Event object, but got", this);
const currentTarget = r8.currentTarget;
return currentTarget == null ? [] : [currentTarget];
};
Object.defineProperty(prototype, "NONE", {
get: function() {
return 0;
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "CAPTURING_PHASE", {
get: function() {
return 1;
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "AT_TARGET", {
get: function() {
return 2;
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "BUBBLING_PHASE", {
get: function() {
return 3;
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "eventPhase", {
get: function() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return r7.eventPhase;
},
set: void 0,
enumerable: true,
configurable: true
});
prototype.stopPropagation = function stopPropagation() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
r7.stopped = true;
if (typeof r7.event.stopPropagation === "function") {
r7.event.stopPropagation();
}
};
prototype.stopImmediatePropagation = function stopImmediatePropagation() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
r7.stopped = true;
r7.immediateStopped = true;
if (typeof r7.event.stopImmediatePropagation === "function") {
r7.event.stopImmediatePropagation();
}
};
Object.defineProperty(prototype, "bubbles", {
get: function() {
const r2 = Boolean;
const r8 = c252_0.get(this);
console.assert(r8 != null, "'this' is expected an Event object, but got", this);
return r2(r8.event.bubbles);
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "cancelable", {
get: function() {
const r2 = Boolean;
const r8 = c252_0.get(this);
console.assert(r8 != null, "'this' is expected an Event object, but got", this);
return r2(r8.event.cancelable);
},
set: void 0,
enumerable: true,
configurable: true
});
prototype.preventDefault = function preventDefault() {
const r9 = c252_0.get(this);
console.assert(r9 != null, "'this' is expected an Event object, but got", this);
if (r9.passiveListener == null) {
if (r9.event.cancelable) {
r9.canceled = true;
if (typeof r9.event.preventDefault === "function") {
r9.event.preventDefault();
}
}
} else {
const console2 = globalThis.console;
if (typeof console2 !== "undefined" ? typeof console.error === "function" : typeof console2 !== "undefined") {
console.error("Unable to preventDefault inside passive event listener invocation.", r9.passiveListener);
}
}
};
Object.defineProperty(prototype, "defaultPrevented", {
get: function() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return r7.canceled;
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "composed", {
get: function() {
const r2 = Boolean;
const r8 = c252_0.get(this);
console.assert(r8 != null, "'this' is expected an Event object, but got", this);
return r2(r8.event.composed);
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "timeStamp", {
get: function() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return r7.timeStamp;
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "srcElement", {
get: function() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return r7.eventTarget;
},
set: void 0,
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "cancelBubble", {
get: function() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return r7.stopped;
},
set: function(a0) {
if (a0) {
const r8 = c252_0.get(this);
console.assert(r8 != null, "'this' is expected an Event object, but got", this);
r8.stopped = true;
if (typeof r8.event.cancelBubble === "boolean") {
r8.event.cancelBubble = true;
}
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(prototype, "returnValue", {
get: function() {
const r7 = c252_0.get(this);
console.assert(r7 != null, "'this' is expected an Event object, but got", this);
return !r7.canceled;
},
set: function(a0) {
if (!a0) {
const r10 = c252_0.get(this);
console.assert(r10 != null, "'this' is expected an Event object, but got", this);
if (r10.passiveListener == null) {
if (r10.event.cancelable) {
r10.canceled = true;
if (typeof r10.event.preventDefault === "function") {
r10.event.preventDefault();
}
}
} else {
const console2 = globalThis.console;
if (typeof console2 !== "undefined" ? typeof console.error === "function" : typeof console2 !== "undefined") {
console.error("Unable to preventDefault inside passive event listener invocation.", r10.passiveListener);
}
}
}
},
enumerable: true,
configurable: true
});
prototype.initEvent = () => {};
value2.prototype = prototype;
Object.defineProperty(value2.prototype, "constructor", {
value: value2,
configurable: true,
writable: true
});
const window2 = globalThis.window;
if (typeof window2 !== "undefined" ? window.Event !== void 0 : typeof window2 !== "undefined") {
Object.setPrototypeOf(value2.prototype, window.Event.prototype);
c252_1.set(window.Event.prototype, value2);
}
c252_6 = new WeakMap();
EventTarget.prototype = {
addEventListener: function(a0, a1, a2) {
if (a1 != null) {
if (typeof a1 !== "function" && !(a1 !== null && typeof a1 === "object")) {
throw new TypeError("'listener' should be a function or an object.");
}
const r10 = c252_6.get(this);
if (r10 == null) {
throw new TypeError("'this' is expected an EventTarget object, but got another value.");
}
let once = a2 !== null && typeof a2 === "object";
const r12 = Boolean;
const listenerType = (once ? r12(a2.capture) : r12(a2)) ? 1 : 2;
const passive = once ? Boolean(a2.passive) : once;
if (once) {
once = Boolean(a2.once);
}
const next = {
listener: a1,
listenerType,
passive,
once,
next: null
};
const r34 = r10.get(a0);
if (r34 !== void 0) {
const r4 = r34 != null;
let r37 = r34;
let r38 = null;
if (r4) {
do {
const listener = r37.listener;
const r40 = r37;
if (listener === a1 && r40.listenerType === listenerType) {
return void 0;
}
r37 = r40.next;
r38 = r40;
} while (r37 != null);
}
r38.next = next;
} else {
r10.set(a0, next);
}
}
},
removeEventListener: function removeEventListener(a0, a1, a2) {
if (a1 != null) {
const r11 = c252_6.get(this);
if (r11 == null) {
throw new TypeError("'this' is expected an EventTarget object, but got another value.");
}
const r2 = a2 !== null && typeof a2 === "object";
const r19 = Boolean;
const r0 = (r2 ? r19(a2.capture) : r19(a2)) ? 1 : 2;
const r23 = r11.get(a0);
const r24 = r23 != null;
let r8 = r23;
let r25 = null;
if (r24) {
do {
const listener = r8.listener;
const r26 = r8;
const r27 = r25;
if (listener === a1 && r26.listenerType === r0) {
if (r27 !== null) {
r27.next = r26.next;
} else if (r26.next !== null) {
r11.set(a0, r26.next);
} else {
r11.delete(a0);
}
return void 0;
}
r8 = r26.next;
r25 = r26;
} while (r8 != null);
}
}
},
dispatchEvent: function dispatchEvent(a0) {
if (a0 != null && typeof a0.type === "string") {
const listeners = getListeners(this);
const type = a0.type;
let r4 = listeners.get(type);
if (r4 == null) {
return true;
}
const r22 = (function wrapEvent(a0, a1) {
return new (getWrapper(Object.getPrototypeOf(a1)))(a0, a1);
})(this, a0);
const r11 = r4 != null;
let r23 = null;
if (r11) {
do {
const once = r4.once;
const r13 = r23;
const r24 = r4;
let r12 = r24;
if (once) {
if (r13 !== null) {
r13.next = r24.next;
r12 = r13;
} else if (r24.next !== null) {
listeners.set(type, r24.next);
r12 = r13;
} else {
listeners.delete(type);
r12 = r13;
}
}
setPassiveListener(r22, r24.passive ? r24.listener : null);
if (typeof r24.listener === "function") {
try {
r24.listener.call(this, r22);
} catch (r47) {
const console2 = globalThis.console;
if (typeof console2 !== "undefined" ? typeof console.error === "function" : typeof console2 !== "undefined") {
console.error(r47);
}
}
} else if (r24.listenerType !== 3 && typeof r24.listener.handleEvent === "function") {
r24.listener.handleEvent(r22);
}
if (isStopped(r22)) {
break;
}
r4 = r24.next;
r23 = r12;
} while (r4 != null);
}
setPassiveListener(r22, null);
(function setEventPhase(a0, a1) {
const r8 = c252_0.get(a0);
console.assert(r8 != null, "'this' is expected an Event object, but got", a0);
r8.eventPhase = 0;
})(r22, 0);
(function setCurrentTarget(a0, a1) {
const r8 = c252_0.get(a0);
console.assert(r8 != null, "'this' is expected an Event object, but got", a0);
r8.currentTarget = null;
})(r22, null);
return !r22.defaultPrevented;
}
throw new TypeError("\"event.type\" should be a string.");
}
};
Object.defineProperty(EventTarget.prototype, "constructor", {
value: EventTarget,
configurable: true,
writable: true
});
const window3 = globalThis.window;
if (typeof window3 !== "undefined" ? window.EventTarget !== void 0 : typeof window3 !== "undefined") {
Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype);
}
export function defineEventAttribute(a0, a1) {
let env12217;
const r5 = Object;
const r9 = `on${a1}`;
const r10 = env12217 = {
$parent: env252
};
env12217[0] = a1;
r5.defineProperty(a0, r9, {
get: $mk101021(r10),
set: $mk101022(r10),
configurable: true,
enumerable: true
});
}
export { EventTarget };
export default EventTarget;
module.exports = EventTarget;
const exports2 = module.exports;
module.exports.default = EventTarget;
exports2.EventTarget = EventTarget;
module.exports.defineEventAttribute = defineEventAttribute;