@everymatrix/player-account-balance-modal 0.0.188 → 0.0.192
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.
|
@@ -1,2080 +1,2 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.app = factory());
|
|
5
|
-
}(this, (function () { 'use strict';
|
|
6
|
-
|
|
7
|
-
function noop() { }
|
|
8
|
-
function add_location(element, file, line, column, char) {
|
|
9
|
-
element.__svelte_meta = {
|
|
10
|
-
loc: { file, line, column, char }
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function run(fn) {
|
|
14
|
-
return fn();
|
|
15
|
-
}
|
|
16
|
-
function blank_object() {
|
|
17
|
-
return Object.create(null);
|
|
18
|
-
}
|
|
19
|
-
function run_all(fns) {
|
|
20
|
-
fns.forEach(run);
|
|
21
|
-
}
|
|
22
|
-
function is_function(thing) {
|
|
23
|
-
return typeof thing === 'function';
|
|
24
|
-
}
|
|
25
|
-
function safe_not_equal(a, b) {
|
|
26
|
-
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
|
|
27
|
-
}
|
|
28
|
-
function is_empty(obj) {
|
|
29
|
-
return Object.keys(obj).length === 0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function append(target, node) {
|
|
33
|
-
target.appendChild(node);
|
|
34
|
-
}
|
|
35
|
-
function insert(target, node, anchor) {
|
|
36
|
-
target.insertBefore(node, anchor || null);
|
|
37
|
-
}
|
|
38
|
-
function detach(node) {
|
|
39
|
-
node.parentNode.removeChild(node);
|
|
40
|
-
}
|
|
41
|
-
function element(name) {
|
|
42
|
-
return document.createElement(name);
|
|
43
|
-
}
|
|
44
|
-
function svg_element(name) {
|
|
45
|
-
return document.createElementNS('http://www.w3.org/2000/svg', name);
|
|
46
|
-
}
|
|
47
|
-
function text(data) {
|
|
48
|
-
return document.createTextNode(data);
|
|
49
|
-
}
|
|
50
|
-
function space() {
|
|
51
|
-
return text(' ');
|
|
52
|
-
}
|
|
53
|
-
function empty() {
|
|
54
|
-
return text('');
|
|
55
|
-
}
|
|
56
|
-
function listen(node, event, handler, options) {
|
|
57
|
-
node.addEventListener(event, handler, options);
|
|
58
|
-
return () => node.removeEventListener(event, handler, options);
|
|
59
|
-
}
|
|
60
|
-
function attr(node, attribute, value) {
|
|
61
|
-
if (value == null)
|
|
62
|
-
node.removeAttribute(attribute);
|
|
63
|
-
else if (node.getAttribute(attribute) !== value)
|
|
64
|
-
node.setAttribute(attribute, value);
|
|
65
|
-
}
|
|
66
|
-
function children(element) {
|
|
67
|
-
return Array.from(element.childNodes);
|
|
68
|
-
}
|
|
69
|
-
function custom_event(type, detail) {
|
|
70
|
-
const e = document.createEvent('CustomEvent');
|
|
71
|
-
e.initCustomEvent(type, false, false, detail);
|
|
72
|
-
return e;
|
|
73
|
-
}
|
|
74
|
-
function attribute_to_object(attributes) {
|
|
75
|
-
const result = {};
|
|
76
|
-
for (const attribute of attributes) {
|
|
77
|
-
result[attribute.name] = attribute.value;
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
let current_component;
|
|
83
|
-
function set_current_component(component) {
|
|
84
|
-
current_component = component;
|
|
85
|
-
}
|
|
86
|
-
function get_current_component() {
|
|
87
|
-
if (!current_component)
|
|
88
|
-
throw new Error('Function called outside component initialization');
|
|
89
|
-
return current_component;
|
|
90
|
-
}
|
|
91
|
-
function onMount(fn) {
|
|
92
|
-
get_current_component().$$.on_mount.push(fn);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const dirty_components = [];
|
|
96
|
-
const binding_callbacks = [];
|
|
97
|
-
const render_callbacks = [];
|
|
98
|
-
const flush_callbacks = [];
|
|
99
|
-
const resolved_promise = Promise.resolve();
|
|
100
|
-
let update_scheduled = false;
|
|
101
|
-
function schedule_update() {
|
|
102
|
-
if (!update_scheduled) {
|
|
103
|
-
update_scheduled = true;
|
|
104
|
-
resolved_promise.then(flush);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function add_render_callback(fn) {
|
|
108
|
-
render_callbacks.push(fn);
|
|
109
|
-
}
|
|
110
|
-
let flushing = false;
|
|
111
|
-
const seen_callbacks = new Set();
|
|
112
|
-
function flush() {
|
|
113
|
-
if (flushing)
|
|
114
|
-
return;
|
|
115
|
-
flushing = true;
|
|
116
|
-
do {
|
|
117
|
-
// first, call beforeUpdate functions
|
|
118
|
-
// and update components
|
|
119
|
-
for (let i = 0; i < dirty_components.length; i += 1) {
|
|
120
|
-
const component = dirty_components[i];
|
|
121
|
-
set_current_component(component);
|
|
122
|
-
update(component.$$);
|
|
123
|
-
}
|
|
124
|
-
set_current_component(null);
|
|
125
|
-
dirty_components.length = 0;
|
|
126
|
-
while (binding_callbacks.length)
|
|
127
|
-
binding_callbacks.pop()();
|
|
128
|
-
// then, once components are updated, call
|
|
129
|
-
// afterUpdate functions. This may cause
|
|
130
|
-
// subsequent updates...
|
|
131
|
-
for (let i = 0; i < render_callbacks.length; i += 1) {
|
|
132
|
-
const callback = render_callbacks[i];
|
|
133
|
-
if (!seen_callbacks.has(callback)) {
|
|
134
|
-
// ...so guard against infinite loops
|
|
135
|
-
seen_callbacks.add(callback);
|
|
136
|
-
callback();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
render_callbacks.length = 0;
|
|
140
|
-
} while (dirty_components.length);
|
|
141
|
-
while (flush_callbacks.length) {
|
|
142
|
-
flush_callbacks.pop()();
|
|
143
|
-
}
|
|
144
|
-
update_scheduled = false;
|
|
145
|
-
flushing = false;
|
|
146
|
-
seen_callbacks.clear();
|
|
147
|
-
}
|
|
148
|
-
function update($$) {
|
|
149
|
-
if ($$.fragment !== null) {
|
|
150
|
-
$$.update();
|
|
151
|
-
run_all($$.before_update);
|
|
152
|
-
const dirty = $$.dirty;
|
|
153
|
-
$$.dirty = [-1];
|
|
154
|
-
$$.fragment && $$.fragment.p($$.ctx, dirty);
|
|
155
|
-
$$.after_update.forEach(add_render_callback);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
const outroing = new Set();
|
|
159
|
-
function transition_in(block, local) {
|
|
160
|
-
if (block && block.i) {
|
|
161
|
-
outroing.delete(block);
|
|
162
|
-
block.i(local);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const globals = (typeof window !== 'undefined'
|
|
167
|
-
? window
|
|
168
|
-
: typeof globalThis !== 'undefined'
|
|
169
|
-
? globalThis
|
|
170
|
-
: global);
|
|
171
|
-
function mount_component(component, target, anchor, customElement) {
|
|
172
|
-
const { fragment, on_mount, on_destroy, after_update } = component.$$;
|
|
173
|
-
fragment && fragment.m(target, anchor);
|
|
174
|
-
if (!customElement) {
|
|
175
|
-
// onMount happens before the initial afterUpdate
|
|
176
|
-
add_render_callback(() => {
|
|
177
|
-
const new_on_destroy = on_mount.map(run).filter(is_function);
|
|
178
|
-
if (on_destroy) {
|
|
179
|
-
on_destroy.push(...new_on_destroy);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
// Edge case - component was destroyed immediately,
|
|
183
|
-
// most likely as a result of a binding initialising
|
|
184
|
-
run_all(new_on_destroy);
|
|
185
|
-
}
|
|
186
|
-
component.$$.on_mount = [];
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
after_update.forEach(add_render_callback);
|
|
190
|
-
}
|
|
191
|
-
function destroy_component(component, detaching) {
|
|
192
|
-
const $$ = component.$$;
|
|
193
|
-
if ($$.fragment !== null) {
|
|
194
|
-
run_all($$.on_destroy);
|
|
195
|
-
$$.fragment && $$.fragment.d(detaching);
|
|
196
|
-
// TODO null out other refs, including component.$$ (but need to
|
|
197
|
-
// preserve final state?)
|
|
198
|
-
$$.on_destroy = $$.fragment = null;
|
|
199
|
-
$$.ctx = [];
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function make_dirty(component, i) {
|
|
203
|
-
if (component.$$.dirty[0] === -1) {
|
|
204
|
-
dirty_components.push(component);
|
|
205
|
-
schedule_update();
|
|
206
|
-
component.$$.dirty.fill(0);
|
|
207
|
-
}
|
|
208
|
-
component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
|
|
209
|
-
}
|
|
210
|
-
function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
|
|
211
|
-
const parent_component = current_component;
|
|
212
|
-
set_current_component(component);
|
|
213
|
-
const $$ = component.$$ = {
|
|
214
|
-
fragment: null,
|
|
215
|
-
ctx: null,
|
|
216
|
-
// state
|
|
217
|
-
props,
|
|
218
|
-
update: noop,
|
|
219
|
-
not_equal,
|
|
220
|
-
bound: blank_object(),
|
|
221
|
-
// lifecycle
|
|
222
|
-
on_mount: [],
|
|
223
|
-
on_destroy: [],
|
|
224
|
-
on_disconnect: [],
|
|
225
|
-
before_update: [],
|
|
226
|
-
after_update: [],
|
|
227
|
-
context: new Map(parent_component ? parent_component.$$.context : options.context || []),
|
|
228
|
-
// everything else
|
|
229
|
-
callbacks: blank_object(),
|
|
230
|
-
dirty,
|
|
231
|
-
skip_bound: false
|
|
232
|
-
};
|
|
233
|
-
let ready = false;
|
|
234
|
-
$$.ctx = instance
|
|
235
|
-
? instance(component, options.props || {}, (i, ret, ...rest) => {
|
|
236
|
-
const value = rest.length ? rest[0] : ret;
|
|
237
|
-
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
|
|
238
|
-
if (!$$.skip_bound && $$.bound[i])
|
|
239
|
-
$$.bound[i](value);
|
|
240
|
-
if (ready)
|
|
241
|
-
make_dirty(component, i);
|
|
242
|
-
}
|
|
243
|
-
return ret;
|
|
244
|
-
})
|
|
245
|
-
: [];
|
|
246
|
-
$$.update();
|
|
247
|
-
ready = true;
|
|
248
|
-
run_all($$.before_update);
|
|
249
|
-
// `false` as a special case of no DOM component
|
|
250
|
-
$$.fragment = create_fragment ? create_fragment($$.ctx) : false;
|
|
251
|
-
if (options.target) {
|
|
252
|
-
if (options.hydrate) {
|
|
253
|
-
const nodes = children(options.target);
|
|
254
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
255
|
-
$$.fragment && $$.fragment.l(nodes);
|
|
256
|
-
nodes.forEach(detach);
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
260
|
-
$$.fragment && $$.fragment.c();
|
|
261
|
-
}
|
|
262
|
-
if (options.intro)
|
|
263
|
-
transition_in(component.$$.fragment);
|
|
264
|
-
mount_component(component, options.target, options.anchor, options.customElement);
|
|
265
|
-
flush();
|
|
266
|
-
}
|
|
267
|
-
set_current_component(parent_component);
|
|
268
|
-
}
|
|
269
|
-
let SvelteElement;
|
|
270
|
-
if (typeof HTMLElement === 'function') {
|
|
271
|
-
SvelteElement = class extends HTMLElement {
|
|
272
|
-
constructor() {
|
|
273
|
-
super();
|
|
274
|
-
this.attachShadow({ mode: 'open' });
|
|
275
|
-
}
|
|
276
|
-
connectedCallback() {
|
|
277
|
-
const { on_mount } = this.$$;
|
|
278
|
-
this.$$.on_disconnect = on_mount.map(run).filter(is_function);
|
|
279
|
-
// @ts-ignore todo: improve typings
|
|
280
|
-
for (const key in this.$$.slotted) {
|
|
281
|
-
// @ts-ignore todo: improve typings
|
|
282
|
-
this.appendChild(this.$$.slotted[key]);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
attributeChangedCallback(attr, _oldValue, newValue) {
|
|
286
|
-
this[attr] = newValue;
|
|
287
|
-
}
|
|
288
|
-
disconnectedCallback() {
|
|
289
|
-
run_all(this.$$.on_disconnect);
|
|
290
|
-
}
|
|
291
|
-
$destroy() {
|
|
292
|
-
destroy_component(this, 1);
|
|
293
|
-
this.$destroy = noop;
|
|
294
|
-
}
|
|
295
|
-
$on(type, callback) {
|
|
296
|
-
// TODO should this delegate to addEventListener?
|
|
297
|
-
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
|
|
298
|
-
callbacks.push(callback);
|
|
299
|
-
return () => {
|
|
300
|
-
const index = callbacks.indexOf(callback);
|
|
301
|
-
if (index !== -1)
|
|
302
|
-
callbacks.splice(index, 1);
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
$set($$props) {
|
|
306
|
-
if (this.$$set && !is_empty($$props)) {
|
|
307
|
-
this.$$.skip_bound = true;
|
|
308
|
-
this.$$set($$props);
|
|
309
|
-
this.$$.skip_bound = false;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function dispatch_dev(type, detail) {
|
|
316
|
-
document.dispatchEvent(custom_event(type, Object.assign({ version: '3.37.0' }, detail)));
|
|
317
|
-
}
|
|
318
|
-
function append_dev(target, node) {
|
|
319
|
-
dispatch_dev('SvelteDOMInsert', { target, node });
|
|
320
|
-
append(target, node);
|
|
321
|
-
}
|
|
322
|
-
function insert_dev(target, node, anchor) {
|
|
323
|
-
dispatch_dev('SvelteDOMInsert', { target, node, anchor });
|
|
324
|
-
insert(target, node, anchor);
|
|
325
|
-
}
|
|
326
|
-
function detach_dev(node) {
|
|
327
|
-
dispatch_dev('SvelteDOMRemove', { node });
|
|
328
|
-
detach(node);
|
|
329
|
-
}
|
|
330
|
-
function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) {
|
|
331
|
-
const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : [];
|
|
332
|
-
if (has_prevent_default)
|
|
333
|
-
modifiers.push('preventDefault');
|
|
334
|
-
if (has_stop_propagation)
|
|
335
|
-
modifiers.push('stopPropagation');
|
|
336
|
-
dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers });
|
|
337
|
-
const dispose = listen(node, event, handler, options);
|
|
338
|
-
return () => {
|
|
339
|
-
dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers });
|
|
340
|
-
dispose();
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function attr_dev(node, attribute, value) {
|
|
344
|
-
attr(node, attribute, value);
|
|
345
|
-
if (value == null)
|
|
346
|
-
dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute });
|
|
347
|
-
else
|
|
348
|
-
dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value });
|
|
349
|
-
}
|
|
350
|
-
function set_data_dev(text, data) {
|
|
351
|
-
data = '' + data;
|
|
352
|
-
if (text.wholeText === data)
|
|
353
|
-
return;
|
|
354
|
-
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
|
355
|
-
text.data = data;
|
|
356
|
-
}
|
|
357
|
-
function validate_slots(name, slot, keys) {
|
|
358
|
-
for (const slot_key of Object.keys(slot)) {
|
|
359
|
-
if (!~keys.indexOf(slot_key)) {
|
|
360
|
-
console.warn(`<${name}> received an unexpected slot "${slot_key}".`);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
366
|
-
|
|
367
|
-
function createCommonjsModule(fn, basedir, module) {
|
|
368
|
-
return module = {
|
|
369
|
-
path: basedir,
|
|
370
|
-
exports: {},
|
|
371
|
-
require: function (path, base) {
|
|
372
|
-
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
373
|
-
}
|
|
374
|
-
}, fn(module, module.exports), module.exports;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function commonjsRequire () {
|
|
378
|
-
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
var eventsource = createCommonjsModule(function (module, exports) {
|
|
382
|
-
/** @license
|
|
383
|
-
* eventsource.js
|
|
384
|
-
* Available under MIT License (MIT)
|
|
385
|
-
* https://github.com/Yaffle/EventSource/
|
|
386
|
-
*/
|
|
387
|
-
|
|
388
|
-
/*jslint indent: 2, vars: true, plusplus: true */
|
|
389
|
-
/*global setTimeout, clearTimeout */
|
|
390
|
-
|
|
391
|
-
(function (global) {
|
|
392
|
-
|
|
393
|
-
var setTimeout = global.setTimeout;
|
|
394
|
-
var clearTimeout = global.clearTimeout;
|
|
395
|
-
var XMLHttpRequest = global.XMLHttpRequest;
|
|
396
|
-
var XDomainRequest = global.XDomainRequest;
|
|
397
|
-
var ActiveXObject = global.ActiveXObject;
|
|
398
|
-
var NativeEventSource = global.EventSource;
|
|
399
|
-
|
|
400
|
-
var document = global.document;
|
|
401
|
-
var Promise = global.Promise;
|
|
402
|
-
var fetch = global.fetch;
|
|
403
|
-
var Response = global.Response;
|
|
404
|
-
var TextDecoder = global.TextDecoder;
|
|
405
|
-
var TextEncoder = global.TextEncoder;
|
|
406
|
-
var AbortController = global.AbortController;
|
|
407
|
-
|
|
408
|
-
if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) { // Firefox 2
|
|
409
|
-
document.readyState = "loading";
|
|
410
|
-
window.addEventListener("load", function (event) {
|
|
411
|
-
document.readyState = "complete";
|
|
412
|
-
}, false);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
if (XMLHttpRequest == null && ActiveXObject != null) { // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6
|
|
416
|
-
XMLHttpRequest = function () {
|
|
417
|
-
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
if (Object.create == undefined) {
|
|
422
|
-
Object.create = function (C) {
|
|
423
|
-
function F(){}
|
|
424
|
-
F.prototype = C;
|
|
425
|
-
return new F();
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
if (!Date.now) {
|
|
430
|
-
Date.now = function now() {
|
|
431
|
-
return new Date().getTime();
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
// see #118 (Promise#finally with polyfilled Promise)
|
|
436
|
-
// see #123 (data URLs crash Edge)
|
|
437
|
-
// see #125 (CSP violations)
|
|
438
|
-
// see pull/#138
|
|
439
|
-
// => No way to polyfill Promise#finally
|
|
440
|
-
|
|
441
|
-
if (AbortController == undefined) {
|
|
442
|
-
var originalFetch2 = fetch;
|
|
443
|
-
fetch = function (url, options) {
|
|
444
|
-
var signal = options.signal;
|
|
445
|
-
return originalFetch2(url, {headers: options.headers, credentials: options.credentials, cache: options.cache}).then(function (response) {
|
|
446
|
-
var reader = response.body.getReader();
|
|
447
|
-
signal._reader = reader;
|
|
448
|
-
if (signal._aborted) {
|
|
449
|
-
signal._reader.cancel();
|
|
450
|
-
}
|
|
451
|
-
return {
|
|
452
|
-
status: response.status,
|
|
453
|
-
statusText: response.statusText,
|
|
454
|
-
headers: response.headers,
|
|
455
|
-
body: {
|
|
456
|
-
getReader: function () {
|
|
457
|
-
return reader;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
});
|
|
462
|
-
};
|
|
463
|
-
AbortController = function () {
|
|
464
|
-
this.signal = {
|
|
465
|
-
_reader: null,
|
|
466
|
-
_aborted: false
|
|
467
|
-
};
|
|
468
|
-
this.abort = function () {
|
|
469
|
-
if (this.signal._reader != null) {
|
|
470
|
-
this.signal._reader.cancel();
|
|
471
|
-
}
|
|
472
|
-
this.signal._aborted = true;
|
|
473
|
-
};
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
function TextDecoderPolyfill() {
|
|
478
|
-
this.bitsNeeded = 0;
|
|
479
|
-
this.codePoint = 0;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
TextDecoderPolyfill.prototype.decode = function (octets) {
|
|
483
|
-
function valid(codePoint, shift, octetsCount) {
|
|
484
|
-
if (octetsCount === 1) {
|
|
485
|
-
return codePoint >= 0x0080 >> shift && codePoint << shift <= 0x07FF;
|
|
486
|
-
}
|
|
487
|
-
if (octetsCount === 2) {
|
|
488
|
-
return codePoint >= 0x0800 >> shift && codePoint << shift <= 0xD7FF || codePoint >= 0xE000 >> shift && codePoint << shift <= 0xFFFF;
|
|
489
|
-
}
|
|
490
|
-
if (octetsCount === 3) {
|
|
491
|
-
return codePoint >= 0x010000 >> shift && codePoint << shift <= 0x10FFFF;
|
|
492
|
-
}
|
|
493
|
-
throw new Error();
|
|
494
|
-
}
|
|
495
|
-
function octetsCount(bitsNeeded, codePoint) {
|
|
496
|
-
if (bitsNeeded === 6 * 1) {
|
|
497
|
-
return codePoint >> 6 > 15 ? 3 : codePoint > 31 ? 2 : 1;
|
|
498
|
-
}
|
|
499
|
-
if (bitsNeeded === 6 * 2) {
|
|
500
|
-
return codePoint > 15 ? 3 : 2;
|
|
501
|
-
}
|
|
502
|
-
if (bitsNeeded === 6 * 3) {
|
|
503
|
-
return 3;
|
|
504
|
-
}
|
|
505
|
-
throw new Error();
|
|
506
|
-
}
|
|
507
|
-
var REPLACER = 0xFFFD;
|
|
508
|
-
var string = "";
|
|
509
|
-
var bitsNeeded = this.bitsNeeded;
|
|
510
|
-
var codePoint = this.codePoint;
|
|
511
|
-
for (var i = 0; i < octets.length; i += 1) {
|
|
512
|
-
var octet = octets[i];
|
|
513
|
-
if (bitsNeeded !== 0) {
|
|
514
|
-
if (octet < 128 || octet > 191 || !valid(codePoint << 6 | octet & 63, bitsNeeded - 6, octetsCount(bitsNeeded, codePoint))) {
|
|
515
|
-
bitsNeeded = 0;
|
|
516
|
-
codePoint = REPLACER;
|
|
517
|
-
string += String.fromCharCode(codePoint);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
if (bitsNeeded === 0) {
|
|
521
|
-
if (octet >= 0 && octet <= 127) {
|
|
522
|
-
bitsNeeded = 0;
|
|
523
|
-
codePoint = octet;
|
|
524
|
-
} else if (octet >= 192 && octet <= 223) {
|
|
525
|
-
bitsNeeded = 6 * 1;
|
|
526
|
-
codePoint = octet & 31;
|
|
527
|
-
} else if (octet >= 224 && octet <= 239) {
|
|
528
|
-
bitsNeeded = 6 * 2;
|
|
529
|
-
codePoint = octet & 15;
|
|
530
|
-
} else if (octet >= 240 && octet <= 247) {
|
|
531
|
-
bitsNeeded = 6 * 3;
|
|
532
|
-
codePoint = octet & 7;
|
|
533
|
-
} else {
|
|
534
|
-
bitsNeeded = 0;
|
|
535
|
-
codePoint = REPLACER;
|
|
536
|
-
}
|
|
537
|
-
if (bitsNeeded !== 0 && !valid(codePoint, bitsNeeded, octetsCount(bitsNeeded, codePoint))) {
|
|
538
|
-
bitsNeeded = 0;
|
|
539
|
-
codePoint = REPLACER;
|
|
540
|
-
}
|
|
541
|
-
} else {
|
|
542
|
-
bitsNeeded -= 6;
|
|
543
|
-
codePoint = codePoint << 6 | octet & 63;
|
|
544
|
-
}
|
|
545
|
-
if (bitsNeeded === 0) {
|
|
546
|
-
if (codePoint <= 0xFFFF) {
|
|
547
|
-
string += String.fromCharCode(codePoint);
|
|
548
|
-
} else {
|
|
549
|
-
string += String.fromCharCode(0xD800 + (codePoint - 0xFFFF - 1 >> 10));
|
|
550
|
-
string += String.fromCharCode(0xDC00 + (codePoint - 0xFFFF - 1 & 0x3FF));
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
this.bitsNeeded = bitsNeeded;
|
|
555
|
-
this.codePoint = codePoint;
|
|
556
|
-
return string;
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
// Firefox < 38 throws an error with stream option
|
|
560
|
-
var supportsStreamOption = function () {
|
|
561
|
-
try {
|
|
562
|
-
return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
|
|
563
|
-
} catch (error) {
|
|
564
|
-
console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + error);
|
|
565
|
-
}
|
|
566
|
-
return false;
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
// IE, Edge
|
|
570
|
-
if (TextDecoder == undefined || TextEncoder == undefined || !supportsStreamOption()) {
|
|
571
|
-
TextDecoder = TextDecoderPolyfill;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
var k = function () {
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
function XHRWrapper(xhr) {
|
|
578
|
-
this.withCredentials = false;
|
|
579
|
-
this.readyState = 0;
|
|
580
|
-
this.status = 0;
|
|
581
|
-
this.statusText = "";
|
|
582
|
-
this.responseText = "";
|
|
583
|
-
this.onprogress = k;
|
|
584
|
-
this.onload = k;
|
|
585
|
-
this.onerror = k;
|
|
586
|
-
this.onreadystatechange = k;
|
|
587
|
-
this._contentType = "";
|
|
588
|
-
this._xhr = xhr;
|
|
589
|
-
this._sendTimeout = 0;
|
|
590
|
-
this._abort = k;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
XHRWrapper.prototype.open = function (method, url) {
|
|
594
|
-
this._abort(true);
|
|
595
|
-
|
|
596
|
-
var that = this;
|
|
597
|
-
var xhr = this._xhr;
|
|
598
|
-
var state = 1;
|
|
599
|
-
var timeout = 0;
|
|
600
|
-
|
|
601
|
-
this._abort = function (silent) {
|
|
602
|
-
if (that._sendTimeout !== 0) {
|
|
603
|
-
clearTimeout(that._sendTimeout);
|
|
604
|
-
that._sendTimeout = 0;
|
|
605
|
-
}
|
|
606
|
-
if (state === 1 || state === 2 || state === 3) {
|
|
607
|
-
state = 4;
|
|
608
|
-
xhr.onload = k;
|
|
609
|
-
xhr.onerror = k;
|
|
610
|
-
xhr.onabort = k;
|
|
611
|
-
xhr.onprogress = k;
|
|
612
|
-
xhr.onreadystatechange = k;
|
|
613
|
-
// IE 8 - 9: XDomainRequest#abort() does not fire any event
|
|
614
|
-
// Opera < 10: XMLHttpRequest#abort() does not fire any event
|
|
615
|
-
xhr.abort();
|
|
616
|
-
if (timeout !== 0) {
|
|
617
|
-
clearTimeout(timeout);
|
|
618
|
-
timeout = 0;
|
|
619
|
-
}
|
|
620
|
-
if (!silent) {
|
|
621
|
-
that.readyState = 4;
|
|
622
|
-
that.onabort(null);
|
|
623
|
-
that.onreadystatechange();
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
state = 0;
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
var onStart = function () {
|
|
630
|
-
if (state === 1) {
|
|
631
|
-
//state = 2;
|
|
632
|
-
var status = 0;
|
|
633
|
-
var statusText = "";
|
|
634
|
-
var contentType = undefined;
|
|
635
|
-
if (!("contentType" in xhr)) {
|
|
636
|
-
try {
|
|
637
|
-
status = xhr.status;
|
|
638
|
-
statusText = xhr.statusText;
|
|
639
|
-
contentType = xhr.getResponseHeader("Content-Type");
|
|
640
|
-
} catch (error) {
|
|
641
|
-
// IE < 10 throws exception for `xhr.status` when xhr.readyState === 2 || xhr.readyState === 3
|
|
642
|
-
// Opera < 11 throws exception for `xhr.status` when xhr.readyState === 2
|
|
643
|
-
// https://bugs.webkit.org/show_bug.cgi?id=29121
|
|
644
|
-
status = 0;
|
|
645
|
-
statusText = "";
|
|
646
|
-
contentType = undefined;
|
|
647
|
-
// Firefox < 14, Chrome ?, Safari ?
|
|
648
|
-
// https://bugs.webkit.org/show_bug.cgi?id=29658
|
|
649
|
-
// https://bugs.webkit.org/show_bug.cgi?id=77854
|
|
650
|
-
}
|
|
651
|
-
} else {
|
|
652
|
-
status = 200;
|
|
653
|
-
statusText = "OK";
|
|
654
|
-
contentType = xhr.contentType;
|
|
655
|
-
}
|
|
656
|
-
if (status !== 0) {
|
|
657
|
-
state = 2;
|
|
658
|
-
that.readyState = 2;
|
|
659
|
-
that.status = status;
|
|
660
|
-
that.statusText = statusText;
|
|
661
|
-
that._contentType = contentType;
|
|
662
|
-
that.onreadystatechange();
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
var onProgress = function () {
|
|
667
|
-
onStart();
|
|
668
|
-
if (state === 2 || state === 3) {
|
|
669
|
-
state = 3;
|
|
670
|
-
var responseText = "";
|
|
671
|
-
try {
|
|
672
|
-
responseText = xhr.responseText;
|
|
673
|
-
} catch (error) {
|
|
674
|
-
// IE 8 - 9 with XMLHttpRequest
|
|
675
|
-
}
|
|
676
|
-
that.readyState = 3;
|
|
677
|
-
that.responseText = responseText;
|
|
678
|
-
that.onprogress();
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
var onFinish = function (type, event) {
|
|
682
|
-
if (event == null || event.preventDefault == null) {
|
|
683
|
-
event = {
|
|
684
|
-
preventDefault: k
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
// Firefox 52 fires "readystatechange" (xhr.readyState === 4) without final "readystatechange" (xhr.readyState === 3)
|
|
688
|
-
// IE 8 fires "onload" without "onprogress"
|
|
689
|
-
onProgress();
|
|
690
|
-
if (state === 1 || state === 2 || state === 3) {
|
|
691
|
-
state = 4;
|
|
692
|
-
if (timeout !== 0) {
|
|
693
|
-
clearTimeout(timeout);
|
|
694
|
-
timeout = 0;
|
|
695
|
-
}
|
|
696
|
-
that.readyState = 4;
|
|
697
|
-
if (type === "load") {
|
|
698
|
-
that.onload(event);
|
|
699
|
-
} else if (type === "error") {
|
|
700
|
-
that.onerror(event);
|
|
701
|
-
} else if (type === "abort") {
|
|
702
|
-
that.onabort(event);
|
|
703
|
-
} else {
|
|
704
|
-
throw new TypeError();
|
|
705
|
-
}
|
|
706
|
-
that.onreadystatechange();
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
var onReadyStateChange = function (event) {
|
|
710
|
-
if (xhr != undefined) { // Opera 12
|
|
711
|
-
if (xhr.readyState === 4) {
|
|
712
|
-
if (!("onload" in xhr) || !("onerror" in xhr) || !("onabort" in xhr)) {
|
|
713
|
-
onFinish(xhr.responseText === "" ? "error" : "load", event);
|
|
714
|
-
}
|
|
715
|
-
} else if (xhr.readyState === 3) {
|
|
716
|
-
if (!("onprogress" in xhr)) { // testing XMLHttpRequest#responseText too many times is too slow in IE 11
|
|
717
|
-
// and in Firefox 3.6
|
|
718
|
-
onProgress();
|
|
719
|
-
}
|
|
720
|
-
} else if (xhr.readyState === 2) {
|
|
721
|
-
onStart();
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
var onTimeout = function () {
|
|
726
|
-
timeout = setTimeout(function () {
|
|
727
|
-
onTimeout();
|
|
728
|
-
}, 500);
|
|
729
|
-
if (xhr.readyState === 3) {
|
|
730
|
-
onProgress();
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
// XDomainRequest#abort removes onprogress, onerror, onload
|
|
735
|
-
if ("onload" in xhr) {
|
|
736
|
-
xhr.onload = function (event) {
|
|
737
|
-
onFinish("load", event);
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
if ("onerror" in xhr) {
|
|
741
|
-
xhr.onerror = function (event) {
|
|
742
|
-
onFinish("error", event);
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
// improper fix to match Firefox behaviour, but it is better than just ignore abort
|
|
746
|
-
// see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
|
|
747
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=880200
|
|
748
|
-
// https://code.google.com/p/chromium/issues/detail?id=153570
|
|
749
|
-
// IE 8 fires "onload" without "onprogress
|
|
750
|
-
if ("onabort" in xhr) {
|
|
751
|
-
xhr.onabort = function (event) {
|
|
752
|
-
onFinish("abort", event);
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
if ("onprogress" in xhr) {
|
|
757
|
-
xhr.onprogress = onProgress;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
// IE 8 - 9 (XMLHTTPRequest)
|
|
761
|
-
// Opera < 12
|
|
762
|
-
// Firefox < 3.5
|
|
763
|
-
// Firefox 3.5 - 3.6 - ? < 9.0
|
|
764
|
-
// onprogress is not fired sometimes or delayed
|
|
765
|
-
// see also #64 (significant lag in IE 11)
|
|
766
|
-
if ("onreadystatechange" in xhr) {
|
|
767
|
-
xhr.onreadystatechange = function (event) {
|
|
768
|
-
onReadyStateChange(event);
|
|
769
|
-
};
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest.prototype)) {
|
|
773
|
-
url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
|
|
774
|
-
}
|
|
775
|
-
xhr.open(method, url, true);
|
|
776
|
-
|
|
777
|
-
if ("readyState" in xhr) {
|
|
778
|
-
// workaround for Opera 12 issue with "progress" events
|
|
779
|
-
// #91 (XMLHttpRequest onprogress not fired for streaming response in Edge 14-15-?)
|
|
780
|
-
timeout = setTimeout(function () {
|
|
781
|
-
onTimeout();
|
|
782
|
-
}, 0);
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
XHRWrapper.prototype.abort = function () {
|
|
786
|
-
this._abort(false);
|
|
787
|
-
};
|
|
788
|
-
XHRWrapper.prototype.getResponseHeader = function (name) {
|
|
789
|
-
return this._contentType;
|
|
790
|
-
};
|
|
791
|
-
XHRWrapper.prototype.setRequestHeader = function (name, value) {
|
|
792
|
-
var xhr = this._xhr;
|
|
793
|
-
if ("setRequestHeader" in xhr) {
|
|
794
|
-
xhr.setRequestHeader(name, value);
|
|
795
|
-
}
|
|
796
|
-
};
|
|
797
|
-
XHRWrapper.prototype.getAllResponseHeaders = function () {
|
|
798
|
-
// XMLHttpRequest#getAllResponseHeaders returns null for CORS requests in Firefox 3.6.28
|
|
799
|
-
return this._xhr.getAllResponseHeaders != undefined ? this._xhr.getAllResponseHeaders() || "" : "";
|
|
800
|
-
};
|
|
801
|
-
XHRWrapper.prototype.send = function () {
|
|
802
|
-
// loading indicator in Safari < ? (6), Chrome < 14, Firefox
|
|
803
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=736723
|
|
804
|
-
if ((!("ontimeout" in XMLHttpRequest.prototype) || (!("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype))) &&
|
|
805
|
-
document != undefined &&
|
|
806
|
-
document.readyState != undefined &&
|
|
807
|
-
document.readyState !== "complete") {
|
|
808
|
-
var that = this;
|
|
809
|
-
that._sendTimeout = setTimeout(function () {
|
|
810
|
-
that._sendTimeout = 0;
|
|
811
|
-
that.send();
|
|
812
|
-
}, 4);
|
|
813
|
-
return;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
var xhr = this._xhr;
|
|
817
|
-
// withCredentials should be set after "open" for Safari and Chrome (< 19 ?)
|
|
818
|
-
if ("withCredentials" in xhr) {
|
|
819
|
-
xhr.withCredentials = this.withCredentials;
|
|
820
|
-
}
|
|
821
|
-
try {
|
|
822
|
-
// xhr.send(); throws "Not enough arguments" in Firefox 3.0
|
|
823
|
-
xhr.send(undefined);
|
|
824
|
-
} catch (error1) {
|
|
825
|
-
// Safari 5.1.7, Opera 12
|
|
826
|
-
throw error1;
|
|
827
|
-
}
|
|
828
|
-
};
|
|
829
|
-
|
|
830
|
-
function toLowerCase(name) {
|
|
831
|
-
return name.replace(/[A-Z]/g, function (c) {
|
|
832
|
-
return String.fromCharCode(c.charCodeAt(0) + 0x20);
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
function HeadersPolyfill(all) {
|
|
837
|
-
// Get headers: implemented according to mozilla's example code: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
|
|
838
|
-
var map = Object.create(null);
|
|
839
|
-
var array = all.split("\r\n");
|
|
840
|
-
for (var i = 0; i < array.length; i += 1) {
|
|
841
|
-
var line = array[i];
|
|
842
|
-
var parts = line.split(": ");
|
|
843
|
-
var name = parts.shift();
|
|
844
|
-
var value = parts.join(": ");
|
|
845
|
-
map[toLowerCase(name)] = value;
|
|
846
|
-
}
|
|
847
|
-
this._map = map;
|
|
848
|
-
}
|
|
849
|
-
HeadersPolyfill.prototype.get = function (name) {
|
|
850
|
-
return this._map[toLowerCase(name)];
|
|
851
|
-
};
|
|
852
|
-
|
|
853
|
-
if (XMLHttpRequest != null && XMLHttpRequest.HEADERS_RECEIVED == null) { // IE < 9, Firefox 3.6
|
|
854
|
-
XMLHttpRequest.HEADERS_RECEIVED = 2;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
function XHRTransport() {
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
XHRTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
|
|
861
|
-
xhr.open("GET", url);
|
|
862
|
-
var offset = 0;
|
|
863
|
-
xhr.onprogress = function () {
|
|
864
|
-
var responseText = xhr.responseText;
|
|
865
|
-
var chunk = responseText.slice(offset);
|
|
866
|
-
offset += chunk.length;
|
|
867
|
-
onProgressCallback(chunk);
|
|
868
|
-
};
|
|
869
|
-
xhr.onerror = function (event) {
|
|
870
|
-
event.preventDefault();
|
|
871
|
-
onFinishCallback(new Error("NetworkError"));
|
|
872
|
-
};
|
|
873
|
-
xhr.onload = function () {
|
|
874
|
-
onFinishCallback(null);
|
|
875
|
-
};
|
|
876
|
-
xhr.onabort = function () {
|
|
877
|
-
onFinishCallback(null);
|
|
878
|
-
};
|
|
879
|
-
xhr.onreadystatechange = function () {
|
|
880
|
-
if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
|
881
|
-
var status = xhr.status;
|
|
882
|
-
var statusText = xhr.statusText;
|
|
883
|
-
var contentType = xhr.getResponseHeader("Content-Type");
|
|
884
|
-
var headers = xhr.getAllResponseHeaders();
|
|
885
|
-
onStartCallback(status, statusText, contentType, new HeadersPolyfill(headers));
|
|
886
|
-
}
|
|
887
|
-
};
|
|
888
|
-
xhr.withCredentials = withCredentials;
|
|
889
|
-
for (var name in headers) {
|
|
890
|
-
if (Object.prototype.hasOwnProperty.call(headers, name)) {
|
|
891
|
-
xhr.setRequestHeader(name, headers[name]);
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
xhr.send();
|
|
895
|
-
return xhr;
|
|
896
|
-
};
|
|
897
|
-
|
|
898
|
-
function HeadersWrapper(headers) {
|
|
899
|
-
this._headers = headers;
|
|
900
|
-
}
|
|
901
|
-
HeadersWrapper.prototype.get = function (name) {
|
|
902
|
-
return this._headers.get(name);
|
|
903
|
-
};
|
|
904
|
-
|
|
905
|
-
function FetchTransport() {
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
FetchTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
|
|
909
|
-
var reader = null;
|
|
910
|
-
var controller = new AbortController();
|
|
911
|
-
var signal = controller.signal;
|
|
912
|
-
var textDecoder = new TextDecoder();
|
|
913
|
-
fetch(url, {
|
|
914
|
-
headers: headers,
|
|
915
|
-
credentials: withCredentials ? "include" : "same-origin",
|
|
916
|
-
signal: signal,
|
|
917
|
-
cache: "no-store"
|
|
918
|
-
}).then(function (response) {
|
|
919
|
-
reader = response.body.getReader();
|
|
920
|
-
onStartCallback(response.status, response.statusText, response.headers.get("Content-Type"), new HeadersWrapper(response.headers));
|
|
921
|
-
// see https://github.com/promises-aplus/promises-spec/issues/179
|
|
922
|
-
return new Promise(function (resolve, reject) {
|
|
923
|
-
var readNextChunk = function () {
|
|
924
|
-
reader.read().then(function (result) {
|
|
925
|
-
if (result.done) {
|
|
926
|
-
//Note: bytes in textDecoder are ignored
|
|
927
|
-
resolve(undefined);
|
|
928
|
-
} else {
|
|
929
|
-
var chunk = textDecoder.decode(result.value, {stream: true});
|
|
930
|
-
onProgressCallback(chunk);
|
|
931
|
-
readNextChunk();
|
|
932
|
-
}
|
|
933
|
-
})["catch"](function (error) {
|
|
934
|
-
reject(error);
|
|
935
|
-
});
|
|
936
|
-
};
|
|
937
|
-
readNextChunk();
|
|
938
|
-
});
|
|
939
|
-
})["catch"](function (error) {
|
|
940
|
-
if (error.name === "AbortError") {
|
|
941
|
-
return undefined;
|
|
942
|
-
} else {
|
|
943
|
-
return error;
|
|
944
|
-
}
|
|
945
|
-
}).then(function (error) {
|
|
946
|
-
onFinishCallback(error);
|
|
947
|
-
});
|
|
948
|
-
return {
|
|
949
|
-
abort: function () {
|
|
950
|
-
if (reader != null) {
|
|
951
|
-
reader.cancel(); // https://bugzilla.mozilla.org/show_bug.cgi?id=1583815
|
|
952
|
-
}
|
|
953
|
-
controller.abort();
|
|
954
|
-
}
|
|
955
|
-
};
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
function EventTarget() {
|
|
959
|
-
this._listeners = Object.create(null);
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
function throwError(e) {
|
|
963
|
-
setTimeout(function () {
|
|
964
|
-
throw e;
|
|
965
|
-
}, 0);
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
EventTarget.prototype.dispatchEvent = function (event) {
|
|
969
|
-
event.target = this;
|
|
970
|
-
var typeListeners = this._listeners[event.type];
|
|
971
|
-
if (typeListeners != undefined) {
|
|
972
|
-
var length = typeListeners.length;
|
|
973
|
-
for (var i = 0; i < length; i += 1) {
|
|
974
|
-
var listener = typeListeners[i];
|
|
975
|
-
try {
|
|
976
|
-
if (typeof listener.handleEvent === "function") {
|
|
977
|
-
listener.handleEvent(event);
|
|
978
|
-
} else {
|
|
979
|
-
listener.call(this, event);
|
|
980
|
-
}
|
|
981
|
-
} catch (e) {
|
|
982
|
-
throwError(e);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
};
|
|
987
|
-
EventTarget.prototype.addEventListener = function (type, listener) {
|
|
988
|
-
type = String(type);
|
|
989
|
-
var listeners = this._listeners;
|
|
990
|
-
var typeListeners = listeners[type];
|
|
991
|
-
if (typeListeners == undefined) {
|
|
992
|
-
typeListeners = [];
|
|
993
|
-
listeners[type] = typeListeners;
|
|
994
|
-
}
|
|
995
|
-
var found = false;
|
|
996
|
-
for (var i = 0; i < typeListeners.length; i += 1) {
|
|
997
|
-
if (typeListeners[i] === listener) {
|
|
998
|
-
found = true;
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
if (!found) {
|
|
1002
|
-
typeListeners.push(listener);
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
EventTarget.prototype.removeEventListener = function (type, listener) {
|
|
1006
|
-
type = String(type);
|
|
1007
|
-
var listeners = this._listeners;
|
|
1008
|
-
var typeListeners = listeners[type];
|
|
1009
|
-
if (typeListeners != undefined) {
|
|
1010
|
-
var filtered = [];
|
|
1011
|
-
for (var i = 0; i < typeListeners.length; i += 1) {
|
|
1012
|
-
if (typeListeners[i] !== listener) {
|
|
1013
|
-
filtered.push(typeListeners[i]);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
if (filtered.length === 0) {
|
|
1017
|
-
delete listeners[type];
|
|
1018
|
-
} else {
|
|
1019
|
-
listeners[type] = filtered;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1023
|
-
|
|
1024
|
-
function Event(type) {
|
|
1025
|
-
this.type = type;
|
|
1026
|
-
this.target = undefined;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
function MessageEvent(type, options) {
|
|
1030
|
-
Event.call(this, type);
|
|
1031
|
-
this.data = options.data;
|
|
1032
|
-
this.lastEventId = options.lastEventId;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
MessageEvent.prototype = Object.create(Event.prototype);
|
|
1036
|
-
|
|
1037
|
-
function ConnectionEvent(type, options) {
|
|
1038
|
-
Event.call(this, type);
|
|
1039
|
-
this.status = options.status;
|
|
1040
|
-
this.statusText = options.statusText;
|
|
1041
|
-
this.headers = options.headers;
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
ConnectionEvent.prototype = Object.create(Event.prototype);
|
|
1045
|
-
|
|
1046
|
-
function ErrorEvent(type, options) {
|
|
1047
|
-
Event.call(this, type);
|
|
1048
|
-
this.error = options.error;
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
ErrorEvent.prototype = Object.create(Event.prototype);
|
|
1052
|
-
|
|
1053
|
-
var WAITING = -1;
|
|
1054
|
-
var CONNECTING = 0;
|
|
1055
|
-
var OPEN = 1;
|
|
1056
|
-
var CLOSED = 2;
|
|
1057
|
-
|
|
1058
|
-
var AFTER_CR = -1;
|
|
1059
|
-
var FIELD_START = 0;
|
|
1060
|
-
var FIELD = 1;
|
|
1061
|
-
var VALUE_START = 2;
|
|
1062
|
-
var VALUE = 3;
|
|
1063
|
-
|
|
1064
|
-
var contentTypeRegExp = /^text\/event\-stream(;.*)?$/i;
|
|
1065
|
-
|
|
1066
|
-
var MINIMUM_DURATION = 1000;
|
|
1067
|
-
var MAXIMUM_DURATION = 18000000;
|
|
1068
|
-
|
|
1069
|
-
var parseDuration = function (value, def) {
|
|
1070
|
-
var n = value == null ? def : parseInt(value, 10);
|
|
1071
|
-
if (n !== n) {
|
|
1072
|
-
n = def;
|
|
1073
|
-
}
|
|
1074
|
-
return clampDuration(n);
|
|
1075
|
-
};
|
|
1076
|
-
var clampDuration = function (n) {
|
|
1077
|
-
return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
|
|
1078
|
-
};
|
|
1079
|
-
|
|
1080
|
-
var fire = function (that, f, event) {
|
|
1081
|
-
try {
|
|
1082
|
-
if (typeof f === "function") {
|
|
1083
|
-
f.call(that, event);
|
|
1084
|
-
}
|
|
1085
|
-
} catch (e) {
|
|
1086
|
-
throwError(e);
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
|
-
function EventSourcePolyfill(url, options) {
|
|
1091
|
-
EventTarget.call(this);
|
|
1092
|
-
options = options || {};
|
|
1093
|
-
|
|
1094
|
-
this.onopen = undefined;
|
|
1095
|
-
this.onmessage = undefined;
|
|
1096
|
-
this.onerror = undefined;
|
|
1097
|
-
|
|
1098
|
-
this.url = undefined;
|
|
1099
|
-
this.readyState = undefined;
|
|
1100
|
-
this.withCredentials = undefined;
|
|
1101
|
-
this.headers = undefined;
|
|
1102
|
-
|
|
1103
|
-
this._close = undefined;
|
|
1104
|
-
|
|
1105
|
-
start(this, url, options);
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
function getBestXHRTransport() {
|
|
1109
|
-
return (XMLHttpRequest != undefined && ("withCredentials" in XMLHttpRequest.prototype)) || XDomainRequest == undefined
|
|
1110
|
-
? new XMLHttpRequest()
|
|
1111
|
-
: new XDomainRequest();
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
var isFetchSupported = fetch != undefined && Response != undefined && "body" in Response.prototype;
|
|
1115
|
-
|
|
1116
|
-
function start(es, url, options) {
|
|
1117
|
-
url = String(url);
|
|
1118
|
-
var withCredentials = Boolean(options.withCredentials);
|
|
1119
|
-
var lastEventIdQueryParameterName = options.lastEventIdQueryParameterName || "lastEventId";
|
|
1120
|
-
|
|
1121
|
-
var initialRetry = clampDuration(1000);
|
|
1122
|
-
var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45000);
|
|
1123
|
-
|
|
1124
|
-
var lastEventId = "";
|
|
1125
|
-
var retry = initialRetry;
|
|
1126
|
-
var wasActivity = false;
|
|
1127
|
-
var textLength = 0;
|
|
1128
|
-
var headers = options.headers || {};
|
|
1129
|
-
var TransportOption = options.Transport;
|
|
1130
|
-
var xhr = isFetchSupported && TransportOption == undefined ? undefined : new XHRWrapper(TransportOption != undefined ? new TransportOption() : getBestXHRTransport());
|
|
1131
|
-
var transport = TransportOption != null && typeof TransportOption !== "string" ? new TransportOption() : (xhr == undefined ? new FetchTransport() : new XHRTransport());
|
|
1132
|
-
var abortController = undefined;
|
|
1133
|
-
var timeout = 0;
|
|
1134
|
-
var currentState = WAITING;
|
|
1135
|
-
var dataBuffer = "";
|
|
1136
|
-
var lastEventIdBuffer = "";
|
|
1137
|
-
var eventTypeBuffer = "";
|
|
1138
|
-
|
|
1139
|
-
var textBuffer = "";
|
|
1140
|
-
var state = FIELD_START;
|
|
1141
|
-
var fieldStart = 0;
|
|
1142
|
-
var valueStart = 0;
|
|
1143
|
-
|
|
1144
|
-
var onStart = function (status, statusText, contentType, headers) {
|
|
1145
|
-
if (currentState === CONNECTING) {
|
|
1146
|
-
if (status === 200 && contentType != undefined && contentTypeRegExp.test(contentType)) {
|
|
1147
|
-
currentState = OPEN;
|
|
1148
|
-
wasActivity = Date.now();
|
|
1149
|
-
retry = initialRetry;
|
|
1150
|
-
es.readyState = OPEN;
|
|
1151
|
-
var event = new ConnectionEvent("open", {
|
|
1152
|
-
status: status,
|
|
1153
|
-
statusText: statusText,
|
|
1154
|
-
headers: headers
|
|
1155
|
-
});
|
|
1156
|
-
es.dispatchEvent(event);
|
|
1157
|
-
fire(es, es.onopen, event);
|
|
1158
|
-
} else {
|
|
1159
|
-
var message = "";
|
|
1160
|
-
if (status !== 200) {
|
|
1161
|
-
if (statusText) {
|
|
1162
|
-
statusText = statusText.replace(/\s+/g, " ");
|
|
1163
|
-
}
|
|
1164
|
-
message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
|
|
1165
|
-
} else {
|
|
1166
|
-
message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == undefined ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
|
|
1167
|
-
}
|
|
1168
|
-
close();
|
|
1169
|
-
var event = new ConnectionEvent("error", {
|
|
1170
|
-
status: status,
|
|
1171
|
-
statusText: statusText,
|
|
1172
|
-
headers: headers
|
|
1173
|
-
});
|
|
1174
|
-
es.dispatchEvent(event);
|
|
1175
|
-
fire(es, es.onerror, event);
|
|
1176
|
-
console.error(message);
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
};
|
|
1180
|
-
|
|
1181
|
-
var onProgress = function (textChunk) {
|
|
1182
|
-
if (currentState === OPEN) {
|
|
1183
|
-
var n = -1;
|
|
1184
|
-
for (var i = 0; i < textChunk.length; i += 1) {
|
|
1185
|
-
var c = textChunk.charCodeAt(i);
|
|
1186
|
-
if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
|
|
1187
|
-
n = i;
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
|
|
1191
|
-
textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
|
|
1192
|
-
if (textChunk !== "") {
|
|
1193
|
-
wasActivity = Date.now();
|
|
1194
|
-
textLength += textChunk.length;
|
|
1195
|
-
}
|
|
1196
|
-
for (var position = 0; position < chunk.length; position += 1) {
|
|
1197
|
-
var c = chunk.charCodeAt(position);
|
|
1198
|
-
if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
|
|
1199
|
-
state = FIELD_START;
|
|
1200
|
-
} else {
|
|
1201
|
-
if (state === AFTER_CR) {
|
|
1202
|
-
state = FIELD_START;
|
|
1203
|
-
}
|
|
1204
|
-
if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
|
|
1205
|
-
if (state !== FIELD_START) {
|
|
1206
|
-
if (state === FIELD) {
|
|
1207
|
-
valueStart = position + 1;
|
|
1208
|
-
}
|
|
1209
|
-
var field = chunk.slice(fieldStart, valueStart - 1);
|
|
1210
|
-
var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
|
|
1211
|
-
if (field === "data") {
|
|
1212
|
-
dataBuffer += "\n";
|
|
1213
|
-
dataBuffer += value;
|
|
1214
|
-
} else if (field === "id") {
|
|
1215
|
-
lastEventIdBuffer = value;
|
|
1216
|
-
} else if (field === "event") {
|
|
1217
|
-
eventTypeBuffer = value;
|
|
1218
|
-
} else if (field === "retry") {
|
|
1219
|
-
initialRetry = parseDuration(value, initialRetry);
|
|
1220
|
-
retry = initialRetry;
|
|
1221
|
-
} else if (field === "heartbeatTimeout") {
|
|
1222
|
-
heartbeatTimeout = parseDuration(value, heartbeatTimeout);
|
|
1223
|
-
if (timeout !== 0) {
|
|
1224
|
-
clearTimeout(timeout);
|
|
1225
|
-
timeout = setTimeout(function () {
|
|
1226
|
-
onTimeout();
|
|
1227
|
-
}, heartbeatTimeout);
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
if (state === FIELD_START) {
|
|
1232
|
-
if (dataBuffer !== "") {
|
|
1233
|
-
lastEventId = lastEventIdBuffer;
|
|
1234
|
-
if (eventTypeBuffer === "") {
|
|
1235
|
-
eventTypeBuffer = "message";
|
|
1236
|
-
}
|
|
1237
|
-
var event = new MessageEvent(eventTypeBuffer, {
|
|
1238
|
-
data: dataBuffer.slice(1),
|
|
1239
|
-
lastEventId: lastEventIdBuffer
|
|
1240
|
-
});
|
|
1241
|
-
es.dispatchEvent(event);
|
|
1242
|
-
if (eventTypeBuffer === "open") {
|
|
1243
|
-
fire(es, es.onopen, event);
|
|
1244
|
-
} else if (eventTypeBuffer === "message") {
|
|
1245
|
-
fire(es, es.onmessage, event);
|
|
1246
|
-
} else if (eventTypeBuffer === "error") {
|
|
1247
|
-
fire(es, es.onerror, event);
|
|
1248
|
-
}
|
|
1249
|
-
if (currentState === CLOSED) {
|
|
1250
|
-
return;
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
dataBuffer = "";
|
|
1254
|
-
eventTypeBuffer = "";
|
|
1255
|
-
}
|
|
1256
|
-
state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
|
|
1257
|
-
} else {
|
|
1258
|
-
if (state === FIELD_START) {
|
|
1259
|
-
fieldStart = position;
|
|
1260
|
-
state = FIELD;
|
|
1261
|
-
}
|
|
1262
|
-
if (state === FIELD) {
|
|
1263
|
-
if (c === ":".charCodeAt(0)) {
|
|
1264
|
-
valueStart = position + 1;
|
|
1265
|
-
state = VALUE_START;
|
|
1266
|
-
}
|
|
1267
|
-
} else if (state === VALUE_START) {
|
|
1268
|
-
state = VALUE;
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
};
|
|
1275
|
-
|
|
1276
|
-
var onFinish = function (error) {
|
|
1277
|
-
if (currentState === OPEN || currentState === CONNECTING) {
|
|
1278
|
-
currentState = WAITING;
|
|
1279
|
-
if (timeout !== 0) {
|
|
1280
|
-
clearTimeout(timeout);
|
|
1281
|
-
timeout = 0;
|
|
1282
|
-
}
|
|
1283
|
-
timeout = setTimeout(function () {
|
|
1284
|
-
onTimeout();
|
|
1285
|
-
}, retry);
|
|
1286
|
-
retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
|
|
1287
|
-
|
|
1288
|
-
es.readyState = CONNECTING;
|
|
1289
|
-
var event = new ErrorEvent("error", {error: error});
|
|
1290
|
-
es.dispatchEvent(event);
|
|
1291
|
-
fire(es, es.onerror, event);
|
|
1292
|
-
if (error != undefined) {
|
|
1293
|
-
console.error(error);
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
};
|
|
1297
|
-
|
|
1298
|
-
var close = function () {
|
|
1299
|
-
currentState = CLOSED;
|
|
1300
|
-
if (abortController != undefined) {
|
|
1301
|
-
abortController.abort();
|
|
1302
|
-
abortController = undefined;
|
|
1303
|
-
}
|
|
1304
|
-
if (timeout !== 0) {
|
|
1305
|
-
clearTimeout(timeout);
|
|
1306
|
-
timeout = 0;
|
|
1307
|
-
}
|
|
1308
|
-
es.readyState = CLOSED;
|
|
1309
|
-
};
|
|
1310
|
-
|
|
1311
|
-
var onTimeout = function () {
|
|
1312
|
-
timeout = 0;
|
|
1313
|
-
|
|
1314
|
-
if (currentState !== WAITING) {
|
|
1315
|
-
if (!wasActivity && abortController != undefined) {
|
|
1316
|
-
onFinish(new Error("No activity within " + heartbeatTimeout + " milliseconds." + " " + (currentState === CONNECTING ? "No response received." : textLength + " chars received.") + " " + "Reconnecting."));
|
|
1317
|
-
if (abortController != undefined) {
|
|
1318
|
-
abortController.abort();
|
|
1319
|
-
abortController = undefined;
|
|
1320
|
-
}
|
|
1321
|
-
} else {
|
|
1322
|
-
var nextHeartbeat = Math.max((wasActivity || Date.now()) + heartbeatTimeout - Date.now(), 1);
|
|
1323
|
-
wasActivity = false;
|
|
1324
|
-
timeout = setTimeout(function () {
|
|
1325
|
-
onTimeout();
|
|
1326
|
-
}, nextHeartbeat);
|
|
1327
|
-
}
|
|
1328
|
-
return;
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
wasActivity = false;
|
|
1332
|
-
textLength = 0;
|
|
1333
|
-
timeout = setTimeout(function () {
|
|
1334
|
-
onTimeout();
|
|
1335
|
-
}, heartbeatTimeout);
|
|
1336
|
-
|
|
1337
|
-
currentState = CONNECTING;
|
|
1338
|
-
dataBuffer = "";
|
|
1339
|
-
eventTypeBuffer = "";
|
|
1340
|
-
lastEventIdBuffer = lastEventId;
|
|
1341
|
-
textBuffer = "";
|
|
1342
|
-
fieldStart = 0;
|
|
1343
|
-
valueStart = 0;
|
|
1344
|
-
state = FIELD_START;
|
|
1345
|
-
|
|
1346
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=428916
|
|
1347
|
-
// Request header field Last-Event-ID is not allowed by Access-Control-Allow-Headers.
|
|
1348
|
-
var requestURL = url;
|
|
1349
|
-
if (url.slice(0, 5) !== "data:" && url.slice(0, 5) !== "blob:") {
|
|
1350
|
-
if (lastEventId !== "") {
|
|
1351
|
-
// Remove the lastEventId parameter if it's already part of the request URL.
|
|
1352
|
-
var i = url.indexOf("?");
|
|
1353
|
-
requestURL = i === -1 ? url : url.slice(0, i + 1) + url.slice(i + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function (p, paramName) {
|
|
1354
|
-
return paramName === lastEventIdQueryParameterName ? '' : p;
|
|
1355
|
-
});
|
|
1356
|
-
// Append the current lastEventId to the request URL.
|
|
1357
|
-
requestURL += (url.indexOf("?") === -1 ? "?" : "&") + lastEventIdQueryParameterName +"=" + encodeURIComponent(lastEventId);
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
var withCredentials = es.withCredentials;
|
|
1361
|
-
var requestHeaders = {};
|
|
1362
|
-
requestHeaders["Accept"] = "text/event-stream";
|
|
1363
|
-
var headers = es.headers;
|
|
1364
|
-
if (headers != undefined) {
|
|
1365
|
-
for (var name in headers) {
|
|
1366
|
-
if (Object.prototype.hasOwnProperty.call(headers, name)) {
|
|
1367
|
-
requestHeaders[name] = headers[name];
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
try {
|
|
1372
|
-
abortController = transport.open(xhr, onStart, onProgress, onFinish, requestURL, withCredentials, requestHeaders);
|
|
1373
|
-
} catch (error) {
|
|
1374
|
-
close();
|
|
1375
|
-
throw error;
|
|
1376
|
-
}
|
|
1377
|
-
};
|
|
1378
|
-
|
|
1379
|
-
es.url = url;
|
|
1380
|
-
es.readyState = CONNECTING;
|
|
1381
|
-
es.withCredentials = withCredentials;
|
|
1382
|
-
es.headers = headers;
|
|
1383
|
-
es._close = close;
|
|
1384
|
-
|
|
1385
|
-
onTimeout();
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
|
|
1389
|
-
EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
|
|
1390
|
-
EventSourcePolyfill.prototype.OPEN = OPEN;
|
|
1391
|
-
EventSourcePolyfill.prototype.CLOSED = CLOSED;
|
|
1392
|
-
EventSourcePolyfill.prototype.close = function () {
|
|
1393
|
-
this._close();
|
|
1394
|
-
};
|
|
1395
|
-
|
|
1396
|
-
EventSourcePolyfill.CONNECTING = CONNECTING;
|
|
1397
|
-
EventSourcePolyfill.OPEN = OPEN;
|
|
1398
|
-
EventSourcePolyfill.CLOSED = CLOSED;
|
|
1399
|
-
EventSourcePolyfill.prototype.withCredentials = undefined;
|
|
1400
|
-
|
|
1401
|
-
var R = NativeEventSource;
|
|
1402
|
-
if (XMLHttpRequest != undefined && (NativeEventSource == undefined || !("withCredentials" in NativeEventSource.prototype))) {
|
|
1403
|
-
// Why replace a native EventSource ?
|
|
1404
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=444328
|
|
1405
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=831392
|
|
1406
|
-
// https://code.google.com/p/chromium/issues/detail?id=260144
|
|
1407
|
-
// https://code.google.com/p/chromium/issues/detail?id=225654
|
|
1408
|
-
// ...
|
|
1409
|
-
R = EventSourcePolyfill;
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
(function (factory) {
|
|
1413
|
-
{
|
|
1414
|
-
var v = factory(exports);
|
|
1415
|
-
if (v !== undefined) module.exports = v;
|
|
1416
|
-
}
|
|
1417
|
-
})(function (exports) {
|
|
1418
|
-
exports.EventSourcePolyfill = EventSourcePolyfill;
|
|
1419
|
-
exports.NativeEventSource = NativeEventSource;
|
|
1420
|
-
exports.EventSource = R;
|
|
1421
|
-
});
|
|
1422
|
-
}(typeof globalThis === 'undefined' ? (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal) : globalThis));
|
|
1423
|
-
});
|
|
1424
|
-
|
|
1425
|
-
/* src/PlayerAccountBalanceModal.svelte generated by Svelte v3.37.0 */
|
|
1426
|
-
|
|
1427
|
-
const { console: console_1 } = globals;
|
|
1428
|
-
const file = "src/PlayerAccountBalanceModal.svelte";
|
|
1429
|
-
|
|
1430
|
-
// (105:2) {#if showBalance}
|
|
1431
|
-
function create_if_block_1(ctx) {
|
|
1432
|
-
let div8;
|
|
1433
|
-
let div0;
|
|
1434
|
-
let t0;
|
|
1435
|
-
let div7;
|
|
1436
|
-
let div1;
|
|
1437
|
-
let p0;
|
|
1438
|
-
let t2;
|
|
1439
|
-
let div5;
|
|
1440
|
-
let div2;
|
|
1441
|
-
let p1;
|
|
1442
|
-
let t4;
|
|
1443
|
-
let p2;
|
|
1444
|
-
let span0;
|
|
1445
|
-
let t5;
|
|
1446
|
-
let t6;
|
|
1447
|
-
let span1;
|
|
1448
|
-
let t7;
|
|
1449
|
-
let t8;
|
|
1450
|
-
let div3;
|
|
1451
|
-
let p3;
|
|
1452
|
-
let t10;
|
|
1453
|
-
let p4;
|
|
1454
|
-
let span2;
|
|
1455
|
-
let t11;
|
|
1456
|
-
let t12;
|
|
1457
|
-
let span3;
|
|
1458
|
-
let t13;
|
|
1459
|
-
let t14;
|
|
1460
|
-
let div4;
|
|
1461
|
-
let p5;
|
|
1462
|
-
let t16;
|
|
1463
|
-
let p6;
|
|
1464
|
-
let span4;
|
|
1465
|
-
let t17;
|
|
1466
|
-
let t18;
|
|
1467
|
-
let span5;
|
|
1468
|
-
let t19;
|
|
1469
|
-
let t20;
|
|
1470
|
-
let div6;
|
|
1471
|
-
let button;
|
|
1472
|
-
let mounted;
|
|
1473
|
-
let dispose;
|
|
1474
|
-
|
|
1475
|
-
const block = {
|
|
1476
|
-
c: function create() {
|
|
1477
|
-
div8 = element("div");
|
|
1478
|
-
div0 = element("div");
|
|
1479
|
-
t0 = space();
|
|
1480
|
-
div7 = element("div");
|
|
1481
|
-
div1 = element("div");
|
|
1482
|
-
p0 = element("p");
|
|
1483
|
-
p0.textContent = "Your Balance";
|
|
1484
|
-
t2 = space();
|
|
1485
|
-
div5 = element("div");
|
|
1486
|
-
div2 = element("div");
|
|
1487
|
-
p1 = element("p");
|
|
1488
|
-
p1.textContent = "Total Balance";
|
|
1489
|
-
t4 = space();
|
|
1490
|
-
p2 = element("p");
|
|
1491
|
-
span0 = element("span");
|
|
1492
|
-
t5 = text(/*totalBalance*/ ctx[0]);
|
|
1493
|
-
t6 = space();
|
|
1494
|
-
span1 = element("span");
|
|
1495
|
-
t7 = text(/*currency*/ ctx[3]);
|
|
1496
|
-
t8 = space();
|
|
1497
|
-
div3 = element("div");
|
|
1498
|
-
p3 = element("p");
|
|
1499
|
-
p3.textContent = "Cash Balance";
|
|
1500
|
-
t10 = space();
|
|
1501
|
-
p4 = element("p");
|
|
1502
|
-
span2 = element("span");
|
|
1503
|
-
t11 = text(/*cashBalance*/ ctx[1]);
|
|
1504
|
-
t12 = space();
|
|
1505
|
-
span3 = element("span");
|
|
1506
|
-
t13 = text(/*currency*/ ctx[3]);
|
|
1507
|
-
t14 = space();
|
|
1508
|
-
div4 = element("div");
|
|
1509
|
-
p5 = element("p");
|
|
1510
|
-
p5.textContent = "Bonus Balance";
|
|
1511
|
-
t16 = space();
|
|
1512
|
-
p6 = element("p");
|
|
1513
|
-
span4 = element("span");
|
|
1514
|
-
t17 = text(/*bonusBalance*/ ctx[2]);
|
|
1515
|
-
t18 = space();
|
|
1516
|
-
span5 = element("span");
|
|
1517
|
-
t19 = text(/*currency*/ ctx[3]);
|
|
1518
|
-
t20 = space();
|
|
1519
|
-
div6 = element("div");
|
|
1520
|
-
button = element("button");
|
|
1521
|
-
button.textContent = "Deposit";
|
|
1522
|
-
attr_dev(div0, "class", "BalanceModalClose");
|
|
1523
|
-
add_location(div0, file, 106, 6, 3766);
|
|
1524
|
-
attr_dev(p0, "class", "BalanceModalTitle");
|
|
1525
|
-
add_location(p0, file, 109, 10, 3926);
|
|
1526
|
-
attr_dev(div1, "class", "BalanceModalHeader");
|
|
1527
|
-
add_location(div1, file, 108, 8, 3883);
|
|
1528
|
-
attr_dev(p1, "class", "BalanceModalText");
|
|
1529
|
-
add_location(p1, file, 113, 12, 4078);
|
|
1530
|
-
attr_dev(span0, "class", "BalanceModalAmount");
|
|
1531
|
-
add_location(span0, file, 115, 14, 4180);
|
|
1532
|
-
attr_dev(span1, "class", "BalanceModalCurrency");
|
|
1533
|
-
add_location(span1, file, 116, 14, 4249);
|
|
1534
|
-
attr_dev(p2, "class", "BalanceModalValue");
|
|
1535
|
-
add_location(p2, file, 114, 12, 4136);
|
|
1536
|
-
attr_dev(div2, "class", "BalanceModalRow");
|
|
1537
|
-
add_location(div2, file, 112, 10, 4036);
|
|
1538
|
-
attr_dev(p3, "class", "BalanceModalText");
|
|
1539
|
-
add_location(p3, file, 120, 12, 4388);
|
|
1540
|
-
attr_dev(span2, "class", "BalanceModalAmount");
|
|
1541
|
-
add_location(span2, file, 122, 14, 4489);
|
|
1542
|
-
attr_dev(span3, "class", "BalanceModalCurrency");
|
|
1543
|
-
add_location(span3, file, 123, 14, 4557);
|
|
1544
|
-
attr_dev(p4, "class", "BalanceModalValue");
|
|
1545
|
-
add_location(p4, file, 121, 12, 4445);
|
|
1546
|
-
attr_dev(div3, "class", "BalanceModalRow");
|
|
1547
|
-
add_location(div3, file, 119, 10, 4346);
|
|
1548
|
-
attr_dev(p5, "class", "BalanceModalText");
|
|
1549
|
-
add_location(p5, file, 127, 12, 4696);
|
|
1550
|
-
attr_dev(span4, "class", "BalanceModalAmount");
|
|
1551
|
-
add_location(span4, file, 129, 14, 4798);
|
|
1552
|
-
attr_dev(span5, "class", "BalanceModalCurrency");
|
|
1553
|
-
add_location(span5, file, 130, 14, 4867);
|
|
1554
|
-
attr_dev(p6, "class", "BalanceModalValue");
|
|
1555
|
-
add_location(p6, file, 128, 12, 4754);
|
|
1556
|
-
attr_dev(div4, "class", "BalanceModalRow");
|
|
1557
|
-
add_location(div4, file, 126, 10, 4654);
|
|
1558
|
-
attr_dev(div5, "class", "BalanceModalBody");
|
|
1559
|
-
add_location(div5, file, 111, 8, 3995);
|
|
1560
|
-
attr_dev(button, "class", "BalanceModalAction");
|
|
1561
|
-
add_location(button, file, 135, 10, 5020);
|
|
1562
|
-
attr_dev(div6, "class", "BalanceModalFooter");
|
|
1563
|
-
add_location(div6, file, 134, 8, 4977);
|
|
1564
|
-
attr_dev(div7, "class", "BalanceModal");
|
|
1565
|
-
add_location(div7, file, 107, 6, 3848);
|
|
1566
|
-
attr_dev(div8, "class", "BalanceModalWrapper");
|
|
1567
|
-
add_location(div8, file, 105, 4, 3726);
|
|
1568
|
-
},
|
|
1569
|
-
m: function mount(target, anchor) {
|
|
1570
|
-
insert_dev(target, div8, anchor);
|
|
1571
|
-
append_dev(div8, div0);
|
|
1572
|
-
append_dev(div8, t0);
|
|
1573
|
-
append_dev(div8, div7);
|
|
1574
|
-
append_dev(div7, div1);
|
|
1575
|
-
append_dev(div1, p0);
|
|
1576
|
-
append_dev(div7, t2);
|
|
1577
|
-
append_dev(div7, div5);
|
|
1578
|
-
append_dev(div5, div2);
|
|
1579
|
-
append_dev(div2, p1);
|
|
1580
|
-
append_dev(div2, t4);
|
|
1581
|
-
append_dev(div2, p2);
|
|
1582
|
-
append_dev(p2, span0);
|
|
1583
|
-
append_dev(span0, t5);
|
|
1584
|
-
append_dev(p2, t6);
|
|
1585
|
-
append_dev(p2, span1);
|
|
1586
|
-
append_dev(span1, t7);
|
|
1587
|
-
append_dev(div5, t8);
|
|
1588
|
-
append_dev(div5, div3);
|
|
1589
|
-
append_dev(div3, p3);
|
|
1590
|
-
append_dev(div3, t10);
|
|
1591
|
-
append_dev(div3, p4);
|
|
1592
|
-
append_dev(p4, span2);
|
|
1593
|
-
append_dev(span2, t11);
|
|
1594
|
-
append_dev(p4, t12);
|
|
1595
|
-
append_dev(p4, span3);
|
|
1596
|
-
append_dev(span3, t13);
|
|
1597
|
-
append_dev(div5, t14);
|
|
1598
|
-
append_dev(div5, div4);
|
|
1599
|
-
append_dev(div4, p5);
|
|
1600
|
-
append_dev(div4, t16);
|
|
1601
|
-
append_dev(div4, p6);
|
|
1602
|
-
append_dev(p6, span4);
|
|
1603
|
-
append_dev(span4, t17);
|
|
1604
|
-
append_dev(p6, t18);
|
|
1605
|
-
append_dev(p6, span5);
|
|
1606
|
-
append_dev(span5, t19);
|
|
1607
|
-
append_dev(div7, t20);
|
|
1608
|
-
append_dev(div7, div6);
|
|
1609
|
-
append_dev(div6, button);
|
|
1610
|
-
|
|
1611
|
-
if (!mounted) {
|
|
1612
|
-
dispose = [
|
|
1613
|
-
listen_dev(div0, "click", /*click_handler_1*/ ctx[11], false, false, false),
|
|
1614
|
-
listen_dev(button, "click", /*click_handler_2*/ ctx[12], false, false, false)
|
|
1615
|
-
];
|
|
1616
|
-
|
|
1617
|
-
mounted = true;
|
|
1618
|
-
}
|
|
1619
|
-
},
|
|
1620
|
-
p: function update(ctx, dirty) {
|
|
1621
|
-
if (dirty & /*totalBalance*/ 1) set_data_dev(t5, /*totalBalance*/ ctx[0]);
|
|
1622
|
-
if (dirty & /*currency*/ 8) set_data_dev(t7, /*currency*/ ctx[3]);
|
|
1623
|
-
if (dirty & /*cashBalance*/ 2) set_data_dev(t11, /*cashBalance*/ ctx[1]);
|
|
1624
|
-
if (dirty & /*currency*/ 8) set_data_dev(t13, /*currency*/ ctx[3]);
|
|
1625
|
-
if (dirty & /*bonusBalance*/ 4) set_data_dev(t17, /*bonusBalance*/ ctx[2]);
|
|
1626
|
-
if (dirty & /*currency*/ 8) set_data_dev(t19, /*currency*/ ctx[3]);
|
|
1627
|
-
},
|
|
1628
|
-
d: function destroy(detaching) {
|
|
1629
|
-
if (detaching) detach_dev(div8);
|
|
1630
|
-
mounted = false;
|
|
1631
|
-
run_all(dispose);
|
|
1632
|
-
}
|
|
1633
|
-
};
|
|
1634
|
-
|
|
1635
|
-
dispatch_dev("SvelteRegisterBlock", {
|
|
1636
|
-
block,
|
|
1637
|
-
id: create_if_block_1.name,
|
|
1638
|
-
type: "if",
|
|
1639
|
-
source: "(105:2) {#if showBalance}",
|
|
1640
|
-
ctx
|
|
1641
|
-
});
|
|
1642
|
-
|
|
1643
|
-
return block;
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
|
-
// (142:0) {#if showBalance}
|
|
1647
|
-
function create_if_block(ctx) {
|
|
1648
|
-
let div;
|
|
1649
|
-
let mounted;
|
|
1650
|
-
let dispose;
|
|
1651
|
-
|
|
1652
|
-
const block = {
|
|
1653
|
-
c: function create() {
|
|
1654
|
-
div = element("div");
|
|
1655
|
-
attr_dev(div, "class", "ShowBalanceModalOverlay");
|
|
1656
|
-
add_location(div, file, 142, 2, 5187);
|
|
1657
|
-
},
|
|
1658
|
-
m: function mount(target, anchor) {
|
|
1659
|
-
insert_dev(target, div, anchor);
|
|
1660
|
-
|
|
1661
|
-
if (!mounted) {
|
|
1662
|
-
dispose = listen_dev(div, "click", /*click_handler_3*/ ctx[13], false, false, false);
|
|
1663
|
-
mounted = true;
|
|
1664
|
-
}
|
|
1665
|
-
},
|
|
1666
|
-
p: noop,
|
|
1667
|
-
d: function destroy(detaching) {
|
|
1668
|
-
if (detaching) detach_dev(div);
|
|
1669
|
-
mounted = false;
|
|
1670
|
-
dispose();
|
|
1671
|
-
}
|
|
1672
|
-
};
|
|
1673
|
-
|
|
1674
|
-
dispatch_dev("SvelteRegisterBlock", {
|
|
1675
|
-
block,
|
|
1676
|
-
id: create_if_block.name,
|
|
1677
|
-
type: "if",
|
|
1678
|
-
source: "(142:0) {#if showBalance}",
|
|
1679
|
-
ctx
|
|
1680
|
-
});
|
|
1681
|
-
|
|
1682
|
-
return block;
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
function create_fragment(ctx) {
|
|
1686
|
-
let div;
|
|
1687
|
-
let p;
|
|
1688
|
-
let t0;
|
|
1689
|
-
let t1;
|
|
1690
|
-
let t2;
|
|
1691
|
-
let t3;
|
|
1692
|
-
let span;
|
|
1693
|
-
let svg;
|
|
1694
|
-
let defs;
|
|
1695
|
-
let style;
|
|
1696
|
-
let t4;
|
|
1697
|
-
let path;
|
|
1698
|
-
let t5;
|
|
1699
|
-
let t6;
|
|
1700
|
-
let if_block1_anchor;
|
|
1701
|
-
let mounted;
|
|
1702
|
-
let dispose;
|
|
1703
|
-
let if_block0 = /*showBalance*/ ctx[4] && create_if_block_1(ctx);
|
|
1704
|
-
let if_block1 = /*showBalance*/ ctx[4] && create_if_block(ctx);
|
|
1705
|
-
|
|
1706
|
-
const block = {
|
|
1707
|
-
c: function create() {
|
|
1708
|
-
div = element("div");
|
|
1709
|
-
p = element("p");
|
|
1710
|
-
t0 = text(/*totalBalance*/ ctx[0]);
|
|
1711
|
-
t1 = space();
|
|
1712
|
-
t2 = text(/*currency*/ ctx[3]);
|
|
1713
|
-
t3 = space();
|
|
1714
|
-
span = element("span");
|
|
1715
|
-
svg = svg_element("svg");
|
|
1716
|
-
defs = svg_element("defs");
|
|
1717
|
-
style = svg_element("style");
|
|
1718
|
-
t4 = text(".a{fill:#fff;}");
|
|
1719
|
-
path = svg_element("path");
|
|
1720
|
-
t5 = space();
|
|
1721
|
-
if (if_block0) if_block0.c();
|
|
1722
|
-
t6 = space();
|
|
1723
|
-
if (if_block1) if_block1.c();
|
|
1724
|
-
if_block1_anchor = empty();
|
|
1725
|
-
this.c = noop;
|
|
1726
|
-
add_location(style, file, 102, 80, 3427);
|
|
1727
|
-
add_location(defs, file, 102, 74, 3421);
|
|
1728
|
-
attr_dev(path, "class", "a");
|
|
1729
|
-
attr_dev(path, "d", "M16.191,19.235l7.562-7.568a1.423,1.423,0,0,1,2.019,0,1.441,1.441,0,0,1,0,2.025L17.2,22.265a1.427,1.427,0,0,1-1.971.042L6.6,13.7a1.429,1.429,0,0,1,2.019-2.025Z");
|
|
1730
|
-
attr_dev(path, "transform", "translate(-6.188 -11.246)");
|
|
1731
|
-
add_location(path, file, 102, 116, 3463);
|
|
1732
|
-
attr_dev(svg, "xmlns", "http://www.w3.org/2000/svg");
|
|
1733
|
-
attr_dev(svg, "viewBox", "0 0 20 11.435");
|
|
1734
|
-
add_location(svg, file, 102, 10, 3357);
|
|
1735
|
-
add_location(span, file, 102, 4, 3351);
|
|
1736
|
-
attr_dev(p, "class", "BalanceValue");
|
|
1737
|
-
add_location(p, file, 100, 2, 3255);
|
|
1738
|
-
attr_dev(div, "class", "ShowBalance");
|
|
1739
|
-
add_location(div, file, 99, 0, 3227);
|
|
1740
|
-
},
|
|
1741
|
-
l: function claim(nodes) {
|
|
1742
|
-
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
|
|
1743
|
-
},
|
|
1744
|
-
m: function mount(target, anchor) {
|
|
1745
|
-
insert_dev(target, div, anchor);
|
|
1746
|
-
append_dev(div, p);
|
|
1747
|
-
append_dev(p, t0);
|
|
1748
|
-
append_dev(p, t1);
|
|
1749
|
-
append_dev(p, t2);
|
|
1750
|
-
append_dev(p, t3);
|
|
1751
|
-
append_dev(p, span);
|
|
1752
|
-
append_dev(span, svg);
|
|
1753
|
-
append_dev(svg, defs);
|
|
1754
|
-
append_dev(defs, style);
|
|
1755
|
-
append_dev(style, t4);
|
|
1756
|
-
append_dev(svg, path);
|
|
1757
|
-
append_dev(div, t5);
|
|
1758
|
-
if (if_block0) if_block0.m(div, null);
|
|
1759
|
-
insert_dev(target, t6, anchor);
|
|
1760
|
-
if (if_block1) if_block1.m(target, anchor);
|
|
1761
|
-
insert_dev(target, if_block1_anchor, anchor);
|
|
1762
|
-
|
|
1763
|
-
if (!mounted) {
|
|
1764
|
-
dispose = listen_dev(p, "click", /*click_handler*/ ctx[10], false, false, false);
|
|
1765
|
-
mounted = true;
|
|
1766
|
-
}
|
|
1767
|
-
},
|
|
1768
|
-
p: function update(ctx, [dirty]) {
|
|
1769
|
-
if (dirty & /*totalBalance*/ 1) set_data_dev(t0, /*totalBalance*/ ctx[0]);
|
|
1770
|
-
if (dirty & /*currency*/ 8) set_data_dev(t2, /*currency*/ ctx[3]);
|
|
1771
|
-
|
|
1772
|
-
if (/*showBalance*/ ctx[4]) {
|
|
1773
|
-
if (if_block0) {
|
|
1774
|
-
if_block0.p(ctx, dirty);
|
|
1775
|
-
} else {
|
|
1776
|
-
if_block0 = create_if_block_1(ctx);
|
|
1777
|
-
if_block0.c();
|
|
1778
|
-
if_block0.m(div, null);
|
|
1779
|
-
}
|
|
1780
|
-
} else if (if_block0) {
|
|
1781
|
-
if_block0.d(1);
|
|
1782
|
-
if_block0 = null;
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
if (/*showBalance*/ ctx[4]) {
|
|
1786
|
-
if (if_block1) {
|
|
1787
|
-
if_block1.p(ctx, dirty);
|
|
1788
|
-
} else {
|
|
1789
|
-
if_block1 = create_if_block(ctx);
|
|
1790
|
-
if_block1.c();
|
|
1791
|
-
if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
|
|
1792
|
-
}
|
|
1793
|
-
} else if (if_block1) {
|
|
1794
|
-
if_block1.d(1);
|
|
1795
|
-
if_block1 = null;
|
|
1796
|
-
}
|
|
1797
|
-
},
|
|
1798
|
-
i: noop,
|
|
1799
|
-
o: noop,
|
|
1800
|
-
d: function destroy(detaching) {
|
|
1801
|
-
if (detaching) detach_dev(div);
|
|
1802
|
-
if (if_block0) if_block0.d();
|
|
1803
|
-
if (detaching) detach_dev(t6);
|
|
1804
|
-
if (if_block1) if_block1.d(detaching);
|
|
1805
|
-
if (detaching) detach_dev(if_block1_anchor);
|
|
1806
|
-
mounted = false;
|
|
1807
|
-
dispose();
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
|
-
|
|
1811
|
-
dispatch_dev("SvelteRegisterBlock", {
|
|
1812
|
-
block,
|
|
1813
|
-
id: create_fragment.name,
|
|
1814
|
-
type: "component",
|
|
1815
|
-
source: "",
|
|
1816
|
-
ctx
|
|
1817
|
-
});
|
|
1818
|
-
|
|
1819
|
-
return block;
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
function instance($$self, $$props, $$invalidate) {
|
|
1823
|
-
let { $$slots: slots = {}, $$scope } = $$props;
|
|
1824
|
-
validate_slots("undefined", slots, []);
|
|
1825
|
-
let { userid = "" } = $$props;
|
|
1826
|
-
let { session = "" } = $$props;
|
|
1827
|
-
let { endpoint = "" } = $$props;
|
|
1828
|
-
let totalBalance = "";
|
|
1829
|
-
let cashBalance = "";
|
|
1830
|
-
let bonusBalance = "";
|
|
1831
|
-
let currency = "";
|
|
1832
|
-
let showBalance = false;
|
|
1833
|
-
let balanceSubject;
|
|
1834
|
-
let realWalletID;
|
|
1835
|
-
let bonusWalletID;
|
|
1836
|
-
|
|
1837
|
-
const menuAction = data => {
|
|
1838
|
-
switch (data) {
|
|
1839
|
-
case "balance":
|
|
1840
|
-
$$invalidate(4, showBalance = true);
|
|
1841
|
-
break;
|
|
1842
|
-
case "closebalance":
|
|
1843
|
-
$$invalidate(4, showBalance = false);
|
|
1844
|
-
break;
|
|
1845
|
-
}
|
|
1846
|
-
};
|
|
1847
|
-
|
|
1848
|
-
const getPlayerAccountBalanceData = url => {
|
|
1849
|
-
return new Promise((resolve, reject) => {
|
|
1850
|
-
let options = {
|
|
1851
|
-
method: "GET",
|
|
1852
|
-
headers: { "X-SessionID": session }
|
|
1853
|
-
};
|
|
1854
|
-
|
|
1855
|
-
fetch(url, options).then(res => {
|
|
1856
|
-
return res.json();
|
|
1857
|
-
}).then(
|
|
1858
|
-
data => {
|
|
1859
|
-
let response = data.items;
|
|
1860
|
-
|
|
1861
|
-
response.forEach(item => {
|
|
1862
|
-
if (item.displayName == "Casino") {
|
|
1863
|
-
realWalletID = item.id;
|
|
1864
|
-
$$invalidate(1, cashBalance = item.balanceAmount);
|
|
1865
|
-
$$invalidate(3, currency = item.currency);
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1868
|
-
if (item.displayName == "UBS") {
|
|
1869
|
-
bonusWalletID = item.id;
|
|
1870
|
-
$$invalidate(2, bonusBalance = item.balanceAmount);
|
|
1871
|
-
}
|
|
1872
|
-
});
|
|
1873
|
-
|
|
1874
|
-
$$invalidate(0, totalBalance = (parseFloat(cashBalance) + parseFloat(bonusBalance)).toFixed(2));
|
|
1875
|
-
subscribeToChange();
|
|
1876
|
-
resolve(data);
|
|
1877
|
-
},
|
|
1878
|
-
err => {
|
|
1879
|
-
console.error(err);
|
|
1880
|
-
reject(err);
|
|
1881
|
-
}
|
|
1882
|
-
);
|
|
1883
|
-
});
|
|
1884
|
-
};
|
|
1885
|
-
|
|
1886
|
-
const balanceListener = e => {
|
|
1887
|
-
if (e.type == "message") {
|
|
1888
|
-
let data = JSON.parse(e.data);
|
|
1889
|
-
|
|
1890
|
-
if (data.balanceChange && data.balanceChange[realWalletID]) {
|
|
1891
|
-
$$invalidate(1, cashBalance = data.balanceChange[realWalletID].afterAmount);
|
|
1892
|
-
}
|
|
1893
|
-
|
|
1894
|
-
if (data.balanceChange && data.balanceChange[bonusWalletID]) {
|
|
1895
|
-
$$invalidate(2, bonusBalance = data.balanceChange[bonusWalletID].afterAmount);
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
$$invalidate(0, totalBalance = (parseFloat(cashBalance) + parseFloat(bonusBalance)).toFixed(2));
|
|
1899
|
-
}
|
|
1900
|
-
};
|
|
1901
|
-
|
|
1902
|
-
const subscribeToChange = () => {
|
|
1903
|
-
balanceSubject.addEventListener("open", balanceListener);
|
|
1904
|
-
balanceSubject.addEventListener("message", balanceListener);
|
|
1905
|
-
balanceSubject.addEventListener("error", balanceListener);
|
|
1906
|
-
};
|
|
1907
|
-
|
|
1908
|
-
const balanceModalOpenDeposit = () => {
|
|
1909
|
-
window.postMessage({ type: "GoToDeposit" }, window.location.href);
|
|
1910
|
-
};
|
|
1911
|
-
|
|
1912
|
-
const initialLoad = () => {
|
|
1913
|
-
balanceSubject = new eventsource.EventSourcePolyfill(`${endpoint}/player/${userid}/balance/updates`,
|
|
1914
|
-
{
|
|
1915
|
-
headers: {
|
|
1916
|
-
"accept": "text/event-stream",
|
|
1917
|
-
"X-SessionID": session
|
|
1918
|
-
}
|
|
1919
|
-
});
|
|
1920
|
-
|
|
1921
|
-
getPlayerAccountBalanceData(`${endpoint}/player/${userid}/account`);
|
|
1922
|
-
};
|
|
1923
|
-
|
|
1924
|
-
onMount(() => {
|
|
1925
|
-
return () => {
|
|
1926
|
-
balanceSubject.removeEventListener("open", balanceListener);
|
|
1927
|
-
balanceSubject.removeEventListener("message", balanceListener);
|
|
1928
|
-
balanceSubject.removeEventListener("error", balanceListener);
|
|
1929
|
-
};
|
|
1930
|
-
});
|
|
1931
|
-
|
|
1932
|
-
const writable_props = ["userid", "session", "endpoint"];
|
|
1933
|
-
|
|
1934
|
-
Object.keys($$props).forEach(key => {
|
|
1935
|
-
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console_1.warn(`<undefined> was created with unknown prop '${key}'`);
|
|
1936
|
-
});
|
|
1937
|
-
|
|
1938
|
-
const click_handler = () => menuAction("balance");
|
|
1939
|
-
const click_handler_1 = () => menuAction("closebalance");
|
|
1940
|
-
const click_handler_2 = () => balanceModalOpenDeposit();
|
|
1941
|
-
const click_handler_3 = () => menuAction("closebalance");
|
|
1942
|
-
|
|
1943
|
-
$$self.$$set = $$props => {
|
|
1944
|
-
if ("userid" in $$props) $$invalidate(7, userid = $$props.userid);
|
|
1945
|
-
if ("session" in $$props) $$invalidate(8, session = $$props.session);
|
|
1946
|
-
if ("endpoint" in $$props) $$invalidate(9, endpoint = $$props.endpoint);
|
|
1947
|
-
};
|
|
1948
|
-
|
|
1949
|
-
$$self.$capture_state = () => ({
|
|
1950
|
-
onMount,
|
|
1951
|
-
EventSourcePolyfill: eventsource.EventSourcePolyfill,
|
|
1952
|
-
userid,
|
|
1953
|
-
session,
|
|
1954
|
-
endpoint,
|
|
1955
|
-
totalBalance,
|
|
1956
|
-
cashBalance,
|
|
1957
|
-
bonusBalance,
|
|
1958
|
-
currency,
|
|
1959
|
-
showBalance,
|
|
1960
|
-
balanceSubject,
|
|
1961
|
-
realWalletID,
|
|
1962
|
-
bonusWalletID,
|
|
1963
|
-
menuAction,
|
|
1964
|
-
getPlayerAccountBalanceData,
|
|
1965
|
-
balanceListener,
|
|
1966
|
-
subscribeToChange,
|
|
1967
|
-
balanceModalOpenDeposit,
|
|
1968
|
-
initialLoad
|
|
1969
|
-
});
|
|
1970
|
-
|
|
1971
|
-
$$self.$inject_state = $$props => {
|
|
1972
|
-
if ("userid" in $$props) $$invalidate(7, userid = $$props.userid);
|
|
1973
|
-
if ("session" in $$props) $$invalidate(8, session = $$props.session);
|
|
1974
|
-
if ("endpoint" in $$props) $$invalidate(9, endpoint = $$props.endpoint);
|
|
1975
|
-
if ("totalBalance" in $$props) $$invalidate(0, totalBalance = $$props.totalBalance);
|
|
1976
|
-
if ("cashBalance" in $$props) $$invalidate(1, cashBalance = $$props.cashBalance);
|
|
1977
|
-
if ("bonusBalance" in $$props) $$invalidate(2, bonusBalance = $$props.bonusBalance);
|
|
1978
|
-
if ("currency" in $$props) $$invalidate(3, currency = $$props.currency);
|
|
1979
|
-
if ("showBalance" in $$props) $$invalidate(4, showBalance = $$props.showBalance);
|
|
1980
|
-
if ("balanceSubject" in $$props) balanceSubject = $$props.balanceSubject;
|
|
1981
|
-
if ("realWalletID" in $$props) realWalletID = $$props.realWalletID;
|
|
1982
|
-
if ("bonusWalletID" in $$props) bonusWalletID = $$props.bonusWalletID;
|
|
1983
|
-
};
|
|
1984
|
-
|
|
1985
|
-
if ($$props && "$$inject" in $$props) {
|
|
1986
|
-
$$self.$inject_state($$props.$$inject);
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
$$self.$$.update = () => {
|
|
1990
|
-
if ($$self.$$.dirty & /*endpoint, userid, session*/ 896) {
|
|
1991
|
-
endpoint && userid && session && initialLoad();
|
|
1992
|
-
}
|
|
1993
|
-
};
|
|
1994
|
-
|
|
1995
|
-
return [
|
|
1996
|
-
totalBalance,
|
|
1997
|
-
cashBalance,
|
|
1998
|
-
bonusBalance,
|
|
1999
|
-
currency,
|
|
2000
|
-
showBalance,
|
|
2001
|
-
menuAction,
|
|
2002
|
-
balanceModalOpenDeposit,
|
|
2003
|
-
userid,
|
|
2004
|
-
session,
|
|
2005
|
-
endpoint,
|
|
2006
|
-
click_handler,
|
|
2007
|
-
click_handler_1,
|
|
2008
|
-
click_handler_2,
|
|
2009
|
-
click_handler_3
|
|
2010
|
-
];
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
class PlayerAccountBalanceModal extends SvelteElement {
|
|
2014
|
-
constructor(options) {
|
|
2015
|
-
super();
|
|
2016
|
-
this.shadowRoot.innerHTML = `<style>p{padding:0;margin:0}.ShowBalance{position:relative}.ShowBalance .BalanceValue{font-size:14px;cursor:pointer}.ShowBalance .BalanceValue svg{width:16px}.BalanceModalWrapper{background-color:#fff;position:absolute;top:45px;left:50%;transform:translateX(-50%);padding:10px;box-shadow:0px 30px 30px #D0046C1A;border-radius:5px;z-index:3;box-shadow:0px 5px 20px 0px #191919}.BalanceModalWrapper:before{content:"";background:#fff;clip-path:polygon(50% 0, 0% 100%, 100% 100%);position:absolute;top:-8px;left:50%;width:25px;height:10px;transform:translateX(-50%);z-index:1}.BalanceModalClose{position:absolute;top:5px;right:5px;width:20px;height:20px;z-index:1;cursor:pointer}.BalanceModalClose:before{content:"";background:#FD2839;position:absolute;top:8px;left:0;width:20px;height:2px;transform:rotate(45deg)}.BalanceModalClose:after{content:"";background:#FD2839;position:absolute;top:8px;left:0;width:20px;height:2px;transform:rotate(-45deg)}.BalanceModal{position:relative;width:280px}.BalanceModalHeader{display:flex;align-items:center;justify-content:center;padding:20px 0}.BalanceModalHeader .BalanceModalTitle{font-size:16px;font-weight:bold;color:#07072A}.BalanceModalRow{display:flex;justify-content:space-between;align-items:center;padding:20px 0;border-bottom:1px solid #D1D1D1}.BalanceModalRow:last-child{border-bottom:none}.BalanceModalRow .BalanceModalText{color:#58586B;font-size:14px;text-transform:capitalize}.BalanceModalRow .BalanceModalValue{font-size:14px;font-weight:bold;color:#07072A}.BalanceModalFooter{display:flex;align-items:center;padding:20px 0 10px}.BalanceModalFooter .BalanceModalAction{background:#FD2839;font-size:12px;color:white;text-transform:uppercase;width:100%;border-radius:5px;border:none;padding:10px 0;cursor:pointer}.BalanceModalFooter .BalanceModalAction:hover{background:#f00215}.ShowBalanceModalOverlay{background-color:rgba(0, 0, 0, 0.7);position:fixed;top:0;bottom:0;left:0;right:0;z-index:2}</style>`;
|
|
2017
|
-
|
|
2018
|
-
init(
|
|
2019
|
-
this,
|
|
2020
|
-
{
|
|
2021
|
-
target: this.shadowRoot,
|
|
2022
|
-
props: attribute_to_object(this.attributes),
|
|
2023
|
-
customElement: true
|
|
2024
|
-
},
|
|
2025
|
-
instance,
|
|
2026
|
-
create_fragment,
|
|
2027
|
-
safe_not_equal,
|
|
2028
|
-
{ userid: 7, session: 8, endpoint: 9 }
|
|
2029
|
-
);
|
|
2030
|
-
|
|
2031
|
-
if (options) {
|
|
2032
|
-
if (options.target) {
|
|
2033
|
-
insert_dev(options.target, this, options.anchor);
|
|
2034
|
-
}
|
|
2035
|
-
|
|
2036
|
-
if (options.props) {
|
|
2037
|
-
this.$set(options.props);
|
|
2038
|
-
flush();
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
static get observedAttributes() {
|
|
2044
|
-
return ["userid", "session", "endpoint"];
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
get userid() {
|
|
2048
|
-
return this.$$.ctx[7];
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
set userid(userid) {
|
|
2052
|
-
this.$set({ userid });
|
|
2053
|
-
flush();
|
|
2054
|
-
}
|
|
2055
|
-
|
|
2056
|
-
get session() {
|
|
2057
|
-
return this.$$.ctx[8];
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
set session(session) {
|
|
2061
|
-
this.$set({ session });
|
|
2062
|
-
flush();
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
get endpoint() {
|
|
2066
|
-
return this.$$.ctx[9];
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
set endpoint(endpoint) {
|
|
2070
|
-
this.$set({ endpoint });
|
|
2071
|
-
flush();
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
|
|
2075
|
-
!customElements.get('player-account-balance-modal') && customElements.define('player-account-balance-modal', PlayerAccountBalanceModal);
|
|
2076
|
-
|
|
2077
|
-
return PlayerAccountBalanceModal;
|
|
2078
|
-
|
|
2079
|
-
})));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).app=t()}(this,function(){"use strict";function v(){}function u(e){return e()}function p(){return Object.create(null)}function q(e){e.forEach(u)}function h(e){return"function"==typeof e}function t(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}function X(e,t){e.appendChild(t)}function G(e,t,n){e.insertBefore(t,n||null)}function U(e){e.parentNode.removeChild(e)}function e(e){return document.createElement(e)}function W(e){return document.createTextNode(e)}function Z(){return W(" ")}function J(e,t,n,o){return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)}function K(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Q(e,t){e.wholeText!==(t=""+t)&&(e.data=t)}let m;function f(e){m=e}const g=[],o=[],a=[],r=[],y=Promise.resolve();let b=!1;function x(e){a.push(e)}let s=!1;const i=new Set;function w(){if(!s){s=!0;do{for(let e=0;e<g.length;e+=1){var t=g[e];f(t),function(e){{var t;null!==e.fragment&&(e.update(),q(e.before_update),t=e.dirty,e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(x))}}(t.$$)}for(f(null),g.length=0;o.length;)o.pop()();for(let e=0;e<a.length;e+=1){const n=a[e];i.has(n)||(i.add(n),n())}}while(a.length=0,g.length);for(;r.length;)r.pop()();b=!1,s=!1,i.clear()}}const C=new Set;function n(o,e,t,n,a,r,s=[-1]){var i,l=m;f(o);const c=o.$$={fragment:null,ctx:null,props:r,update:v,not_equal:a,bound:p(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(l?l.$$.context:e.context||[]),callbacks:p(),dirty:s,skip_bound:!1};let d=!1;if(c.ctx=t?t(o,e.props||{},(e,t,...n)=>{n=n.length?n[0]:t;return c.ctx&&a(c.ctx[e],c.ctx[e]=n)&&(!c.skip_bound&&c.bound[e]&&c.bound[e](n),d&&(n=e,-1===(e=o).$$.dirty[0]&&(g.push(e),b||(b=!0,y.then(w)),e.$$.dirty.fill(0)),e.$$.dirty[n/31|0]|=1<<n%31)),t}):[],c.update(),d=!0,q(c.before_update),c.fragment=!!n&&n(c.ctx),e.target){if(e.hydrate){const v=(n=e.target,Array.from(n.childNodes));c.fragment&&c.fragment.l(v),v.forEach(U)}else c.fragment&&c.fragment.c();e.intro&&(i=o.$$.fragment)&&i.i&&(C.delete(i),i.i(void 0)),function(t,e,n,o){const{fragment:a,on_mount:r,on_destroy:s,after_update:i}=t.$$;a&&a.m(e,n),o||x(()=>{var e=r.map(u).filter(h);s?s.push(...e):q(e),t.$$.on_mount=[]}),i.forEach(x)}(o,e.target,e.anchor,e.customElement),w()}f(l)}let l;"function"==typeof HTMLElement&&(l=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:e}=this.$$;this.$$.on_disconnect=e.map(u).filter(h);for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(e,t,n){this[e]=n}disconnectedCallback(){q(this.$$.on_disconnect)}$destroy(){!function(e){const t=e.$$;null!==t.fragment&&(q(t.on_destroy),t.fragment&&t.fragment.d(1),t.on_destroy=t.fragment=null,t.ctx=[])}(this),this.$destroy=v}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{var e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(e){this.$$set&&0!==Object.keys(e).length&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}});var c,E,d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},T=(E=(c={path:void 0,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&c.path)}}).exports,function(e){var o,R=e.setTimeout,D=e.clearTimeout,O=e.XMLHttpRequest,a=e.XDomainRequest,t=e.ActiveXObject,n=e.EventSource,r=e.document,u=e.Promise,p=e.fetch,s=e.Response,h=e.TextDecoder,i=e.TextEncoder,f=e.AbortController;function l(){this.bitsNeeded=0,this.codePoint=0}"undefined"==typeof window||void 0===r||"readyState"in r||null!=r.body||(r.readyState="loading",window.addEventListener("load",function(e){r.readyState="complete"},!1)),null==O&&null!=t&&(O=function(){return new t("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==f&&(o=p,p=function(e,t){var n=t.signal;return o(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then(function(e){var t=e.body.getReader();return n._reader=t,n._aborted&&n._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}})},f=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}),l.prototype.decode=function(e){function t(e,t,n){if(1===n)return 128>>t<=e&&e<<t<=2047;if(2===n)return 2048>>t<=e&&e<<t<=55295||57344>>t<=e&&e<<t<=65535;if(3===n)return 65536>>t<=e&&e<<t<=1114111;throw new Error}function n(e,t){if(6===e)return 15<t>>6?3:31<t?2:1;if(12===e)return 15<t?3:2;if(18===e)return 3;throw new Error}for(var o="",a=this.bitsNeeded,r=this.codePoint,s=0;s<e.length;s+=1){var i=e[s];0!==a&&(i<128||191<i||!t(r<<6|63&i,a-6,n(a,r)))&&(a=0,r=65533,o+=String.fromCharCode(r)),0===a?(r=0<=i&&i<=127?(a=0,i):192<=i&&i<=223?(a=6,31&i):224<=i&&i<=239?(a=12,15&i):240<=i&&i<=247?(a=18,7&i):(a=0,65533),0===a||t(r,a,n(a,r))||(a=0,r=65533)):(a-=6,r=r<<6|63&i),0===a&&(r<=65535?o+=String.fromCharCode(r):(o+=String.fromCharCode(55296+(r-65535-1>>10)),o+=String.fromCharCode(56320+(r-65535-1&1023))))}return this.bitsNeeded=a,this.codePoint=r,o},null!=h&&null!=i&&function(){try{return"test"===(new h).decode((new i).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}}()||(h=l);var d=function(){};function k(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=d,this.onload=d,this.onerror=d,this.onreadystatechange=d,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=d}function c(e){return e.replace(/[A-Z]/g,function(e){return String.fromCharCode(e.charCodeAt(0)+32)})}function g(e){for(var t=Object.create(null),n=e.split("\r\n"),o=0;o<n.length;o+=1){var a=n[o].split(": "),r=a.shift(),a=a.join(": ");t[c(r)]=a}this._map=t}function H(){}function y(e){this._headers=e}function N(){}function v(){this._listeners=Object.create(null)}function m(e){R(function(){throw e},0)}function b(e){this.type=e,this.target=void 0}function L(e,t){b.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function j(e,t){b.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function F(e,t){b.call(this,e),this.error=t.error}k.prototype.open=function(e,t){this._abort(!0);var a=this,r=this._xhr,s=1,n=0;this._abort=function(e){0!==a._sendTimeout&&(D(a._sendTimeout),a._sendTimeout=0),1!==s&&2!==s&&3!==s||(s=4,r.onload=d,r.onerror=d,r.onabort=d,r.onprogress=d,r.onreadystatechange=d,r.abort(),0!==n&&(D(n),n=0),e||(a.readyState=4,a.onabort(null),a.onreadystatechange())),s=0};function o(){if(1===s){var t=0,n="",o=void 0;if("contentType"in r)t=200,n="OK",o=r.contentType;else try{t=r.status,n=r.statusText,o=r.getResponseHeader("Content-Type")}catch(e){n="",o=void(t=0)}0!==t&&(s=2,a.readyState=2,a.status=t,a.statusText=n,a._contentType=o,a.onreadystatechange())}}function i(){if(o(),2===s||3===s){s=3;var e="";try{e=r.responseText}catch(e){}a.readyState=3,a.responseText=e,a.onprogress()}}function l(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:d}),i(),1===s||2===s||3===s){if(s=4,0!==n&&(D(n),n=0),a.readyState=4,"load"===e)a.onload(t);else if("error"===e)a.onerror(t);else{if("abort"!==e)throw new TypeError;a.onabort(t)}a.onreadystatechange()}}var c=function(){n=R(function(){c()},500),3===r.readyState&&i()};"onload"in r&&(r.onload=function(e){l("load",e)}),"onerror"in r&&(r.onerror=function(e){l("error",e)}),"onabort"in r&&(r.onabort=function(e){l("abort",e)}),"onprogress"in r&&(r.onprogress=i),"onreadystatechange"in r&&(r.onreadystatechange=function(e){e=e,null!=r&&(4===r.readyState?"onload"in r&&"onerror"in r&&"onabort"in r||l(""===r.responseText?"error":"load",e):3===r.readyState?"onprogress"in r||i():2===r.readyState&&o())}),!("contentType"in r)&&"ontimeout"in O.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),r.open(e,t,!0),"readyState"in r&&(n=R(function(){c()},0))},k.prototype.abort=function(){this._abort(!1)},k.prototype.getResponseHeader=function(e){return this._contentType},k.prototype.setRequestHeader=function(e,t){var n=this._xhr;"setRequestHeader"in n&&n.setRequestHeader(e,t)},k.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},k.prototype.send=function(){if("ontimeout"in O.prototype&&("sendAsBinary"in O.prototype||"mozAnon"in O.prototype)||null==r||null==r.readyState||"complete"===r.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=R(function(){t._sendTimeout=0,t.send()},4)}},g.prototype.get=function(e){return this._map[c(e)]},null!=O&&null==O.HEADERS_RECEIVED&&(O.HEADERS_RECEIVED=2),H.prototype.open=function(a,r,t,n,e,o,s){a.open("GET",e);var i,l=0;for(i in a.onprogress=function(){var e=a.responseText.slice(l);l+=e.length,t(e)},a.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},a.onload=function(){n(null)},a.onabort=function(){n(null)},a.onreadystatechange=function(){var e,t,n,o;a.readyState===O.HEADERS_RECEIVED&&(e=a.status,t=a.statusText,n=a.getResponseHeader("Content-Type"),o=a.getAllResponseHeaders(),r(e,t,n,new g(o)))},a.withCredentials=o,s)Object.prototype.hasOwnProperty.call(s,i)&&a.setRequestHeader(i,s[i]);return a.send(),a},y.prototype.get=function(e){return this._headers.get(e)},N.prototype.open=function(e,t,a,n,o,r,s){var i=null,l=new f,c=l.signal,d=new h;return p(o,{headers:s,credentials:r?"include":"same-origin",signal:c,cache:"no-store"}).then(function(e){return i=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new y(e.headers)),new u(function(t,n){var o=function(){i.read().then(function(e){e.done?t(void 0):(e=d.decode(e.value,{stream:!0}),a(e),o())}).catch(function(e){n(e)})};o()})}).catch(function(e){return"AbortError"===e.name?void 0:e}).then(function(e){n(e)}),{abort:function(){null!=i&&i.cancel(),l.abort()}}},v.prototype.dispatchEvent=function(e){var t=(e.target=this)._listeners[e.type];if(null!=t)for(var n=t.length,o=0;o<n;o+=1){var a=t[o];try{"function"==typeof a.handleEvent?a.handleEvent(e):a.call(this,e)}catch(e){m(e)}}},v.prototype.addEventListener=function(e,t){e=String(e);var n=this._listeners,o=n[e];null==o&&(n[e]=o=[]);for(var a=!1,r=0;r<o.length;r+=1)o[r]===t&&(a=!0);a||o.push(t)},v.prototype.removeEventListener=function(e,t){e=String(e);var n=this._listeners,o=n[e];if(null!=o){for(var a=[],r=0;r<o.length;r+=1)o[r]!==t&&a.push(o[r]);0===a.length?delete n[e]:n[e]=a}},L.prototype=Object.create(b.prototype),j.prototype=Object.create(b.prototype),F.prototype=Object.create(b.prototype);function I(e,t){return e=null==e?t:parseInt(e,10),V(e=e!=e?t:e)}function P(e,t,n){try{"function"==typeof t&&t.call(e,n)}catch(e){m(e)}}var z=/^text\/event\-stream(;.*)?$/i,V=function(e){return Math.min(Math.max(e,1e3),18e6)};function x(e,t){v.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(l,r,e){r=String(r);function s(e,t,n,o){var a,r;0===w&&(200===e&&null!=n&&z.test(n)?(w=1,g=Date.now(),f=u,l.readyState=1,a=new j("open",{status:e,statusText:t,headers:o}),l.dispatchEvent(a),P(l,l.onopen,a)):(r="",r=200!==e?"EventSource's response has a status "+e+" "+(t=t&&t.replace(/\s+/g," "))+" that is not 200. Aborting the connection.":"EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",S(),a=new j("error",{status:e,statusText:t,headers:o}),l.dispatchEvent(a),P(l,l.onerror,a),console.error(r)))}function i(e){if(1===w){for(var t=-1,n=0;n<e.length;n+=1)(s=e.charCodeAt(n))!=="\n".charCodeAt(0)&&s!=="\r".charCodeAt(0)||(t=n);var o=(-1!==t?$:"")+e.slice(0,t+1);$=(-1===t?$:"")+e.slice(t+1),""!==e&&(g=Date.now(),y+=e.length);for(var a=0;a<o.length;a+=1){var r,s=o.charCodeAt(a);if(-1===B&&s==="\n".charCodeAt(0))B=0;else if(-1===B&&(B=0),s==="\r".charCodeAt(0)||s==="\n".charCodeAt(0)){if(0!==B&&(1===B&&(M=a+1),r=o.slice(_,M-1),i=o.slice(M+(M<a&&o.charCodeAt(M)===" ".charCodeAt(0)?1:0),a),"data"===r?(C+="\n",C+=i):"id"===r?E=i:"event"===r?T=i:"retry"===r?(u=I(i,u),f=u):"heartbeatTimeout"===r&&(p=I(i,p),0!==x&&(D(x),x=R(function(){A()},p)))),0===B){if(""!==C){h=E;var i=new L(T=""===T?"message":T,{data:C.slice(1),lastEventId:E});if(l.dispatchEvent(i),"open"===T?P(l,l.onopen,i):"message"===T?P(l,l.onmessage,i):"error"===T&&P(l,l.onerror,i),2===w)return}T=C=""}B=s==="\r".charCodeAt(0)?-1:0}else 0===B&&(_=a,B=1),1===B?s===":".charCodeAt(0)&&(M=a+1,B=2):2===B&&(B=3)}}}function c(e){var t;1!==w&&0!==w||(w=-1,0!==x&&(D(x),x=0),x=R(function(){A()},f),f=V(Math.min(16*u,2*f)),l.readyState=0,t=new F("error",{error:e}),l.dispatchEvent(t),P(l,l.onerror,t),null!=e&&console.error(e))}var t=Boolean(e.withCredentials),d=e.lastEventIdQueryParameterName||"lastEventId",u=V(1e3),p=I(e.heartbeatTimeout,45e3),h="",f=u,g=!1,y=0,n=e.headers||{},e=e.Transport,v=q&&null==e?void 0:new k(new(null!=e?e:null!=O&&"withCredentials"in O.prototype||null==a?O:a)),m=new(null!=e&&"string"!=typeof e?e:null==v?N:H),b=void 0,x=0,w=-1,C="",E="",T="",$="",B=0,_=0,M=0,S=function(){w=2,null!=b&&(b.abort(),b=void 0),0!==x&&(D(x),x=0),l.readyState=2},A=function(){if(x=0,-1===w){g=!1,y=0,x=R(function(){A()},p),E=h,$=T=C="",B=M=_=w=0;var e=r;"data:"!==r.slice(0,5)&&"blob:"!==r.slice(0,5)&&""!==h&&(e=-1===(t=r.indexOf("?"))?r:r.slice(0,t+1)+r.slice(t+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,function(e,t){return t===d?"":e}),e+=(-1===r.indexOf("?")?"?":"&")+d+"="+encodeURIComponent(h));var t=l.withCredentials,n={Accept:"text/event-stream"},o=l.headers;if(null!=o)for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(n[a]=o[a]);try{b=m.open(v,s,i,c,e,t,n)}catch(e){throw S(),e}}else g||null==b?(t=Math.max((g||Date.now())+p-Date.now(),1),g=!1,x=R(function(){A()},t)):(c(new Error("No activity within "+p+" milliseconds. "+(0===w?"No response received.":y+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0))};l.url=r,l.readyState=0,l.withCredentials=t,l.headers=n,l._close=S,A()}(this,e,t)}var q=null!=p&&null!=s&&"body"in s.prototype;(x.prototype=Object.create(v.prototype)).CONNECTING=0,x.prototype.OPEN=1,x.prototype.CLOSED=2,x.prototype.close=function(){this._close()},x.CONNECTING=0,x.OPEN=1,x.CLOSED=2,x.prototype.withCredentials=void 0;e=n;null==O||null!=n&&"withCredentials"in n.prototype||(e=x),(s=E).EventSourcePolyfill=x,s.NativeEventSource=n,s.EventSource=e}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:d:globalThis),c.exports);function $(n){let o,a,r,s,i,l,c,d,u,p,h,f,g,y,v,m,b,x,w,C,E,T,$,B,_,M,S,A,R,D,O,k,H,N,L,j,F,I,P,z,V;return{c(){o=e("div"),a=e("div"),r=Z(),s=e("div"),i=e("div"),i.innerHTML='<p class="BalanceModalTitle">Your Balance</p>',l=Z(),c=e("div"),d=e("div"),u=e("p"),u.textContent="Total Balance",p=Z(),h=e("p"),f=e("span"),g=W(n[0]),y=Z(),v=e("span"),m=W(n[3]),b=Z(),x=e("div"),w=e("p"),w.textContent="Cash Balance",C=Z(),E=e("p"),T=e("span"),$=W(n[1]),B=Z(),_=e("span"),M=W(n[3]),S=Z(),A=e("div"),R=e("p"),R.textContent="Bonus Balance",D=Z(),O=e("p"),k=e("span"),H=W(n[2]),N=Z(),L=e("span"),j=W(n[3]),F=Z(),I=e("div"),P=e("button"),P.textContent="Deposit",K(a,"class","BalanceModalClose"),K(i,"class","BalanceModalHeader"),K(u,"class","BalanceModalText"),K(f,"class","BalanceModalAmount"),K(v,"class","BalanceModalCurrency"),K(h,"class","BalanceModalValue"),K(d,"class","BalanceModalRow"),K(w,"class","BalanceModalText"),K(T,"class","BalanceModalAmount"),K(_,"class","BalanceModalCurrency"),K(E,"class","BalanceModalValue"),K(x,"class","BalanceModalRow"),K(R,"class","BalanceModalText"),K(k,"class","BalanceModalAmount"),K(L,"class","BalanceModalCurrency"),K(O,"class","BalanceModalValue"),K(A,"class","BalanceModalRow"),K(c,"class","BalanceModalBody"),K(P,"class","BalanceModalAction"),K(I,"class","BalanceModalFooter"),K(s,"class","BalanceModal"),K(o,"class","BalanceModalWrapper")},m(e,t){G(e,o,t),X(o,a),X(o,r),X(o,s),X(s,i),X(s,l),X(s,c),X(c,d),X(d,u),X(d,p),X(d,h),X(h,f),X(f,g),X(h,y),X(h,v),X(v,m),X(c,b),X(c,x),X(x,w),X(x,C),X(x,E),X(E,T),X(T,$),X(E,B),X(E,_),X(_,M),X(c,S),X(c,A),X(A,R),X(A,D),X(A,O),X(O,k),X(k,H),X(O,N),X(O,L),X(L,j),X(s,F),X(s,I),X(I,P),z||(V=[J(a,"click",n[11]),J(P,"click",n[12])],z=!0)},p(e,t){1&t&&Q(g,e[0]),8&t&&Q(m,e[3]),2&t&&Q($,e[1]),8&t&&Q(M,e[3]),4&t&&Q(H,e[2]),8&t&&Q(j,e[3])},d(e){e&&U(o),z=!1,q(V)}}}function B(n){let o,a,r;return{c(){o=e("div"),K(o,"class","ShowBalanceModalOverlay")},m(e,t){G(e,o,t),a||(r=J(o,"click",n[13]),a=!0)},p:v,d(e){e&&U(o),a=!1,r()}}}function _(n){let o,a,r,s,i,l,c,d,u,p,h,f,g=n[4]&&$(n),y=n[4]&&B(n);return{c(){o=e("div"),a=e("p"),r=W(n[0]),s=Z(),i=W(n[3]),l=Z(),c=e("span"),c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 11.435"><defs><style>.a{fill:#fff;}</style></defs><path class="a" d="M16.191,19.235l7.562-7.568a1.423,1.423,0,0,1,2.019,0,1.441,1.441,0,0,1,0,2.025L17.2,22.265a1.427,1.427,0,0,1-1.971.042L6.6,13.7a1.429,1.429,0,0,1,2.019-2.025Z" transform="translate(-6.188 -11.246)"></path></svg>',d=Z(),g&&g.c(),u=Z(),y&&y.c(),p=W(""),this.c=v,K(a,"class","BalanceValue"),K(o,"class","ShowBalance")},m(e,t){G(e,o,t),X(o,a),X(a,r),X(a,s),X(a,i),X(a,l),X(a,c),X(o,d),g&&g.m(o,null),G(e,u,t),y&&y.m(e,t),G(e,p,t),h||(f=J(a,"click",n[10]),h=!0)},p(e,[t]){1&t&&Q(r,e[0]),8&t&&Q(i,e[3]),e[4]?g?g.p(e,t):(g=$(e),g.c(),g.m(o,null)):g&&(g.d(1),g=null),e[4]?y?y.p(e,t):(y=B(e),y.c(),y.m(p.parentNode,p)):y&&(y.d(1),y=null)},i:v,o:v,d(e){e&&U(o),g&&g.d(),e&&U(u),y&&y.d(e),e&&U(p),h=!1,f()}}}function M(e,t,o){let a,r,s,{userid:n=""}=t,{session:i=""}=t,{endpoint:l=""}=t,c="",d="",u="",p="",h=!1;const f=e=>{switch(e){case"balance":o(4,h=!0);break;case"closebalance":o(4,h=!1)}},g=e=>{"message"==e.type&&((e=JSON.parse(e.data)).balanceChange&&e.balanceChange[r]&&o(1,d=e.balanceChange[r].afterAmount),e.balanceChange&&e.balanceChange[s]&&o(2,u=e.balanceChange[s].afterAmount),o(0,c=(parseFloat(d)+parseFloat(u)).toFixed(2)))},y=()=>{window.postMessage({type:"GoToDeposit"},window.location.href)},v=()=>{var e;a=new T.EventSourcePolyfill(`${l}/player/${n}/balance/updates`,{headers:{accept:"text/event-stream","X-SessionID":i}}),e=`${l}/player/${n}/account`,new Promise((t,n)=>{fetch(e,{method:"GET",headers:{"X-SessionID":i}}).then(e=>e.json()).then(e=>{e.items.forEach(e=>{"Casino"==e.displayName&&(r=e.id,o(1,d=e.balanceAmount),o(3,p=e.currency)),"UBS"==e.displayName&&(s=e.id,o(2,u=e.balanceAmount))}),o(0,c=(parseFloat(d)+parseFloat(u)).toFixed(2)),a.addEventListener("open",g),a.addEventListener("message",g),a.addEventListener("error",g),t(e)},e=>{console.error(e),n(e)})})};return t=()=>()=>{a.removeEventListener("open",g),a.removeEventListener("message",g),a.removeEventListener("error",g)},function(){if(!m)throw new Error("Function called outside component initialization");return m}().$$.on_mount.push(t),e.$$set=e=>{"userid"in e&&o(7,n=e.userid),"session"in e&&o(8,i=e.session),"endpoint"in e&&o(9,l=e.endpoint)},e.$$.update=()=>{896&e.$$.dirty&&l&&n&&i&&v()},[c,d,u,p,h,f,y,n,i,l,()=>f("balance"),()=>f("closebalance"),()=>y(),()=>f("closebalance")]}class S extends l{constructor(e){super(),this.shadowRoot.innerHTML='<style>p{padding:0;margin:0}.ShowBalance{position:relative}.ShowBalance .BalanceValue{font-size:14px;cursor:pointer}.ShowBalance .BalanceValue svg{width:16px}.BalanceModalWrapper{background-color:#fff;position:absolute;top:45px;left:50%;transform:translateX(-50%);padding:10px;box-shadow:0px 30px 30px #D0046C1A;border-radius:5px;z-index:3;box-shadow:0px 5px 20px 0px #191919}.BalanceModalWrapper:before{content:"";background:#fff;clip-path:polygon(50% 0, 0% 100%, 100% 100%);position:absolute;top:-8px;left:50%;width:25px;height:10px;transform:translateX(-50%);z-index:1}.BalanceModalClose{position:absolute;top:5px;right:5px;width:20px;height:20px;z-index:1;cursor:pointer}.BalanceModalClose:before{content:"";background:#FD2839;position:absolute;top:8px;left:0;width:20px;height:2px;transform:rotate(45deg)}.BalanceModalClose:after{content:"";background:#FD2839;position:absolute;top:8px;left:0;width:20px;height:2px;transform:rotate(-45deg)}.BalanceModal{position:relative;width:280px}.BalanceModalHeader{display:flex;align-items:center;justify-content:center;padding:20px 0}.BalanceModalHeader .BalanceModalTitle{font-size:16px;font-weight:bold;color:#07072A}.BalanceModalRow{display:flex;justify-content:space-between;align-items:center;padding:20px 0;border-bottom:1px solid #D1D1D1}.BalanceModalRow:last-child{border-bottom:none}.BalanceModalRow .BalanceModalText{color:#58586B;font-size:14px;text-transform:capitalize}.BalanceModalRow .BalanceModalValue{font-size:14px;font-weight:bold;color:#07072A}.BalanceModalFooter{display:flex;align-items:center;padding:20px 0 10px}.BalanceModalFooter .BalanceModalAction{background:#FD2839;font-size:12px;color:white;text-transform:uppercase;width:100%;border-radius:5px;border:none;padding:10px 0;cursor:pointer}.BalanceModalFooter .BalanceModalAction:hover{background:#f00215}.ShowBalanceModalOverlay{background-color:rgba(0, 0, 0, 0.7);position:fixed;top:0;bottom:0;left:0;right:0;z-index:2}</style>',n(this,{target:this.shadowRoot,props:function(e){const t={};for(const n of e)t[n.name]=n.value;return t}(this.attributes),customElement:!0},M,_,t,{userid:7,session:8,endpoint:9}),e&&(e.target&&G(e.target,this,e.anchor),e.props&&(this.$set(e.props),w()))}static get observedAttributes(){return["userid","session","endpoint"]}get userid(){return this.$$.ctx[7]}set userid(e){this.$set({userid:e}),w()}get session(){return this.$$.ctx[8]}set session(e){this.$set({session:e}),w()}get endpoint(){return this.$$.ctx[9]}set endpoint(e){this.$set({endpoint:e}),w()}}return customElements.get("player-account-balance-modal")||customElements.define("player-account-balance-modal",S),S});
|
|
2080
2
|
//# sourceMappingURL=player-account-balance-modal.js.map
|