@interopio/widget 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/io-browser-widget-react.es.js +1515 -0
- package/dist/io-browser-widget-react.es.js.map +1 -0
- package/dist/io-browser-widget-react.umd.js +1520 -0
- package/dist/io-browser-widget-react.umd.js.map +1 -0
- package/dist/io-browser-widget.es.js +1937 -0
- package/dist/io-browser-widget.es.js.map +1 -0
- package/dist/io-browser-widget.umd.js +1945 -0
- package/dist/io-browser-widget.umd.js.map +1 -0
- package/package.json +46 -0
- package/widget.d.ts +42 -0
|
@@ -0,0 +1,1520 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('react-dom')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['react', 'react-dom'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["io-browser-widget-react"] = factory(global.React, global.ReactDOM));
|
|
5
|
+
})(this, (function (React, require$$0) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wraps values in an `Ok` type.
|
|
9
|
+
*
|
|
10
|
+
* Example: `ok(5) // => {ok: true, result: 5}`
|
|
11
|
+
*/
|
|
12
|
+
var ok = function (result) { return ({ ok: true, result: result }); };
|
|
13
|
+
/**
|
|
14
|
+
* Wraps errors in an `Err` type.
|
|
15
|
+
*
|
|
16
|
+
* Example: `err('on fire') // => {ok: false, error: 'on fire'}`
|
|
17
|
+
*/
|
|
18
|
+
var err = function (error) { return ({ ok: false, error: error }); };
|
|
19
|
+
/**
|
|
20
|
+
* Create a `Promise` that either resolves with the result of `Ok` or rejects
|
|
21
|
+
* with the error of `Err`.
|
|
22
|
+
*/
|
|
23
|
+
var asPromise = function (r) {
|
|
24
|
+
return r.ok === true ? Promise.resolve(r.result) : Promise.reject(r.error);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Unwraps a `Result` and returns either the result of an `Ok`, or
|
|
28
|
+
* `defaultValue`.
|
|
29
|
+
*
|
|
30
|
+
* Example:
|
|
31
|
+
* ```
|
|
32
|
+
* Result.withDefault(5, number().run(json))
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* It would be nice if `Decoder` had an instance method that mirrored this
|
|
36
|
+
* function. Such a method would look something like this:
|
|
37
|
+
* ```
|
|
38
|
+
* class Decoder<A> {
|
|
39
|
+
* runWithDefault = (defaultValue: A, json: any): A =>
|
|
40
|
+
* Result.withDefault(defaultValue, this.run(json));
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* number().runWithDefault(5, json)
|
|
44
|
+
* ```
|
|
45
|
+
* Unfortunately, the type of `defaultValue: A` on the method causes issues
|
|
46
|
+
* with type inference on the `object` decoder in some situations. While these
|
|
47
|
+
* inference issues can be solved by providing the optional type argument for
|
|
48
|
+
* `object`s, the extra trouble and confusion doesn't seem worth it.
|
|
49
|
+
*/
|
|
50
|
+
var withDefault = function (defaultValue, r) {
|
|
51
|
+
return r.ok === true ? r.result : defaultValue;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Return the successful result, or throw an error.
|
|
55
|
+
*/
|
|
56
|
+
var withException = function (r) {
|
|
57
|
+
if (r.ok === true) {
|
|
58
|
+
return r.result;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw r.error;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Apply `f` to the result of an `Ok`, or pass the error through.
|
|
66
|
+
*/
|
|
67
|
+
var map = function (f, r) {
|
|
68
|
+
return r.ok === true ? ok(f(r.result)) : r;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Apply `f` to the result of two `Ok`s, or pass an error through. If both
|
|
72
|
+
* `Result`s are errors then the first one is returned.
|
|
73
|
+
*/
|
|
74
|
+
var map2 = function (f, ar, br) {
|
|
75
|
+
return ar.ok === false ? ar :
|
|
76
|
+
br.ok === false ? br :
|
|
77
|
+
ok(f(ar.result, br.result));
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Apply `f` to the error of an `Err`, or pass the success through.
|
|
81
|
+
*/
|
|
82
|
+
var mapError = function (f, r) {
|
|
83
|
+
return r.ok === true ? r : err(f(r.error));
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Chain together a sequence of computations that may fail, similar to a
|
|
87
|
+
* `Promise`. If the first computation fails then the error will propagate
|
|
88
|
+
* through. If it succeeds, then `f` will be applied to the value, returning a
|
|
89
|
+
* new `Result`.
|
|
90
|
+
*/
|
|
91
|
+
var andThen = function (f, r) {
|
|
92
|
+
return r.ok === true ? f(r.result) : r;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/*! *****************************************************************************
|
|
96
|
+
Copyright (c) Microsoft Corporation.
|
|
97
|
+
|
|
98
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
99
|
+
purpose with or without fee is hereby granted.
|
|
100
|
+
|
|
101
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
102
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
103
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
104
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
105
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
106
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
107
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
108
|
+
***************************************************************************** */
|
|
109
|
+
/* global Reflect, Promise */
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
var __assign = function() {
|
|
114
|
+
__assign = Object.assign || function __assign(t) {
|
|
115
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
116
|
+
s = arguments[i];
|
|
117
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
118
|
+
}
|
|
119
|
+
return t;
|
|
120
|
+
};
|
|
121
|
+
return __assign.apply(this, arguments);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
function __rest(s, e) {
|
|
125
|
+
var t = {};
|
|
126
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
127
|
+
t[p] = s[p];
|
|
128
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
129
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
130
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
131
|
+
t[p[i]] = s[p[i]];
|
|
132
|
+
}
|
|
133
|
+
return t;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function isEqual(a, b) {
|
|
137
|
+
if (a === b) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
if (a === null && b === null) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
if (typeof (a) !== typeof (b)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
if (typeof (a) === 'object') {
|
|
147
|
+
// Array
|
|
148
|
+
if (Array.isArray(a)) {
|
|
149
|
+
if (!Array.isArray(b)) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
if (a.length !== b.length) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
for (var i = 0; i < a.length; i++) {
|
|
156
|
+
if (!isEqual(a[i], b[i])) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
// Hash table
|
|
163
|
+
var keys = Object.keys(a);
|
|
164
|
+
if (keys.length !== Object.keys(b).length) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
for (var i = 0; i < keys.length; i++) {
|
|
168
|
+
if (!b.hasOwnProperty(keys[i])) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
if (!isEqual(a[keys[i]], b[keys[i]])) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/*
|
|
179
|
+
* Helpers
|
|
180
|
+
*/
|
|
181
|
+
var isJsonArray = function (json) { return Array.isArray(json); };
|
|
182
|
+
var isJsonObject = function (json) {
|
|
183
|
+
return typeof json === 'object' && json !== null && !isJsonArray(json);
|
|
184
|
+
};
|
|
185
|
+
var typeString = function (json) {
|
|
186
|
+
switch (typeof json) {
|
|
187
|
+
case 'string':
|
|
188
|
+
return 'a string';
|
|
189
|
+
case 'number':
|
|
190
|
+
return 'a number';
|
|
191
|
+
case 'boolean':
|
|
192
|
+
return 'a boolean';
|
|
193
|
+
case 'undefined':
|
|
194
|
+
return 'undefined';
|
|
195
|
+
case 'object':
|
|
196
|
+
if (json instanceof Array) {
|
|
197
|
+
return 'an array';
|
|
198
|
+
}
|
|
199
|
+
else if (json === null) {
|
|
200
|
+
return 'null';
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
return 'an object';
|
|
204
|
+
}
|
|
205
|
+
default:
|
|
206
|
+
return JSON.stringify(json);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var expectedGot = function (expected, got) {
|
|
210
|
+
return "expected " + expected + ", got " + typeString(got);
|
|
211
|
+
};
|
|
212
|
+
var printPath = function (paths) {
|
|
213
|
+
return paths.map(function (path) { return (typeof path === 'string' ? "." + path : "[" + path + "]"); }).join('');
|
|
214
|
+
};
|
|
215
|
+
var prependAt = function (newAt, _a) {
|
|
216
|
+
var at = _a.at, rest = __rest(_a, ["at"]);
|
|
217
|
+
return (__assign({ at: newAt + (at || '') }, rest));
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Decoders transform json objects with unknown structure into known and
|
|
221
|
+
* verified forms. You can create objects of type `Decoder<A>` with either the
|
|
222
|
+
* primitive decoder functions, such as `boolean()` and `string()`, or by
|
|
223
|
+
* applying higher-order decoders to the primitives, such as `array(boolean())`
|
|
224
|
+
* or `dict(string())`.
|
|
225
|
+
*
|
|
226
|
+
* Each of the decoder functions are available both as a static method on
|
|
227
|
+
* `Decoder` and as a function alias -- for example the string decoder is
|
|
228
|
+
* defined at `Decoder.string()`, but is also aliased to `string()`. Using the
|
|
229
|
+
* function aliases exported with the library is recommended.
|
|
230
|
+
*
|
|
231
|
+
* `Decoder` exposes a number of 'run' methods, which all decode json in the
|
|
232
|
+
* same way, but communicate success and failure in different ways. The `map`
|
|
233
|
+
* and `andThen` methods modify decoders without having to call a 'run' method.
|
|
234
|
+
*
|
|
235
|
+
* Alternatively, the main decoder `run()` method returns an object of type
|
|
236
|
+
* `Result<A, DecoderError>`. This library provides a number of helper
|
|
237
|
+
* functions for dealing with the `Result` type, so you can do all the same
|
|
238
|
+
* things with a `Result` as with the decoder methods.
|
|
239
|
+
*/
|
|
240
|
+
var Decoder = /** @class */ (function () {
|
|
241
|
+
/**
|
|
242
|
+
* The Decoder class constructor is kept private to separate the internal
|
|
243
|
+
* `decode` function from the external `run` function. The distinction
|
|
244
|
+
* between the two functions is that `decode` returns a
|
|
245
|
+
* `Partial<DecoderError>` on failure, which contains an unfinished error
|
|
246
|
+
* report. When `run` is called on a decoder, the relevant series of `decode`
|
|
247
|
+
* calls is made, and then on failure the resulting `Partial<DecoderError>`
|
|
248
|
+
* is turned into a `DecoderError` by filling in the missing information.
|
|
249
|
+
*
|
|
250
|
+
* While hiding the constructor may seem restrictive, leveraging the
|
|
251
|
+
* provided decoder combinators and helper functions such as
|
|
252
|
+
* `andThen` and `map` should be enough to build specialized decoders as
|
|
253
|
+
* needed.
|
|
254
|
+
*/
|
|
255
|
+
function Decoder(decode) {
|
|
256
|
+
var _this = this;
|
|
257
|
+
this.decode = decode;
|
|
258
|
+
/**
|
|
259
|
+
* Run the decoder and return a `Result` with either the decoded value or a
|
|
260
|
+
* `DecoderError` containing the json input, the location of the error, and
|
|
261
|
+
* the error message.
|
|
262
|
+
*
|
|
263
|
+
* Examples:
|
|
264
|
+
* ```
|
|
265
|
+
* number().run(12)
|
|
266
|
+
* // => {ok: true, result: 12}
|
|
267
|
+
*
|
|
268
|
+
* string().run(9001)
|
|
269
|
+
* // =>
|
|
270
|
+
* // {
|
|
271
|
+
* // ok: false,
|
|
272
|
+
* // error: {
|
|
273
|
+
* // kind: 'DecoderError',
|
|
274
|
+
* // input: 9001,
|
|
275
|
+
* // at: 'input',
|
|
276
|
+
* // message: 'expected a string, got 9001'
|
|
277
|
+
* // }
|
|
278
|
+
* // }
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
this.run = function (json) {
|
|
282
|
+
return mapError(function (error) { return ({
|
|
283
|
+
kind: 'DecoderError',
|
|
284
|
+
input: json,
|
|
285
|
+
at: 'input' + (error.at || ''),
|
|
286
|
+
message: error.message || ''
|
|
287
|
+
}); }, _this.decode(json));
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* Run the decoder as a `Promise`.
|
|
291
|
+
*/
|
|
292
|
+
this.runPromise = function (json) { return asPromise(_this.run(json)); };
|
|
293
|
+
/**
|
|
294
|
+
* Run the decoder and return the value on success, or throw an exception
|
|
295
|
+
* with a formatted error string.
|
|
296
|
+
*/
|
|
297
|
+
this.runWithException = function (json) { return withException(_this.run(json)); };
|
|
298
|
+
/**
|
|
299
|
+
* Construct a new decoder that applies a transformation to the decoded
|
|
300
|
+
* result. If the decoder succeeds then `f` will be applied to the value. If
|
|
301
|
+
* it fails the error will propagated through.
|
|
302
|
+
*
|
|
303
|
+
* Example:
|
|
304
|
+
* ```
|
|
305
|
+
* number().map(x => x * 5).run(10)
|
|
306
|
+
* // => {ok: true, result: 50}
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
this.map = function (f) {
|
|
310
|
+
return new Decoder(function (json) { return map(f, _this.decode(json)); });
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* Chain together a sequence of decoders. The first decoder will run, and
|
|
314
|
+
* then the function will determine what decoder to run second. If the result
|
|
315
|
+
* of the first decoder succeeds then `f` will be applied to the decoded
|
|
316
|
+
* value. If it fails the error will propagate through.
|
|
317
|
+
*
|
|
318
|
+
* This is a very powerful method -- it can act as both the `map` and `where`
|
|
319
|
+
* methods, can improve error messages for edge cases, and can be used to
|
|
320
|
+
* make a decoder for custom types.
|
|
321
|
+
*
|
|
322
|
+
* Example of adding an error message:
|
|
323
|
+
* ```
|
|
324
|
+
* const versionDecoder = valueAt(['version'], number());
|
|
325
|
+
* const infoDecoder3 = object({a: boolean()});
|
|
326
|
+
*
|
|
327
|
+
* const decoder = versionDecoder.andThen(version => {
|
|
328
|
+
* switch (version) {
|
|
329
|
+
* case 3:
|
|
330
|
+
* return infoDecoder3;
|
|
331
|
+
* default:
|
|
332
|
+
* return fail(`Unable to decode info, version ${version} is not supported.`);
|
|
333
|
+
* }
|
|
334
|
+
* });
|
|
335
|
+
*
|
|
336
|
+
* decoder.run({version: 3, a: true})
|
|
337
|
+
* // => {ok: true, result: {a: true}}
|
|
338
|
+
*
|
|
339
|
+
* decoder.run({version: 5, x: 'abc'})
|
|
340
|
+
* // =>
|
|
341
|
+
* // {
|
|
342
|
+
* // ok: false,
|
|
343
|
+
* // error: {... message: 'Unable to decode info, version 5 is not supported.'}
|
|
344
|
+
* // }
|
|
345
|
+
* ```
|
|
346
|
+
*
|
|
347
|
+
* Example of decoding a custom type:
|
|
348
|
+
* ```
|
|
349
|
+
* // nominal type for arrays with a length of at least one
|
|
350
|
+
* type NonEmptyArray<T> = T[] & { __nonEmptyArrayBrand__: void };
|
|
351
|
+
*
|
|
352
|
+
* const nonEmptyArrayDecoder = <T>(values: Decoder<T>): Decoder<NonEmptyArray<T>> =>
|
|
353
|
+
* array(values).andThen(arr =>
|
|
354
|
+
* arr.length > 0
|
|
355
|
+
* ? succeed(createNonEmptyArray(arr))
|
|
356
|
+
* : fail(`expected a non-empty array, got an empty array`)
|
|
357
|
+
* );
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
this.andThen = function (f) {
|
|
361
|
+
return new Decoder(function (json) {
|
|
362
|
+
return andThen(function (value) { return f(value).decode(json); }, _this.decode(json));
|
|
363
|
+
});
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Add constraints to a decoder _without_ changing the resulting type. The
|
|
367
|
+
* `test` argument is a predicate function which returns true for valid
|
|
368
|
+
* inputs. When `test` fails on an input, the decoder fails with the given
|
|
369
|
+
* `errorMessage`.
|
|
370
|
+
*
|
|
371
|
+
* ```
|
|
372
|
+
* const chars = (length: number): Decoder<string> =>
|
|
373
|
+
* string().where(
|
|
374
|
+
* (s: string) => s.length === length,
|
|
375
|
+
* `expected a string of length ${length}`
|
|
376
|
+
* );
|
|
377
|
+
*
|
|
378
|
+
* chars(5).run('12345')
|
|
379
|
+
* // => {ok: true, result: '12345'}
|
|
380
|
+
*
|
|
381
|
+
* chars(2).run('HELLO')
|
|
382
|
+
* // => {ok: false, error: {... message: 'expected a string of length 2'}}
|
|
383
|
+
*
|
|
384
|
+
* chars(12).run(true)
|
|
385
|
+
* // => {ok: false, error: {... message: 'expected a string, got a boolean'}}
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
this.where = function (test, errorMessage) {
|
|
389
|
+
return _this.andThen(function (value) { return (test(value) ? Decoder.succeed(value) : Decoder.fail(errorMessage)); });
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Decoder primitive that validates strings, and fails on all other input.
|
|
394
|
+
*/
|
|
395
|
+
Decoder.string = function () {
|
|
396
|
+
return new Decoder(function (json) {
|
|
397
|
+
return typeof json === 'string'
|
|
398
|
+
? ok(json)
|
|
399
|
+
: err({ message: expectedGot('a string', json) });
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
/**
|
|
403
|
+
* Decoder primitive that validates numbers, and fails on all other input.
|
|
404
|
+
*/
|
|
405
|
+
Decoder.number = function () {
|
|
406
|
+
return new Decoder(function (json) {
|
|
407
|
+
return typeof json === 'number'
|
|
408
|
+
? ok(json)
|
|
409
|
+
: err({ message: expectedGot('a number', json) });
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* Decoder primitive that validates booleans, and fails on all other input.
|
|
414
|
+
*/
|
|
415
|
+
Decoder.boolean = function () {
|
|
416
|
+
return new Decoder(function (json) {
|
|
417
|
+
return typeof json === 'boolean'
|
|
418
|
+
? ok(json)
|
|
419
|
+
: err({ message: expectedGot('a boolean', json) });
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
Decoder.constant = function (value) {
|
|
423
|
+
return new Decoder(function (json) {
|
|
424
|
+
return isEqual(json, value)
|
|
425
|
+
? ok(value)
|
|
426
|
+
: err({ message: "expected " + JSON.stringify(value) + ", got " + JSON.stringify(json) });
|
|
427
|
+
});
|
|
428
|
+
};
|
|
429
|
+
Decoder.object = function (decoders) {
|
|
430
|
+
return new Decoder(function (json) {
|
|
431
|
+
if (isJsonObject(json) && decoders) {
|
|
432
|
+
var obj = {};
|
|
433
|
+
for (var key in decoders) {
|
|
434
|
+
if (decoders.hasOwnProperty(key)) {
|
|
435
|
+
var r = decoders[key].decode(json[key]);
|
|
436
|
+
if (r.ok === true) {
|
|
437
|
+
// tslint:disable-next-line:strict-type-predicates
|
|
438
|
+
if (r.result !== undefined) {
|
|
439
|
+
obj[key] = r.result;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
else if (json[key] === undefined) {
|
|
443
|
+
return err({ message: "the key '" + key + "' is required but was not present" });
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
return err(prependAt("." + key, r.error));
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return ok(obj);
|
|
451
|
+
}
|
|
452
|
+
else if (isJsonObject(json)) {
|
|
453
|
+
return ok(json);
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
return err({ message: expectedGot('an object', json) });
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
};
|
|
460
|
+
Decoder.array = function (decoder) {
|
|
461
|
+
return new Decoder(function (json) {
|
|
462
|
+
if (isJsonArray(json) && decoder) {
|
|
463
|
+
var decodeValue_1 = function (v, i) {
|
|
464
|
+
return mapError(function (err$$1) { return prependAt("[" + i + "]", err$$1); }, decoder.decode(v));
|
|
465
|
+
};
|
|
466
|
+
return json.reduce(function (acc, v, i) {
|
|
467
|
+
return map2(function (arr, result) { return arr.concat([result]); }, acc, decodeValue_1(v, i));
|
|
468
|
+
}, ok([]));
|
|
469
|
+
}
|
|
470
|
+
else if (isJsonArray(json)) {
|
|
471
|
+
return ok(json);
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
return err({ message: expectedGot('an array', json) });
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
};
|
|
478
|
+
Decoder.tuple = function (decoders) {
|
|
479
|
+
return new Decoder(function (json) {
|
|
480
|
+
if (isJsonArray(json)) {
|
|
481
|
+
if (json.length !== decoders.length) {
|
|
482
|
+
return err({
|
|
483
|
+
message: "expected a tuple of length " + decoders.length + ", got one of length " + json.length
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
var result = [];
|
|
487
|
+
for (var i = 0; i < decoders.length; i++) {
|
|
488
|
+
var nth = decoders[i].decode(json[i]);
|
|
489
|
+
if (nth.ok) {
|
|
490
|
+
result[i] = nth.result;
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
return err(prependAt("[" + i + "]", nth.error));
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return ok(result);
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
return err({ message: expectedGot("a tuple of length " + decoders.length, json) });
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
Decoder.union = function (ad, bd) {
|
|
504
|
+
var decoders = [];
|
|
505
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
506
|
+
decoders[_i - 2] = arguments[_i];
|
|
507
|
+
}
|
|
508
|
+
return Decoder.oneOf.apply(Decoder, [ad, bd].concat(decoders));
|
|
509
|
+
};
|
|
510
|
+
Decoder.intersection = function (ad, bd) {
|
|
511
|
+
var ds = [];
|
|
512
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
513
|
+
ds[_i - 2] = arguments[_i];
|
|
514
|
+
}
|
|
515
|
+
return new Decoder(function (json) {
|
|
516
|
+
return [ad, bd].concat(ds).reduce(function (acc, decoder) { return map2(Object.assign, acc, decoder.decode(json)); }, ok({}));
|
|
517
|
+
});
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* Escape hatch to bypass validation. Always succeeds and types the result as
|
|
521
|
+
* `any`. Useful for defining decoders incrementally, particularly for
|
|
522
|
+
* complex objects.
|
|
523
|
+
*
|
|
524
|
+
* Example:
|
|
525
|
+
* ```
|
|
526
|
+
* interface User {
|
|
527
|
+
* name: string;
|
|
528
|
+
* complexUserData: ComplexType;
|
|
529
|
+
* }
|
|
530
|
+
*
|
|
531
|
+
* const userDecoder: Decoder<User> = object({
|
|
532
|
+
* name: string(),
|
|
533
|
+
* complexUserData: anyJson()
|
|
534
|
+
* });
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
537
|
+
Decoder.anyJson = function () { return new Decoder(function (json) { return ok(json); }); };
|
|
538
|
+
/**
|
|
539
|
+
* Decoder identity function which always succeeds and types the result as
|
|
540
|
+
* `unknown`.
|
|
541
|
+
*/
|
|
542
|
+
Decoder.unknownJson = function () {
|
|
543
|
+
return new Decoder(function (json) { return ok(json); });
|
|
544
|
+
};
|
|
545
|
+
/**
|
|
546
|
+
* Decoder for json objects where the keys are unknown strings, but the values
|
|
547
|
+
* should all be of the same type.
|
|
548
|
+
*
|
|
549
|
+
* Example:
|
|
550
|
+
* ```
|
|
551
|
+
* dict(number()).run({chocolate: 12, vanilla: 10, mint: 37});
|
|
552
|
+
* // => {ok: true, result: {chocolate: 12, vanilla: 10, mint: 37}}
|
|
553
|
+
* ```
|
|
554
|
+
*/
|
|
555
|
+
Decoder.dict = function (decoder) {
|
|
556
|
+
return new Decoder(function (json) {
|
|
557
|
+
if (isJsonObject(json)) {
|
|
558
|
+
var obj = {};
|
|
559
|
+
for (var key in json) {
|
|
560
|
+
if (json.hasOwnProperty(key)) {
|
|
561
|
+
var r = decoder.decode(json[key]);
|
|
562
|
+
if (r.ok === true) {
|
|
563
|
+
obj[key] = r.result;
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
return err(prependAt("." + key, r.error));
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return ok(obj);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
return err({ message: expectedGot('an object', json) });
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
};
|
|
577
|
+
/**
|
|
578
|
+
* Decoder for values that may be `undefined`. This is primarily helpful for
|
|
579
|
+
* decoding interfaces with optional fields.
|
|
580
|
+
*
|
|
581
|
+
* Example:
|
|
582
|
+
* ```
|
|
583
|
+
* interface User {
|
|
584
|
+
* id: number;
|
|
585
|
+
* isOwner?: boolean;
|
|
586
|
+
* }
|
|
587
|
+
*
|
|
588
|
+
* const decoder: Decoder<User> = object({
|
|
589
|
+
* id: number(),
|
|
590
|
+
* isOwner: optional(boolean())
|
|
591
|
+
* });
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
Decoder.optional = function (decoder) {
|
|
595
|
+
return new Decoder(function (json) { return (json === undefined || json === null ? ok(undefined) : decoder.decode(json)); });
|
|
596
|
+
};
|
|
597
|
+
/**
|
|
598
|
+
* Decoder that attempts to run each decoder in `decoders` and either succeeds
|
|
599
|
+
* with the first successful decoder, or fails after all decoders have failed.
|
|
600
|
+
*
|
|
601
|
+
* Note that `oneOf` expects the decoders to all have the same return type,
|
|
602
|
+
* while `union` creates a decoder for the union type of all the input
|
|
603
|
+
* decoders.
|
|
604
|
+
*
|
|
605
|
+
* Examples:
|
|
606
|
+
* ```
|
|
607
|
+
* oneOf(string(), number().map(String))
|
|
608
|
+
* oneOf(constant('start'), constant('stop'), succeed('unknown'))
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
Decoder.oneOf = function () {
|
|
612
|
+
var decoders = [];
|
|
613
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
614
|
+
decoders[_i] = arguments[_i];
|
|
615
|
+
}
|
|
616
|
+
return new Decoder(function (json) {
|
|
617
|
+
var errors = [];
|
|
618
|
+
for (var i = 0; i < decoders.length; i++) {
|
|
619
|
+
var r = decoders[i].decode(json);
|
|
620
|
+
if (r.ok === true) {
|
|
621
|
+
return r;
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
errors[i] = r.error;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
var errorsList = errors
|
|
628
|
+
.map(function (error) { return "at error" + (error.at || '') + ": " + error.message; })
|
|
629
|
+
.join('", "');
|
|
630
|
+
return err({
|
|
631
|
+
message: "expected a value matching one of the decoders, got the errors [\"" + errorsList + "\"]"
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
};
|
|
635
|
+
/**
|
|
636
|
+
* Decoder that always succeeds with either the decoded value, or a fallback
|
|
637
|
+
* default value.
|
|
638
|
+
*/
|
|
639
|
+
Decoder.withDefault = function (defaultValue, decoder) {
|
|
640
|
+
return new Decoder(function (json) {
|
|
641
|
+
return ok(withDefault(defaultValue, decoder.decode(json)));
|
|
642
|
+
});
|
|
643
|
+
};
|
|
644
|
+
/**
|
|
645
|
+
* Decoder that pulls a specific field out of a json structure, instead of
|
|
646
|
+
* decoding and returning the full structure. The `paths` array describes the
|
|
647
|
+
* object keys and array indices to traverse, so that values can be pulled out
|
|
648
|
+
* of a nested structure.
|
|
649
|
+
*
|
|
650
|
+
* Example:
|
|
651
|
+
* ```
|
|
652
|
+
* const decoder = valueAt(['a', 'b', 0], string());
|
|
653
|
+
*
|
|
654
|
+
* decoder.run({a: {b: ['surprise!']}})
|
|
655
|
+
* // => {ok: true, result: 'surprise!'}
|
|
656
|
+
*
|
|
657
|
+
* decoder.run({a: {x: 'cats'}})
|
|
658
|
+
* // => {ok: false, error: {... at: 'input.a.b[0]' message: 'path does not exist'}}
|
|
659
|
+
* ```
|
|
660
|
+
*
|
|
661
|
+
* Note that the `decoder` is ran on the value found at the last key in the
|
|
662
|
+
* path, even if the last key is not found. This allows the `optional`
|
|
663
|
+
* decoder to succeed when appropriate.
|
|
664
|
+
* ```
|
|
665
|
+
* const optionalDecoder = valueAt(['a', 'b', 'c'], optional(string()));
|
|
666
|
+
*
|
|
667
|
+
* optionalDecoder.run({a: {b: {c: 'surprise!'}}})
|
|
668
|
+
* // => {ok: true, result: 'surprise!'}
|
|
669
|
+
*
|
|
670
|
+
* optionalDecoder.run({a: {b: 'cats'}})
|
|
671
|
+
* // => {ok: false, error: {... at: 'input.a.b.c' message: 'expected an object, got "cats"'}
|
|
672
|
+
*
|
|
673
|
+
* optionalDecoder.run({a: {b: {z: 1}}})
|
|
674
|
+
* // => {ok: true, result: undefined}
|
|
675
|
+
* ```
|
|
676
|
+
*/
|
|
677
|
+
Decoder.valueAt = function (paths, decoder) {
|
|
678
|
+
return new Decoder(function (json) {
|
|
679
|
+
var jsonAtPath = json;
|
|
680
|
+
for (var i = 0; i < paths.length; i++) {
|
|
681
|
+
if (jsonAtPath === undefined) {
|
|
682
|
+
return err({
|
|
683
|
+
at: printPath(paths.slice(0, i + 1)),
|
|
684
|
+
message: 'path does not exist'
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
else if (typeof paths[i] === 'string' && !isJsonObject(jsonAtPath)) {
|
|
688
|
+
return err({
|
|
689
|
+
at: printPath(paths.slice(0, i + 1)),
|
|
690
|
+
message: expectedGot('an object', jsonAtPath)
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
else if (typeof paths[i] === 'number' && !isJsonArray(jsonAtPath)) {
|
|
694
|
+
return err({
|
|
695
|
+
at: printPath(paths.slice(0, i + 1)),
|
|
696
|
+
message: expectedGot('an array', jsonAtPath)
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
jsonAtPath = jsonAtPath[paths[i]];
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return mapError(function (error) {
|
|
704
|
+
return jsonAtPath === undefined
|
|
705
|
+
? { at: printPath(paths), message: 'path does not exist' }
|
|
706
|
+
: prependAt(printPath(paths), error);
|
|
707
|
+
}, decoder.decode(jsonAtPath));
|
|
708
|
+
});
|
|
709
|
+
};
|
|
710
|
+
/**
|
|
711
|
+
* Decoder that ignores the input json and always succeeds with `fixedValue`.
|
|
712
|
+
*/
|
|
713
|
+
Decoder.succeed = function (fixedValue) {
|
|
714
|
+
return new Decoder(function (json) { return ok(fixedValue); });
|
|
715
|
+
};
|
|
716
|
+
/**
|
|
717
|
+
* Decoder that ignores the input json and always fails with `errorMessage`.
|
|
718
|
+
*/
|
|
719
|
+
Decoder.fail = function (errorMessage) {
|
|
720
|
+
return new Decoder(function (json) { return err({ message: errorMessage }); });
|
|
721
|
+
};
|
|
722
|
+
/**
|
|
723
|
+
* Decoder that allows for validating recursive data structures. Unlike with
|
|
724
|
+
* functions, decoders assigned to variables can't reference themselves
|
|
725
|
+
* before they are fully defined. We can avoid prematurely referencing the
|
|
726
|
+
* decoder by wrapping it in a function that won't be called until use, at
|
|
727
|
+
* which point the decoder has been defined.
|
|
728
|
+
*
|
|
729
|
+
* Example:
|
|
730
|
+
* ```
|
|
731
|
+
* interface Comment {
|
|
732
|
+
* msg: string;
|
|
733
|
+
* replies: Comment[];
|
|
734
|
+
* }
|
|
735
|
+
*
|
|
736
|
+
* const decoder: Decoder<Comment> = object({
|
|
737
|
+
* msg: string(),
|
|
738
|
+
* replies: lazy(() => array(decoder))
|
|
739
|
+
* });
|
|
740
|
+
* ```
|
|
741
|
+
*/
|
|
742
|
+
Decoder.lazy = function (mkDecoder) {
|
|
743
|
+
return new Decoder(function (json) { return mkDecoder().decode(json); });
|
|
744
|
+
};
|
|
745
|
+
return Decoder;
|
|
746
|
+
}());
|
|
747
|
+
|
|
748
|
+
/* tslint:disable:variable-name */
|
|
749
|
+
/** See `Decoder.string` */
|
|
750
|
+
Decoder.string;
|
|
751
|
+
/** See `Decoder.number` */
|
|
752
|
+
Decoder.number;
|
|
753
|
+
/** See `Decoder.boolean` */
|
|
754
|
+
var boolean = Decoder.boolean;
|
|
755
|
+
/** See `Decoder.anyJson` */
|
|
756
|
+
Decoder.anyJson;
|
|
757
|
+
/** See `Decoder.unknownJson` */
|
|
758
|
+
Decoder.unknownJson;
|
|
759
|
+
/** See `Decoder.constant` */
|
|
760
|
+
var constant = Decoder.constant;
|
|
761
|
+
/** See `Decoder.object` */
|
|
762
|
+
var object = Decoder.object;
|
|
763
|
+
/** See `Decoder.array` */
|
|
764
|
+
Decoder.array;
|
|
765
|
+
/** See `Decoder.tuple` */
|
|
766
|
+
Decoder.tuple;
|
|
767
|
+
/** See `Decoder.dict` */
|
|
768
|
+
Decoder.dict;
|
|
769
|
+
/** See `Decoder.optional` */
|
|
770
|
+
var optional = Decoder.optional;
|
|
771
|
+
/** See `Decoder.oneOf` */
|
|
772
|
+
var oneOf = Decoder.oneOf;
|
|
773
|
+
/** See `Decoder.union` */
|
|
774
|
+
Decoder.union;
|
|
775
|
+
/** See `Decoder.intersection` */
|
|
776
|
+
Decoder.intersection;
|
|
777
|
+
/** See `Decoder.withDefault` */
|
|
778
|
+
Decoder.withDefault;
|
|
779
|
+
/** See `Decoder.valueAt` */
|
|
780
|
+
Decoder.valueAt;
|
|
781
|
+
/** See `Decoder.succeed` */
|
|
782
|
+
Decoder.succeed;
|
|
783
|
+
/** See `Decoder.fail` */
|
|
784
|
+
Decoder.fail;
|
|
785
|
+
/** See `Decoder.lazy` */
|
|
786
|
+
Decoder.lazy;
|
|
787
|
+
|
|
788
|
+
const channelSelectorTypeDecoder = oneOf(constant("directional"), constant("default"));
|
|
789
|
+
const channelSelectorDecoder = object({
|
|
790
|
+
type: optional(channelSelectorTypeDecoder),
|
|
791
|
+
enable: optional(boolean())
|
|
792
|
+
});
|
|
793
|
+
const positionDecoder = oneOf(constant("top"), constant("bottom"), constant("left"), constant("right"));
|
|
794
|
+
const modeDecoder = oneOf(constant("default"), constant("compact"));
|
|
795
|
+
const configDecoder = object({
|
|
796
|
+
channelSelector: optional(channelSelectorDecoder),
|
|
797
|
+
position: optional(positionDecoder),
|
|
798
|
+
mode: optional(modeDecoder)
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
const defaultConfig = {
|
|
802
|
+
channelSelector: {
|
|
803
|
+
enable: true,
|
|
804
|
+
type: "default"
|
|
805
|
+
},
|
|
806
|
+
position: "bottom",
|
|
807
|
+
mode: "default"
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
const browserPlatformMethodName = "T42.Web.Platform.Control";
|
|
811
|
+
|
|
812
|
+
class Bridge {
|
|
813
|
+
io;
|
|
814
|
+
defaultTransportTimeout = 30000;
|
|
815
|
+
logger;
|
|
816
|
+
constructor(io) {
|
|
817
|
+
this.io = io;
|
|
818
|
+
const windowId = io.windows.my().id;
|
|
819
|
+
this.logger = io.logger.subLogger(`widget.bridge-${windowId}`);
|
|
820
|
+
}
|
|
821
|
+
async initiate() {
|
|
822
|
+
const browserGlobal = window.glue42core || window.iobrowser;
|
|
823
|
+
if (!browserGlobal) {
|
|
824
|
+
const errorMsg = "App is not running in IO.Connect.Browser environment";
|
|
825
|
+
this.logger.trace(errorMsg);
|
|
826
|
+
return { success: false, reason: errorMsg };
|
|
827
|
+
}
|
|
828
|
+
const res = await this.checkPlatformMethodsExist();
|
|
829
|
+
this.logger.trace(`Bridge initiated successfully`);
|
|
830
|
+
return res;
|
|
831
|
+
}
|
|
832
|
+
async send(operation, domain, operationArguments, options) {
|
|
833
|
+
const browserGlobal = window.glue42core || window.iobrowser;
|
|
834
|
+
const platformTarget = browserGlobal.communicationId;
|
|
835
|
+
const invocationArguments = { operation, domain, data: operationArguments };
|
|
836
|
+
const operationSupported = options?.includeOperationCheck ? (await this.checkOperationSupported(operation, domain)).isSupported : true;
|
|
837
|
+
if (!operationSupported) {
|
|
838
|
+
throw new Error(`Cannot complete operation: ${operation} for domain: ${domain} because this client is connected to a platform which does not support it`);
|
|
839
|
+
}
|
|
840
|
+
let invocationResult;
|
|
841
|
+
const baseErrorMessage = `Internal Widget Communication Error. Attempted operation: ${JSON.stringify(invocationArguments)}. `;
|
|
842
|
+
try {
|
|
843
|
+
invocationResult = await this.io.interop.invoke(browserPlatformMethodName, invocationArguments, platformTarget ? { instance: platformTarget } : "best", { methodResponseTimeoutMs: this.defaultTransportTimeout });
|
|
844
|
+
if (!invocationResult) {
|
|
845
|
+
throw new Error("Received unsupported result from Platform - empty result");
|
|
846
|
+
}
|
|
847
|
+
if (!Array.isArray(invocationResult.all_return_values) || invocationResult.all_return_values.length === 0) {
|
|
848
|
+
throw new Error("Received unsupported result from Platform - empty values collection");
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
catch (error) {
|
|
852
|
+
if (error?.all_errors?.length) {
|
|
853
|
+
const invocationErrorMessage = error.all_errors[0].message;
|
|
854
|
+
throw new Error(`${baseErrorMessage} -> Inner message: ${invocationErrorMessage}`);
|
|
855
|
+
}
|
|
856
|
+
throw new Error(`${baseErrorMessage} -> Inner message: ${error.message}`);
|
|
857
|
+
}
|
|
858
|
+
return invocationResult.all_return_values[0].returned;
|
|
859
|
+
}
|
|
860
|
+
async checkOperationSupported(operation, domain) {
|
|
861
|
+
try {
|
|
862
|
+
const result = await this.send("operationCheck", domain, { operation });
|
|
863
|
+
return result;
|
|
864
|
+
}
|
|
865
|
+
catch (error) {
|
|
866
|
+
return { isSupported: false };
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
async checkPlatformMethodsExist() {
|
|
870
|
+
const workspacesInitCheckSupported = await this.checkOperationSupported("workspacesInitCheck", "system");
|
|
871
|
+
if (!workspacesInitCheckSupported.isSupported) {
|
|
872
|
+
const errorMsg = `IO.Connect Browser Platform is an older version and does not support 'workspacesInitCheck' operation for 'system' domain`;
|
|
873
|
+
this.logger.trace(errorMsg);
|
|
874
|
+
return { success: false, reason: errorMsg };
|
|
875
|
+
}
|
|
876
|
+
return { success: true };
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
var createRoot;
|
|
881
|
+
|
|
882
|
+
var m$1 = require$$0;
|
|
883
|
+
{
|
|
884
|
+
createRoot = m$1.createRoot;
|
|
885
|
+
m$1.hydrateRoot;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
let GlueControllerContext;
|
|
889
|
+
const createGlueControllerContext = (glueController) => {
|
|
890
|
+
GlueControllerContext = React.createContext(glueController);
|
|
891
|
+
return GlueControllerContext;
|
|
892
|
+
};
|
|
893
|
+
|
|
894
|
+
const useThemeSync = () => {
|
|
895
|
+
const glueController = React.useContext(GlueControllerContext);
|
|
896
|
+
React.useEffect(() => {
|
|
897
|
+
let isUnsubscribed = false;
|
|
898
|
+
const themesApi = glueController.io?.themes;
|
|
899
|
+
if (!themesApi) {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
const changeTheme = async (theme) => {
|
|
903
|
+
if (isUnsubscribed) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
const htmlElement = document.documentElement;
|
|
907
|
+
if (htmlElement.classList.contains(theme.name)) {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const allThemes = await themesApi.list();
|
|
911
|
+
htmlElement.classList.remove(...allThemes.map(({ name }) => name));
|
|
912
|
+
htmlElement.classList.add(theme.name);
|
|
913
|
+
};
|
|
914
|
+
themesApi.onChanged(changeTheme);
|
|
915
|
+
themesApi.getCurrent().then(changeTheme);
|
|
916
|
+
return () => {
|
|
917
|
+
isUnsubscribed = true;
|
|
918
|
+
};
|
|
919
|
+
}, [glueController]);
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
const drop = (e, setSelectedPosition) => {
|
|
923
|
+
e.preventDefault();
|
|
924
|
+
const x = e.clientX;
|
|
925
|
+
const y = e.clientY;
|
|
926
|
+
const screenWidth = window.innerWidth;
|
|
927
|
+
const screenHeight = window.innerHeight;
|
|
928
|
+
const centerX = screenWidth / 2;
|
|
929
|
+
const centerY = screenHeight / 2;
|
|
930
|
+
const widgetElem = Array.from(document.getElementsByClassName('io-window-widget'))[0];
|
|
931
|
+
let widgetClassName = "";
|
|
932
|
+
let position = "bottom";
|
|
933
|
+
if (x < centerX && y < centerY) {
|
|
934
|
+
position = centerX - x < centerY - y ? "top" : "left";
|
|
935
|
+
widgetClassName = `io-window-widget io-window-widget-${position}`;
|
|
936
|
+
}
|
|
937
|
+
else if (x < centerX && y > centerY) {
|
|
938
|
+
position = Math.abs(centerY - y) < x ? "bottom" : "left";
|
|
939
|
+
widgetClassName = `io-window-widget ${position === "left" ? "io-window-widget-left" : ""}`;
|
|
940
|
+
}
|
|
941
|
+
else if (x > centerX && y < centerY) {
|
|
942
|
+
position = screenWidth - x < y ? "right" : "top";
|
|
943
|
+
widgetClassName = `io-window-widget io-window-widget-${position}`;
|
|
944
|
+
}
|
|
945
|
+
else {
|
|
946
|
+
position = screenWidth - x < screenHeight - y ? "right" : "bottom";
|
|
947
|
+
widgetClassName = `io-window-widget ${position === "right" ? "io-window-widget-right" : ""}`;
|
|
948
|
+
}
|
|
949
|
+
widgetElem.className = widgetClassName;
|
|
950
|
+
setSelectedPosition(position);
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
const DragSection = () => {
|
|
954
|
+
return (React.createElement("div", { className: "drag-element" },
|
|
955
|
+
React.createElement("div", null),
|
|
956
|
+
React.createElement("div", null),
|
|
957
|
+
React.createElement("div", null),
|
|
958
|
+
React.createElement("div", null),
|
|
959
|
+
React.createElement("div", null),
|
|
960
|
+
React.createElement("div", null),
|
|
961
|
+
React.createElement("div", null),
|
|
962
|
+
React.createElement("div", null)));
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
var jsxRuntime = {exports: {}};
|
|
966
|
+
|
|
967
|
+
var reactJsxRuntime_production_min = {};
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* @license React
|
|
971
|
+
* react-jsx-runtime.production.min.js
|
|
972
|
+
*
|
|
973
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
974
|
+
*
|
|
975
|
+
* This source code is licensed under the MIT license found in the
|
|
976
|
+
* LICENSE file in the root directory of this source tree.
|
|
977
|
+
*/
|
|
978
|
+
var f$1=React,k$1=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p$1={key:!0,ref:!0,__self:!0,__source:!0};
|
|
979
|
+
function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p$1.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k$1,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
|
|
980
|
+
|
|
981
|
+
{
|
|
982
|
+
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
986
|
+
|
|
987
|
+
var propTypes = {exports: {}};
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
991
|
+
*
|
|
992
|
+
* This source code is licensed under the MIT license found in the
|
|
993
|
+
* LICENSE file in the root directory of this source tree.
|
|
994
|
+
*/
|
|
995
|
+
|
|
996
|
+
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
997
|
+
|
|
998
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1002
|
+
*
|
|
1003
|
+
* This source code is licensed under the MIT license found in the
|
|
1004
|
+
* LICENSE file in the root directory of this source tree.
|
|
1005
|
+
*/
|
|
1006
|
+
|
|
1007
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
1008
|
+
|
|
1009
|
+
function emptyFunction() {}
|
|
1010
|
+
function emptyFunctionWithReset() {}
|
|
1011
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
1012
|
+
|
|
1013
|
+
var factoryWithThrowingShims = function() {
|
|
1014
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
1015
|
+
if (secret === ReactPropTypesSecret) {
|
|
1016
|
+
// It is still safe when called from React.
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
var err = new Error(
|
|
1020
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
1021
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
1022
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
1023
|
+
);
|
|
1024
|
+
err.name = 'Invariant Violation';
|
|
1025
|
+
throw err;
|
|
1026
|
+
} shim.isRequired = shim;
|
|
1027
|
+
function getShim() {
|
|
1028
|
+
return shim;
|
|
1029
|
+
} // Important!
|
|
1030
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
1031
|
+
var ReactPropTypes = {
|
|
1032
|
+
array: shim,
|
|
1033
|
+
bigint: shim,
|
|
1034
|
+
bool: shim,
|
|
1035
|
+
func: shim,
|
|
1036
|
+
number: shim,
|
|
1037
|
+
object: shim,
|
|
1038
|
+
string: shim,
|
|
1039
|
+
symbol: shim,
|
|
1040
|
+
|
|
1041
|
+
any: shim,
|
|
1042
|
+
arrayOf: getShim,
|
|
1043
|
+
element: shim,
|
|
1044
|
+
elementType: shim,
|
|
1045
|
+
instanceOf: getShim,
|
|
1046
|
+
node: shim,
|
|
1047
|
+
objectOf: getShim,
|
|
1048
|
+
oneOf: getShim,
|
|
1049
|
+
oneOfType: getShim,
|
|
1050
|
+
shape: getShim,
|
|
1051
|
+
exact: getShim,
|
|
1052
|
+
|
|
1053
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
1054
|
+
resetWarningCache: emptyFunction
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
1058
|
+
|
|
1059
|
+
return ReactPropTypes;
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
1064
|
+
*
|
|
1065
|
+
* This source code is licensed under the MIT license found in the
|
|
1066
|
+
* LICENSE file in the root directory of this source tree.
|
|
1067
|
+
*/
|
|
1068
|
+
|
|
1069
|
+
{
|
|
1070
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
1071
|
+
// http://fb.me/prop-types-in-prod
|
|
1072
|
+
propTypes.exports = factoryWithThrowingShims();
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
var propTypesExports = propTypes.exports;
|
|
1076
|
+
|
|
1077
|
+
const extractErrorMsg = (error) => {
|
|
1078
|
+
const errorMessage = error.message ? JSON.stringify(error.message) : JSON.stringify(error);
|
|
1079
|
+
const stringError = typeof error === "string" ? error : errorMessage;
|
|
1080
|
+
return stringError;
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
const useIOConnectInit = (settings, onInitError) => {
|
|
1084
|
+
const [io, setIOConnect] = React.useState(null);
|
|
1085
|
+
React.useEffect(() => {
|
|
1086
|
+
const initialize = async () => {
|
|
1087
|
+
try {
|
|
1088
|
+
if (settings.browser && settings.browserPlatform) {
|
|
1089
|
+
throw new Error("Cannot initialize, because the settings are over-specified: defined are both browser and browserPlatform. Please set one or the other");
|
|
1090
|
+
}
|
|
1091
|
+
const isDesktop = (typeof window.glue42gd !== "undefined") || (typeof window.iodesktop !== "undefined");
|
|
1092
|
+
if (isDesktop) {
|
|
1093
|
+
const factory = settings.desktop?.factory || settings.browser?.factory || settings.browserPlatform?.factory || window.Glue;
|
|
1094
|
+
const config = settings.desktop?.config || settings.browser?.config || settings.browserPlatform?.config;
|
|
1095
|
+
const factoryResult = await factory(config);
|
|
1096
|
+
setIOConnect(factoryResult.io || factoryResult.glue || factoryResult);
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
const config = settings.browser?.config || settings.browserPlatform?.config;
|
|
1100
|
+
const factory = settings.browser?.factory || settings.browserPlatform?.factory || window.IOBrowser || window.IOBrowserPlatform;
|
|
1101
|
+
const factoryResult = await factory(config);
|
|
1102
|
+
setIOConnect(factoryResult.io || factoryResult.glue || factoryResult);
|
|
1103
|
+
}
|
|
1104
|
+
catch (error) {
|
|
1105
|
+
console.error(error);
|
|
1106
|
+
onInitError?.(error instanceof Error ? error : new Error(extractErrorMsg(error)));
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
initialize();
|
|
1110
|
+
}, []);
|
|
1111
|
+
return io;
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
const IOConnectContext = React.createContext(null);
|
|
1115
|
+
const IOConnectProvider = React.memo(({ children, fallback = null, settings = {}, onInitError }) => {
|
|
1116
|
+
const glue = useIOConnectInit(settings, onInitError);
|
|
1117
|
+
return glue ? (React.createElement(IOConnectContext.Provider, { value: glue }, children)) : (React.createElement(React.Fragment, null, fallback));
|
|
1118
|
+
});
|
|
1119
|
+
IOConnectProvider.propTypes = {
|
|
1120
|
+
children: propTypesExports.node,
|
|
1121
|
+
settings: propTypesExports.object,
|
|
1122
|
+
fallback: propTypesExports.node,
|
|
1123
|
+
};
|
|
1124
|
+
IOConnectProvider.displayName = 'IOConnectProvider';
|
|
1125
|
+
|
|
1126
|
+
function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p,b={exports:{}};
|
|
1127
|
+
/*!
|
|
1128
|
+
Copyright (c) 2018 Jed Watson.
|
|
1129
|
+
Licensed under the MIT License (MIT), see
|
|
1130
|
+
http://jedwatson.github.io/classnames
|
|
1131
|
+
*/p=b,function(){var e={}.hasOwnProperty;function t(){for(var e="",t=0;t<arguments.length;t++){var o=arguments[t];o&&(e=i(e,n(o)));}return e}function n(n){if("string"==typeof n||"number"==typeof n)return n;if("object"!=typeof n)return "";if(Array.isArray(n))return t.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var o="";for(var a in n)e.call(n,a)&&n[a]&&(o=i(o,a));return o}function i(e,t){return t?e?e+" "+t:e+t:e}p.exports?(t.default=t,p.exports=t):window.classNames=t;}();var v=f(b.exports);function y({className:t,size:n="16",variant:i="workspace",...o}){const a=v(t,"icon",{[`icon-size-${n}`]:n});return jsxRuntimeExports.jsx("span",{className:a,...o,children:jsxRuntimeExports.jsx("i",{className:`icon-${i}`})})}function w({className:i="io-alert",variant:o="low",title:a="Alert title",text:s,children:r,...l}){const c=v(i,o);return jsxRuntimeExports.jsx("div",{className:c,...l,children:a&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("h3",{className:`io-color-${o}`,children:[jsxRuntimeExports.jsx(y,{variant:{info:"circle-info",low:"circle-info",medium:"circle-info",high:"triangle-exclamation",critical:"ban"}[o],size:"12"}),a]}),s&&jsxRuntimeExports.jsx("p",{children:s}),r]})})}function N({className:t="io-badge",variant:n="default",children:i,...o}){const a=v(t,{[`${t}-${n}`]:"default"!==n});return jsxRuntimeExports.jsx("div",{className:a,...o,children:i})}function S({className:t="io-title",tag:n="h2",size:i="normal",text:o="Title",...a}){const s=n,r=v({[`${t}-semibold`]:"small"===i,[t]:"normal"===i,[`${t}-${i}`]:"large"===i});return jsxRuntimeExports.jsx(s,{className:r,...a,children:o})}function k({className:n="io-block",title:i,titleSize:o="normal",tag:a,hint:s,children:r,...l}){return jsxRuntimeExports.jsxs("div",{className:n,...l,children:[i&&jsxRuntimeExports.jsx(S,{tag:a,text:i,size:o}),r,s&&jsxRuntimeExports.jsx("p",{className:"io-text-smaller",children:s})]})}function C({className:n="io-btn",variant:o="default",size:a="normal",icon:s,iconRight:r=!1,text:l,onClick:c,disabled:d,children:u,...h}){const m=v(n,{[`${n}-${o}`]:"primary"===o||"outline"===o||"link"===o,[`${n}-lg`]:"large"===a}),g=React.useCallback((e=>{if(!d)return c?c(e):void 0;e.preventDefault();}),[c,d]);return jsxRuntimeExports.jsxs("button",{type:"button",className:m,"aria-label":"button",onClick:g,disabled:d,tabIndex:0,...h,children:[s&&!r&&jsxRuntimeExports.jsx(y,{variant:s,size:"12"}),u??l,s&&r&&jsxRuntimeExports.jsx(y,{variant:s,size:"12"})]})}function B({className:t="io-btn-icon",variant:n="default",icon:o="workspace",size:a="16",iconSize:s="16",onClick:r,disabled:l,children:c,...d}){const u=v(t,{[`${t}-${n}`]:"default"!==n,[`${t}-size-${a}`]:"24"===a||"32"===a}),h=React.useCallback((e=>{if(!l)return r?r(e):void 0;e.preventDefault();}),[r,l]);return jsxRuntimeExports.jsx("button",{type:"button",className:u,"aria-label":"button",onClick:h,disabled:l,...d,children:c??(o&&jsxRuntimeExports.jsx(y,{variant:o,size:s}))})}const x=React.createContext({});const I=React.createContext({});function $({className:n="io-list",prepend:o,append:s,isSelected:r,disabled:l=!1,children:c,...d}){const{variant:u,selected:h,checkIcon:m,handleItemClick:g}=React.useContext(I),f=r??h?.some((e=>e.children===c)),p=v(`${n}-item`,{selected:"default"!==u&&f,[`${n}-item-disabled`]:l}),b=React.useCallback(((e,t)=>{l?e.preventDefault():g&&g(e,t);}),[g,l]);return jsxRuntimeExports.jsxs("li",{className:p,role:"menuitem","aria-roledescription":"menuitem",tabIndex:0,onClick:e=>b(e,{children:c}),...d,children:[(m&&"none"!==m||o)&&jsxRuntimeExports.jsxs("div",{className:`${n}-left-column`,children:["default"!==u&&"none"!==m&&jsxRuntimeExports.jsx(y,{variant:m}),o]}),jsxRuntimeExports.jsx("span",{className:`${n}-text`,children:c}),s&&jsxRuntimeExports.jsx("div",{className:`${n}-right-column`,children:s})]})}function T({className:n="io-list-item io-list-item-title",prepend:i,append:o,children:a,...s}){return jsxRuntimeExports.jsxs("li",{className:n,...s,children:[i,jsxRuntimeExports.jsx("span",{className:"io-list-text",children:a}),o]})}function A({className:n="io-list-item io-list-item-section",prepend:i,append:o,children:a,...s}){return jsxRuntimeExports.jsxs("li",{className:n,...s,children:[i,jsxRuntimeExports.jsx("span",{className:"io-list-text",children:a}),o]})}function P({className:t="io-list",variant:n="default",checkIcon:i="none",children:o,...a}){const[r,l]=React.useState([]),c=v(t,{[`${t}-selectable`]:"default"!==n});return jsxRuntimeExports.jsx(I.Provider,{value:{variant:n,selected:r,checkIcon:i,handleItemClick:(e,t)=>{if("single"===n)l([t]);else {const e=r.some((e=>e.children?.toString()===t.children?.toString())),n=r.filter((e=>e.children!==t.children));l(e?n:[...r,t]);}}},children:jsxRuntimeExports.jsx("ul",{className:c,...a,children:o})})}function F(e,t){React.useEffect((()=>{const n=n=>{e.current&&!e.current.contains(n.target)&&t();};return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n);}}),[e,t]);}function L({className:t="io-dropdown",variant:n="default",align:o="down",disabled:a,children:r,...c}){const[d,u]=React.useState(!1),h=React.useRef(null),m=v(t,{[`${t}-open`]:d,[`${t}-${n}`]:"default"!==n}),g=React.useCallback((()=>{u(!d);}),[d]);return F(h,React.useCallback((()=>{u(!1);}),[])),jsxRuntimeExports.jsx(x.Provider,{value:{isOpen:d,handleOpen:g,variant:n,align:o,disabled:a},children:jsxRuntimeExports.jsx("div",{className:m,ref:h,...c,children:r})})}function z({className:t="io-btn-group",variant:n="default",align:i="left",children:o,...a}){const s=v(t,{[`${t}-sticky`]:"sticky"===n,[`${t}-append`]:"append"===n,[`${t}-fullwidth`]:"fullwidth"===n,[`${t}-right`]:"right"===i});return jsxRuntimeExports.jsx("div",{className:s,...a,children:o})}function _({className:t="io-header",draggable:n=!1,children:i,...o}){const a=v(t,{draggable:n});return jsxRuntimeExports.jsx("header",{className:a,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--spacing-8)"},...o,children:i})}function E({className:t="io-dialog-header",children:n,...i}){return jsxRuntimeExports.jsx(_,{className:t,...i,children:n})}function D({className:t="io-dialog-body",children:n,...i}){return jsxRuntimeExports.jsx("div",{className:t,...i,children:n})}function H({className:t="io-footer",children:n,...i}){return jsxRuntimeExports.jsx("footer",{className:t,...i,children:n})}function O({className:t="io-dialog-footer",...n}){return jsxRuntimeExports.jsx(H,{className:t,...n})}function M({className:n="io-loader",size:i="large",variant:o="default",align:a="up",text:s,...r}){const l=v(n,{[`${n}-${o}`]:"default"!==o,[`${n}-md`]:"normal"===i,[`${n}-sm`]:"small"===i,[`direction-${a}`]:a});return jsxRuntimeExports.jsxs("div",{className:l,...r,children:[jsxRuntimeExports.jsx("div",{className:`${n}-icon`}),s&&jsxRuntimeExports.jsx("div",{className:`${n}-text`,children:s})]})}function V({className:t="io-panel-header",children:n,...i}){return jsxRuntimeExports.jsx(_,{className:t,...i,children:n})}P.Item=$,P.ItemTitle=T,P.ItemSection=A,L.Button=function({icon:t="chevron-down",...n}){const{handleOpen:o,disabled:s}=React.useContext(x),r=React.useCallback((e=>{e.stopPropagation(),o&&o();}),[o]);return jsxRuntimeExports.jsx(C,{icon:t,iconRight:!0,onClick:r,disabled:s,...n})},L.ButtonIcon=function({size:t="32",...n}){const{handleOpen:o,disabled:s}=React.useContext(x),r=React.useCallback((()=>{o&&o();}),[o]);return jsxRuntimeExports.jsx(B,{size:t,onClick:r,disabled:s,...n})},L.Content=function({className:t="io-dropdown-content",...n}){const{handleOpen:o}=React.useContext(x),s=React.useCallback((e=>{e.stopPropagation(),o&&o();}),[o]);return jsxRuntimeExports.jsx("div",{className:t,role:"button",onClick:s,...n})},L.List=P,L.Item=$,L.ItemTitle=T,L.ItemSection=A,z.Button=C,z.ButtonIcon=B,z.Dropdown=L,_.Title=S,_.ButtonGroup=z,_.Button=C,_.ButtonIcon=B,_.Dropdown=L,E.Title=S,E.ButtonGroup=z,E.Button=C,E.ButtonIcon=B,E.Dropdown=L,D.Content=function({className:t="io-dialog-content",children:n,...i}){return jsxRuntimeExports.jsx("div",{className:t,...i,children:n})},H.ButtonGroup=z,H.Button=C,H.ButtonIcon=B,H.Dropdown=L,O.ButtonGroup=z,O.Button=C,O.ButtonIcon=B,O.Dropdown=L,V.Title=S,V.ButtonGroup=z,V.Button=C,V.ButtonIcon=B,V.Dropdown=L;const R=React.forwardRef((({className:t="io-panel-body",children:n,...i},o)=>jsxRuntimeExports.jsx("div",{className:t,ref:o,...i,children:n})));function J({className:t="io-panel-footer",...n}){return jsxRuntimeExports.jsx(H,{className:t,...n})}function U({className:t="io-panel",children:n,...i}){return jsxRuntimeExports.jsx("div",{className:t,...i,children:n})}function Q({className:t="io-progress",variant:n="active",value:i=0,...o}){return jsxRuntimeExports.jsx("div",{className:`${t} ${n}`,...o,children:jsxRuntimeExports.jsx("div",{className:`${t}-bar`,style:{width:`${i<0?0:i>100?100:i}%`}})})}function Y({text:t="Label",...n}){return jsxRuntimeExports.jsx("label",{...n,children:t})}R.displayName="PanelBody",J.ButtonGroup=z,J.Button=C,J.ButtonIcon=B,J.Dropdown=L,U.Header=V,U.Body=R,U.Footer=J;const K=React.forwardRef((function({id:n="input",className:i="io",type:o="text",name:a="input",align:s="up",label:r,iconPrepend:l,iconAppend:c,placeholder:d,disabled:u,readOnly:h,...m},g){const f=v(`${i}-control-input`,{[`${i}-control-leading-icon`]:l,[`${i}-control-trailing-icon`]:c,[`${i}-control-disabled`]:u,[`${i}-control-readonly`]:h,[`direction-${s}`]:s});return jsxRuntimeExports.jsxs("div",{className:f,children:[r&&jsxRuntimeExports.jsx(Y,{htmlFor:n,text:r}),l&&jsxRuntimeExports.jsx(y,{variant:l}),jsxRuntimeExports.jsx("input",{id:n,className:`${i}-input`,ref:g,type:o,name:a,tabIndex:0,placeholder:d||(()=>{switch(o){case"email":return "Enter your email here...";case"number":return "Enter number here...";case"password":return "Enter your password here...";case"tel":return "Enter your phone number here...";case"file":return "Select a file...";default:return "Enter text here..."}})(),disabled:u,readOnly:h,...m}),c&&jsxRuntimeExports.jsx(y,{variant:c})]})})),W=React.forwardRef((function({id:n="textarea",className:i="io",name:o="textarea",align:a="up",label:s,rows:r=4,placeholder:l="Enter text here...",disabled:c,readOnly:d,...u},h){const m=v(`${i}-control-textarea`,{[`${i}-control-disabled`]:c,[`${i}-control-readonly`]:d,[`direction-${a}`]:a});return jsxRuntimeExports.jsxs("div",{className:m,children:[s&&jsxRuntimeExports.jsx(Y,{htmlFor:n,text:s}),jsxRuntimeExports.jsx("textarea",{id:n,className:`${i}-textarea`,ref:h,name:o,tabIndex:0,placeholder:l,disabled:c,readOnly:d,rows:r,...u})]})})),X=React.forwardRef((function({id:n="checkbox",className:i="io",name:o="checkbox",align:a="left",label:s,checked:r,disabled:l,...c},d){const u=v(`${i}-control-checkbox`,{[`${i}-control-checked`]:r,[`${i}-control-disabled`]:l,[`direction-${a}`]:a});return jsxRuntimeExports.jsxs("div",{className:u,children:[jsxRuntimeExports.jsx("input",{type:"checkbox",id:n,className:`${i}-checkbox`,ref:d,name:o,tabIndex:0,checked:r,disabled:l,...c}),s&&jsxRuntimeExports.jsx(Y,{htmlFor:n,text:s})]})}));React.forwardRef((function({id:n="radio",className:i="io",name:o="radio",align:a="left",label:s,checked:r,disabled:l,...c},d){const u=v(`${i}-control-radio`,{[`${i}-control-checked`]:r,[`${i}-control-disabled`]:l,[`direction-${a}`]:a});return jsxRuntimeExports.jsxs("div",{className:u,children:[jsxRuntimeExports.jsx("input",{type:"radio",id:n,className:`${i}-radio`,ref:d,name:o,tabIndex:0,checked:r,disabled:l,...c}),s&&jsxRuntimeExports.jsx(Y,{htmlFor:n,text:s})]})}));const ee=React.forwardRef((function({id:n="toggle",className:i="io",name:o="toggle",align:a="left",label:s="Toggle",checked:r,disabled:l,...c},d){const u=v(`${i}-control-toggle`,{[`${i}-control-checked`]:r,[`${i}-control-disabled`]:l,[`direction-${a}`]:a});return jsxRuntimeExports.jsx("div",{className:u,children:jsxRuntimeExports.jsxs("label",{className:`${i}-toggle`,tabIndex:0,children:[jsxRuntimeExports.jsx("input",{type:"checkbox",id:n,className:`${i}-checkbox`,ref:d,name:o,checked:r,disabled:l,...c}),jsxRuntimeExports.jsx("span",{className:"slider"}),s]})})}));function ne(e,t){const n=React.useCallback((n=>{t.some((e=>n.key===e))&&(n.preventDefault(),e());}),[e,t]);React.useEffect((()=>(document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n);})),[n]);}function ae(e,t=500){const[n,i]=React.useState(e);return React.useEffect((()=>{const n=setTimeout((()=>{i(e);}),t);return ()=>clearTimeout(n)}),[e,t]),n}React.createContext({theme:"dark"});function ue(e,t,n){return Math.min(Math.max(e,n),t)}class he extends Error{constructor(e){super(`Failed to parse color: "${e}"`);}}var me=he;function ge(e){if("string"!=typeof e)throw new me(e);if("transparent"===e.trim().toLowerCase())return [0,0,0,0];let t=e.trim();t=Se.test(e)?function(e){const t=e.toLowerCase().trim(),n=pe[function(e){let t=5381,n=e.length;for(;n;)t=33*t^e.charCodeAt(--n);return (t>>>0)%2341}(t)];if(!n)throw new me(e);return `#${n}`}(e):e;const n=ve.exec(t);if(n){const e=Array.from(n).slice(1);return [...e.slice(0,3).map((e=>parseInt(be(e,2),16))),parseInt(be(e[3]||"f",2),16)/255]}const i=ye.exec(t);if(i){const e=Array.from(i).slice(1);return [...e.slice(0,3).map((e=>parseInt(e,16))),parseInt(e[3]||"ff",16)/255]}const o=we.exec(t);if(o){const e=Array.from(o).slice(1);return [...e.slice(0,3).map((e=>parseInt(e,10))),parseFloat(e[3]||"1")]}const a=Ne.exec(t);if(a){const[t,n,i,o]=Array.from(a).slice(1).map(parseFloat);if(ue(0,100,n)!==n)throw new me(e);if(ue(0,100,i)!==i)throw new me(e);return [...Ce(t,n,i),Number.isNaN(o)?1:o]}throw new me(e)}const fe=e=>parseInt(e.replace(/_/g,""),36),pe="1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce(((e,t)=>{const n=fe(t.substring(0,3)),i=fe(t.substring(3)).toString(16);let o="";for(let e=0;e<6-i.length;e++)o+="0";return e[n]=`${o}${i}`,e}),{});const be=(e,t)=>Array.from(Array(t)).map((()=>e)).join(""),ve=new RegExp(`^#${be("([a-f0-9])",3)}([a-f0-9])?$`,"i"),ye=new RegExp(`^#${be("([a-f0-9]{2})",3)}([a-f0-9]{2})?$`,"i"),we=new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${be(",\\s*(\\d+)\\s*",2)}(?:,\\s*([\\d.]+))?\\s*\\)$`,"i"),Ne=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,Se=/^[a-z]+$/i,ke=e=>Math.round(255*e),Ce=(e,t,n)=>{let i=n/100;if(0===t)return [i,i,i].map(ke);const o=(e%360+360)%360/60,a=(1-Math.abs(2*i-1))*(t/100),s=a*(1-Math.abs(o%2-1));let r=0,l=0,c=0;o>=0&&o<1?(r=a,l=s):o>=1&&o<2?(r=s,l=a):o>=2&&o<3?(l=a,c=s):o>=3&&o<4?(l=s,c=a):o>=4&&o<5?(r=s,c=a):o>=5&&o<6&&(r=a,c=s);const d=i-a/2;return [r+d,l+d,c+d].map(ke)};function Be(e){return function(e){if("transparent"===e)return 0;function t(e){const t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}const[n,i,o]=ge(e);return .2126*t(n)+.7152*t(i)+.0722*t(o)}(e)>.179}function xe({className:t="io-channel-badge",channel:n,...i}){return jsxRuntimeExports.jsx("div",{className:t,style:{color:(o=n.color,Be(o)?"#000":"#fff"),backgroundColor:n.color},...i,children:n.label});var o;}const Ie=React.createContext({});function $e({channel:o,isSelected:s,onChannelSelect:r,...l}){const{variant:c,selectedChannels:d}=React.useContext(Ie),u=s||o.isSelected||d?.includes(o),h=React.useCallback((e=>{r&&r(e);}),[r]);return jsxRuntimeExports.jsx($,{prepend:jsxRuntimeExports.jsx(xe,{channel:o}),append:jsxRuntimeExports.jsx("single"===c?()=>u&&jsxRuntimeExports.jsx(y,{variant:"check"})||null:()=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{onClick:e=>e.stopPropagation(),children:jsxRuntimeExports.jsx(ee,{label:"Publish",checked:o.write,onChange:()=>h({...o,isSelected:!(!o.read&&(o.write||o.read)),write:!o.write})})}),jsxRuntimeExports.jsx("div",{onClick:e=>e.stopPropagation(),children:jsxRuntimeExports.jsx(ee,{label:"Subscribe",checked:o.read,onChange:()=>h({...o,isSelected:!(!o.write&&(o.write||o.read)),read:!o.read})})})]}),{}),isSelected:u,onClick:()=>{h("single"===c?{...o,isSelected:!u}:{...o,isSelected:!u,read:!u,write:!u});},...l,children:o.name},o.name)}const Te=React.forwardRef((({className:n="io-list-channels",variant:i="single",variantToggle:o=!1,channels:a=[],onVariantChange:s,onChannelSelect:r,...l},c)=>{const d=v(n,{"io-bi-direction":"directionalSingle"===i}),u=a.filter((e=>e.isSelected));return jsxRuntimeExports.jsx(Ie.Provider,{value:{variant:i,selectedChannels:u,onVariantChange:s,onChannelSelect:r},children:jsxRuntimeExports.jsx("div",{className:d,ref:c,children:jsxRuntimeExports.jsxs(P,{variant:"single",...l,children:[jsxRuntimeExports.jsx(P.ItemTitle,{append:o&&jsxRuntimeExports.jsx(ee,{label:"Directional",align:"right",onChange:e=>s&&s(e.target.checked),checked:"directionalSingle"===i}),children:"single"===i?"Select Channel":"Select Directional Channel"}),a?.map((t=>jsxRuntimeExports.jsx($e,{channel:t,onChannelSelect:r},t.name)))]})})})}));Te.displayName="ChannelSelector";var Ae=Object.freeze({__proto__:null,Channel:$e,ChannelBadge:xe,ChannelSelector:Te,useIOCDChannels:function(e){const t="T42.ChannelSelector.Execute",n=React.useContext(IOConnectContext),[o,c]=React.useState(null),[u,h]=React.useState(""),[m,f]=React.useState(!1),[p,b]=React.useState(),[v,y]=React.useState("single"),w=React.useRef(),N=n?.windows.my(),S=React.useCallback(((e,t,i)=>{if("will-show"===e.command){(async()=>{w.current=i,c([]),f(!0);const t=e.windowId,o=e.channels,a=o.find((e=>e.isSelected));let s=a?.name;if(void 0===s){const e=n?.windows.findById(t);s=await(e?.getChannel());}y(e.variant),h(t),c(function(e,t){const n=Array.from({length:e.length},((e,t)=>String.fromCharCode(t+65)));return e.map(((e,i)=>{const o=e.meta;return {key:e.name,color:o.color,name:e.name,isSelected:e.name===t,label:n[i],write:e.write,read:e.read}}))}(o,s)),f(!1);})().catch((e=>{b(e),f(!1);}));}}),[n?.windows]),k=React.useCallback((({name:e,read:t,write:i,isSelected:a})=>{const s=()=>{if("directionalSingle"!==v)return N?.hide()},r=o?.find((e=>e.isSelected))?.name;("single"===v?r===e:r===e&&!t&&!i)?n?.channels.leave(u).finally((()=>{s();})):n?.channels.join(e,u).finally((()=>{s();}));const l=n?.channels;"directionalSingle"===v&&"function"==typeof l?.restrict&&l?.restrict({name:e,read:t,write:i,windowId:u}),c((n=>n?n.map((n=>n.name===e?{...n,isSelected:a,read:t,write:i}:{...n,isSelected:!1,read:!1,write:!1})):n));}),[n?.channels,o,v,N,u]);return ne((()=>{N?.hide();}),["Escape"]),React.useEffect((()=>{const e=N?.onClosing((async e=>(e({showDialog:!1}),Promise.resolve())));return e}),[N]),React.useLayoutEffect((()=>{if(e?.current&&o&&o.length>0){const{height:t,width:n,x:i,y:o}=e.current.getBoundingClientRect();w.current&&t>0&&w.current({height:t,width:n,x:i,y:o});}}),[o,e]),React.useEffect((()=>((async()=>{await(n?.interop.registerAsync(t,S));})(),()=>{n?.interop.unregister(t);})),[n?.interop,S]),{onChannelSelected:k,variant:v,isLoading:m,channels:o,error:p}}});React.createContext({config:{message:""},theme:"dark",setResult:()=>{}});function Ve({title:n="Downloads"}){const{ItemSearch:i,HeaderButtons:o}=ut();return jsxRuntimeExports.jsxs("div",{className:"io-dm-header",children:[jsxRuntimeExports.jsxs(_,{children:[jsxRuntimeExports.jsx(_.Title,{tag:"h1",text:n,size:"large"}),jsxRuntimeExports.jsx(o,{})]}),jsxRuntimeExports.jsx(i,{})]})}const Je=React.createContext({items:[],settings:{},removeItem:()=>{},pauseResumeItem:()=>{},cancelItem:()=>{},clearItems:()=>{},showItemInFolder:()=>{},isSettingsVisible:!1,showSettings:()=>{},hideSettings:()=>{},isSearchVisible:!1,showSearch:()=>{},hideSearch:()=>{},searchQuery:"",setSearch:()=>{},itemsCount:0,setCount:()=>{},chooseDownloadLocation:()=>{},sortItems:()=>[],downloadLocationConfig:{filePaths:[],canceled:!1},isDownloadLocationDialogVisible:!1}),Ue=()=>React.useContext(Je);function qe({className:n="io-header-search",icon:i="search",placeholder:o="Search",...a}){const s=React.useRef(null),{isSearchVisible:c,searchQuery:d,setSearch:u,itemsCount:h}=Ue();return React.useEffect((()=>{c?s.current?.focus():(s.current?.blur(),u(""));}),[c,u]),c?jsxRuntimeExports.jsxs("div",{className:n,children:[jsxRuntimeExports.jsx(K,{ref:s,value:d,iconPrepend:i,placeholder:o,onChange:e=>u(e.target.value),...a}),c&&d.length>0&&jsxRuntimeExports.jsx("p",{className:`${n}-count`,children:`${h} results`})]}):null}function Ge({className:n,...i}){const{SearchButton:o,SettingsButton:a,MoreButton:s}=ut();return jsxRuntimeExports.jsxs(z,{className:n,align:"right",...i,children:[jsxRuntimeExports.jsx(o,{}),jsxRuntimeExports.jsx(a,{}),jsxRuntimeExports.jsx(s,{})]})}function Qe({...t}){const{isSearchVisible:n,showSearch:i,hideSearch:o,items:a}=Ue();return jsxRuntimeExports.jsx(B,{icon:n?"search-filled":"search",variant:"circle",size:"32",onClick:n?o:i,disabled:0===a.length,...t})}function Ye({icon:t="cog",...n}){const{showSettings:i}=Ue();return jsxRuntimeExports.jsx(B,{icon:t,variant:"circle",size:"32",onClick:i,...n})}function Ke({icon:n="ellipsis",...i}){const{items:o,clearItems:a}=Ue(),s=0===o.length;return jsxRuntimeExports.jsxs(L,{variant:"outline",...i,children:[jsxRuntimeExports.jsx(L.ButtonIcon,{icon:n,variant:"circle",size:"32"}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{children:jsxRuntimeExports.jsx(L.Item,{disabled:s,onClick:e=>(e=>{s?e.stopPropagation():a();})(e),children:"Clear All"})})})]})}function We(e,t=!1,n=!1,i=!1){const o=e.getDate(),a=["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()],s=e.getFullYear(),r=e.getHours(),l=e.getMinutes();let c="";return c=l<10?`0${l}`:`${l}`,t?"Today"===t?n?"Today":`Today at ${r}:${c}`:"Yesterday"===t?n?"Yesterday":`Yesterday at ${r}:${c}`:`${r}:${c}`:i?n?`${a} ${o}`:`${a} ${o} at ${r}:${c}`:n?`${a} ${o}, ${s}`:`${a} ${o}, ${s} at ${r}:${c}`}function Xe(e,t={showTime:!0}){const n=new Date(1e3*e),i=new Date,o=Math.round((i-n)/1e3),a=Math.round(o/60),s=i.toDateString()===n.toDateString(),r=new Date(i.setDate(i.getDate()-1)).toDateString()===n.toDateString(),l=i.getFullYear()===n.getFullYear();return t.showTime?o<5?"Just Now":o<60?`${o} seconds ago`:o<90?"about a minute ago":a<60?`${a} minutes ago`:s?We(n,"Today",!1,!0):r?We(n,"Yesterday",!1,!0):l?We(n,!1,!1,!0):We(n):s?"Today":r?"Yesterday":l?We(n,!1,!0,!0):We(n,!1,!0)}function Ze({className:t="io-dm-body",...n}){const{DownloadListEmpty:i,ItemGroup:o,Item:a}=ut(),{items:s,searchQuery:l,setCount:c,sortItems:d}=Ue(),h=d(s),m=ae(l),g=React.useMemo((()=>h.filter((e=>e.displayInfo.filename.toLowerCase().includes(m.toLowerCase())||e.displayInfo.url.toLowerCase().includes(m.toLowerCase())))),[h,m]),f=React.useMemo((()=>g.map((e=>({...e,displayInfo:{...e.displayInfo,startTime:Xe(e.displayInfo.startTime,{showTime:!1})}})))),[g]),p=React.useMemo((()=>Object.values(f.reduce(((e={},t)=>(e[t.displayInfo.startTime]=e[t.displayInfo.startTime]?.concat([])??[],e[t.displayInfo.startTime].push(t),e)),{}))),[f]);return React.useEffect((()=>{c(g.length);}),[g,c]),jsxRuntimeExports.jsx("div",{className:t,...n,children:p&&0!==p.length?p.map((t=>jsxRuntimeExports.jsx(o,{title:String(t[0].displayInfo.startTime)??null,children:t.map((t=>jsxRuntimeExports.jsx(a,{item:t},t.id)))},t[0].id??""))):jsxRuntimeExports.jsx(i,{})})}function et({className:n="io-dm-no-items",icon:i="download",text:o="No downloads to display.",...a}){return jsxRuntimeExports.jsxs("div",{className:n,...a,children:[jsxRuntimeExports.jsx(y,{variant:i}),jsxRuntimeExports.jsx("p",{children:o})]})}function tt({className:n="io-dm-item-group",title:i,children:o,...a}){return jsxRuntimeExports.jsxs("div",{className:n,...a,children:[i&&jsxRuntimeExports.jsx("p",{children:i}),o]})}function nt({className:i="io-dm-item",item:o,...a}){const{ItemHeader:s,ItemBody:r,ItemFooter:l}=ut(),{state:c,url:d,filename:u,receivedBytes:h,totalBytes:m,speed:g,timeRemaining:f}=o.displayInfo;if(!o)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});const p=v(i,{[c]:o.displayInfo.state});return jsxRuntimeExports.jsxs("div",{className:p,...a,children:[jsxRuntimeExports.jsx(s,{itemID:o.id,filename:u,state:c}),jsxRuntimeExports.jsx(r,{state:c,url:d,bytesReceived:h,bytesTotal:m,speed:g,timeRemaining:f}),jsxRuntimeExports.jsx(l,{itemID:o.id,state:c})]})}function it({bytesReceived:t=0,bytesTotal:n=0,...o}){const a=React.useCallback((()=>t&&n?Math.round(t/n*100):0),[t,n]);return jsxRuntimeExports.jsx(Q,{value:a(),...o})}function ot({className:n="io-dm-item-header",itemID:o,filename:a,state:s,cancel:r,remove:l,...c}){const{cancelItem:d,removeItem:u}=Ue(),h=React.useCallback((e=>{r?r(e):d(e);}),[r,d]),m=React.useCallback((e=>{l?l(e):u(e);}),[l,u]);return jsxRuntimeExports.jsxs("div",{className:n,...c,children:[jsxRuntimeExports.jsx(S,{text:a,style:{textDecoration:"interrupted"===s||"cancelled"===s?"line-through":"none"}}),jsxRuntimeExports.jsx(B,{icon:"close",onClick:()=>{"progressing"===s||"paused"===s?h(o):m(o);}})]})}function at({className:n="io-dm-item-body",state:i,url:o,bytesReceived:a=0,bytesTotal:s=0,speed:r=0,timeRemaining:l=0,...c}){const d=e=>{const t=["Bytes","KB","MB","GB","TB"];if(0===e)return "0";const n=Math.floor(Math.log(e)/Math.log(1024));return 0===n?`${e}${t[n]}`:`${(e/1024**n).toFixed(1)}${t[n]}`};return jsxRuntimeExports.jsxs("div",{className:n,...c,children:[jsxRuntimeExports.jsx("p",{className:"io-text-small",children:o}),(h=i,"cancelled"===h||"interrupted"===h||"completed"===h?null:jsxRuntimeExports.jsx(it,{variant:"paused"===h?"paused":"active",bytesReceived:a,bytesTotal:s})),jsxRuntimeExports.jsx("p",{className:"io-text-default-lh16",children:"completed"===i?`${d(a??0)} - Done`:"cancelled"===i||"interrupted"===i?`${d(a??0)}/${d(s??0)} - Failed`:`${d(a??0)}/${d(s??0)} (${u=r,(u?`${(u/1e6/8).toFixed(2)}MB/s`:0)??0}) - ${(e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60);let i="";return t>0&&(i+=`${t} hour${t>1?"s":""}, `),n>0&&(i+=`${n} min${n>1?"s":""}, `),((e=Math.floor(e%60))>0||""===i)&&(i+=`${e} sec${1!==e?"s":""}`),`${i.trim()} left`})(l)??0}`})]});var u,h;}function st({className:o="io-dm-item-footer",itemID:a,state:s,pauseResume:r,showInFolder:l,cancel:c,...d}){const{pauseResumeItem:u,showItemInFolder:h,cancelItem:m}=Ue(),g=React.useCallback((e=>{r?r(e):u(e);}),[r,u]),f=React.useCallback((e=>{l?l(e):h(e);}),[l,h]),p=React.useCallback((e=>{c?c(e):m(e);}),[c,m]);return jsxRuntimeExports.jsx("div",{className:o,...d,children:(()=>{switch(s){case"progressing":return jsxRuntimeExports.jsxs(z,{align:"right",children:[jsxRuntimeExports.jsx(z.Button,{variant:"primary",text:"Pause",onClick:()=>g(a)}),jsxRuntimeExports.jsx(z.Button,{variant:"link",text:"Cancel",onClick:()=>p(a)})]});case"paused":return jsxRuntimeExports.jsx(z,{align:"right",children:jsxRuntimeExports.jsx(z.Button,{variant:"primary",text:"Resume",onClick:()=>g(a)})});case"completed":return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(w,{variant:"medium",title:"Complete"}),jsxRuntimeExports.jsx(z,{align:"right",children:jsxRuntimeExports.jsx(z.Button,{variant:"primary",text:"Show in Folder",onClick:()=>f(a)})})]});case"cancelled":return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(w,{variant:"high",title:"Cancelled"})});case"interrupted":return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(w,{variant:"critical",title:"Failed"}),jsxRuntimeExports.jsx(z,{align:"right",children:jsxRuntimeExports.jsx(z.Button,{variant:"primary",text:"Retry",onClick:()=>g(a)})})]});default:return null}})()})}function rt({className:n="io-panel io-settings",title:i="Settings",...o}){const{settings:a,hideSettings:s,chooseDownloadLocation:r,isDownloadLocationDialogVisible:l}=Ue(),c=a.downloadLocations?.find((e=>e.selected))?.path??"",d=()=>{r();};return jsxRuntimeExports.jsxs(U,{className:n,...o,children:[jsxRuntimeExports.jsxs(U.Header,{children:[jsxRuntimeExports.jsx(U.Header.Title,{size:"large",text:i,tag:"h1"}),jsxRuntimeExports.jsx(U.Header.ButtonGroup,{children:jsxRuntimeExports.jsx(B,{variant:"circle",icon:"close",size:"32",onClick:()=>{s();},disabled:l})})]}),jsxRuntimeExports.jsx(U.Body,{children:jsxRuntimeExports.jsxs("div",{className:"io-settings-form-group",children:[jsxRuntimeExports.jsx(K,{iconAppend:"expand",label:"Download location",placeholder:"Select a folder",value:c,readOnly:!0,onClick:d,disabled:l}),jsxRuntimeExports.jsx(C,{text:"Browse",onClick:d,disabled:l})]})})]})}const lt={Header:Ve,ItemSearch:qe,HeaderButtons:Ge,SearchButton:Qe,SettingsButton:Ye,MoreButton:Ke,Body:Ze,DownloadListEmpty:et,ItemGroup:tt,Item:nt,ItemProgress:it,ItemHeader:ot,ItemBody:at,ItemFooter:st,Settings:rt},ct=React.createContext(lt),dt=React.memo((({children:t,components:n})=>{const i=React.useMemo((()=>({...lt,...n})),[n]);return jsxRuntimeExports.jsx(ct.Provider,{value:i,children:t})}));dt.displayName="ComponentsStore";const ut=()=>React.useContext(ct);function gt(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,n={};function i(n,i){var o=n instanceof Error?n:new Error(n);if(t)t(o);else {var a='[ERROR] callback-registry: User callback for key "'+i+'" failed: '+o.stack;if(e)switch(e.errorHandling){case"log":return console.error(a);case"silent":return;case"throw":throw new Error(a)}console.error(a);}}return {add:function(e,t,o){var a=n[e];return a||(a=[],n[e]=a),a.push(t),o&&setTimeout((function(){o.forEach((function(o){var a;if(null===(a=n[e])||void 0===a?void 0:a.includes(t))try{Array.isArray(o)?t.apply(void 0,o):t.apply(void 0,[o]);}catch(t){i(t,e);}}));}),0),function(){var i=n[e];i&&(i=i.reduce((function(e,n,i){return n===t&&e.length===i||e.push(n),e}),[]),0===i.length?delete n[e]:n[e]=i);}},execute:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];var a=n[e];if(!a||0===a.length)return [];var s=[];return a.forEach((function(n){try{var o=n.apply(void 0,t);s.push(o);}catch(t){s.push(void 0),i(t,e);}})),s},clear:function(){n={};},clearKey:function(e){n[e]&&delete n[e];}}}gt.default=gt;f(gt);const bt=React.createContext({config:{env:"",region:"",version:"",buildVersion:"",theme:"",isError:!1,mailingList:"",createJiraTicket:!0,sendEmail:!1,attachments:[],applicationTitle:"",allowEditRecipients:!0,attachmentsViewMode:"category",environmentInfo:"",selectedCategories:[],errorMessage:"",showEnvironmentInfo:!1,context:{},technicalInfo:"",sendEmailClient:"Outlook"},onThemeChanged:e=>{},openUrl:()=>{},submit:()=>Promise.resolve({}),setBounds:()=>{},close:e=>{},showMailingList:!0,setShowMailingList:()=>{},attachmentCategories:[],submitInProgress:!1,setSubmitInProgress:()=>{},submitStatus:{type:"success",title:"",text:""},setSubmitStatus:()=>{},submitCompleted:!1,setSubmitCompleted:()=>{},jiraTicketURL:"",setJiraTicketURL:()=>{},submitFeedback:()=>{}}),vt=()=>React.useContext(bt);function yt({...n}){const{config:i,close:o}=vt(),{applicationTitle:a}=i;return jsxRuntimeExports.jsxs(_,{draggable:!0,...n,children:[jsxRuntimeExports.jsx(_.Title,{tag:"h1",text:a?`Feedback Form - ${a}`:"Feedback Form",size:"large"}),jsxRuntimeExports.jsx(_.ButtonGroup,{className:"non-draggable",children:jsxRuntimeExports.jsx(_.ButtonIcon,{variant:"circle",icon:"close",size:"32",onClick:()=>o()})})]})}function wt({className:n="io-panel-body",handleSubmit:i,...o}){const{config:a,submitFeedback:s}=vt(),{IntroField:r,DescriptionField:l,TechInfoField:c,EnvInfoField:d,FileAttachmentsField:u,CategoryAttachmentsField:h,SettingsField:m,MailListField:g}=Ht(),f=i??s,p=`Your feedback will be submitted to the ${a.buildVersion} team and some additional information will be automatically included to help us examine your issue.`;return jsxRuntimeExports.jsxs("form",{className:n,id:"feedback",onSubmit:e=>f(e),...o,children:[jsxRuntimeExports.jsx(r,{children:jsxRuntimeExports.jsx("p",{children:p})}),jsxRuntimeExports.jsx(m,{}),jsxRuntimeExports.jsx(g,{}),jsxRuntimeExports.jsx(l,{}),jsxRuntimeExports.jsx(c,{readOnly:!0}),jsxRuntimeExports.jsx(d,{readOnly:!0}),"file"===a.attachmentsViewMode?jsxRuntimeExports.jsx(u,{}):jsxRuntimeExports.jsx(h,{})]})}function Nt({...n}){const{FooterButtons:i}=Ht(),{openUrl:o,submitInProgress:a,submitStatus:s,jiraTicketURL:r}=vt();return jsxRuntimeExports.jsx(H,{...n,children:jsxRuntimeExports.jsxs("div",a?{className:"flex ai-center jc-between",children:[jsxRuntimeExports.jsx(k,{children:jsxRuntimeExports.jsx("p",{children:s.title})}),jsxRuntimeExports.jsx(M,{align:"right",size:"small"})]}:{className:"flex ai-center jc-between",children:[jsxRuntimeExports.jsxs(k,{children:[jsxRuntimeExports.jsx("p",{className:"error"===s.type?"io-text-error":"",children:s.title}),r&&jsxRuntimeExports.jsx("a",{href:r,onClick:e=>{e.preventDefault(),o(r);},children:r})]}),jsxRuntimeExports.jsx(i,{})]})})}function St({className:t,...n}){const{CloseButton:i}=Ht(),{close:o}=vt();return jsxRuntimeExports.jsx(z,{className:t,...n,children:jsxRuntimeExports.jsx(i,{onClick:()=>o()})})}function kt({className:n,...i}){const{SubmitButton:o,CancelButton:a,CloseButton:s}=Ht(),{close:r,submitCompleted:l}=vt();return l?jsxRuntimeExports.jsx(z,{className:n,...i,children:jsxRuntimeExports.jsx(s,{text:"Close",onClick:()=>r()})}):jsxRuntimeExports.jsxs(z,{className:n,...i,children:[jsxRuntimeExports.jsx(o,{}),jsxRuntimeExports.jsx(a,{onClick:()=>r()})]})}function Ct({text:t="Submit",...n}){return jsxRuntimeExports.jsx(C,{form:"feedback",type:"submit",variant:"primary",text:t,...n})}function Bt({text:t="Cancel",...n}){return jsxRuntimeExports.jsx(C,{variant:"outline",text:t,...n})}function xt({...t}){return jsxRuntimeExports.jsx(C,{variant:"primary",...t})}function It({showField:t=!0,className:n,title:i,hint:o,children:a,...s}){return t?jsxRuntimeExports.jsx(k,{className:n,title:i,hint:o,...s,children:a}):null}function $t({showField:t=!0,className:n,title:i="Description",hint:o,readOnly:a=!1,disabled:s,...r}){return t?jsxRuntimeExports.jsx(k,{className:n,hint:o,title:"",...r,children:jsxRuntimeExports.jsx(W,{id:"description",name:"description",label:i,readOnly:a,disabled:s})}):null}function Tt({showField:t,className:n,title:i="Technical Information",hint:o,fieldValue:a,readOnly:s=!1,disabled:r,...l}){const{config:c}=vt(),d=t??c.errorMessage,u=a??c.errorMessage;return d&&u?jsxRuntimeExports.jsx(k,{className:n,hint:o,...l,children:jsxRuntimeExports.jsx(W,{id:"errorMessage",name:"errorMessage",label:i,value:u,readOnly:s,disabled:r})}):null}function At({showField:t,className:n,title:i="Environment Information",hint:o,fieldValue:a,readOnly:s=!1,disabled:r,...l}){const{config:c}=vt(),d=t??c.showEnvironmentInfo,u=a??c.environmentInfo;return d&&u?jsxRuntimeExports.jsx(k,{className:n,hint:o,...l,children:jsxRuntimeExports.jsx(W,{id:"environmentInfo",name:"environmentInfo",label:i,value:u,readOnly:s,disabled:r})}):null}function Pt({showField:n=!0,className:o="io-block io-block-list-gap",title:a="Attachments",hint:s,readOnly:r=!1,disabled:l,attachments:c,selectedCategories:d,...u}){const{config:h}=vt(),m=c??h.attachments,g=d??h.selectedCategories,f=React.useCallback((e=>!!g&&-1!==g.indexOf(e)),[g]);return n?!m||m.length<=0?jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h2",{className:"io-title",children:"Attachments"}),jsxRuntimeExports.jsx("p",{children:"No Attachments"})]}):jsxRuntimeExports.jsx(k,{className:o,title:a,hint:s,...u,children:jsxRuntimeExports.jsx("div",{className:"file-attachments",children:m.map((t=>jsxRuntimeExports.jsx(X,{id:t.id,name:t.id,label:t.name,readOnly:r,disabled:l,defaultChecked:f(t.category)},t.id)))})}):null}function Ft({showField:t=!0,className:n,title:o="Attachments",hint:a,readOnly:s=!1,disabled:r,categories:l,selectedCategories:c,...d}){const{config:u,attachmentCategories:h}=vt(),m=l??h,g=c??u.selectedCategories,f=React.useCallback((e=>!!g&&-1!==g.indexOf(e)),[g]);return t?!m||m.length<=0?jsxRuntimeExports.jsx("p",{children:"No Attachments"}):jsxRuntimeExports.jsx(k,{className:n,title:o,hint:a,...d,children:jsxRuntimeExports.jsx("div",{className:"category-attachments",children:m.map((t=>jsxRuntimeExports.jsx(ee,{id:t,name:t,align:"right",label:t,readOnly:s,disabled:r,defaultChecked:f(t)},t)))})}):null}function Lt({className:n="io-block io-block-list-gap",title:i,hint:o,showField:a=!0,showJiraTicketField:s,jiraTicketLabel:r="Create Jira Ticket",showSendEmailField:l,sendEmailLabel:c="Send Email",readOnly:d=!1,disabled:u,...h}){const{config:m,showMailingList:g,setShowMailingList:f}=vt();if(!a)return null;const p=s??m.createJiraTicket,b=l??m.sendEmail;return jsxRuntimeExports.jsxs(k,{className:n,hint:o,title:i,...h,children:[p&&jsxRuntimeExports.jsx(ee,{id:"createJiraTicket",name:"createJiraTicket",label:r,align:"right",readOnly:d,disabled:u,defaultChecked:p}),b&&jsxRuntimeExports.jsx(ee,{onChange:()=>{f(!g);},id:"sendEmail",name:"sendEmail",label:c,align:"right",readOnly:d,disabled:u,defaultChecked:b})]})}function zt({showField:t=!0,className:n,title:i="Email List",hint:o="Separate with commas or semicolons.",placehodler:a="john.doe@somedomain.com; jane.doe@otherdomain.com",readOnly:s=!1,disabled:r,...l}){const{config:c,showMailingList:d}=vt();return (t??c.sendEmail)&&d?jsxRuntimeExports.jsx(k,{className:n,hint:o,...l,children:jsxRuntimeExports.jsx(K,{id:"mailingList",name:"mailingList",label:i,placeholder:a,readOnly:s,disabled:r,defaultValue:c.mailingList??""})}):null}const _t={Header:yt,Body:wt,Footer:Nt,HeaderButtons:St,FooterButtons:kt,SubmitButton:Ct,CancelButton:Bt,CloseButton:xt,IntroField:It,DescriptionField:$t,TechInfoField:Tt,EnvInfoField:At,FileAttachmentsField:Pt,CategoryAttachmentsField:Ft,SettingsField:Lt,MailListField:zt},Et=React.createContext(_t),Dt=React.memo((({children:t,components:n})=>{const i=React.useMemo((()=>({..._t,...n})),[n]);return jsxRuntimeExports.jsx(Et.Provider,{value:i,children:t})}));function Ht(e){return {...React.useContext(Et),...e}}Dt.displayName="ComponentsStore";function Mt({...n}){const{HeaderCaption:i,HeaderActions:o,HeaderSearch:a}=ai();return jsxRuntimeExports.jsxs(V,{...n,children:[jsxRuntimeExports.jsx(i,{}),jsxRuntimeExports.jsx(o,{}),jsxRuntimeExports.jsx(a,{})]})}function Vt({className:n="io-panel-header-caption",...i}){const{HeaderCaptionTitle:o,HeaderCaptionCount:a,HeaderCaptionButtons:s}=ai();return jsxRuntimeExports.jsxs("div",{className:n,...i,children:[jsxRuntimeExports.jsx(o,{}),jsxRuntimeExports.jsx(a,{}),jsxRuntimeExports.jsx(s,{})]})}function Jt(e){const t=React.useContext(IOConnectContext),n=t?.appManager,[o,l]=React.useState([]),[c,d]=React.useState(0),u="*",h=React.useCallback((e=>[...e].sort(((e,t)=>{const n=(e.title??e.name).toLowerCase(),i=(t.title??t.name).toLowerCase();return n<i?-1:n>i?1:0}))),[]);return React.useEffect((()=>{if(!n)return;const e=n.onAppAdded((e=>{l((t=>[...t,{title:e.title,name:e.name,hidden:e.hidden}]));}));return ()=>{e();}}),[n]),React.useEffect((()=>{if(!n)return;const e=n.onAppRemoved((e=>{l((t=>t.filter((t=>t.name!==e.name))));}));return ()=>{e();}}),[n,o]),React.useEffect((()=>{if(!n)return;const e=n.onAppChanged((e=>{l((t=>{const n=t.find((t=>t.name===e.name));return [...t.filter((t=>t.name!==e.name)),{title:e.title,name:n?.name,hidden:n?.hidden,allowed:n?.allowed}]}));}));return ()=>{e();}}),[n]),React.useEffect((()=>{const n=e?.allApplications??t.appManager.applications().length;let i=0;const a=[...o],s=e?.sourceFilter;if(void 0===s||!Array.isArray(s.allowed)||!Array.isArray(s.blocked))return;const r=s.allowed,c=s.blocked;0===r.length||-1!==c.indexOf(u)||0===r.length&&0===c.length||-1!==r.indexOf(u)&&-1!==c.indexOf(u)?(i=n,a.forEach((e=>{e.allowed=!1;}))):-1!==r.indexOf(u)&&a.forEach((e=>{e.allowed=!0;})),-1===c.indexOf(u)&&c.length>0&&(i=s.blocked.length),r.forEach((e=>{const t=a.find((t=>t.name===e));t&&(t.allowed=!0);})),c.forEach((e=>{const t=a.find((t=>t.name===e));t&&(t.allowed=!1);})),d(n-i),l(a);}),[e]),{apps:o,allowedApps:c,sortAppsAlphabetically:h}}const qt=React.createContext({allApps:[],settings:{},configuration:{},notifications:[],onClose:()=>{},allApplications:0,clearAll:()=>{},showPanel:()=>{},hidePanel:()=>{},saveFilter:()=>{},clearAllOld:()=>{},notificationStacks:[],isPanelVisible:!1,saveSetting:()=>{},allowedApplications:0,saveAllFilter:()=>{}}),Gt=()=>React.useContext(qt);function Qt({className:n="io-panel-header-caption-filter",...i}){const{allApplications:o,allowedApplications:a}=Gt();return jsxRuntimeExports.jsxs("div",{className:n,...i,children:[jsxRuntimeExports.jsx(y,{variant:"filter"}),jsxRuntimeExports.jsx("span",{className:`${n}-allowed`,children:a}),"of ",jsxRuntimeExports.jsx("span",{className:`${n}-all`,children:o}),"apps"]})}function Yt({text:n="Notifications",counter:i,...o}){const{notifications:a}=Gt(),s=a.length;return jsxRuntimeExports.jsx(S,{text:n,size:"large",...o,children:(i??!0)&&jsxRuntimeExports.jsxs("span",{children:["(",s,")"]})})}const Kt=React.createContext({isSearchVisible:!1,showSearch:()=>{},hideSearch:()=>{},searchQuery:"",setSearch:()=>{},isSettingsVisible:!1,showSettings:()=>{},hideSettings:()=>{},sortNotificationsBy:"newest",setSortBy:()=>{},viewNotificationsBy:"unread",setViewBy:()=>{},notificationsCount:0,setCount:()=>{}}),Wt=()=>React.useContext(Kt);function Xt({...n}){const{HeaderCaptionButtonSearch:i,HeaderCaptionButtonSettings:o,HeaderCaptionButtonClose:a}=ai();return jsxRuntimeExports.jsxs(z,{...n,children:[jsxRuntimeExports.jsx(i,{}),jsxRuntimeExports.jsx(o,{}),jsxRuntimeExports.jsx(a,{})]})}const Zt="newest",en="oldest",tn="severity",nn=["None","Low","Medium","High","Critical"],on={key:Zt,descending:!0},an=e=>[...e].sort(((e,t)=>(t.timestamp||0)-(e.timestamp||0))),sn=e=>[...e].sort(((e,t)=>(e.timestamp||0)-(t.timestamp||0))),rn=(e,t)=>{const n=nn[0];return [...e].sort(((e,i)=>{const o=nn.indexOf(e.severity||n),a=nn.indexOf(i.severity||n);return (t?-1:1)*(o-a)}))},ln={[Zt]:an,[en]:sn,[tn]:rn};function cn({...t}){const[n,i]=React.useState([]),{NotificationsList:o,Notification:a}=ai(),{sortNotificationsBy:c,viewNotificationsBy:d,setCount:h,searchQuery:m,notificationsCount:g}=Wt(),{notifications:f}=Gt(),p=React.useRef(null),b=ae(m),v=React.useMemo((()=>((e,t)=>{if(!e)return [];switch(t){case"all":default:return e;case"unread":return e.filter((e=>"Active"===e.state||"Stale"===e.state));case"read":return e.filter((e=>"Acknowledged"===e.state||"Seen"===e.state));case"snoozed":return e.filter((e=>"Snoozed"===e.state))}})(f,d)),[f,d]),y=React.useMemo((()=>v.filter((e=>e.title.toLowerCase().includes(b.toLowerCase())||e.body?.toLowerCase().includes(b.toLowerCase())))),[v,b]);return React.useEffect((()=>{switch(c){case"newest":i(an(y));break;case"oldest":i(sn(y));break;case"severity":i(rn(y,!0));break;default:i(y);}h(y.length);}),[y,c,h]),React.useEffect((()=>{p.current&&p.current?.scrollTo({top:0,behavior:"smooth"});}),[b,g,c,d]),jsxRuntimeExports.jsx(R,{ref:p,...t,children:jsxRuntimeExports.jsx(o,{notifications:n,Notification:a})})}function dn({...t}){const{FooterButtons:n}=ai();return jsxRuntimeExports.jsx(J,{...t,children:jsxRuntimeExports.jsx(n,{})})}function un({className:n,...i}){const{FooterButtonClearAll:o,FooterButtonClearAllOld:a}=ai(),{notifications:l}=Gt(),[c,d]=React.useState(!1);return React.useEffect((()=>{l.filter((e=>"Stale"===e.state||"Acknowledged"===e.state)).length>0?d(!0):d(!1);}),[l]),jsxRuntimeExports.jsxs(z,{className:n,align:"right",...i,children:[jsxRuntimeExports.jsx(a,{disabled:!c}),jsxRuntimeExports.jsx(o,{disabled:l.length<=0})]})}function hn({text:t="Clear All",...n}){const{clearAll:i}=Gt();return jsxRuntimeExports.jsx(C,{text:t,onClick:()=>{i();},...n})}function mn({text:t="Clear Old",...n}){const{clearAllOld:i}=Gt();return jsxRuntimeExports.jsx(C,{text:t,onClick:()=>{i();},...n})}function gn({className:n="io-panel io-settings",title:i="Settings",...o}){const{SettingsGeneral:a,SettingsPlacement:s,SettingsStacking:r,SettingsSnooze:l,SettingsSubscriptions:c}=ai(),{hideSettings:d}=Wt();return jsxRuntimeExports.jsxs(U,{className:n,...o,children:[jsxRuntimeExports.jsxs(U.Header,{children:[jsxRuntimeExports.jsx(U.Header.Title,{size:"large",text:i,tag:"h1"}),jsxRuntimeExports.jsx(U.Header.ButtonGroup,{children:jsxRuntimeExports.jsx(U.Header.ButtonIcon,{variant:"circle",icon:"close",size:"32",onClick:d})})]}),jsxRuntimeExports.jsxs(U.Body,{children:[jsxRuntimeExports.jsx(a,{}),jsxRuntimeExports.jsx(r,{}),jsxRuntimeExports.jsx(s,{}),jsxRuntimeExports.jsx(l,{}),jsxRuntimeExports.jsx(c,{})]})]})}function fn({className:n="io-panel-settings-general",title:i="General",...o}){const{SettingsAllowNotifications:a,SettingsPanelAutoHide:s,SettingsHideToastsAfter:r}=ai();return jsxRuntimeExports.jsx("div",{className:n,...o,children:jsxRuntimeExports.jsxs(k,{title:i,children:[jsxRuntimeExports.jsx(a,{}),jsxRuntimeExports.jsx(s,{}),jsxRuntimeExports.jsx(r,{})]})})}function pn({label:t="Allow notifications",align:n="right",...o}){const{settings:a,saveSetting:s}=Gt(),r=React.useCallback((e=>{s({enabledNotifications:e});}),[s]);return jsxRuntimeExports.jsx(ee,{label:t,align:n,onChange:e=>r(e.target.checked),checked:a.enabledNotifications,...o})}function bn({label:t="Auto hide panel",align:n="right",...o}){const{settings:a,saveSetting:s}=Gt(),r=React.useCallback((e=>{s({autoHidePanel:e});}),[s]);return jsxRuntimeExports.jsx(ee,{label:t,align:n,onChange:e=>r(e.target.checked),checked:a.autoHidePanel,...o})}function vn({label:t="Panel always on top",align:n="right",...o}){const{settings:a,saveSetting:s}=Gt(),r=React.useCallback((e=>{s({alwaysOnTop:e});}),[s]);return jsxRuntimeExports.jsx(ee,{label:t,align:n,onChange:e=>r(e.target.checked),checked:a.alwaysOnTop,...o})}function yn({className:n="flex jc-between ai-center",title:o="Hide toasts after",items:a=[15,30,45,60],...s}){const{settings:r,saveSetting:l}=Gt(),c=React.useCallback((e=>{e||(e=15e3),r.toastExpiry!==e&&l({toastExpiry:1e3*e});}),[r.toastExpiry,l]),d=e=>e<60?`${e} seconds`:60===e?"1 minute":e/60+" minutes";return jsxRuntimeExports.jsxs("div",{className:n,...s,children:[jsxRuntimeExports.jsx("div",{className:"io-text-clipper "+(r.enabledNotifications?"":"io-text-disabled"),children:jsxRuntimeExports.jsx("span",{children:o})}),jsxRuntimeExports.jsxs(L,{variant:"outline",disabled:!r.enabledNotifications,children:[jsxRuntimeExports.jsx(L.Button,{text:d(r.toastExpiry/1e3??0)}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{variant:"single",children:a.map((t=>jsxRuntimeExports.jsx(L.Item,{onClick:()=>{c(t);},children:d(t)},t)))})})]})]})}function wn({className:n="flex jc-between ai-center",title:i="Highlight new for",...o}){const{settings:a,saveSetting:s}=Gt(),r=["30 seconds","1 minute","5 minutes","Never"];return jsxRuntimeExports.jsxs("div",{className:n,...o,children:[jsxRuntimeExports.jsx("div",{className:"io-text-clipper "+(a.enabledNotifications?"":"io-text-disabled"),children:jsxRuntimeExports.jsx("span",{children:i})}),jsxRuntimeExports.jsxs(L,{variant:"outline",disabled:!a.enabledNotifications,children:[jsxRuntimeExports.jsx(L.Button,{text:r[0]}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{variant:"single",children:r.map((t=>jsxRuntimeExports.jsx(L.Item,{children:t},t)))})})]})]})}function Nn({className:n="flex jc-between ai-center",title:i="Mark as read after",...o}){const{settings:a,saveSetting:s}=Gt(),r=["1 minute","5 minutes","Never"];return jsxRuntimeExports.jsxs("div",{className:n,...o,children:[jsxRuntimeExports.jsx("div",{className:"io-text-clipper "+(a.enabledNotifications?"":"io-text-disabled"),children:jsxRuntimeExports.jsx("span",{children:i})}),jsxRuntimeExports.jsxs(L,{variant:"outline",disabled:!a.enabledNotifications,children:[jsxRuntimeExports.jsx(L.Button,{text:r[0]}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{variant:"single",children:r.map((t=>jsxRuntimeExports.jsx(L.Item,{children:t},t)))})})]})]})}function Sn({className:n="io-panel-settings-stacking",title:i="Stacking",...o}){const{SettingsToastStacking:a,SettingsToastStackBy:s}=ai();return jsxRuntimeExports.jsx("div",{className:n,...o,children:jsxRuntimeExports.jsxs(k,{title:i,children:[jsxRuntimeExports.jsx(a,{}),jsxRuntimeExports.jsx(s,{})]})})}function kn({label:t="Allow toast stacking",align:n="right",...o}){const{settings:a,saveSetting:s}=Gt(),r=React.useCallback((e=>{s({toastStacking:e});}),[s]);return jsxRuntimeExports.jsx(ee,{label:t,align:n,onChange:e=>r(e.target.checked),checked:a.toastStacking,disabled:!a.enabledNotifications,...o})}const Cn=e=>e.replace(/(^|-)\w/g,(e=>e.toUpperCase().replace("-"," ")));function Bn({className:n="flex jc-between ai-center",title:o="Group by",...a}){const{settings:s,saveSetting:r}=Gt(),l=React.useCallback((e=>{e||(e="severity"),s.stackBy!==e&&r({stackBy:e.toLowerCase()});}),[s.stackBy,r]);return jsxRuntimeExports.jsxs("div",{className:n,...a,children:[jsxRuntimeExports.jsx("div",{className:"io-text-clipper "+(s.enabledNotifications?"":"io-text-disabled"),children:jsxRuntimeExports.jsx("span",{children:o})}),jsxRuntimeExports.jsxs(L,{variant:"outline",disabled:!s.enabledNotifications,children:[jsxRuntimeExports.jsx(L.Button,{text:s.stackBy?Cn(s.stackBy):"Severity"}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{variant:"single",children:["Severity","Application"].map((t=>jsxRuntimeExports.jsx(L.Item,{onClick:()=>{l(t);},children:t},t)))})})]})]})}function xn({className:n="io-panel-settings-placement",title:i="Placement",...o}){const{SettingsPlacementPanel:a,SettingsPlacementToasts:s}=ai();return jsxRuntimeExports.jsx("div",{className:n,...o,children:jsxRuntimeExports.jsxs(k,{title:i,children:[jsxRuntimeExports.jsx(a,{}),jsxRuntimeExports.jsx(s,{})]})})}function In({className:n="flex jc-between ai-center",title:o="Panel position",...a}){const{settings:s,saveSetting:r}=Gt(),l=React.useCallback((e=>{e||(e="right"),s.placement?.panel!==e&&r({placement:{...s.placement,panel:e.toLowerCase()}});}),[s.placement,r]);return jsxRuntimeExports.jsxs("div",{className:n,...a,children:[jsxRuntimeExports.jsx("div",{className:"io-text-clipper",children:jsxRuntimeExports.jsx("span",{children:o})}),jsxRuntimeExports.jsxs(L,{variant:"outline",children:[jsxRuntimeExports.jsx(L.Button,{text:s.placement?.panel?Cn(s.placement?.panel):"Right"}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{variant:"single",children:["Right","Left"].map((t=>jsxRuntimeExports.jsx(L.Item,{onClick:()=>{l(t);},children:t},t)))})})]})]})}function $n({className:n="flex jc-between ai-center",title:o="Toasts position",...a}){const{settings:s,saveSetting:r}=Gt(),l=React.useCallback((e=>{if(e||(e="bottom-right"),s.placement?.toasts===e)return;const t=e.replace(/\s+/g,"-").toLowerCase();r({placement:{...s.placement,toasts:t}});}),[s.placement,r]);return jsxRuntimeExports.jsxs("div",{className:n,...a,children:[jsxRuntimeExports.jsx("div",{className:"io-text-clipper",children:jsxRuntimeExports.jsx("span",{children:o})}),jsxRuntimeExports.jsxs(L,{variant:"outline",children:[jsxRuntimeExports.jsx(L.Button,{text:s.placement?.toasts?Cn(s.placement?.toasts):"Bottom Right"}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{variant:"single",children:["Top Right","Top Left","Bottom Right","Bottom Left"].map((t=>jsxRuntimeExports.jsx(L.Item,{onClick:()=>{l(t);},children:t},t)))})})]})]})}function Tn({className:t="io-panel-settings-snooze",title:n="Snooze",...i}){const{SettingsSnoozeDuration:o}=ai(),{settings:a}=Gt();return a.snooze?.enabled?jsxRuntimeExports.jsx("div",{className:t,...i,children:jsxRuntimeExports.jsx(k,{title:n,children:jsxRuntimeExports.jsx(o,{})})}):null}function An({className:n="flex jc-between ai-center",title:o="Default duration",items:a=[60,120,180,300],...s}){const{settings:r,saveSetting:l}=Gt(),c=React.useCallback((e=>{e||(e=6e4),r.snooze&&r.snooze?.duration!==e&&l({snooze:{...r.snooze,duration:1e3*e}});}),[r.snooze,l]),d=e=>e<60?`${e} seconds`:60===e?"1 minute":e/60+" minutes";return r.snooze?.enabled?jsxRuntimeExports.jsxs("div",{className:n,...s,children:[jsxRuntimeExports.jsx("div",{className:"io-text-clipper "+(r.enabledNotifications?"":"io-text-disabled"),children:jsxRuntimeExports.jsx("span",{children:o})}),jsxRuntimeExports.jsxs(L,{variant:"outline",disabled:!r.enabledNotifications,children:[jsxRuntimeExports.jsx(L.Button,{text:d(r.snooze?.duration/1e3??0)}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{variant:"single",children:a.map((t=>jsxRuntimeExports.jsx(L.Item,{onClick:()=>{c(t);},children:d(t)},t)))})})]})]}):null}function Pn({className:n="io-panel-settings-subscriptions",title:i="Subscriptions",...o}){const{SettingsSubscriptionsToggleAll:a,SettingsSubscriptionsToggleApp:s}=ai(),{allApps:r}=Gt(),{sortAppsAlphabetically:l}=Jt(),c=l(r);return jsxRuntimeExports.jsx("div",{className:n,...o,children:jsxRuntimeExports.jsxs(k,{title:i,children:[jsxRuntimeExports.jsx("p",{className:"io-text-section",children:"Apps"}),jsxRuntimeExports.jsx(a,{}),c.map((t=>jsxRuntimeExports.jsx(s,{label:t.title??t.name,app:t},t.name)))]})})}function Fn({label:t="All apps",align:n="right",...o}){const{allApplications:a,allowedApplications:s,settings:r,saveAllFilter:l}=Gt(),c=React.useCallback((e=>{l(e);}),[l]);return jsxRuntimeExports.jsx(ee,{id:"*",align:n,label:t,onChange:e=>c(e.target.checked),checked:s===a,disabled:!r.enabledNotifications,...o})}function Ln({label:t="App",align:n="right",app:o,...a}){const{allApplications:s,allowedApplications:r,allApps:l,settings:c,saveAllFilter:d,saveFilter:u}=Gt(),h=r===s,m=React.useCallback(((e,t)=>{const n=l.map((n=>n.name===t.name?{...n,allowed:e}:n)),i=n.every((e=>!1===e.allowed));i?d(!1):u(n);}),[l,d,u]);return !o||o.hidden?null:jsxRuntimeExports.jsx(ee,{id:o.name,label:t,align:n,onChange:e=>m(e.target.checked,o),checked:h||o.allowed,disabled:!c.enabledNotifications,...a})}function zn({className:n="io-notification-header",notification:i,...o}){const{HeaderCount:a,HeaderBadge:s,HeaderTitle:r,HeaderTimestamp:l,HeaderButtonSnooze:c,HeaderButtonClose:d}=Wn();return jsxRuntimeExports.jsxs("div",{className:n,...o,children:[jsxRuntimeExports.jsx(s,{notification:i}),jsxRuntimeExports.jsx(a,{notification:i}),jsxRuntimeExports.jsx(r,{notification:i}),jsxRuntimeExports.jsx(l,{notification:i}),jsxRuntimeExports.jsxs(z,{children:[jsxRuntimeExports.jsx(c,{notification:i}),jsxRuntimeExports.jsx(d,{notification:i})]})]})}function _n({notification:t,...n}){const{settings:i,isPanelVisible:o,notificationStacks:a}=Gt(),{toastStacking:s,stackBy:r}=i,l="application"===r?"source":r??"source";let c;if(s){const e=a.find((e=>e.key===t[l]));c=e?.items.length??0;}return s&&!o&&c&&c>1?jsxRuntimeExports.jsx(N,{...n,children:c<10?c:"9+"}):null}function En({className:n="io-notification-header-badge",notification:i,...o}){return i&&i.severity&&"None"!==i.severity?jsxRuntimeExports.jsxs("div",{className:n,...o,children:[jsxRuntimeExports.jsx(y,{variant:(e=>{if(!e)return "circle-info";switch(e.toLowerCase()){case"info":case"low":case"medium":default:return "circle-info";case"high":return "triangle-exclamation";case"critical":return "ban"}})(i.severity),size:"12"}),i.severity]}):null}function Dn({className:n="io-notification-header-icon",state:i,severity:o="None",icon:a,...s}){const{isPanelVisible:r}=Gt();return jsxRuntimeExports.jsxs("div",{className:n,...s,children:[a&&jsxRuntimeExports.jsx("span",{className:`${n}-image`,children:jsxRuntimeExports.jsx("img",{src:a,alt:`${n}-${a}`})}),jsxRuntimeExports.jsx("span",{className:`${n}-badge color-${o.toLowerCase()}`,children:r&&"Acknowledged"!==i&&"New"})]})}function Hn({className:t="io-notification-header-title",notification:{appTitle:n},...i}){return jsxRuntimeExports.jsx("div",{className:t,...i,children:n})}function On({className:t="io-notification-timestamp",notification:{timestamp:n,state:i,snooze:o},...a}){return jsxRuntimeExports.jsx("small",o&&"Snoozed"===i?{className:t,...a,children:"Snoozed"}:{className:t,...a,children:Xe(n??0)??"Just Now"})}function jn({notification:{snooze:t,state:n},...o}){const{settings:a}=Gt(),s=React.useCallback((e=>{e.stopPropagation(),t&&t(a.snooze?.duration);}),[t,a.snooze?.duration]);return t&&"Snoozed"!==n&&a.snooze?.enabled?jsxRuntimeExports.jsx(C,{icon:"snooze",variant:"link",text:"Snooze",tabIndex:-1,onClick:s,...o}):null}function Mn({notification:{updateState:t,close:n},...i}){const{isPanelVisible:o}=Gt();return jsxRuntimeExports.jsx(B,{icon:"close",size:"24",tabIndex:-1,onClick:e=>{o?n().catch(console.error):(e.stopPropagation(),t("Acknowledged").catch(console.error));},...i})}function Vn({className:n="io-notification-body",notification:i,...o}){const{BodyIcon:a,BodyTitle:s,BodyDescription:r}=Wn(),{onClick:l}=i,{settings:c}=Gt();return jsxRuntimeExports.jsxs("div",{className:n,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||l({close:!1});},onClick:()=>{c.toastStacking?l({close:!1}):l();},...o,children:[jsxRuntimeExports.jsx(a,{icon:i.icon}),jsxRuntimeExports.jsxs("div",{className:`${n}-content`,children:[jsxRuntimeExports.jsx(s,{text:i.title}),jsxRuntimeExports.jsx(r,{text:i.body})]})]})}function Rn({className:t="io-notification-body-icon",icon:n,...i}){return n?jsxRuntimeExports.jsx("div",{className:t,...i,children:jsxRuntimeExports.jsx("img",{src:n,alt:"notification-icon"})}):null}function Jn({text:t,...n}){return jsxRuntimeExports.jsx(S,{text:t,...n})}function Un({className:t="io-notification-body-description",text:n,...i}){return jsxRuntimeExports.jsx("p",{className:t,...i,children:n})}function qn({className:t="io-notification-footer",notification:n}){const{FooterButton:i}=Wn();return jsxRuntimeExports.jsx("div",{className:t,children:jsxRuntimeExports.jsx(z,{align:"right",children:n.actions?.map(((t,n)=>jsxRuntimeExports.jsx(i,{notificationAction:t,variant:0===n?"primary":"link"},`${t.title+n.toString()}`)))})})}function Gn({notificationAction:t,...n}){return jsxRuntimeExports.jsx(C,{text:t.title,onClick:e=>{e.stopPropagation(),t.onClick();},...n})}const Qn={Header:zn,HeaderCount:_n,HeaderBadge:En,HeaderIcon:Dn,HeaderTitle:Hn,HeaderTimestamp:On,HeaderButtonSnooze:jn,HeaderButtonClose:Mn,Body:Vn,BodyIcon:Rn,BodyTitle:Jn,BodyDescription:Un,Footer:qn,FooterButton:Gn},Yn=React.createContext(Qn),Kn=React.memo((({children:t,components:n})=>{const i=React.useMemo((()=>({...Qn,...n})),[n]);return jsxRuntimeExports.jsx(Yn.Provider,{value:i,children:t})}));function Wn(e){return {...React.useContext(Yn),...e}}function Xn({className:n="io-notification",notification:i,...o}){const{Header:a,Body:s,Footer:r}=Wn(),{severity:l}=i,c=v(n,`severity-${l?.toLowerCase()??"none"}`,{"state-new":"Acknowledged"!==i.state});return jsxRuntimeExports.jsxs("div",{className:c,...o,children:[jsxRuntimeExports.jsx(a,{notification:i}),jsxRuntimeExports.jsx(s,{notification:i}),jsxRuntimeExports.jsx(r,{notification:i})]})}function Zn({components:t,notification:n,...i}){return jsxRuntimeExports.jsx(Kn,{components:t,children:jsxRuntimeExports.jsx(Xn,{notification:n,...i})})}function ei({className:n="io-notification-stack",notifications:o,...a}){const[r,l]=React.useState(!1),c=2===o.length?"small":o.length>=3?"large":"normal",d=o[0].severity,u=v(n,{[`${n}-open`]:r,[`${n}-${c}`]:"normal"!==c,[`${n}-${d}`]:d&&"None"!==d}),h=React.useCallback((()=>{l(!r);}),[r]),m=React.useCallback((e=>{e.stopPropagation(),o.forEach((e=>{e.close();}));}),[o]);return jsxRuntimeExports.jsxs("div",{className:u,onClick:h,...a,children:["normal"!==c&&jsxRuntimeExports.jsx("div",{className:`${n}-btn`,children:jsxRuntimeExports.jsx(C,{icon:"close",onClick:e=>m(e),children:jsxRuntimeExports.jsx("span",{className:"io-btn-text",children:"Clear All"})})}),o.map((t=>jsxRuntimeExports.jsx(Zn,{notification:t},t.id)))]})}function ti({className:t="io-notification-list",Notification:n,notifications:i,noNotificationText:o="No notifications to display",...a}){const{notifications:s,notificationStacks:r,settings:l,isPanelVisible:c}=Gt(),{toastStacking:d}=l,u=i??s;return jsxRuntimeExports.jsx("div",{className:t,...a,children:d&&!c?r.length>0?r.map((t=>jsxRuntimeExports.jsx(ei,{notifications:t.items},t.key))):jsxRuntimeExports.jsx("div",{className:"flex jc-center mt-8",children:o??""}):u.length>0?u.map((t=>jsxRuntimeExports.jsx(n,{notification:t},t.id))):jsxRuntimeExports.jsx("div",{className:"flex jc-center mt-8",children:o??""})})}Kn.displayName="ComponentsStoreProvider";const ni={Header:Mt,HeaderCaption:Vt,HeaderCaptionFilter:Qt,HeaderCaptionTitle:Yt,HeaderCaptionCount:function({...t}){const{notificationsCount:n}=Wt();return jsxRuntimeExports.jsx(N,{...t,children:(n||0).toString()})},HeaderCaptionButtons:Xt,HeaderCaptionButtonSearch:function({...t}){const{notifications:n}=Gt(),{isSearchVisible:i,showSearch:o,hideSearch:a}=Wt();return jsxRuntimeExports.jsx(B,{icon:i?"search-filled":"search",variant:"circle",size:"32",onClick:i?a:o,disabled:0===n.length,...t})},HeaderCaptionButtonSettings:function({icon:t="cog",...n}){const{showSettings:i}=Wt();return jsxRuntimeExports.jsx(B,{icon:t,size:"32",variant:"circle",onClick:i,...n})},HeaderCaptionButtonClose:function({icon:t="close",...n}){const{hidePanel:i}=Gt();return jsxRuntimeExports.jsx(B,{icon:t,size:"32",variant:"circle",onClick:i,...n})},HeaderActions:function({className:n="io-panel-header-actions",...i}){const{HeaderActionSort:o,HeaderActionView:a,HeaderActionClear:s,HeaderActionEdit:r}=ai();return jsxRuntimeExports.jsxs("div",{className:n,...i,children:[jsxRuntimeExports.jsxs(z,{children:[jsxRuntimeExports.jsx(o,{}),jsxRuntimeExports.jsx(a,{})]}),jsxRuntimeExports.jsx(z,{children:jsxRuntimeExports.jsx(s,{})})]})},HeaderActionSort:function({text:n="Sort by",...o}){const{sortNotificationsBy:a,setSortBy:r}=Wt(),{onNotificationsSort:l}=(()=>{const{notifications:e}=Gt(),[t,n]=React.useState(on),{key:o,descending:a}=t,r=React.useMemo((()=>ln[o](e,a)),[e,o,a]),l=React.useCallback((e=>{n((t=>({key:e,descending:t.key!==e?on.descending:!t.descending})));}),[]);return {onNotificationsSort:l,sortedNotifications:r}})();return jsxRuntimeExports.jsxs(L,{variant:"outline",...o,children:[jsxRuntimeExports.jsxs(L.Button,{variant:"link",children:[n," ",jsxRuntimeExports.jsx("strong",{children:a})]}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{variant:"single",children:["Newest","Oldest","Severity"].map((t=>jsxRuntimeExports.jsx(L.Item,{onClick:()=>{r(t.toLowerCase()),l(t.toLowerCase());},children:t},t)))})})]})},HeaderActionView:function({text:n="View",...i}){const{settings:o}=Gt(),{viewNotificationsBy:a,setViewBy:s}=Wt(),r=o.snooze?.enabled?["All","Read","Unread","Snoozed"]:["All","Read","Unread"];return jsxRuntimeExports.jsxs(L,{variant:"outline",...i,children:[jsxRuntimeExports.jsxs(L.Button,{variant:"link",children:[n," ",jsxRuntimeExports.jsx("strong",{children:a})]}),jsxRuntimeExports.jsx(L.Content,{children:jsxRuntimeExports.jsx(L.List,{variant:"single",children:r.map((t=>jsxRuntimeExports.jsx(L.Item,{onClick:()=>s(t.toLowerCase()),children:t},t)))})})]})},HeaderActionClear:function({text:t="Clear All",...n}){const{notifications:i,clearAll:o}=Gt();return jsxRuntimeExports.jsx(C,{variant:"link",text:t,onClick:o,disabled:0===i.length,...n})},HeaderActionEdit:function({...t}){return jsxRuntimeExports.jsx(B,{icon:"pen-to-square",size:"32",...t})},HeaderSearch:function({className:n="io-panel-header-search",icon:i="search",placeholder:o="Search",...a}){const{isSearchVisible:s,searchQuery:c,setSearch:d,notificationsCount:u}=Wt(),h=React.useRef(null);return React.useEffect((()=>{s?h.current?.focus():(h.current?.blur(),d(""));}),[s,d]),s?jsxRuntimeExports.jsxs("div",{className:n,children:[jsxRuntimeExports.jsx(K,{ref:h,value:c,iconPrepend:i,placeholder:o,onChange:e=>d(e.target.value),...a}),s&&c.length>0&&jsxRuntimeExports.jsx("p",{className:`${n}-count`,children:`${u} results`})]}):null},Body:cn,Footer:dn,FooterButtons:un,FooterButtonClearAll:hn,FooterButtonClearAllOld:mn,Notification:Zn,NotificationsList:ti,Settings:gn,SettingsGeneral:fn,SettingsAllowNotifications:pn,SettingsPanelAutoHide:bn,SettingsPanelAlwaysOnTop:vn,SettingsHideToastsAfter:yn,SettingsMarkAsNew:wn,SettingsMarkAsRead:Nn,SettingsStacking:Sn,SettingsToastStacking:kn,SettingsToastStackBy:Bn,SettingsPlacement:xn,SettingsPlacementPanel:In,SettingsPlacementToasts:$n,SettingsSnooze:Tn,SettingsSnoozeDuration:An,SettingsSubscriptions:Pn,SettingsSubscriptionsToggleAll:Fn,SettingsSubscriptionsToggleApp:Ln},ii=React.createContext(ni),oi=React.memo((({children:t,components:n})=>{const i=React.useMemo((()=>({...ni,...n})),[n]);return jsxRuntimeExports.jsx(ii.Provider,{value:i,children:t})}));function ai(e){return {...React.useContext(ii),...e}}oi.displayName="ComponentsStoreProvider";const li={Body:function({className:t="io-toasts-body",notifications:n,maxToasts:i=1,...o}){const{NotificationsList:a,Notification:l}=ui(),[c,d]=React.useState([]);return React.useEffect((()=>{const e=i<0?n.length:i,t=n.filter((e=>"Active"===e.state)).slice(0,e);for(const e of t)e.onShow();d(t);}),[n,i]),jsxRuntimeExports.jsx("div",{className:t,...o,children:jsxRuntimeExports.jsx(a,{Notification:l,notifications:c,noNotificationText:""})})},Notification:Zn,NotificationsList:ti},ci=React.createContext(li),di=React.memo((({children:t,components:n})=>{const i=React.useMemo((()=>({...li,...n})),[n]);return jsxRuntimeExports.jsx(ci.Provider,{value:i,children:t})}));function ui(e){return {...React.useContext(ci),...e}}di.displayName="ComponentsStoreProvider";
|
|
1132
|
+
|
|
1133
|
+
const getInitialType = (glueController) => {
|
|
1134
|
+
const type = glueController.config.channelSelector?.type;
|
|
1135
|
+
if (!type) {
|
|
1136
|
+
return "single";
|
|
1137
|
+
}
|
|
1138
|
+
return type === "default" ? "single" : "directionalSingle";
|
|
1139
|
+
};
|
|
1140
|
+
const getChannelRestrictions = async (glueController, name) => {
|
|
1141
|
+
const restrictions = typeof glueController.io.channels.getRestrictions === "function" ? await glueController.io.channels.getRestrictions() : { channels: [] };
|
|
1142
|
+
const channelRestriction = restrictions.channels.find((restriction) => restriction.name === name);
|
|
1143
|
+
const read = typeof channelRestriction?.read === "boolean" ? channelRestriction.read : true;
|
|
1144
|
+
const write = typeof channelRestriction?.write === "boolean" ? channelRestriction.write : true;
|
|
1145
|
+
return { read, write };
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
const { ChannelSelector } = Ae;
|
|
1149
|
+
const ChannelSelectorWrapper = ({ mode }) => {
|
|
1150
|
+
const glueController = React.useContext(GlueControllerContext);
|
|
1151
|
+
const [variantToggle, setVariantToggle] = React.useState(true);
|
|
1152
|
+
const [channelsInfo, setChannelsInfo] = React.useState([]);
|
|
1153
|
+
const [type, setType] = React.useState(getInitialType(glueController));
|
|
1154
|
+
const handleSingleChannelSelect = React.useCallback(async ({ name }) => {
|
|
1155
|
+
const channel = channelsInfo.find((ch) => ch.name === name);
|
|
1156
|
+
if (channel?.isSelected) {
|
|
1157
|
+
setChannelsInfo(channels => channels.map((ch) => ({ ...ch, isSelected: false, read: false, write: false })));
|
|
1158
|
+
return glueController.io.channels.leave();
|
|
1159
|
+
}
|
|
1160
|
+
await glueController.io.channels.join(name);
|
|
1161
|
+
if (!variantToggle) {
|
|
1162
|
+
setChannelsInfo(channels => channels.map((ch) => ch.name === name ? ({ ...ch, isSelected: true }) : ({ ...ch, isSelected: false })));
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
const { read, write } = await getChannelRestrictions(glueController, name);
|
|
1166
|
+
setChannelsInfo((channels) => channels.map((ch) => ch.name === name ? ({ ...ch, isSelected: true, read, write }) : ({ ...ch, isSelected: false, read: false, write: false })));
|
|
1167
|
+
}, [glueController, channelsInfo, variantToggle]);
|
|
1168
|
+
const handleDirectionalChannelSelect = React.useCallback(async ({ name, isSelected, read, write }) => {
|
|
1169
|
+
if (isSelected && !read && !write) {
|
|
1170
|
+
setChannelsInfo((channels) => channels.map((ch) => ({ ...ch, isSelected: false, read: false, write: false })));
|
|
1171
|
+
await glueController.io.channels.restrict({ name, read, write });
|
|
1172
|
+
return glueController.io.channels.leave();
|
|
1173
|
+
}
|
|
1174
|
+
if (!isSelected && !read && !write) {
|
|
1175
|
+
setChannelsInfo((channels) => channels.map((ch) => ch.name === name ? ({ ...ch, isSelected, read, write }) : ({ ...ch, isSelected: false, write: false, read: false })));
|
|
1176
|
+
return glueController.io.channels.leave();
|
|
1177
|
+
}
|
|
1178
|
+
const prevSelectedIsTheSame = channelsInfo.find((ch) => ch.isSelected && ch.name === name);
|
|
1179
|
+
if (prevSelectedIsTheSame) {
|
|
1180
|
+
await glueController.io.channels.restrict({ name, read, write });
|
|
1181
|
+
setChannelsInfo((channels) => channels.map((ch) => ch.name === name ? ({ ...ch, isSelected, read, write }) : ({ ...ch, isSelected: false, write: false, read: false })));
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
await glueController.io.channels.join(name);
|
|
1185
|
+
if (!read || !write) {
|
|
1186
|
+
await glueController.io.channels.restrict({ name, read, write });
|
|
1187
|
+
}
|
|
1188
|
+
setChannelsInfo((channels) => channels.map((ch) => ch.name === name ? ({ ...ch, isSelected: true, read, write }) : ({ ...ch, isSelected: false, write: false, read: false })));
|
|
1189
|
+
}, [glueController, channelsInfo]);
|
|
1190
|
+
const onTypeChange = (checked) => {
|
|
1191
|
+
setType(checked ? "directionalSingle" : "single");
|
|
1192
|
+
};
|
|
1193
|
+
const getChannels = React.useCallback(async () => {
|
|
1194
|
+
const allChannels = await glueController.io.channels.list();
|
|
1195
|
+
const myCurrentChannel = await glueController.io.channels.getMy();
|
|
1196
|
+
const channelsInfo = await Promise.all(allChannels.map(async (ch) => {
|
|
1197
|
+
const restrictions = typeof glueController.io.channels.getRestrictions === "function" ? await glueController.io.channels.getRestrictions() : { channels: [] };
|
|
1198
|
+
const channelRestrictions = restrictions.channels.find((restriction) => restriction.name === ch.name);
|
|
1199
|
+
return {
|
|
1200
|
+
color: ch.meta.color,
|
|
1201
|
+
name: ch.name,
|
|
1202
|
+
isSelected: ch.name === myCurrentChannel?.name,
|
|
1203
|
+
label: ch.name[0],
|
|
1204
|
+
read: !!channelRestrictions?.read,
|
|
1205
|
+
write: !!channelRestrictions?.write
|
|
1206
|
+
};
|
|
1207
|
+
}));
|
|
1208
|
+
setChannelsInfo(channelsInfo);
|
|
1209
|
+
}, [glueController]);
|
|
1210
|
+
React.useEffect(() => {
|
|
1211
|
+
const subscribeForChannelChanged = () => {
|
|
1212
|
+
glueController.io.channels.onChanged(async (name) => {
|
|
1213
|
+
const { read, write } = await getChannelRestrictions(glueController, name);
|
|
1214
|
+
setChannelsInfo((channels) => channels.map((ch) => ch.name === name ? { ...ch, isSelected: true, read, write } : { ...ch, isSelected: false, read: false, write: false }));
|
|
1215
|
+
});
|
|
1216
|
+
};
|
|
1217
|
+
const checkSetVariantToggle = async () => {
|
|
1218
|
+
const clientRestrictionsMethodsExist = typeof glueController.io.channels.restrict === "function" && typeof glueController.io.channels.restrictAll === "function" && typeof glueController.io.channels.getRestrictions === "function";
|
|
1219
|
+
if (!clientRestrictionsMethodsExist) {
|
|
1220
|
+
setVariantToggle(false);
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
const platformRestrictionsMethodsExist = await glueController.checkChannelRestrictionsExistInPlatform();
|
|
1224
|
+
setVariantToggle(platformRestrictionsMethodsExist);
|
|
1225
|
+
};
|
|
1226
|
+
const initialSetup = async () => {
|
|
1227
|
+
subscribeForChannelChanged();
|
|
1228
|
+
await checkSetVariantToggle();
|
|
1229
|
+
};
|
|
1230
|
+
initialSetup();
|
|
1231
|
+
}, [glueController]);
|
|
1232
|
+
React.useEffect(() => {
|
|
1233
|
+
const handleBtnBackgroundChange = () => {
|
|
1234
|
+
const selectorBtn = Array.from(document.getElementsByClassName("io-btn-icon"))[0];
|
|
1235
|
+
const selectedChannel = channelsInfo.find((channelInfo) => channelInfo.isSelected);
|
|
1236
|
+
selectorBtn.style.backgroundColor = selectedChannel?.color ?? "";
|
|
1237
|
+
};
|
|
1238
|
+
handleBtnBackgroundChange();
|
|
1239
|
+
}, [channelsInfo]);
|
|
1240
|
+
return (React.createElement(L, { onClick: getChannels },
|
|
1241
|
+
mode === "default" ? (React.createElement(L.ButtonIcon, { className: "io-btn-icon", icon: "link", iconSize: "16", size: "32", variant: "circle" })) : (React.createElement(L.Button, { icon: "link", text: "Select channel", iconRight: false })),
|
|
1242
|
+
React.createElement(L.Content, null,
|
|
1243
|
+
React.createElement(ChannelSelector, { className: "io-list-channels", variant: type, channels: channelsInfo, onChannelSelect: type === "single" ? handleSingleChannelSelect : handleDirectionalChannelSelect, variantToggle: variantToggle, onVariantChange: onTypeChange }))));
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
const PositionDropdown = ({ position, positionClickHandler }) => {
|
|
1247
|
+
const positions = ["bottom", "left", "right", "top"].map((p) => {
|
|
1248
|
+
return (React.createElement(L.Item, { key: p, isSelected: p === position, onClick: () => positionClickHandler(p) }, p[0].toUpperCase() + p.slice(1)));
|
|
1249
|
+
});
|
|
1250
|
+
return (React.createElement(L.List, { variant: "single", checkIcon: "check" },
|
|
1251
|
+
React.createElement(L.ItemSection, null, "Widget Position"),
|
|
1252
|
+
positions));
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
const ModeDropdown = ({ mode, modeClickHandler }) => {
|
|
1256
|
+
return (React.createElement(L.List, null,
|
|
1257
|
+
React.createElement(L.ItemSection, null, "Widget Mode"),
|
|
1258
|
+
React.createElement(L.Item, null,
|
|
1259
|
+
React.createElement(ee, { label: "Compact", align: "right", checked: mode === "compact", onChange: () => modeClickHandler(mode === "compact" ? "default" : "compact") }))));
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
const Settings = ({ position, positionClickHandler, mode, modeClickHandler }) => {
|
|
1263
|
+
return (React.createElement(L, { align: "up" },
|
|
1264
|
+
React.createElement(L.ButtonIcon, { className: "io-btn-icon", icon: "cog", iconSize: "16", size: "32", variant: "circle" }),
|
|
1265
|
+
React.createElement(L.Content, null,
|
|
1266
|
+
React.createElement(PositionDropdown, { position: position, positionClickHandler: positionClickHandler }),
|
|
1267
|
+
React.createElement(ModeDropdown, { mode: mode, modeClickHandler: modeClickHandler }))));
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
const DefaultWidget = ({ showBringBackToWspBtn, handleBringBackToWspClick, showChannelSelectorBtn, position, positionClickHandler, mode, modeClickHandler, }) => {
|
|
1271
|
+
return (React.createElement(z, { align: "left", className: "io-btn-group", variant: "default" },
|
|
1272
|
+
showChannelSelectorBtn ? React.createElement(ChannelSelectorWrapper, { mode: mode }) : null,
|
|
1273
|
+
showBringBackToWspBtn ? (React.createElement(B, { className: "io-btn-icon", icon: "pop-in-widget", iconSize: "16", size: "32", variant: "circle", onClick: handleBringBackToWspClick })) : null,
|
|
1274
|
+
React.createElement(Settings, { position: position, positionClickHandler: positionClickHandler, mode: mode, modeClickHandler: modeClickHandler })));
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1277
|
+
const CompactWidget = ({ position, positionClickHandler, mode, modeClickHandler, handleBringBackToWspClick, showBringBackToWspBtn, showChannelSelectorBtn, }) => {
|
|
1278
|
+
return (React.createElement(L, null,
|
|
1279
|
+
React.createElement(L.ButtonIcon, { className: "io-btn-icon", iconSize: "16", size: "32", variant: "circle" }),
|
|
1280
|
+
React.createElement(L.Content, null,
|
|
1281
|
+
React.createElement(L.ItemSection, null, "Application"),
|
|
1282
|
+
React.createElement(L.List, null,
|
|
1283
|
+
showBringBackToWspBtn ? (React.createElement(L.Item, { onClick: handleBringBackToWspClick, prepend: React.createElement(y, { variant: "pop-in-widget" }) }, "Pop in")) : null,
|
|
1284
|
+
showChannelSelectorBtn ? React.createElement(ChannelSelectorWrapper, { mode: mode }) : null),
|
|
1285
|
+
React.createElement(PositionDropdown, { position: position, positionClickHandler: positionClickHandler }),
|
|
1286
|
+
React.createElement(ModeDropdown, { mode: mode, modeClickHandler: modeClickHandler }))));
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
const Widget = () => {
|
|
1290
|
+
const glueController = React.useContext(GlueControllerContext);
|
|
1291
|
+
const [position, setPosition] = React.useState(glueController.config.position ?? "bottom");
|
|
1292
|
+
const [mode, setMode] = React.useState(glueController.config.mode ?? "default");
|
|
1293
|
+
const [showBringBackToWspBtn, setShowBringBackToWspBtn] = React.useState(false);
|
|
1294
|
+
useThemeSync();
|
|
1295
|
+
React.useEffect(() => {
|
|
1296
|
+
const checkIsEjectedWindow = async () => {
|
|
1297
|
+
const { isEjected, ejectData } = await glueController.checkIsEjected();
|
|
1298
|
+
if (!isEjected || !glueController.io.workspaces) {
|
|
1299
|
+
setShowBringBackToWspBtn(isEjected);
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
const unOnWorkspaceClosed = await glueController.io.workspaces.onWorkspaceClosed((closed) => {
|
|
1303
|
+
if (closed.workspaceId !== ejectData?.workspaceId) {
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
unOnWorkspaceClosed();
|
|
1307
|
+
setShowBringBackToWspBtn(false);
|
|
1308
|
+
});
|
|
1309
|
+
setShowBringBackToWspBtn(isEjected);
|
|
1310
|
+
};
|
|
1311
|
+
checkIsEjectedWindow();
|
|
1312
|
+
}, [glueController]);
|
|
1313
|
+
const positionClickHandler = React.useCallback((position) => {
|
|
1314
|
+
const widgetElem = Array.from(document.getElementsByClassName("io-window-widget"))[0];
|
|
1315
|
+
widgetElem.className =
|
|
1316
|
+
position !== "bottom" ? `io-window-widget io-window-widget-${position}` : "io-window-widget";
|
|
1317
|
+
setPosition(position);
|
|
1318
|
+
}, []);
|
|
1319
|
+
const modeClickHandler = React.useCallback((mode) => {
|
|
1320
|
+
const widgetElem = Array.from(document.getElementsByClassName("io-window-widget"))[0];
|
|
1321
|
+
widgetElem.className = mode !== "default" ? `io-window-widget io-window-widget-${mode}` : "io-window-widget";
|
|
1322
|
+
setMode(mode);
|
|
1323
|
+
}, []);
|
|
1324
|
+
const handleDragEnd = (e) => drop(e, setPosition);
|
|
1325
|
+
const getWidgetClassName = () => {
|
|
1326
|
+
if (position === "bottom" && mode === "default") {
|
|
1327
|
+
return "io-window-widget";
|
|
1328
|
+
}
|
|
1329
|
+
return `io-window-widget io-window-widget-${position} io-window-widget-${mode}`;
|
|
1330
|
+
};
|
|
1331
|
+
const getWidgetProps = () => {
|
|
1332
|
+
return {
|
|
1333
|
+
showChannelSelectorBtn: glueController.config.channelSelector?.enable ?? true,
|
|
1334
|
+
position,
|
|
1335
|
+
positionClickHandler,
|
|
1336
|
+
mode,
|
|
1337
|
+
modeClickHandler,
|
|
1338
|
+
showBringBackToWspBtn,
|
|
1339
|
+
handleBringBackToWspClick
|
|
1340
|
+
};
|
|
1341
|
+
};
|
|
1342
|
+
const handleBringBackToWspClick = React.useCallback(async () => {
|
|
1343
|
+
try {
|
|
1344
|
+
await glueController.bringBackToWsp();
|
|
1345
|
+
}
|
|
1346
|
+
catch (error) {
|
|
1347
|
+
glueController.getLogger(`widget-component-${glueController.windowId}`).error(error);
|
|
1348
|
+
await glueController.removeEjectedWindowContext();
|
|
1349
|
+
setShowBringBackToWspBtn(false);
|
|
1350
|
+
}
|
|
1351
|
+
}, [glueController]);
|
|
1352
|
+
return (React.createElement("div", { className: getWidgetClassName(), draggable: "true", onDragEnd: handleDragEnd, role: "button", tabIndex: 0 },
|
|
1353
|
+
React.createElement(DragSection, null),
|
|
1354
|
+
mode === "default" ? (React.createElement(DefaultWidget, { ...getWidgetProps() })) : (React.createElement(CompactWidget, { ...getWidgetProps() }))));
|
|
1355
|
+
};
|
|
1356
|
+
|
|
1357
|
+
class DOMController {
|
|
1358
|
+
glueController;
|
|
1359
|
+
constructor(glueController) {
|
|
1360
|
+
this.glueController = glueController;
|
|
1361
|
+
}
|
|
1362
|
+
async attachWidget() {
|
|
1363
|
+
const domNode = document.createElement("div");
|
|
1364
|
+
const root = createRoot(domNode);
|
|
1365
|
+
const GlueControllerContext = createGlueControllerContext(this.glueController);
|
|
1366
|
+
root.render(React.createElement(GlueControllerContext.Provider, { value: this.glueController },
|
|
1367
|
+
React.createElement(Widget, null)));
|
|
1368
|
+
document.body.appendChild(domNode);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
class GlueController {
|
|
1373
|
+
_io;
|
|
1374
|
+
_config;
|
|
1375
|
+
bridge;
|
|
1376
|
+
_windowId;
|
|
1377
|
+
_logger;
|
|
1378
|
+
constructor(_io, _config, bridge) {
|
|
1379
|
+
this._io = _io;
|
|
1380
|
+
this._config = _config;
|
|
1381
|
+
this.bridge = bridge;
|
|
1382
|
+
this._windowId = this._io.windows.my().id;
|
|
1383
|
+
this._logger = this._io.logger.subLogger(`widget-${this._windowId}`);
|
|
1384
|
+
}
|
|
1385
|
+
get io() {
|
|
1386
|
+
return this._io;
|
|
1387
|
+
}
|
|
1388
|
+
get config() {
|
|
1389
|
+
return this._config;
|
|
1390
|
+
}
|
|
1391
|
+
get logger() {
|
|
1392
|
+
return this._logger;
|
|
1393
|
+
}
|
|
1394
|
+
get windowId() {
|
|
1395
|
+
return this._windowId;
|
|
1396
|
+
}
|
|
1397
|
+
getLogger(name) {
|
|
1398
|
+
return this.io.logger.subLogger(name);
|
|
1399
|
+
}
|
|
1400
|
+
async checkShowWidget() {
|
|
1401
|
+
const errorMsg = `Current window is in workspace`;
|
|
1402
|
+
if (this.io.workspaces && await this.io.workspaces.inWorkspace()) {
|
|
1403
|
+
return { show: false, reason: errorMsg };
|
|
1404
|
+
}
|
|
1405
|
+
const isWorkspacesLibInitialized = await this.checkWorkspacesLibInitialized();
|
|
1406
|
+
if (!isWorkspacesLibInitialized) {
|
|
1407
|
+
return { show: true };
|
|
1408
|
+
}
|
|
1409
|
+
const isWindowInWorkspace = await this.checkWindowInWorkspace();
|
|
1410
|
+
return isWindowInWorkspace ? { show: false, reason: errorMsg } : { show: true };
|
|
1411
|
+
}
|
|
1412
|
+
async checkChannelRestrictionsExistInPlatform() {
|
|
1413
|
+
const restrictExist = await this.bridge.checkOperationSupported("restrict", "channels");
|
|
1414
|
+
if (!restrictExist.isSupported) {
|
|
1415
|
+
return false;
|
|
1416
|
+
}
|
|
1417
|
+
const getRestrictionsExist = await this.bridge.checkOperationSupported("getRestrictions", "channels");
|
|
1418
|
+
if (!getRestrictionsExist.isSupported) {
|
|
1419
|
+
return false;
|
|
1420
|
+
}
|
|
1421
|
+
const restrictAll = await this.bridge.checkOperationSupported("restrictAll", "channels");
|
|
1422
|
+
return restrictAll.isSupported;
|
|
1423
|
+
}
|
|
1424
|
+
async checkIsEjected() {
|
|
1425
|
+
const context = await this.io.contexts.get(`___window___${this.windowId}`);
|
|
1426
|
+
const frameId = context?.___io___?.ejectedWindow?.frameId;
|
|
1427
|
+
const workspaceId = context?.___io___?.ejectedWindow?.workspaceId;
|
|
1428
|
+
return frameId && workspaceId
|
|
1429
|
+
? { isEjected: true, ejectData: { frameId, workspaceId } }
|
|
1430
|
+
: { isEjected: false };
|
|
1431
|
+
}
|
|
1432
|
+
async removeEjectedWindowContext() {
|
|
1433
|
+
await this.io.contexts.setPath(`___window___${this.windowId}`, "___io___.ejectedWindow", null);
|
|
1434
|
+
const appInstance = this.io.appManager.myInstance;
|
|
1435
|
+
if (!appInstance) {
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1438
|
+
await this.io.contexts.setPath(`___instance___${this.windowId}`, "___io___.ejectedWindow", null);
|
|
1439
|
+
}
|
|
1440
|
+
async bringBackToWsp() {
|
|
1441
|
+
await this.bridge.send("bringBackToWorkspace", "workspaces", { windowId: this.windowId }, { includeOperationCheck: true });
|
|
1442
|
+
}
|
|
1443
|
+
async checkWindowInWorkspace() {
|
|
1444
|
+
try {
|
|
1445
|
+
const res = await this.bridge.send("isWindowInWorkspace", "workspaces", { itemId: this.windowId });
|
|
1446
|
+
return res.inWorkspace;
|
|
1447
|
+
}
|
|
1448
|
+
catch (error) {
|
|
1449
|
+
this.logger.trace(typeof error === "string" ? error : JSON.stringify(error));
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
async checkWorkspacesLibInitialized() {
|
|
1453
|
+
try {
|
|
1454
|
+
const res = await this.bridge.send("workspacesInitCheck", "system", {}, { includeOperationCheck: true });
|
|
1455
|
+
return res.initialized;
|
|
1456
|
+
}
|
|
1457
|
+
catch (error) {
|
|
1458
|
+
this.logger.trace(typeof error === "string" ? error : JSON.stringify(error));
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
class IoC {
|
|
1464
|
+
io;
|
|
1465
|
+
config;
|
|
1466
|
+
_domController;
|
|
1467
|
+
_bridge;
|
|
1468
|
+
_glueController;
|
|
1469
|
+
constructor(io, config) {
|
|
1470
|
+
this.io = io;
|
|
1471
|
+
this.config = config;
|
|
1472
|
+
}
|
|
1473
|
+
get domController() {
|
|
1474
|
+
if (!this._domController) {
|
|
1475
|
+
this._domController = new DOMController(this.glueController);
|
|
1476
|
+
}
|
|
1477
|
+
return this._domController;
|
|
1478
|
+
}
|
|
1479
|
+
get bridge() {
|
|
1480
|
+
if (!this._bridge) {
|
|
1481
|
+
this._bridge = new Bridge(this.io);
|
|
1482
|
+
}
|
|
1483
|
+
return this._bridge;
|
|
1484
|
+
}
|
|
1485
|
+
get glueController() {
|
|
1486
|
+
if (!this._glueController) {
|
|
1487
|
+
this._glueController = new GlueController(this.io, this.config, this.bridge);
|
|
1488
|
+
}
|
|
1489
|
+
return this._glueController;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
const IOBrowserWidgetFactory = async (io, config) => {
|
|
1494
|
+
const widgetConfig = config?.widget ? configDecoder.runWithException(config.widget) : defaultConfig;
|
|
1495
|
+
const ioc = new IoC(io, widgetConfig);
|
|
1496
|
+
const logger = ioc.glueController.getLogger(`widget.factory-${io.windows.my().id}`);
|
|
1497
|
+
const baseErrorMessage = `Widget won't be shown. Reason:`;
|
|
1498
|
+
const initiateRes = await ioc.bridge.initiate();
|
|
1499
|
+
if (!initiateRes.success) {
|
|
1500
|
+
logger.error(`${baseErrorMessage} ${initiateRes.reason}`);
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
logger.trace(`Bridge initiated successfully`);
|
|
1504
|
+
const showWidgetRes = await ioc.glueController.checkShowWidget();
|
|
1505
|
+
if (!showWidgetRes.show) {
|
|
1506
|
+
logger.error(`${baseErrorMessage} ${showWidgetRes.reason}`);
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
logger.trace(`Widget will be attached to DOM`);
|
|
1510
|
+
await ioc.domController.attachWidget();
|
|
1511
|
+
};
|
|
1512
|
+
|
|
1513
|
+
if (typeof window !== "undefined") {
|
|
1514
|
+
window.IOBrowserWidget = IOBrowserWidgetFactory;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
return IOBrowserWidgetFactory;
|
|
1518
|
+
|
|
1519
|
+
}));
|
|
1520
|
+
//# sourceMappingURL=io-browser-widget-react.umd.js.map
|