@sitecore-feaas/clientside 0.1.15 → 0.1.17

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.
Files changed (94) hide show
  1. package/README.md +5 -5
  2. package/build/basic.js +10 -0
  3. package/build/basic.js.map +1 -0
  4. package/build/cloud.js +22 -0
  5. package/build/cloud.js.map +1 -0
  6. package/build/components/FEAASBase.js +229 -0
  7. package/build/components/FEAASBase.js.map +1 -0
  8. package/build/components/FEAASComponent.js +84 -0
  9. package/build/components/FEAASComponent.js.map +1 -0
  10. package/build/components/FEAASLoader.js +100 -0
  11. package/build/components/FEAASLoader.js.map +1 -0
  12. package/build/components/FEAASStylesheet.js +31 -0
  13. package/build/components/FEAASStylesheet.js.map +1 -0
  14. package/build/dom.js +301 -0
  15. package/build/dom.js.map +1 -0
  16. package/build/fetch.js +56 -0
  17. package/build/fetch.js.map +1 -0
  18. package/build/ui/FEAASContext.js +68 -0
  19. package/build/ui/FEAASContext.js.map +1 -0
  20. package/build/ui/FEAASEditor.js +180 -0
  21. package/build/ui/FEAASEditor.js.map +1 -0
  22. package/build/ui/FEAASPicker.js +81 -0
  23. package/build/ui/FEAASPicker.js.map +1 -0
  24. package/build/ui/index.js +5 -0
  25. package/build/ui/index.js.map +1 -0
  26. package/dist/browser/basic.esm.js +68 -0
  27. package/dist/browser/basic.esm.js.map +1 -0
  28. package/dist/browser/basic.js +5 -4
  29. package/dist/browser/basic.js.map +1 -0
  30. package/dist/browser/index.esm.js +73 -0
  31. package/dist/browser/index.esm.js.map +1 -0
  32. package/dist/browser/index.js +8 -7
  33. package/dist/browser/index.js.map +1 -0
  34. package/dist/node/basic.esm.js +66 -0
  35. package/dist/node/basic.esm.js.map +1 -0
  36. package/dist/node/basic.js +4 -1458
  37. package/dist/node/basic.js.map +1 -0
  38. package/dist/node/index.esm.js +71 -0
  39. package/dist/node/index.esm.js.map +1 -0
  40. package/dist/node/index.js +7 -1858
  41. package/dist/node/index.js.map +1 -0
  42. package/package.json +25 -36
  43. package/scripts/build.js +77 -0
  44. package/src/basic.ts +10 -1
  45. package/src/components/FEAASBase.tsx +4 -2
  46. package/src/components/FEAASComponent.ts +7 -2
  47. package/src/components/FEAASLoader.ts +2 -0
  48. package/src/components/FEAASStylesheet.ts +2 -1
  49. package/src/dom.ts +9 -2
  50. package/src/{components → ui}/FEAASContext.tsx +3 -5
  51. package/src/{components → ui}/FEAASEditor.tsx +4 -4
  52. package/src/{components → ui}/FEAASPicker.tsx +3 -4
  53. package/src/ui/index.ts +4 -0
  54. package/src/ui/tsconfig.json +22 -0
  55. package/test/render.ts +35 -1
  56. package/test/tsconfig.json +10 -0
  57. package/tsconfig.json +3 -3
  58. package/tsconfig.test.json +0 -0
  59. package/types/basic.d.ts +8 -1
  60. package/types/basic.d.ts.map +1 -0
  61. package/types/cloud.d.ts +1 -0
  62. package/types/cloud.d.ts.map +1 -0
  63. package/types/components/FEAASBase.d.ts +7 -1
  64. package/types/components/FEAASBase.d.ts.map +1 -0
  65. package/types/components/FEAASComponent.d.ts +7 -1
  66. package/types/components/FEAASComponent.d.ts.map +1 -0
  67. package/types/components/FEAASLoader.d.ts +2 -1
  68. package/types/components/FEAASLoader.d.ts.map +1 -0
  69. package/types/components/FEAASStylesheet.d.ts +7 -3
  70. package/types/components/FEAASStylesheet.d.ts.map +1 -0
  71. package/types/dom.d.ts +1 -0
  72. package/types/dom.d.ts.map +1 -0
  73. package/types/fetch.d.ts +1 -0
  74. package/types/fetch.d.ts.map +1 -0
  75. package/types/tsbuildinfo +1 -1
  76. package/types/tsbuildinfo_ui +1 -0
  77. package/types/{components → ui}/FEAASContext.d.ts +3 -2
  78. package/types/ui/FEAASContext.d.ts.map +1 -0
  79. package/types/{components → ui}/FEAASEditor.d.ts +3 -2
  80. package/types/ui/FEAASEditor.d.ts.map +1 -0
  81. package/types/{components → ui}/FEAASPicker.d.ts +3 -2
  82. package/types/ui/FEAASPicker.d.ts.map +1 -0
  83. package/types/ui/index.d.ts +5 -0
  84. package/types/ui/index.d.ts.map +1 -0
  85. package/dist/browser/basic.cjs +0 -67
  86. package/dist/browser/index.cjs +0 -72
  87. package/dist/node/basic.cjs +0 -1539
  88. package/dist/node/index.cjs +0 -1941
  89. package/src/components/index.tsx +0 -7
  90. package/src/index.ts +0 -4
  91. package/test/components.js +0 -11
  92. package/test/render.js +0 -688
  93. package/types/components/index.d.ts +0 -7
  94. package/types/index.d.ts +0 -4
@@ -1,1318 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __async = (__this, __arguments, generator) => {
21
- return new Promise((resolve, reject) => {
22
- var fulfilled = (value) => {
23
- try {
24
- step(generator.next(value));
25
- } catch (e) {
26
- reject(e);
27
- }
28
- };
29
- var rejected = (value) => {
30
- try {
31
- step(generator.throw(value));
32
- } catch (e) {
33
- reject(e);
34
- }
35
- };
36
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
- step((generator = generator.apply(__this, __arguments)).next());
38
- });
39
- };
40
-
41
- // ../node_modules/jsonpath-plus/dist/index-browser-esm.js
42
- function _typeof(obj) {
43
- "@babel/helpers - typeof";
44
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
45
- _typeof = function(obj2) {
46
- return typeof obj2;
47
- };
48
- } else {
49
- _typeof = function(obj2) {
50
- return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
51
- };
52
- }
53
- return _typeof(obj);
54
- }
55
- function _classCallCheck(instance, Constructor) {
56
- if (!(instance instanceof Constructor)) {
57
- throw new TypeError("Cannot call a class as a function");
58
- }
59
- }
60
- function _inherits(subClass, superClass) {
61
- if (typeof superClass !== "function" && superClass !== null) {
62
- throw new TypeError("Super expression must either be null or a function");
63
- }
64
- subClass.prototype = Object.create(superClass && superClass.prototype, {
65
- constructor: {
66
- value: subClass,
67
- writable: true,
68
- configurable: true
69
- }
70
- });
71
- if (superClass)
72
- _setPrototypeOf(subClass, superClass);
73
- }
74
- function _getPrototypeOf(o) {
75
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
76
- return o2.__proto__ || Object.getPrototypeOf(o2);
77
- };
78
- return _getPrototypeOf(o);
79
- }
80
- function _setPrototypeOf(o, p) {
81
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
82
- o2.__proto__ = p2;
83
- return o2;
84
- };
85
- return _setPrototypeOf(o, p);
86
- }
87
- function _isNativeReflectConstruct() {
88
- if (typeof Reflect === "undefined" || !Reflect.construct)
89
- return false;
90
- if (Reflect.construct.sham)
91
- return false;
92
- if (typeof Proxy === "function")
93
- return true;
94
- try {
95
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
96
- }));
97
- return true;
98
- } catch (e) {
99
- return false;
100
- }
101
- }
102
- function _construct(Parent, args, Class) {
103
- if (_isNativeReflectConstruct()) {
104
- _construct = Reflect.construct;
105
- } else {
106
- _construct = function _construct2(Parent2, args2, Class2) {
107
- var a = [null];
108
- a.push.apply(a, args2);
109
- var Constructor = Function.bind.apply(Parent2, a);
110
- var instance = new Constructor();
111
- if (Class2)
112
- _setPrototypeOf(instance, Class2.prototype);
113
- return instance;
114
- };
115
- }
116
- return _construct.apply(null, arguments);
117
- }
118
- function _isNativeFunction(fn) {
119
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
120
- }
121
- function _wrapNativeSuper(Class) {
122
- var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
123
- _wrapNativeSuper = function _wrapNativeSuper2(Class2) {
124
- if (Class2 === null || !_isNativeFunction(Class2))
125
- return Class2;
126
- if (typeof Class2 !== "function") {
127
- throw new TypeError("Super expression must either be null or a function");
128
- }
129
- if (typeof _cache !== "undefined") {
130
- if (_cache.has(Class2))
131
- return _cache.get(Class2);
132
- _cache.set(Class2, Wrapper);
133
- }
134
- function Wrapper() {
135
- return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
136
- }
137
- Wrapper.prototype = Object.create(Class2.prototype, {
138
- constructor: {
139
- value: Wrapper,
140
- enumerable: false,
141
- writable: true,
142
- configurable: true
143
- }
144
- });
145
- return _setPrototypeOf(Wrapper, Class2);
146
- };
147
- return _wrapNativeSuper(Class);
148
- }
149
- function _assertThisInitialized(self) {
150
- if (self === void 0) {
151
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
152
- }
153
- return self;
154
- }
155
- function _possibleConstructorReturn(self, call) {
156
- if (call && (typeof call === "object" || typeof call === "function")) {
157
- return call;
158
- }
159
- return _assertThisInitialized(self);
160
- }
161
- function _createSuper(Derived) {
162
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
163
- return function _createSuperInternal() {
164
- var Super = _getPrototypeOf(Derived), result;
165
- if (hasNativeReflectConstruct) {
166
- var NewTarget = _getPrototypeOf(this).constructor;
167
- result = Reflect.construct(Super, arguments, NewTarget);
168
- } else {
169
- result = Super.apply(this, arguments);
170
- }
171
- return _possibleConstructorReturn(this, result);
172
- };
173
- }
174
- function _toConsumableArray(arr) {
175
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
176
- }
177
- function _arrayWithoutHoles(arr) {
178
- if (Array.isArray(arr))
179
- return _arrayLikeToArray(arr);
180
- }
181
- function _iterableToArray(iter) {
182
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
183
- return Array.from(iter);
184
- }
185
- function _unsupportedIterableToArray(o, minLen) {
186
- if (!o)
187
- return;
188
- if (typeof o === "string")
189
- return _arrayLikeToArray(o, minLen);
190
- var n = Object.prototype.toString.call(o).slice(8, -1);
191
- if (n === "Object" && o.constructor)
192
- n = o.constructor.name;
193
- if (n === "Map" || n === "Set")
194
- return Array.from(o);
195
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
196
- return _arrayLikeToArray(o, minLen);
197
- }
198
- function _arrayLikeToArray(arr, len) {
199
- if (len == null || len > arr.length)
200
- len = arr.length;
201
- for (var i = 0, arr2 = new Array(len); i < len; i++)
202
- arr2[i] = arr[i];
203
- return arr2;
204
- }
205
- function _nonIterableSpread() {
206
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
207
- }
208
- function _createForOfIteratorHelper(o, allowArrayLike) {
209
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
210
- if (!it) {
211
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
212
- if (it)
213
- o = it;
214
- var i = 0;
215
- var F = function() {
216
- };
217
- return {
218
- s: F,
219
- n: function() {
220
- if (i >= o.length)
221
- return {
222
- done: true
223
- };
224
- return {
225
- done: false,
226
- value: o[i++]
227
- };
228
- },
229
- e: function(e) {
230
- throw e;
231
- },
232
- f: F
233
- };
234
- }
235
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
236
- }
237
- var normalCompletion = true, didErr = false, err;
238
- return {
239
- s: function() {
240
- it = it.call(o);
241
- },
242
- n: function() {
243
- var step = it.next();
244
- normalCompletion = step.done;
245
- return step;
246
- },
247
- e: function(e) {
248
- didErr = true;
249
- err = e;
250
- },
251
- f: function() {
252
- try {
253
- if (!normalCompletion && it.return != null)
254
- it.return();
255
- } finally {
256
- if (didErr)
257
- throw err;
258
- }
259
- }
260
- };
261
- }
262
- var hasOwnProp = Object.prototype.hasOwnProperty;
263
- function push(arr, item) {
264
- arr = arr.slice();
265
- arr.push(item);
266
- return arr;
267
- }
268
- function unshift(item, arr) {
269
- arr = arr.slice();
270
- arr.unshift(item);
271
- return arr;
272
- }
273
- var NewError = /* @__PURE__ */ function(_Error) {
274
- _inherits(NewError2, _Error);
275
- var _super = _createSuper(NewError2);
276
- function NewError2(value) {
277
- var _this;
278
- _classCallCheck(this, NewError2);
279
- _this = _super.call(this, 'JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');
280
- _this.avoidNew = true;
281
- _this.value = value;
282
- _this.name = "NewError";
283
- return _this;
284
- }
285
- return NewError2;
286
- }(/* @__PURE__ */ _wrapNativeSuper(Error));
287
- function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
288
- if (!(this instanceof JSONPath)) {
289
- try {
290
- return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
291
- } catch (e) {
292
- if (!e.avoidNew) {
293
- throw e;
294
- }
295
- return e.value;
296
- }
297
- }
298
- if (typeof opts === "string") {
299
- otherTypeCallback = callback;
300
- callback = obj;
301
- obj = expr;
302
- expr = opts;
303
- opts = null;
304
- }
305
- var optObj = opts && _typeof(opts) === "object";
306
- opts = opts || {};
307
- this.json = opts.json || obj;
308
- this.path = opts.path || expr;
309
- this.resultType = opts.resultType || "value";
310
- this.flatten = opts.flatten || false;
311
- this.wrap = hasOwnProp.call(opts, "wrap") ? opts.wrap : true;
312
- this.sandbox = opts.sandbox || {};
313
- this.preventEval = opts.preventEval || false;
314
- this.parent = opts.parent || null;
315
- this.parentProperty = opts.parentProperty || null;
316
- this.callback = opts.callback || callback || null;
317
- this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
318
- throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.");
319
- };
320
- if (opts.autostart !== false) {
321
- var args = {
322
- path: optObj ? opts.path : expr
323
- };
324
- if (!optObj) {
325
- args.json = obj;
326
- } else if ("json" in opts) {
327
- args.json = opts.json;
328
- }
329
- var ret = this.evaluate(args);
330
- if (!ret || _typeof(ret) !== "object") {
331
- throw new NewError(ret);
332
- }
333
- return ret;
334
- }
335
- }
336
- JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
337
- var _this2 = this;
338
- var currParent = this.parent, currParentProperty = this.parentProperty;
339
- var flatten = this.flatten, wrap = this.wrap;
340
- this.currResultType = this.resultType;
341
- this.currPreventEval = this.preventEval;
342
- this.currSandbox = this.sandbox;
343
- callback = callback || this.callback;
344
- this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
345
- json = json || this.json;
346
- expr = expr || this.path;
347
- if (expr && _typeof(expr) === "object" && !Array.isArray(expr)) {
348
- if (!expr.path && expr.path !== "") {
349
- throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');
350
- }
351
- if (!hasOwnProp.call(expr, "json")) {
352
- throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');
353
- }
354
- var _expr = expr;
355
- json = _expr.json;
356
- flatten = hasOwnProp.call(expr, "flatten") ? expr.flatten : flatten;
357
- this.currResultType = hasOwnProp.call(expr, "resultType") ? expr.resultType : this.currResultType;
358
- this.currSandbox = hasOwnProp.call(expr, "sandbox") ? expr.sandbox : this.currSandbox;
359
- wrap = hasOwnProp.call(expr, "wrap") ? expr.wrap : wrap;
360
- this.currPreventEval = hasOwnProp.call(expr, "preventEval") ? expr.preventEval : this.currPreventEval;
361
- callback = hasOwnProp.call(expr, "callback") ? expr.callback : callback;
362
- this.currOtherTypeCallback = hasOwnProp.call(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
363
- currParent = hasOwnProp.call(expr, "parent") ? expr.parent : currParent;
364
- currParentProperty = hasOwnProp.call(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
365
- expr = expr.path;
366
- }
367
- currParent = currParent || null;
368
- currParentProperty = currParentProperty || null;
369
- if (Array.isArray(expr)) {
370
- expr = JSONPath.toPathString(expr);
371
- }
372
- if (!expr && expr !== "" || !json) {
373
- return void 0;
374
- }
375
- var exprList = JSONPath.toPathArray(expr);
376
- if (exprList[0] === "$" && exprList.length > 1) {
377
- exprList.shift();
378
- }
379
- this._hasParentSelector = null;
380
- var result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
381
- return ea && !ea.isParentSelector;
382
- });
383
- if (!result.length) {
384
- return wrap ? [] : void 0;
385
- }
386
- if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
387
- return this._getPreferredOutput(result[0]);
388
- }
389
- return result.reduce(function(rslt, ea) {
390
- var valOrPath = _this2._getPreferredOutput(ea);
391
- if (flatten && Array.isArray(valOrPath)) {
392
- rslt = rslt.concat(valOrPath);
393
- } else {
394
- rslt.push(valOrPath);
395
- }
396
- return rslt;
397
- }, []);
398
- };
399
- JSONPath.prototype._getPreferredOutput = function(ea) {
400
- var resultType = this.currResultType;
401
- switch (resultType) {
402
- case "all": {
403
- var path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
404
- ea.pointer = JSONPath.toPointer(path);
405
- ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
406
- return ea;
407
- }
408
- case "value":
409
- case "parent":
410
- case "parentProperty":
411
- return ea[resultType];
412
- case "path":
413
- return JSONPath.toPathString(ea[resultType]);
414
- case "pointer":
415
- return JSONPath.toPointer(ea.path);
416
- default:
417
- throw new TypeError("Unknown result type");
418
- }
419
- };
420
- JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
421
- if (callback) {
422
- var preferredOutput = this._getPreferredOutput(fullRetObj);
423
- fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
424
- callback(preferredOutput, type, fullRetObj);
425
- }
426
- };
427
- JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, callback, hasArrExpr, literalPriority) {
428
- var _this3 = this;
429
- var retObj;
430
- if (!expr.length) {
431
- retObj = {
432
- path,
433
- value: val,
434
- parent,
435
- parentProperty: parentPropName,
436
- hasArrExpr
437
- };
438
- this._handleCallback(retObj, callback, "value");
439
- return retObj;
440
- }
441
- var loc = expr[0], x = expr.slice(1);
442
- var ret = [];
443
- function addRet(elems) {
444
- if (Array.isArray(elems)) {
445
- elems.forEach(function(t2) {
446
- ret.push(t2);
447
- });
448
- } else {
449
- ret.push(elems);
450
- }
451
- }
452
- if ((typeof loc !== "string" || literalPriority) && val && hasOwnProp.call(val, loc)) {
453
- addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr));
454
- } else if (loc === "*") {
455
- this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
456
- addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true, true));
457
- });
458
- } else if (loc === "..") {
459
- addRet(this._trace(x, val, path, parent, parentPropName, callback, hasArrExpr));
460
- this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
461
- if (_typeof(v[m]) === "object") {
462
- addRet(_this3._trace(unshift(l, _x), v[m], push(p, m), v, m, cb, true));
463
- }
464
- });
465
- } else if (loc === "^") {
466
- this._hasParentSelector = true;
467
- return {
468
- path: path.slice(0, -1),
469
- expr: x,
470
- isParentSelector: true
471
- };
472
- } else if (loc === "~") {
473
- retObj = {
474
- path: push(path, loc),
475
- value: parentPropName,
476
- parent,
477
- parentProperty: null
478
- };
479
- this._handleCallback(retObj, callback, "property");
480
- return retObj;
481
- } else if (loc === "$") {
482
- addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));
483
- } else if (/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(loc)) {
484
- addRet(this._slice(loc, x, val, path, parent, parentPropName, callback));
485
- } else if (loc.indexOf("?(") === 0) {
486
- if (this.currPreventEval) {
487
- throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
488
- }
489
- this._walk(loc, x, val, path, parent, parentPropName, callback, function(m, l, _x, v, p, par, pr, cb) {
490
- if (_this3._eval(l.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/, "$1"), v[m], m, p, par, pr)) {
491
- addRet(_this3._trace(unshift(m, _x), v, p, par, pr, cb, true));
492
- }
493
- });
494
- } else if (loc[0] === "(") {
495
- if (this.currPreventEval) {
496
- throw new Error("Eval [(expr)] prevented in JSONPath expression.");
497
- }
498
- addRet(this._trace(unshift(this._eval(loc, val, path[path.length - 1], path.slice(0, -1), parent, parentPropName), x), val, path, parent, parentPropName, callback, hasArrExpr));
499
- } else if (loc[0] === "@") {
500
- var addType = false;
501
- var valueType = loc.slice(1, -2);
502
- switch (valueType) {
503
- case "scalar":
504
- if (!val || !["object", "function"].includes(_typeof(val))) {
505
- addType = true;
506
- }
507
- break;
508
- case "boolean":
509
- case "string":
510
- case "undefined":
511
- case "function":
512
- if (_typeof(val) === valueType) {
513
- addType = true;
514
- }
515
- break;
516
- case "integer":
517
- if (Number.isFinite(val) && !(val % 1)) {
518
- addType = true;
519
- }
520
- break;
521
- case "number":
522
- if (Number.isFinite(val)) {
523
- addType = true;
524
- }
525
- break;
526
- case "nonFinite":
527
- if (typeof val === "number" && !Number.isFinite(val)) {
528
- addType = true;
529
- }
530
- break;
531
- case "object":
532
- if (val && _typeof(val) === valueType) {
533
- addType = true;
534
- }
535
- break;
536
- case "array":
537
- if (Array.isArray(val)) {
538
- addType = true;
539
- }
540
- break;
541
- case "other":
542
- addType = this.currOtherTypeCallback(val, path, parent, parentPropName);
543
- break;
544
- case "null":
545
- if (val === null) {
546
- addType = true;
547
- }
548
- break;
549
- default:
550
- throw new TypeError("Unknown value type " + valueType);
551
- }
552
- if (addType) {
553
- retObj = {
554
- path,
555
- value: val,
556
- parent,
557
- parentProperty: parentPropName
558
- };
559
- this._handleCallback(retObj, callback, "value");
560
- return retObj;
561
- }
562
- } else if (loc[0] === "`" && val && hasOwnProp.call(val, loc.slice(1))) {
563
- var locProp = loc.slice(1);
564
- addRet(this._trace(x, val[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true));
565
- } else if (loc.includes(",")) {
566
- var parts = loc.split(",");
567
- var _iterator = _createForOfIteratorHelper(parts), _step;
568
- try {
569
- for (_iterator.s(); !(_step = _iterator.n()).done; ) {
570
- var part = _step.value;
571
- addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true));
572
- }
573
- } catch (err) {
574
- _iterator.e(err);
575
- } finally {
576
- _iterator.f();
577
- }
578
- } else if (!literalPriority && val && hasOwnProp.call(val, loc)) {
579
- addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr, true));
580
- }
581
- if (this._hasParentSelector) {
582
- for (var t = 0; t < ret.length; t++) {
583
- var rett = ret[t];
584
- if (rett && rett.isParentSelector) {
585
- var tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
586
- if (Array.isArray(tmp)) {
587
- ret[t] = tmp[0];
588
- var tl = tmp.length;
589
- for (var tt = 1; tt < tl; tt++) {
590
- t++;
591
- ret.splice(t, 0, tmp[tt]);
592
- }
593
- } else {
594
- ret[t] = tmp;
595
- }
596
- }
597
- }
598
- }
599
- return ret;
600
- };
601
- JSONPath.prototype._walk = function(loc, expr, val, path, parent, parentPropName, callback, f) {
602
- if (Array.isArray(val)) {
603
- var n = val.length;
604
- for (var i = 0; i < n; i++) {
605
- f(i, loc, expr, val, path, parent, parentPropName, callback);
606
- }
607
- } else if (val && _typeof(val) === "object") {
608
- Object.keys(val).forEach(function(m) {
609
- f(m, loc, expr, val, path, parent, parentPropName, callback);
610
- });
611
- }
612
- };
613
- JSONPath.prototype._slice = function(loc, expr, val, path, parent, parentPropName, callback) {
614
- if (!Array.isArray(val)) {
615
- return void 0;
616
- }
617
- var len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
618
- var start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
619
- start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
620
- end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
621
- var ret = [];
622
- for (var i = start; i < end; i += step) {
623
- var tmp = this._trace(unshift(i, expr), val, path, parent, parentPropName, callback, true);
624
- tmp.forEach(function(t) {
625
- ret.push(t);
626
- });
627
- }
628
- return ret;
629
- };
630
- JSONPath.prototype._eval = function(code, _v, _vname, path, parent, parentPropName) {
631
- if (code.includes("@parentProperty")) {
632
- this.currSandbox._$_parentProperty = parentPropName;
633
- code = code.replace(/@parentProperty/g, "_$_parentProperty");
634
- }
635
- if (code.includes("@parent")) {
636
- this.currSandbox._$_parent = parent;
637
- code = code.replace(/@parent/g, "_$_parent");
638
- }
639
- if (code.includes("@property")) {
640
- this.currSandbox._$_property = _vname;
641
- code = code.replace(/@property/g, "_$_property");
642
- }
643
- if (code.includes("@path")) {
644
- this.currSandbox._$_path = JSONPath.toPathString(path.concat([_vname]));
645
- code = code.replace(/@path/g, "_$_path");
646
- }
647
- if (code.includes("@root")) {
648
- this.currSandbox._$_root = this.json;
649
- code = code.replace(/@root/g, "_$_root");
650
- }
651
- if (/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/.test(code)) {
652
- this.currSandbox._$_v = _v;
653
- code = code.replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g, "_$_v$1");
654
- }
655
- try {
656
- return this.vm.runInNewContext(code, this.currSandbox);
657
- } catch (e) {
658
- console.log(e);
659
- throw new Error("jsonPath: " + e.message + ": " + code);
660
- }
661
- };
662
- JSONPath.cache = {};
663
- JSONPath.toPathString = function(pathArr) {
664
- var x = pathArr, n = x.length;
665
- var p = "$";
666
- for (var i = 1; i < n; i++) {
667
- if (!/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(x[i])) {
668
- p += /^[\*0-9]+$/.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
669
- }
670
- }
671
- return p;
672
- };
673
- JSONPath.toPointer = function(pointer) {
674
- var x = pointer, n = x.length;
675
- var p = "";
676
- for (var i = 1; i < n; i++) {
677
- if (!/^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(x[i])) {
678
- p += "/" + x[i].toString().replace(/~/g, "~0").replace(/\//g, "~1");
679
- }
680
- }
681
- return p;
682
- };
683
- JSONPath.toPathArray = function(expr) {
684
- var cache = JSONPath.cache;
685
- if (cache[expr]) {
686
- return cache[expr].concat();
687
- }
688
- var subx = [];
689
- var normalized = expr.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g, ";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]]/g, function($0, $1) {
690
- return "[#" + (subx.push($1) - 1) + "]";
691
- }).replace(/\[["']((?:(?!['\]])[\s\S])*)["']\]/g, function($0, prop) {
692
- return "['" + prop.replace(/\./g, "%@%").replace(/~/g, "%%@@%%") + "']";
693
- }).replace(/~/g, ";~;").replace(/["']?\.["']?(?!(?:(?!\[)[\s\S])*\])|\[["']?/g, ";").replace(/%@%/g, ".").replace(/%%@@%%/g, "~").replace(/(?:;)?(\^+)(?:;)?/g, function($0, ups) {
694
- return ";" + ups.split("").join(";") + ";";
695
- }).replace(/;;;|;;/g, ";..;").replace(/;$|'?\]|'$/g, "");
696
- var exprList = normalized.split(";").map(function(exp) {
697
- var match = exp.match(/#([0-9]+)/);
698
- return !match || !match[1] ? exp : subx[match[1]];
699
- });
700
- cache[expr] = exprList;
701
- return cache[expr].concat();
702
- };
703
- var moveToAnotherArray = function moveToAnotherArray2(source, target, conditionCb) {
704
- var il = source.length;
705
- for (var i = 0; i < il; i++) {
706
- var item = source[i];
707
- if (conditionCb(item)) {
708
- target.push(source.splice(i--, 1)[0]);
709
- }
710
- }
711
- };
712
- JSONPath.prototype.vm = {
713
- runInNewContext: function runInNewContext(expr, context) {
714
- var keys = Object.keys(context);
715
- var funcs = [];
716
- moveToAnotherArray(keys, funcs, function(key) {
717
- return typeof context[key] === "function";
718
- });
719
- var values = keys.map(function(vr, i) {
720
- return context[vr];
721
- });
722
- var funcString = funcs.reduce(function(s, func) {
723
- var fString = context[func].toString();
724
- if (!/function/.test(fString)) {
725
- fString = "function " + fString;
726
- }
727
- return "var " + func + "=" + fString + ";" + s;
728
- }, "");
729
- expr = funcString + expr;
730
- if (!/(["'])use strict\1/.test(expr) && !keys.includes("arguments")) {
731
- expr = "var arguments = undefined;" + expr;
732
- }
733
- expr = expr.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/, "");
734
- var lastStatementEnd = expr.lastIndexOf(";");
735
- var code = lastStatementEnd > -1 ? expr.slice(0, lastStatementEnd + 1) + " return " + expr.slice(lastStatementEnd + 1) : " return " + expr;
736
- return _construct(Function, _toConsumableArray(keys).concat([code])).apply(void 0, _toConsumableArray(values));
737
- }
738
- };
739
-
740
- // src/fetch.ts
741
- function fetchAndRevalidate(url, options, validator, callback) {
742
- return __async(this, null, function* () {
743
- const date = new Date();
744
- const initialResponse = yield fetch(url, options);
745
- if (!initialResponse.ok)
746
- throw new Error("Fetch failed");
747
- const responseDate = new Date(initialResponse.headers.get("date"));
748
- var response = initialResponse;
749
- callback(initialResponse, "cached");
750
- if (responseDate < date) {
751
- const freshHeadResponse = yield fetch(url + "?" + Math.random(), __spreadProps(__spreadValues({}, options), {
752
- method: "HEAD",
753
- cache: "no-cache"
754
- }));
755
- if (freshHeadResponse.headers.get("last-modified") != initialResponse.headers.get("last-modified")) {
756
- if (validator(freshHeadResponse) === false) {
757
- throw new Error("Response is stale");
758
- }
759
- response = yield fetch(url, __spreadProps(__spreadValues({}, options), {
760
- cache: "reload"
761
- }));
762
- }
763
- }
764
- if (validator(response) === false) {
765
- throw new Error("Response is not valid");
766
- }
767
- if (initialResponse !== response) {
768
- callback(response, "valid");
769
- }
770
- return response;
771
- });
772
- }
773
-
774
- // src/cloud.ts
775
- function getComponentURL({
776
- cdn = "https://feaascomponentsapidev.blob.core.windows.net",
777
- hostname,
778
- library,
779
- component,
780
- version,
781
- revision = "published"
782
- }) {
783
- return `${cdn || hostname}/components/${library}/${component}/${version}/${revision}.html`;
784
- }
785
- function getStylesheetURL({
786
- cdn = `https://feaascomponentsapidev.blob.core.windows.net`,
787
- hostname,
788
- library,
789
- revision = "published"
790
- }) {
791
- return `${cdn || hostname}/styles/${library}/${revision}.css`;
792
- }
793
- function fetchComponent(props, callback) {
794
- return __async(this, null, function* () {
795
- return fetchAndRevalidate(
796
- getComponentURL(props),
797
- {},
798
- (response) => {
799
- return response.headers.get("x-ms-meta-versionDeletedAt") == null;
800
- },
801
- (response) => {
802
- response.text().then(callback);
803
- }
804
- );
805
- });
806
- }
807
- function fetchStylesheet(props, callback) {
808
- return __async(this, null, function* () {
809
- return fetchAndRevalidate(
810
- getStylesheetURL(props),
811
- {},
812
- (response) => {
813
- return response.headers.get("x-ms-meta-deletedAt") == null;
814
- },
815
- (response) => {
816
- response.text().then(callback);
817
- }
818
- );
819
- });
820
- }
821
-
822
- // src/dom.ts
823
- function renderComponentElement(content, datasources) {
824
- const wrapper = document.createElement("div");
825
- wrapper.innerHTML = content;
826
- const fragment = document.createDocumentFragment();
827
- while (wrapper.firstChild) {
828
- fragment.appendChild(wrapper.firstChild);
829
- }
830
- renderDOMElement(fragment, datasources);
831
- return wrapper;
832
- }
833
- function cleanCollectionBit(path) {
834
- return path.replace(/(\[[^\]\[]+\]|\.\*)$/g, "");
835
- }
836
- function normalizeCollectionScope(path) {
837
- return cleanCollectionBit(path) + ".*";
838
- }
839
- function getDOMCollectionIndex(element) {
840
- const datascope = element.getAttribute("data-path-scope");
841
- var index = 0;
842
- for (var p = element; p = p.previousElementSibling; ) {
843
- if (p.getAttribute("data-path-scope") == datascope) {
844
- index++;
845
- }
846
- }
847
- return index;
848
- }
849
- function updateDOMClones(element, targetCount, config) {
850
- const datascope = element.getAttribute("data-path-scope");
851
- if (datascope == null) {
852
- return;
853
- }
854
- var index = getDOMCollectionIndex(element);
855
- if (index != 0) {
856
- return;
857
- }
858
- const parentElement = element.parentElement;
859
- if (parentElement == null) {
860
- return;
861
- }
862
- if (targetCount == 0) {
863
- element.style.display = "none";
864
- } else if (element.style.display) {
865
- element.style.display = "";
866
- if (element.getAttribute("style") == "")
867
- element.removeAttribute("style");
868
- }
869
- var count = index + 1;
870
- var last = element;
871
- for (var n = element; n = n.nextElementSibling; ) {
872
- if (n.getAttribute("data-path-scope") == datascope) {
873
- count++;
874
- last = n;
875
- }
876
- }
877
- for (var i = count; i < targetCount; i++) {
878
- parentElement.insertBefore(last.cloneNode(true), last.nextElementSibling);
879
- }
880
- for (var i = Math.max(1, targetCount); i < count; i++) {
881
- last = last.previousElementSibling;
882
- parentElement.removeChild(last.nextElementSibling);
883
- }
884
- }
885
- function queryScopes(scopes, datapath, singleValue = false, json = scopes) {
886
- var path = datapath;
887
- const keys = Object.keys(scopes).sort((b, a) => a.length - b.length);
888
- for (const scope of keys) {
889
- if (datapath.startsWith(scope) && "ends with it") {
890
- if (scope == datapath) {
891
- if (singleValue) {
892
- return scopes[scope];
893
- } else {
894
- continue;
895
- }
896
- }
897
- path = datapath.substring(scope.length + 1);
898
- json = scopes[scope];
899
- break;
900
- }
901
- }
902
- const collection = JSONPath({
903
- path,
904
- json
905
- });
906
- if (singleValue && collection && Array.isArray(collection)) {
907
- return collection[0];
908
- } else {
909
- return collection;
910
- }
911
- }
912
- function setDOMAttribute(element, attribute, value, config) {
913
- var _a;
914
- if (!element)
915
- return;
916
- var target = element;
917
- if (config == null ? void 0 : config.processValue) {
918
- value = config == null ? void 0 : config.processValue(element, attribute, value);
919
- }
920
- var prop = attribute.replace("data-path-", "");
921
- if (attribute == "data-path-src") {
922
- target = element.tagName == "IMG" ? element : element.querySelector("img, video");
923
- } else if (attribute == "data-path-href") {
924
- target = element.querySelector("a") || element.closest("a");
925
- } else if (attribute == "data-path-alt") {
926
- target = element.querySelector("img, picture");
927
- } else if (attribute == "data-path-hidden") {
928
- value = !value ? true : null;
929
- } else if (attribute == "data-path" || attribute == "data-embed-html" || attribute == "html") {
930
- prop = "innerHTML";
931
- } else if (attribute == "data-embed-src") {
932
- loadScript(element, value);
933
- } else if (attribute == "data-path-attributes") {
934
- const oldKeys = ((_a = element.getAttribute("data-attributes-keys")) == null ? void 0 : _a.split(",").filter(Boolean)) || [];
935
- for (var property in value) {
936
- var subvalue = value[property];
937
- setDOMAttribute(
938
- element,
939
- property,
940
- typeof subvalue == "object" && subvalue ? JSON.stringify(subvalue) : subvalue,
941
- config
942
- );
943
- }
944
- for (var i = 0; i < oldKeys.length; i++) {
945
- if (value == null || !(oldKeys[i] in value)) {
946
- setDOMAttribute(element, oldKeys[i], null, config);
947
- }
948
- }
949
- setDOMAttribute(element, "data-attributes-keys", Object.keys(value || {}).join(","));
950
- return;
951
- }
952
- if (typeof value == "boolean") {
953
- value = value ? "" : null;
954
- }
955
- if (!target)
956
- return;
957
- var placeholder = String(element.getAttribute("data-path-placeholder") || target[prop]);
958
- if (value != null) {
959
- if (prop == "innerHTML") {
960
- if (target.innerHTML != value) {
961
- target.innerHTML = value;
962
- }
963
- } else {
964
- if (target.getAttribute(prop) != value) {
965
- target.setAttribute(prop, value);
966
- }
967
- }
968
- } else {
969
- if (prop == "innerHTML") {
970
- target.innerHTML = placeholder;
971
- } else {
972
- target.removeAttribute(prop);
973
- }
974
- }
975
- }
976
- function observeDOMElement(element) {
977
- const observer = new element.ownerDocument.defaultView.MutationObserver((changes) => {
978
- changes.forEach((change) => {
979
- const target = change.target;
980
- const src = target.getAttribute("data-embed-src");
981
- if (src) {
982
- loadScript(target, src);
983
- }
984
- if (change.addedNodes) {
985
- change.addedNodes.forEach((node) => {
986
- if (node.nodeType == 1)
987
- autoloadScripts(node, false);
988
- });
989
- }
990
- });
991
- });
992
- observer.observe(element, { attributes: true, subtree: true, childList: true });
993
- return observer;
994
- }
995
- function autoloadScripts(element, observe = true) {
996
- const embeds = element.querySelectorAll("[data-embed-src]");
997
- for (var i = 0; i < embeds.length; i++) {
998
- const embed = embeds[i];
999
- loadScript(embed, embed.getAttribute("data-embed-src"));
1000
- }
1001
- if (observe)
1002
- return observeDOMElement(element);
1003
- }
1004
- function loadScript(element, src) {
1005
- for (var p = element; p; p = p.parentElement) {
1006
- if (!p.parentElement) {
1007
- const scripts = p.querySelectorAll("script");
1008
- for (var i = 0; i < scripts.length; i++) {
1009
- if (scripts[i].getAttribute("src") == src) {
1010
- return true;
1011
- }
1012
- }
1013
- if (p.tagName == "HTML")
1014
- p = p.querySelector("head") || p;
1015
- const script = p.ownerDocument.createElement("script");
1016
- script.type = "module";
1017
- script.src = src;
1018
- p.appendChild(script);
1019
- break;
1020
- }
1021
- }
1022
- }
1023
- var sortOrder = ["data-attributes-keys", "data-path-attributes", "data-path-scope"];
1024
- function renderDOMElement(input, datascopes, config, isNested) {
1025
- var _a, _b, _c;
1026
- const element = input;
1027
- if (!isNested) {
1028
- datascopes = ((_a = config == null ? void 0 : config.processData) == null ? void 0 : _a.call(config, element, datascopes)) || datascopes;
1029
- }
1030
- if (element.nodeType == 1) {
1031
- const datascope = element.getAttribute("data-path-scope");
1032
- if (datascope) {
1033
- const index = getDOMCollectionIndex(element);
1034
- const collection = queryScopes(datascopes, datascope, false) || [];
1035
- if (index == 0) {
1036
- updateDOMClones(element, ((_b = config == null ? void 0 : config.shouldRepeat) == null ? void 0 : _b.call(config, element, collection)) === false ? 1 : collection.length, config);
1037
- }
1038
- datascopes = __spreadProps(__spreadValues({}, datascopes), {
1039
- [normalizeCollectionScope(datascope)]: collection[index]
1040
- });
1041
- }
1042
- const attrs = Array.prototype.slice.call(element.attributes).sort((a, b) => {
1043
- return sortOrder.indexOf(a.name) - sortOrder.indexOf(b.name);
1044
- });
1045
- for (var i = 0; i < attrs.length; i++) {
1046
- const { name, value: datapath } = attrs[i];
1047
- if (name.startsWith("data-path") && name != "data-path-scope") {
1048
- setDOMAttribute(element, name, queryScopes(datascopes, datapath, true), config);
1049
- }
1050
- if (name == "data-embed-src") {
1051
- setDOMAttribute(element, name, element.getAttribute(name), config);
1052
- }
1053
- }
1054
- }
1055
- for (var i = 0; i < element.children.length; i++) {
1056
- renderDOMElement(element.children[i], datascopes, config, true);
1057
- }
1058
- if (!isNested) {
1059
- (_c = config == null ? void 0 : config.onRender) == null ? void 0 : _c.call(config, element, datascopes);
1060
- }
1061
- return element;
1062
- }
1063
- function renderDOMContent(root, template, data, config) {
1064
- var _a;
1065
- const newTemplate = ((_a = config == null ? void 0 : config.processTemplate) == null ? void 0 : _a.call(config, root, template, data)) || template;
1066
- root.innerHTML = newTemplate;
1067
- root.classList.add("-feaas");
1068
- return renderDOMElement(root, data, config);
1069
- }
1070
- function renderStylesheet(props, style) {
1071
- renderStylesheetPromise(props, style || (style = document.createElement("style")));
1072
- return style;
1073
- }
1074
- function renderStylesheetPromise(props, style) {
1075
- style || (style = document.createElement("style"));
1076
- return fetchStylesheet(props, (cssText) => {
1077
- style.textContent = cssText;
1078
- }).then(() => style);
1079
- }
1080
- function renderComponent(props, root) {
1081
- renderComponentPromise(props, root || (root = document.createElement("div")));
1082
- return root;
1083
- }
1084
- function renderComponentPromise(props, root) {
1085
- return __async(this, null, function* () {
1086
- root || (root = document.createElement("div"));
1087
- if (!root.childNodes.length) {
1088
- if ("template" in props) {
1089
- return renderDOMContent(root, props.template, props.data, props);
1090
- } else {
1091
- return fetchComponent(props, (template) => {
1092
- return renderDOMContent(root, template, props.data, props);
1093
- }).then(() => root);
1094
- }
1095
- } else {
1096
- return renderDOMElement(root, props.data, props);
1097
- }
1098
- });
1099
- }
1100
-
1101
- // src/components/FEAASBase.tsx
1102
- var FEAASBase = class extends HTMLElement {
1103
- constructor() {
1104
- super(...arguments);
1105
- this.connected = null;
1106
- this.refs = {};
1107
- this.descendants = [];
1108
- this.onLoad = (payload) => {
1109
- if (payload == null)
1110
- return;
1111
- this.payload = payload;
1112
- this.render();
1113
- };
1114
- }
1115
- getProps(context) {
1116
- return {};
1117
- }
1118
- getRoot() {
1119
- return this;
1120
- }
1121
- attributeChangedCallback(name, oldValue, newValue) {
1122
- this.set();
1123
- }
1124
- connectedCallback() {
1125
- console.log("FEAAS: Connected", this);
1126
- this.connected = new Event("feaasConnected", { bubbles: true, composed: true });
1127
- this.dispatchEvent(this.connected);
1128
- this.addEventListener("feaasConnected", this);
1129
- this.addEventListener("feaasDisconnected", this);
1130
- this.set();
1131
- }
1132
- disconnectedCallback() {
1133
- console.log("FEAAS: Disconnected", this);
1134
- this.removeEventListener("feaasConnected", this);
1135
- this.removeEventListener("feaasDisconnected", this);
1136
- this.dispatchEvent(new Event("feaasDisconnected", { bubbles: true, composed: true }));
1137
- this.connected = null;
1138
- }
1139
- handleEvent(event) {
1140
- switch (event.type) {
1141
- case "feaasConnected":
1142
- this.nestedCallback(event);
1143
- break;
1144
- case "feaasDisconnected":
1145
- this.unnestedCallback(event);
1146
- break;
1147
- }
1148
- }
1149
- unnestedCallback(event) {
1150
- const target = event.composedPath()[0];
1151
- const index = this.descendants.indexOf(target);
1152
- if (index == -1)
1153
- return;
1154
- console.log("FEAAS: Unnest", this, target);
1155
- this.descendants.splice(index, -1);
1156
- this.refs[target.getComponentName()] = null;
1157
- if (target.refs.parent == this)
1158
- target.refs.parent = null;
1159
- if (target.refs.top == this) {
1160
- target.refs.top = target.refs.parent;
1161
- }
1162
- }
1163
- nestedCallback(event) {
1164
- var _a, _b;
1165
- const target = event.composedPath()[0];
1166
- const index = this.descendants.indexOf(target);
1167
- if (index != -1)
1168
- return;
1169
- this.descendants.push(target);
1170
- console.log("FEAAS: Nest", this, target);
1171
- this.refs[target.getComponentName()] = target;
1172
- target.refs.top = this;
1173
- (_a = target.refs).parent || (_a.parent = this);
1174
- if (target.renderReact) {
1175
- for (var p = target.refs.parent; p; p = p.refs.parent) {
1176
- if (p.renderReact) {
1177
- (_b = target.refs).parentReact || (_b.parentReact = p);
1178
- target.refs.topReact = p;
1179
- }
1180
- }
1181
- }
1182
- }
1183
- getComponentName() {
1184
- return this.tagName.replace("FEAAS-", "").toLowerCase();
1185
- }
1186
- isReadyToLoad() {
1187
- return this.payload === void 0 && this.getAttribute("hidden") == null;
1188
- }
1189
- reify() {
1190
- return __async(this, null, function* () {
1191
- if (this.payload !== void 0) {
1192
- this.render();
1193
- } else if (this.isReadyToLoad()) {
1194
- this.payload = null;
1195
- this.load().then(this.onLoad);
1196
- }
1197
- });
1198
- }
1199
- load() {
1200
- return Promise.resolve(null);
1201
- }
1202
- render(nested = false) {
1203
- var _a, _b, _c;
1204
- console.log("FEAAS: React", this.tagName, this.payload);
1205
- if (this.payload == null)
1206
- return;
1207
- const { React: React2, ReactDOM } = this.payload || {};
1208
- if (!React2)
1209
- throw new Error(`${this.tagName}: React is not present in payload`);
1210
- if (!ReactDOM)
1211
- throw new Error(`${this.tagName}: ReactDOM is not present in payload`);
1212
- if (!this.refs.topReact && !this.forceUpdateReact) {
1213
- ReactDOM.render(React2.createElement(this.getReactWrapper()), this.getReactRoot());
1214
- } else if (this.forceUpdateReact) {
1215
- (_a = this.forceUpdateReact) == null ? void 0 : _a.call(this);
1216
- } else {
1217
- (_c = (_b = this.refs.topReact).forceUpdateReact) == null ? void 0 : _c.call(_b);
1218
- }
1219
- }
1220
- invokeReactRendering() {
1221
- const { React: React2, ReactDOM } = this.payload || {};
1222
- const children = this.descendants.filter((r) => {
1223
- return r.refs.parentReact == this && r.payload;
1224
- }).map((child, index) => {
1225
- return React2.createElement(this.getReactWrapper(child), {
1226
- key: this.tagName + "-" + index,
1227
- slot: child.getAttribute("slot")
1228
- });
1229
- });
1230
- return this.renderReact(__spreadProps(__spreadValues({}, this.props), { children }), this.payload);
1231
- }
1232
- getReactWrapper(target = this, displayName = target.tagName) {
1233
- const Wrapper = target.reactWrapper || (target.reactWrapper = (props) => {
1234
- if (target.renderReact) {
1235
- const { React: React2, ReactDOM } = target.payload || {};
1236
- const [value, forceUpdateReact] = React2.useReducer((r) => r + 1, 0);
1237
- target.forceUpdateReact = forceUpdateReact;
1238
- return ReactDOM.createPortal(/* @__PURE__ */ React2.createElement(React2.Fragment, null, target.invokeReactRendering()), target.getReactRoot());
1239
- } else {
1240
- return target.render();
1241
- }
1242
- });
1243
- Object.assign(Wrapper, {
1244
- displayName
1245
- });
1246
- return Wrapper;
1247
- }
1248
- getUID() {
1249
- return this.uid || (this.uid = String(Math.random()));
1250
- }
1251
- getReactRoot() {
1252
- return this.getRoot();
1253
- }
1254
- set(overrides) {
1255
- this.overrides = __spreadValues(__spreadValues({}, this.overrides), overrides);
1256
- this.props = __spreadValues(__spreadValues({}, this.getProps()), this.overrides);
1257
- for (var property in this.props) {
1258
- const value = this.props[property];
1259
- if (this.props[property] == null) {
1260
- this.removeAttribute(property);
1261
- } else if (typeof value == "string" || typeof value == "number") {
1262
- if (this.getAttribute(property) != String(value))
1263
- this.setAttribute(property, String(value));
1264
- }
1265
- }
1266
- this.scheduleRender();
1267
- }
1268
- scheduleRender() {
1269
- cancelAnimationFrame(this.nextRender);
1270
- this.nextRender = requestAnimationFrame(() => {
1271
- this.reify();
1272
- });
1273
- }
1274
- formatURL(src, hostname) {
1275
- if (typeof src == "string" && src.match(/^\/[^\/]/)) {
1276
- return hostname + src;
1277
- } else {
1278
- return src;
1279
- }
1280
- }
1281
- getContextAttribute(name, element = this) {
1282
- var _a, _b;
1283
- return (_b = (_a = element.closest(`[${name}]`)) == null ? void 0 : _a.getAttribute(name)) != null ? _b : this.getAttribute(name);
1284
- }
1285
- static register(tagName) {
1286
- if (!window.customElements.get(tagName)) {
1287
- window.customElements.define(tagName, this);
1288
- }
1289
- }
1290
- };
1291
-
1292
- // src/components/FEAASLoader.ts
1293
- function FEAASLoaderProps(element = this) {
1294
- return {
1295
- hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null
1296
- };
1297
- }
1298
- var FEAASLoader = class extends FEAASBase {
1299
- attributeChangedCallback(name, oldValue, newValue) {
1300
- if (name == "hidden") {
1301
- this.style.setProperty("display", "block", "important");
1302
- this.style.setProperty("transition", "opacity 0.3s", "important");
1303
- if (newValue) {
1304
- this.style.setProperty("opacity", "0", "important");
1305
- this.style.pointerEvents = "none";
1306
- } else {
1307
- this.style.setProperty("opacity", "1", "important");
1308
- this.style.pointerEvents = "all";
1309
- }
1310
- }
1311
- }
1312
- connectedCallback() {
1313
- this.attributeChangedCallback("hidden", this.getAttribute("hidden"), this.getAttribute("hidden"));
1314
- this.stylesheet = document.createElement("style");
1315
- this.stylesheet.textContent = `
1
+ var mt=Object.create;var $=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Rt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var xt=(t,e)=>{for(var r in e)$(t,r,{get:e[r],enumerable:!0})},Y=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wt(e))!Et.call(t,o)&&o!==r&&$(t,o,{get:()=>e[o],enumerable:!(i=At(e,o))||i.enumerable});return t};var Ct=(t,e,r)=>(r=t!=null?mt(Rt(t)):{},Y(e||!t||!t.__esModule?$(r,"default",{value:t,enumerable:!0}):r,t)),_t=t=>Y($({},"__esModule",{value:!0}),t);var Dt={};xt(Dt,{Base:()=>y,Component:()=>_,FEAASBase:()=>y,FEAASComponent:()=>_,FEAASComponentsProps:()=>st,FEAASContext:()=>P,FEAASContextProps:()=>ht,FEAASEditor:()=>H,FEAASEditorProps:()=>dt,FEAASLoader:()=>k,FEAASLoaderProps:()=>$t,FEAASPicker:()=>I,FEAASPickerLazy:()=>S,FEAASPickerLazyProps:()=>ut,FEAASPickerProps:()=>ct,FEAASStylesheet:()=>U,FEAASStylesheetProps:()=>at,Loader:()=>k,Stylesheet:()=>U,autoloadScripts:()=>it,cleanCollectionBit:()=>Z,fetchAndRevalidate:()=>D,getFramePosition:()=>lt,loadScript:()=>j,normalizeCollectionScope:()=>tt,observeDOMElement:()=>rt,queryScopes:()=>J,renderComponent:()=>Mt,renderComponentElement:()=>Pt,renderComponentPromise:()=>nt,renderDOMContent:()=>C,renderDOMElement:()=>w,renderStylesheet:()=>Ot,renderStylesheetPromise:()=>ot,setDOMAttribute:()=>R});module.exports=_t(Dt);var Q=Ct(require("vm"),1),{hasOwnProperty:b}=Object.prototype;function A(t,e){return t=t.slice(),t.push(e),t}function q(t,e){return e=e.slice(),e.unshift(t),e}var z=class extends Error{constructor(e){super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'),this.avoidNew=!0,this.value=e,this.name="NewError"}};function p(t,e,r,i,o){if(!(this instanceof p))try{return new p(t,e,r,i,o)}catch(s){if(!s.avoidNew)throw s;return s.value}typeof t=="string"&&(o=i,i=r,r=e,e=t,t=null);let n=t&&typeof t=="object";if(t=t||{},this.json=t.json||r,this.path=t.path||e,this.resultType=t.resultType||"value",this.flatten=t.flatten||!1,this.wrap=b.call(t,"wrap")?t.wrap:!0,this.sandbox=t.sandbox||{},this.preventEval=t.preventEval||!1,this.parent=t.parent||null,this.parentProperty=t.parentProperty||null,this.callback=t.callback||i||null,this.otherTypeCallback=t.otherTypeCallback||o||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},t.autostart!==!1){let s={path:n?t.path:e};n?"json"in t&&(s.json=t.json):s.json=r;let a=this.evaluate(s);if(!a||typeof a!="object")throw new z(a);return a}}p.prototype.evaluate=function(t,e,r,i){let o=this.parent,n=this.parentProperty,{flatten:s,wrap:a}=this;if(this.currResultType=this.resultType,this.currPreventEval=this.preventEval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=i||this.otherTypeCallback,e=e||this.json,t=t||this.path,t&&typeof t=="object"&&!Array.isArray(t)){if(!t.path&&t.path!=="")throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!b.call(t,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:e}=t),s=b.call(t,"flatten")?t.flatten:s,this.currResultType=b.call(t,"resultType")?t.resultType:this.currResultType,this.currSandbox=b.call(t,"sandbox")?t.sandbox:this.currSandbox,a=b.call(t,"wrap")?t.wrap:a,this.currPreventEval=b.call(t,"preventEval")?t.preventEval:this.currPreventEval,r=b.call(t,"callback")?t.callback:r,this.currOtherTypeCallback=b.call(t,"otherTypeCallback")?t.otherTypeCallback:this.currOtherTypeCallback,o=b.call(t,"parent")?t.parent:o,n=b.call(t,"parentProperty")?t.parentProperty:n,t=t.path}if(o=o||null,n=n||null,Array.isArray(t)&&(t=p.toPathString(t)),!t&&t!==""||!e)return;let d=p.toPathArray(t);d[0]==="$"&&d.length>1&&d.shift(),this._hasParentSelector=null;let l=this._trace(d,e,["$"],o,n,r).filter(function(h){return h&&!h.isParentSelector});return l.length?!a&&l.length===1&&!l[0].hasArrExpr?this._getPreferredOutput(l[0]):l.reduce((h,u)=>{let f=this._getPreferredOutput(u);return s&&Array.isArray(f)?h=h.concat(f):h.push(f),h},[]):a?[]:void 0};p.prototype._getPreferredOutput=function(t){let e=this.currResultType;switch(e){case"all":{let r=Array.isArray(t.path)?t.path:p.toPathArray(t.path);return t.pointer=p.toPointer(r),t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),t}case"value":case"parent":case"parentProperty":return t[e];case"path":return p.toPathString(t[e]);case"pointer":return p.toPointer(t.path);default:throw new TypeError("Unknown result type")}};p.prototype._handleCallback=function(t,e,r){if(e){let i=this._getPreferredOutput(t);t.path=typeof t.path=="string"?t.path:p.toPathString(t.path),e(i,r,t)}};p.prototype._trace=function(t,e,r,i,o,n,s,a){let d;if(!t.length)return d={path:r,value:e,parent:i,parentProperty:o,hasArrExpr:s},this._handleCallback(d,n,"value"),d;let l=t[0],h=t.slice(1),u=[];function f(c){Array.isArray(c)?c.forEach(g=>{u.push(g)}):u.push(c)}if((typeof l!="string"||a)&&e&&b.call(e,l))f(this._trace(h,e[l],A(r,l),e,l,n,s));else if(l==="*")this._walk(e,c=>{f(this._trace(h,e[c],A(r,c),e,c,n,!0,!0))});else if(l==="..")f(this._trace(h,e,r,i,o,n,s)),this._walk(e,c=>{typeof e[c]=="object"&&f(this._trace(t.slice(),e[c],A(r,c),e,c,n,!0))});else{if(l==="^")return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:h,isParentSelector:!0};if(l==="~")return d={path:A(r,l),value:o,parent:i,parentProperty:null},this._handleCallback(d,n,"property"),d;if(l==="$")f(this._trace(h,e,r,null,null,n,s));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l))f(this._slice(l,h,e,r,i,o,n));else if(l.indexOf("?(")===0){if(this.currPreventEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");let c=l.replace(/^\?\((.*?)\)$/u,"$1");this._walk(e,g=>{this._eval(c,e[g],g,r,i,o)&&f(this._trace(h,e[g],A(r,g),e,g,n,!0))})}else if(l[0]==="("){if(this.currPreventEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");f(this._trace(q(this._eval(l,e,r[r.length-1],r.slice(0,-1),i,o),h),e,r,i,o,n,s))}else if(l[0]==="@"){let c=!1,g=l.slice(1,-2);switch(g){case"scalar":(!e||!["object","function"].includes(typeof e))&&(c=!0);break;case"boolean":case"string":case"undefined":case"function":typeof e===g&&(c=!0);break;case"integer":Number.isFinite(e)&&!(e%1)&&(c=!0);break;case"number":Number.isFinite(e)&&(c=!0);break;case"nonFinite":typeof e=="number"&&!Number.isFinite(e)&&(c=!0);break;case"object":e&&typeof e===g&&(c=!0);break;case"array":Array.isArray(e)&&(c=!0);break;case"other":c=this.currOtherTypeCallback(e,r,i,o);break;case"null":e===null&&(c=!0);break;default:throw new TypeError("Unknown value type "+g)}if(c)return d={path:r,value:e,parent:i,parentProperty:o},this._handleCallback(d,n,"value"),d}else if(l[0]==="`"&&e&&b.call(e,l.slice(1))){let c=l.slice(1);f(this._trace(h,e[c],A(r,c),e,c,n,s,!0))}else if(l.includes(",")){let c=l.split(",");for(let g of c)f(this._trace(q(g,h),e,r,i,o,n,!0))}else!a&&e&&b.call(e,l)&&f(this._trace(h,e[l],A(r,l),e,l,n,s,!0))}if(this._hasParentSelector)for(let c=0;c<u.length;c++){let g=u[c];if(g&&g.isParentSelector){let m=this._trace(g.expr,e,g.path,i,o,n,s);if(Array.isArray(m)){u[c]=m[0];let W=m.length;for(let E=1;E<W;E++)c++,u.splice(c,0,m[E])}else u[c]=m}}return u};p.prototype._walk=function(t,e){if(Array.isArray(t)){let r=t.length;for(let i=0;i<r;i++)e(i)}else t&&typeof t=="object"&&Object.keys(t).forEach(r=>{e(r)})};p.prototype._slice=function(t,e,r,i,o,n,s){if(!Array.isArray(r))return;let a=r.length,d=t.split(":"),l=d[2]&&Number.parseInt(d[2])||1,h=d[0]&&Number.parseInt(d[0])||0,u=d[1]&&Number.parseInt(d[1])||a;h=h<0?Math.max(0,h+a):Math.min(a,h),u=u<0?Math.max(0,u+a):Math.min(a,u);let f=[];for(let c=h;c<u;c+=l)this._trace(q(c,e),r,i,o,n,s,!0).forEach(m=>{f.push(m)});return f};p.prototype._eval=function(t,e,r,i,o,n){this.currSandbox._$_parentProperty=n,this.currSandbox._$_parent=o,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=e;let s=t.includes("@path");s&&(this.currSandbox._$_path=p.toPathString(i.concat([r])));let a="script:"+t;if(!p.cache[a]){let d=t.replace(/@parentProperty/gu,"_$_parentProperty").replace(/@parent/gu,"_$_parent").replace(/@property/gu,"_$_property").replace(/@root/gu,"_$_root").replace(/@([.\s)[])/gu,"_$_v$1");s&&(d=d.replace(/@path/gu,"_$_path")),p.cache[a]=new this.vm.Script(d)}try{return p.cache[a].runInNewContext(this.currSandbox)}catch(d){throw new Error("jsonPath: "+d.message+": "+t)}};p.cache={};p.toPathString=function(t){let e=t,r=e.length,i="$";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(e[o])||(i+=/^[0-9*]+$/u.test(e[o])?"["+e[o]+"]":"['"+e[o]+"']");return i};p.toPointer=function(t){let e=t,r=e.length,i="";for(let o=1;o<r;o++)/^(~|\^|@.*?\(\))$/u.test(e[o])||(i+="/"+e[o].toString().replace(/~/gu,"~0").replace(/\//gu,"~1"));return i};p.toPathArray=function(t){let{cache:e}=p;if(e[t])return e[t].concat();let r=[],o=t.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu,";$&;").replace(/[['](\??\(.*?\))[\]']/gu,function(n,s){return"[#"+(r.push(s)-1)+"]"}).replace(/\[['"]([^'\]]*)['"]\]/gu,function(n,s){return"['"+s.replace(/\./gu,"%@%").replace(/~/gu,"%%@@%%")+"']"}).replace(/~/gu,";~;").replace(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu,";").replace(/%@%/gu,".").replace(/%%@@%%/gu,"~").replace(/(?:;)?(\^+)(?:;)?/gu,function(n,s){return";"+s.split("").join(";")+";"}).replace(/;;;|;;/gu,";..;").replace(/;$|'?\]|'$/gu,"").split(";").map(function(n){let s=n.match(/#(\d+)/u);return!s||!s[1]?n:r[s[1]]});return e[t]=o,e[t].concat()};p.prototype.vm=Q.default;async function D(t,e,r,i){let o=new Date,n=await fetch(t,e);if(!n.ok)throw new Error("Fetch failed");let s=new Date(n.headers.get("date"));var a=n;if(i(n,"cached"),s<o){let d=await fetch(t+"?"+Math.random(),{...e,method:"HEAD",cache:"no-cache"});if(d.headers.get("last-modified")!=n.headers.get("last-modified")){if(r(d)===!1)throw new Error("Response is stale");a=await fetch(t,{...e,cache:"reload"})}}if(r(a)===!1)throw new Error("Response is not valid");return n!==a&&i(a,"valid"),a}function kt({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,component:i,version:o,revision:n="published"}){return`${t||e}/components/${r}/${i}/${o}/${n}.html`}function St({cdn:t="https://feaascomponentsapidev.blob.core.windows.net",hostname:e,library:r,revision:i="published"}){return`${t||e}/styles/${r}/${i}.css`}async function N(t,e){return D(kt(t),{},r=>r.headers.get("x-ms-meta-versionDeletedAt")==null,r=>{r.text().then(e)})}async function F(t,e){return D(St(t),{},r=>r.headers.get("x-ms-meta-deletedAt")==null,r=>{r.text().then(e)})}function Pt(t,e){let r=document.createElement("div");r.innerHTML=t;let i=document.createDocumentFragment();for(;r.firstChild;)i.appendChild(r.firstChild);return w(i,e),r}function Z(t){return t.replace(/(\[[^\]\[]+\]|\.\*)$/g,"")}function tt(t){return Z(t)+".*"}function et(t){let e=t.getAttribute("data-path-scope");for(var r=0,i=t;i=i.previousElementSibling;)i.getAttribute("data-path-scope")==e&&r++;return r}function Tt(t,e,r){let i=t.getAttribute("data-path-scope");if(i==null)return;var o=et(t);if(o!=0)return;let n=t.parentElement;if(n!=null){e==0?t.style.display="none":t.style.display&&(t.style.display="",t.getAttribute("style")==""&&t.removeAttribute("style"));for(var s=o+1,a=t,d=t;d=d.nextElementSibling;)d.getAttribute("data-path-scope")==i&&(s++,a=d);for(var l=s;l<e;l++)n.insertBefore(a.cloneNode(!0),a.nextElementSibling);for(var l=Math.max(1,e);l<s;l++)a=a.previousElementSibling,n.removeChild(a.nextElementSibling)}}function J(t,e,r=!1,i=t){var o=e;let n=Object.keys(t).sort((a,d)=>d.length-a.length);for(let a of n)if(e.startsWith(a)){if(a==e){if(r)return t[a];continue}o=e.substring(a.length+1),i=t[a];break}var s=p({path:o,json:i});return t!=null&&t._&&Array.isArray(s)&&(s==null?void 0:s.length)==0&&(s=p({path:o.replace(/^.*?\./,"_."),json:t})),r&&Array.isArray(s)?s[0]:s}function R(t,e,r,i){var o;if(t){var n=t;i!=null&&i.processValue&&(r=i==null?void 0:i.processValue(t,e,r));var s=e.replace("data-path-","");if(e=="data-path-src")n=t.tagName=="IMG"?t:t.querySelector("img, video");else if(e=="data-path-href")n=t.querySelector("a")||t.closest("a");else if(e=="data-path-alt")n=t.querySelector("img, picture");else if(e=="data-path-hidden")r=r?null:!0;else if(e=="data-path"||e=="data-embed-html"||e=="html")s="innerHTML";else if(e=="data-embed-src")j(t,r);else if(e=="data-path-attributes"){let u=((o=t.getAttribute("data-attributes-keys"))===null||o===void 0?void 0:o.split(",").filter(Boolean))||[];for(var a in r){var d=r[a];R(t,a,typeof d=="object"&&d?JSON.stringify(d):d,i)}for(var l=0;l<u.length;l++)(r==null||!(u[l]in r))&&R(t,u[l],null,i);R(t,"data-attributes-keys",Object.keys(r||{}).join(","));return}if(typeof r=="boolean"&&(r=r?"":null),!!n){var h=String(t.getAttribute("data-path-placeholder")||n[s]);r!=null?s=="innerHTML"?n.innerHTML!=r&&(n.innerHTML=r):n.getAttribute(s)!=r&&n.setAttribute(s,r):s=="innerHTML"?n.innerHTML=h:n.removeAttribute(s)}}}function rt(t){let e=new t.ownerDocument.defaultView.MutationObserver(r=>{r.forEach(i=>{let o=i.target,n=o.getAttribute("data-embed-src");n&&j(o,n),i.addedNodes&&i.addedNodes.forEach(s=>{s.nodeType==1&&it(s,!1)})})});return e.observe(t,{attributes:!0,subtree:!0,childList:!0}),e}function it(t,e=!0){let r=t.querySelectorAll("[data-embed-src]");for(var i=0;i<r.length;i++){let o=r[i];j(o,o.getAttribute("data-embed-src"))}if(e)return rt(t)}function j(t,e){for(var r=t;r;r=r.parentElement)if(!r.parentElement){let o=r.querySelectorAll("script");for(var i=0;i<o.length;i++)if(o[i].getAttribute("src")==e)return!0;r.tagName=="HTML"&&(r=r.querySelector("head")||r);let n=r.ownerDocument.createElement("script");n.type="module",n.src=e,r.appendChild(n);break}}var X=["data-attributes-keys","data-path-attributes","data-path-scope"];function w(t,e,r,i){var o,n,s;let a=t;if(i||(e=((o=r==null?void 0:r.processData)===null||o===void 0?void 0:o.call(r,a,e))||e),a.nodeType==1){let l=a.getAttribute("data-path-scope");if(l){let u=et(a),f=J(e,l,!1)||[];u==0&&Tt(a,((n=r==null?void 0:r.shouldRepeat)===null||n===void 0?void 0:n.call(r,a,f))===!1?1:f.length,r),e={...e,[tt(l)]:f[u]}}let h=Array.prototype.slice.call(a.attributes).sort((u,f)=>X.indexOf(u.name)-X.indexOf(f.name));for(var d=0;d<h.length;d++){let{name:u,value:f}=h[d];u.startsWith("data-path")&&u!="data-path-scope"&&R(a,u,J(e,f,!0),r),u=="data-embed-src"&&R(a,u,a.getAttribute(u),r)}}for(var d=0;d<a.children.length;d++)w(a.children[d],e,r,!0);return i||(s=r==null?void 0:r.onRender)===null||s===void 0||s.call(r,a,e),a}function C(t,e,r,i){var o;let n=((o=i==null?void 0:i.processTemplate)===null||o===void 0?void 0:o.call(i,t,e,r))||e;return t.innerHTML=n,t.classList.add("-feaas"),w(t,r,i)}function Ot(t,e){return ot(t,e||(e=document.createElement("style"))),e}function ot(t,e){return e||(e=document.createElement("style")),F(t,r=>{e.textContent=r}).then(()=>e)}function Mt(t,e){return nt(t,e||(e=document.createElement("div"))),e}async function nt(t,e){return e||(e=document.createElement("div")),e.childNodes.length?w(e,t.data,t):"template"in t?C(e,t.template,t.data,t):N(t,r=>C(e,r,t.data,t)).then(()=>e)}var Lt=typeof HTMLElement=="undefined"?class{}:HTMLElement,y=class extends Lt{constructor(){super(...arguments),this.connected=null,this.refs={},this.descendants=[],this.onLoad=e=>{e!=null&&(this.payload=e,this.render())}}getProps(e){return{}}getRoot(){return this}attributeChangedCallback(e,r,i){this.set()}connectedCallback(){console.log("FEAAS: Connected",this),this.connected=new Event("feaasConnected",{bubbles:!0,composed:!0}),this.dispatchEvent(this.connected),this.addEventListener("feaasConnected",this),this.addEventListener("feaasDisconnected",this),this.set()}disconnectedCallback(){console.log("FEAAS: Disconnected",this),this.removeEventListener("feaasConnected",this),this.removeEventListener("feaasDisconnected",this),this.dispatchEvent(new Event("feaasDisconnected",{bubbles:!0,composed:!0})),this.connected=null}handleEvent(e){switch(e.type){case"feaasConnected":this.nestedCallback(e);break;case"feaasDisconnected":this.unnestedCallback(e);break}}unnestedCallback(e){let r=e.composedPath()[0],i=this.descendants.indexOf(r);i!=-1&&(console.log("FEAAS: Unnest",this,r),this.descendants.splice(i,-1),this.refs[r.getComponentName()]=null,r.refs.parent==this&&(r.refs.parent=null),r.refs.top==this&&(r.refs.top=r.refs.parent))}nestedCallback(e){var r,i;let o=e.composedPath()[0];if(this.descendants.indexOf(o)==-1&&(this.descendants.push(o),console.log("FEAAS: Nest",this,o),this.refs[o.getComponentName()]=o,o.refs.top=this,(r=o.refs).parent||(r.parent=this),o.renderReact))for(var s=o.refs.parent;s;s=s.refs.parent)s.renderReact&&((i=o.refs).parentReact||(i.parentReact=s),o.refs.topReact=s)}getComponentName(){return this.tagName.replace("FEAAS-","").toLowerCase()}isReadyToLoad(){return this.payload===void 0&&this.getAttribute("hidden")==null}async reify(){this.payload!==void 0?this.render():this.isReadyToLoad()&&(this.payload=null,this.load().then(this.onLoad))}load(){return Promise.resolve(null)}render(e=!1){var r,i,o;if(console.log("FEAAS: React",this.tagName,this.payload),this.payload==null)return;let{React:n,ReactDOM:s}=this.payload||{};if(!n)throw new Error(`${this.tagName}: React is not present in payload`);if(!s)throw new Error(`${this.tagName}: ReactDOM is not present in payload`);!this.refs.topReact&&!this.forceUpdateReact?s.render(n.createElement(this.getReactWrapper()),this.getReactRoot()):this.forceUpdateReact?(r=this.forceUpdateReact)===null||r===void 0||r.call(this):(o=(i=this.refs.topReact).forceUpdateReact)===null||o===void 0||o.call(i)}invokeReactRendering(){let{React:e,ReactDOM:r}=this.payload||{},i=this.descendants.filter(o=>o.refs.parentReact==this&&o.payload).map((o,n)=>e.createElement(this.getReactWrapper(o),{key:this.tagName+"-"+n,slot:o.getAttribute("slot")}));return this.renderReact({...this.props,children:i},this.payload)}getReactWrapper(e=this,r=e.tagName){let i=e.reactWrapper||(e.reactWrapper=o=>{if(e.renderReact){let{React:n,ReactDOM:s}=e.payload||{},[a,d]=n.useReducer(l=>l+1,0);return e.forceUpdateReact=d,s.createPortal(n.createElement(n.Fragment,null,e.invokeReactRendering()),e.getReactRoot())}else return e.render()});return Object.assign(i,{displayName:r}),i}getUID(){return this.uid||(this.uid=String(Math.random()))}getReactRoot(){return this.getRoot()}set(e){this.overrides={...this.overrides,...e},this.props={...this.getProps(),...this.overrides};for(var r in this.props){let i=this.props[r];this.props[r]==null?this.removeAttribute(r):(typeof i=="string"||typeof i=="number")&&this.getAttribute(r)!=String(i)&&this.setAttribute(r,String(i))}this.scheduleRender()}scheduleRender(){cancelAnimationFrame(this.nextRender),this.nextRender=requestAnimationFrame(()=>{this.reify()})}formatURL(e,r){return typeof e=="string"&&e.match(/^\/[^\/]/)?r+e:e}getContextAttribute(e,r=this){var i,o;return(o=(i=r.closest(`[${e}]`))===null||i===void 0?void 0:i.getAttribute(e))!==null&&o!==void 0?o:this.getAttribute(e)}static register(e){typeof window!="undefined"&&!window.customElements.get(e)&&window.customElements.define(e,this)}};function st(t=this){let e,r=t.getAttribute("data");if(r!=null)try{e=typeof r=="string"?JSON.parse(r):{}}catch(i){}return{data:e!=null?e:{},library:t.getAttribute("library"),component:t.getAttribute("component"),version:t.getAttribute("version"),revision:t.getAttribute("revision"),hostname:t.getAttribute("hostname"),cdn:t.getContextAttribute("cdn"),template:t.getAttribute("template"),suspended:t.getAttribute("suspended")!=null}}var _=class extends y{setData(e){this.set({data:e})}getProps(){return st(this)}attributeChangedCallback(e,r,i){this.payload=void 0,this.needsRefresh=!0,super.attributeChangedCallback(e,r,i)}getOriginal(){let e=this.getAttribute("data-path-scope");if(e){for(var r=this;(r=r.previousElementSibling)&&r.getAttribute("data-path-scope")==e;)var i=r;return i}}isReadyToLoad(){return super.isReadyToLoad()&&this.props.library!=null&&this.props.component!=null&&this.props.version!=null}async load(){if(!this.getOriginal())try{N(this.props,this.onLoad)}catch(e){console.error(`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`)}}render(){if(Array.from(this.children).filter(e=>e.tagName!="BR").length>0&&!this.needsRefresh)w(this,this.props.data);else{if(this.needsRefresh=!0,this.getOriginal())return;C(this,this.payload,this.props.data)}}};_.observedAttributes=["library","component","version","revision","hostname","cdn","template","data"];_.register("feaas-component");function $t(t=this){return{hidden:(t==null?void 0:t.getAttribute("hidden"))!=null}}var k=class extends y{attributeChangedCallback(e,r,i){e=="hidden"&&(this.style.setProperty("display","block","important"),this.style.setProperty("transition","opacity 0.3s","important"),i?(this.style.setProperty("opacity","0","important"),this.style.pointerEvents="none"):(this.style.setProperty("opacity","1","important"),this.style.pointerEvents="all"))}connectedCallback(){this.attributeChangedCallback("hidden",this.getAttribute("hidden"),this.getAttribute("hidden")),this.stylesheet=document.createElement("style"),this.stylesheet.textContent=`
1316
2
  #loader {
1317
3
  position: absolute;
1318
4
  top: 0;
@@ -1353,10 +39,7 @@ var FEAASLoader = class extends FEAASBase {
1353
39
  width: 48px;
1354
40
  height: 48px;
1355
41
  }
1356
- `;
1357
- this.loader = document.createElement("div");
1358
- this.loader.id = "loader";
1359
- this.loader.innerHTML = `
42
+ `,this.loader=document.createElement("div"),this.loader.id="loader",this.loader.innerHTML=`
1360
43
  <div class="spinner">
1361
44
  <svg
1362
45
  viewBox="0 0 100 100"
@@ -1379,544 +62,10 @@ var FEAASLoader = class extends FEAASBase {
1379
62
  style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
1380
63
  ></circle>
1381
64
  </svg>
1382
- </div>`;
1383
- this.getRoot().appendChild(this.stylesheet);
1384
- this.getRoot().appendChild(this.loader);
1385
- }
1386
- };
1387
- FEAASLoader.observedAttributes = ["hidden"];
1388
- FEAASLoader.register("feaas-loader");
1389
-
1390
- // src/components/FEAASStylesheet.ts
1391
- function FEAASStylesheetProps(element = this) {
1392
- var _a;
1393
- return {
1394
- library: element == null ? void 0 : element.getContextAttribute("library"),
1395
- revision: (_a = element == null ? void 0 : element.getAttribute("revision")) != null ? _a : "published",
1396
- cdn: (element == null ? void 0 : element.getContextAttribute("cdn")) || (element == null ? void 0 : element.getContextAttribute("hostname"))
1397
- };
1398
- }
1399
- var FEAASStylesheet = class extends FEAASBase {
1400
- getProps() {
1401
- return FEAASStylesheetProps(this);
1402
- }
1403
- isReadyToLoad() {
1404
- return this.props.library != null && this.props.revision != null && this.props.cdn != null;
1405
- }
1406
- load() {
1407
- return __async(this, null, function* () {
1408
- fetchStylesheet(this.props, this.onLoad);
1409
- });
1410
- }
1411
- render() {
1412
- if (!this.stylesheet) {
1413
- this.stylesheet = document.createElement("style");
1414
- this.appendChild(this.stylesheet);
1415
- }
1416
- this.stylesheet.textContent = this.payload;
1417
- }
1418
- };
1419
- FEAASStylesheet.register("feaas-stylesheet");
1420
-
1421
- // src/components/FEAASComponent.ts
1422
- function FEAASComponentsProps(element = this) {
1423
- let data;
1424
- const dataValue = element.getAttribute("data");
1425
- if (dataValue != null) {
1426
- try {
1427
- data = typeof dataValue == "string" ? JSON.parse(dataValue) : {};
1428
- } catch (e) {
1429
- }
1430
- }
1431
- return {
1432
- data: data != null ? data : {},
1433
- library: element.getAttribute("library"),
1434
- component: element.getAttribute("component"),
1435
- version: element.getAttribute("version"),
1436
- revision: element.getAttribute("revision"),
1437
- hostname: element.getAttribute("hostname"),
1438
- cdn: element.getContextAttribute("cdn"),
1439
- template: element.getAttribute("template")
1440
- };
1441
- }
1442
- var FEAASComponent = class extends FEAASBase {
1443
- setData(data) {
1444
- this.set({ data });
1445
- }
1446
- getProps() {
1447
- return FEAASComponentsProps(this);
1448
- }
1449
- attributeChangedCallback(name, oldValue, newValue) {
1450
- this.payload = void 0;
1451
- this.needsRefresh = true;
1452
- super.attributeChangedCallback(name, oldValue, newValue);
1453
- }
1454
- getOriginal() {
1455
- const scope = this.getAttribute("data-path-scope");
1456
- if (!scope)
1457
- return;
1458
- for (var current = this; current = current.previousElementSibling; ) {
1459
- if (current.getAttribute("data-path-scope") == scope) {
1460
- var last = current;
1461
- } else {
1462
- break;
1463
- }
1464
- }
1465
- return last;
1466
- }
1467
- isReadyToLoad() {
1468
- return super.isReadyToLoad() && this.props.library != null && this.props.component != null && this.props.version != null;
1469
- }
1470
- load() {
1471
- return __async(this, null, function* () {
1472
- if (this.getOriginal()) {
1473
- return;
1474
- }
1475
- try {
1476
- fetchComponent(this.props, this.onLoad);
1477
- } catch (e) {
1478
- console.error(
1479
- `FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`
1480
- );
1481
- }
1482
- });
1483
- }
1484
- render() {
1485
- if (Array.from(this.children).filter((c) => c.tagName != "BR").length > 0 && !this.needsRefresh) {
1486
- renderDOMElement(this, this.props.data);
1487
- } else {
1488
- this.needsRefresh = true;
1489
- if (this.getOriginal()) {
1490
- return;
1491
- }
1492
- renderDOMContent(this, this.payload, this.props.data);
1493
- }
1494
- }
1495
- };
1496
- FEAASComponent.observedAttributes = ["library", "component", "version", "revision", "hostname", "cdn", "template", "data"];
1497
- FEAASComponent.register("feaas-component");
1498
-
1499
- // src/components/FEAASEditor.tsx
1500
- function getFramePosition(element) {
1501
- let positions = [];
1502
- if (element) {
1503
- let currentWindow = element.ownerDocument.defaultView;
1504
- let currentParentWindow;
1505
- let rect;
1506
- while (currentWindow !== window.top) {
1507
- currentParentWindow = currentWindow.parent;
1508
- for (let idx = 0; idx < currentParentWindow.frames.length; idx++)
1509
- if (currentParentWindow.frames[idx] === currentWindow) {
1510
- for (let frameElement of currentParentWindow.document.getElementsByTagName("iframe")) {
1511
- if (frameElement.contentWindow === currentWindow) {
1512
- rect = frameElement.getBoundingClientRect();
1513
- const style = frameElement.contentWindow.getComputedStyle(frameElement);
1514
- positions.push({
1515
- left: rect.left + parseInt(style.borderLeftWidth),
1516
- top: rect.top + parseInt(style.borderTopWidth)
1517
- });
1518
- }
1519
- }
1520
- currentWindow = currentParentWindow;
1521
- break;
1522
- }
1523
- }
1524
- }
1525
- return positions.reduce(
1526
- (accumulator, currentValue) => {
1527
- return {
1528
- left: accumulator.left + currentValue.left,
1529
- top: accumulator.top + currentValue.top
1530
- };
1531
- },
1532
- { left: 0, top: 0 }
1533
- );
1534
- }
1535
- function FEAASEditorProps(element = this) {
1536
- var _a;
1537
- return {
1538
- context: HTMLElement,
1539
- frontend: element == null ? void 0 : element.getContextAttribute("frontend"),
1540
- src: (_a = element == null ? void 0 : element.getAttribute("src")) != null ? _a : "/assets/editor.js",
1541
- library: element == null ? void 0 : element.getAttribute("library"),
1542
- component: element == null ? void 0 : element.getAttribute("component"),
1543
- version: element == null ? void 0 : element.getAttribute("version"),
1544
- revision: (element == null ? void 0 : element.getAttribute("revision")) || "saved",
1545
- hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null,
1546
- for: element == null ? void 0 : element.getAttribute("for")
1547
- };
1548
- }
1549
- var FEAASEditor = class extends FEAASBase {
1550
- constructor() {
1551
- super(...arguments);
1552
- this.framePoint = { top: 0, left: 0 };
1553
- this.wrapperRect = { top: 0, left: 0, width: 0, height: 0 };
1554
- this.bodyRect = { top: 0, left: 0, width: 0, height: 0 };
1555
- this.getTarget = () => {
1556
- return document.querySelector("iframe").contentWindow.document.getElementById(this.props.for);
1557
- };
1558
- this.onChromeMeasureElement = (element, rect) => {
1559
- if (rect == null) {
1560
- rect = element.getBoundingClientRect();
1561
- }
1562
- if (element.ownerDocument == document) {
1563
- return {
1564
- left: rect.left - this.bodyRect.left,
1565
- top: rect.top - this.bodyRect.top,
1566
- width: rect.width,
1567
- height: rect.height
1568
- };
1569
- }
1570
- return {
1571
- left: rect.left + this.framePoint.left - this.bodyRect.left,
1572
- top: rect.top + this.framePoint.top - this.bodyRect.top,
1573
- width: rect.width,
1574
- height: rect.height
1575
- };
1576
- };
1577
- this.onBeforeMeasure = (refs) => {
1578
- if (refs.memoized.focusable)
1579
- this.framePoint = getFramePosition(refs.memoized.focusable);
1580
- this.wrapperRect = this.wrapper.getBoundingClientRect();
1581
- this.bodyRect = this.wrapper.ownerDocument.body.parentElement.getBoundingClientRect();
1582
- };
1583
- this.onMeasure = () => {
1584
- };
1585
- this.onPosition = ({ focusable, root }) => {
1586
- const chrome = this.wrapper.querySelector(".editor-chrome");
1587
- const absolute = this.wrapper.querySelector(".ui.overlays");
1588
- if (focusable) {
1589
- const topbarHeight = 64;
1590
- const padding = 16;
1591
- chrome.style.width = focusable.width + padding * 2 + "px";
1592
- chrome.style.height = focusable.height + padding * 1 + topbarHeight + "px";
1593
- chrome.style.left = focusable.left - padding + "px";
1594
- chrome.style.top = focusable.top - topbarHeight + "px";
1595
- if (absolute) {
1596
- absolute.style.left = root.left + "px";
1597
- absolute.style.top = root.top + "px";
1598
- }
1599
- } else {
1600
- chrome.style.left = "-1000px";
1601
- chrome.style.top = "-1000px";
1602
- }
1603
- };
1604
- }
1605
- getProps() {
1606
- return FEAASEditorProps(this);
1607
- }
1608
- load() {
1609
- return import(this.formatURL(this.props.src, this.props.frontend));
1610
- }
1611
- renderReact({ children, component: componentId, version: versionId }, {
1612
- Editor,
1613
- VersionStatusList,
1614
- Version,
1615
- EditorUIUndo,
1616
- EditorUIMode,
1617
- React: { useEffect, useMemo, useState },
1618
- Chakra: { HStack, Box },
1619
- Chrome,
1620
- ReactDOM,
1621
- useSDK,
1622
- useSlots,
1623
- useModelObserver
1624
- }) {
1625
- if (!this.payload)
1626
- return;
1627
- const { sdk } = useSDK();
1628
- const [component, setComponent] = useState();
1629
- const library = sdk.library;
1630
- useEffect(() => {
1631
- return setComponent(library.components.getItem(componentId));
1632
- }, [componentId, library]);
1633
- useEffect(() => {
1634
- component == null ? void 0 : component.versions.fetch();
1635
- }, [component]);
1636
- const target = useMemo(this.getTarget, [this.props.for]);
1637
- const observedVersions = useModelObserver(component == null ? void 0 : component.versions);
1638
- const versions = useMemo(() => {
1639
- return (observedVersions == null ? void 0 : observedVersions.filter((v) => v.id == versionId || !versionId)) || [];
1640
- }, [observedVersions]);
1641
- if (!component)
1642
- return;
1643
- return useSlots(children, ({ picker, children: children2 }) => /* @__PURE__ */ React.createElement(Box, {
1644
- ref: (el) => this.wrapper = el
1645
- }, /* @__PURE__ */ React.createElement(Box, {
1646
- className: "editor-wrapper",
1647
- position: "absolute",
1648
- left: 0,
1649
- top: 0
1650
- }, /* @__PURE__ */ React.createElement(Editor, {
1651
- sdk,
1652
- library: sdk.library,
1653
- component,
1654
- versions,
1655
- context: {
1656
- onChromeMeasure: this.onMeasure,
1657
- onChromeBeforeMeasure: this.onBeforeMeasure,
1658
- onChromeMeasureElement: this.onChromeMeasureElement,
1659
- onChromePosition: this.onPosition
1660
- }
1661
- }, ({ editor, status, isArchivedDisplayed }) => ({
1662
- after: children2,
1663
- picker,
1664
- chrome: editor && /* @__PURE__ */ React.createElement(Chrome, null),
1665
- children: component.reduceVersionRevisions(versions).filter((snapshot) => {
1666
- var _a;
1667
- return isArchivedDisplayed || !((_a = snapshot.saved || snapshot.draft) == null ? void 0 : _a.deletedAt);
1668
- }).map((snapshot, index) => /* @__PURE__ */ React.createElement(Box, {
1669
- key: snapshot.head.id,
1670
- position: "absolute",
1671
- left: 0,
1672
- top: 0,
1673
- className: "editor-chrome",
1674
- p: 4,
1675
- boxShadow: "2xl",
1676
- pointerEvents: "none"
1677
- }, /* @__PURE__ */ React.createElement(Box, {
1678
- className: "borders",
1679
- pointerEvents: "none",
1680
- left: 0,
1681
- width: "4",
1682
- top: 0,
1683
- bottom: 0,
1684
- backdropFilter: "blur(2px)",
1685
- background: "rgb(244 244 244 / 80%)",
1686
- position: "absolute"
1687
- }), /* @__PURE__ */ React.createElement(Box, {
1688
- className: "borders",
1689
- pointerEvents: "none",
1690
- right: 0,
1691
- width: "4",
1692
- top: 0,
1693
- bottom: 0,
1694
- backdropFilter: "blur(2px)",
1695
- background: "rgb(244 244 244 / 80%)",
1696
- position: "absolute"
1697
- }), /* @__PURE__ */ React.createElement(Box, {
1698
- className: "borders",
1699
- pointerEvents: "none",
1700
- top: 0,
1701
- height: "16",
1702
- left: 0,
1703
- right: 0,
1704
- backdropFilter: "blur(2px)",
1705
- background: "rgb(244 244 244 / 80%)",
1706
- position: "absolute"
1707
- }), /* @__PURE__ */ React.createElement(Box, {
1708
- className: "borders",
1709
- pointerEvents: "none",
1710
- bottom: 0,
1711
- height: "4",
1712
- left: 0,
1713
- right: 0,
1714
- backdropFilter: "blur(2px)",
1715
- background: "rgb(244 244 244 / 80%)",
1716
- position: "absolute"
1717
- }), /* @__PURE__ */ React.createElement(Version, {
1718
- version: snapshot.head,
1719
- node: target
1720
- }, {
1721
- left: /* @__PURE__ */ React.createElement(HStack, {
1722
- justifyContent: "space-between"
1723
- }, /* @__PURE__ */ React.createElement(EditorUIUndo, {
1724
- size: "sm",
1725
- editor: status == "ready" ? editor : null
1726
- }), /* @__PURE__ */ React.createElement(EditorUIMode, {
1727
- size: "sm"
1728
- })),
1729
- middle: /* @__PURE__ */ React.createElement(VersionStatusList, null)
1730
- })))
1731
- })))));
1732
- }
1733
- isReadyToLoad() {
1734
- return this.props.component != null && this.props.version != null;
1735
- }
1736
- };
1737
- FEAASEditor.register("feaas-editor");
1738
-
1739
- // src/components/FEAASPicker.tsx
1740
- function FEAASPickerProps(element = this) {
1741
- var _a, _b;
1742
- return {
1743
- part: (element == null ? void 0 : element.getAttribute("part")) || "picker",
1744
- slot: (element == null ? void 0 : element.getAttribute("part")) || "slot",
1745
- mode: element == null ? void 0 : element.getAttribute("mode"),
1746
- frontend: (_a = element == null ? void 0 : element.getContextAttribute("frontend")) != null ? _a : "https://components.sitecorecloud.io",
1747
- src: (_b = element == null ? void 0 : element.getAttribute("src")) != null ? _b : "/assets/picker.js",
1748
- hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null,
1749
- context: void 0,
1750
- onClose: void 0
1751
- };
1752
- }
1753
- var FEAASPicker = class extends FEAASBase {
1754
- getProps() {
1755
- return FEAASPickerProps(this);
1756
- }
1757
- load() {
1758
- return import(this.formatURL(this.props.src, this.props.frontend));
1759
- }
1760
- renderReact({ context, mode, children }, { Picker, React: React2, ReactDOM }) {
1761
- return /* @__PURE__ */ React2.createElement(Picker, {
1762
- mode: mode || void 0,
1763
- onClose: this.props.onClose,
1764
- context
1765
- }, children);
1766
- }
1767
- };
1768
- FEAASPicker.register("feaas-picker");
1769
- function FEAASPickerLazyProps(element = this) {
1770
- var _a, _b;
1771
- return {
1772
- library: (element == null ? void 0 : element.getAttribute("library")) || "library",
1773
- mode: element == null ? void 0 : element.getAttribute("mode"),
1774
- frontend: (_a = element == null ? void 0 : element.getContextAttribute("frontend")) != null ? _a : "https://components.sitecorecloud.io",
1775
- src: (_b = element == null ? void 0 : element.getAttribute("src")) != null ? _b : "/assets/picker.js",
1776
- hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null,
1777
- context: null,
1778
- getToken: null
1779
- };
1780
- }
1781
- var FEAASPickerLazy = class extends FEAASBase {
1782
- constructor() {
1783
- super(...arguments);
1784
- this.payload = null;
1785
- this.onClose = () => {
1786
- this.removeAttribute("mode");
1787
- };
1788
- }
1789
- getProps() {
1790
- return FEAASPickerLazyProps(this);
1791
- }
1792
- render() {
1793
- const { frontend, library, getToken, src, mode, context } = this.props;
1794
- if (this.getAttribute("mode") == null) {
1795
- this.setAttribute("hidden", "hidden");
1796
- } else {
1797
- this.removeAttribute("hidden");
1798
- }
1799
- if (this.children.length == 0)
1800
- this.innerHTML = `
1801
- <feaas-context library='${library}'>
1802
- <feaas-picker mode='${mode}'>
65
+ </div>`,this.getRoot().appendChild(this.stylesheet),this.getRoot().appendChild(this.loader)}};k.observedAttributes=["hidden"];k.register("feaas-loader");function at(t=this){var e;return{library:t==null?void 0:t.getContextAttribute("library"),revision:(e=t==null?void 0:t.getAttribute("revision"))!==null&&e!==void 0?e:"published",cdn:(t==null?void 0:t.getContextAttribute("cdn"))||(t==null?void 0:t.getContextAttribute("hostname"))}}var U=class extends y{getProps(){return at(this)}isReadyToLoad(){return this.props.library!=null&&this.props.revision!=null&&this.props.cdn!=null}async load(){F(this.props,this.onLoad)}render(){this.stylesheet||(this.stylesheet=document.createElement("style"),this.appendChild(this.stylesheet)),this.stylesheet.textContent=this.payload}};U.register("feaas-stylesheet");var V;typeof window!="undefined"&&((V=window.FEAASLoading)!==null&&V!==void 0||(window.FEAASLoading=Promise.resolve()));function lt(t){let e=[];if(t){let r=t.ownerDocument.defaultView,i,o;for(;r!==window.top;){i=r.parent;for(let n=0;n<i.frames.length;n++)if(i.frames[n]===r){for(let s of i.document.getElementsByTagName("iframe"))if(s.contentWindow===r){o=s.getBoundingClientRect();let a=s.contentWindow.getComputedStyle(s);e.push({left:o.left+parseInt(a.borderLeftWidth),top:o.top+parseInt(a.borderTopWidth)})}r=i;break}}}return e.reduce((r,i)=>({left:r.left+i.left,top:r.top+i.top}),{left:0,top:0})}function dt(t=this){var e;return{context:HTMLElement,frontend:t==null?void 0:t.getContextAttribute("frontend"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/assets/editor.js",library:t==null?void 0:t.getAttribute("library"),component:t==null?void 0:t.getAttribute("component"),version:t==null?void 0:t.getAttribute("version"),revision:(t==null?void 0:t.getAttribute("revision"))||"saved",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,for:t==null?void 0:t.getAttribute("for")}}var H=class extends y{constructor(){super(...arguments),this.framePoint={top:0,left:0},this.wrapperRect={top:0,left:0,width:0,height:0},this.bodyRect={top:0,left:0,width:0,height:0},this.getTarget=()=>document.querySelector("iframe").contentWindow.document.getElementById(this.props.for),this.onChromeMeasureElement=(e,r)=>(r==null&&(r=e.getBoundingClientRect()),e.ownerDocument==document?{left:r.left-this.bodyRect.left,top:r.top-this.bodyRect.top,width:r.width,height:r.height}:{left:r.left+this.framePoint.left-this.bodyRect.left,top:r.top+this.framePoint.top-this.bodyRect.top,width:r.width,height:r.height}),this.onBeforeMeasure=e=>{e.memoized.focusable&&(this.framePoint=lt(e.memoized.focusable)),this.wrapperRect=this.wrapper.getBoundingClientRect(),this.bodyRect=this.wrapper.ownerDocument.body.parentElement.getBoundingClientRect()},this.onMeasure=()=>{},this.onPosition=({focusable:e,root:r})=>{let i=this.wrapper.querySelector(".editor-chrome"),o=this.wrapper.querySelector(".ui.overlays");e?(i.style.width=e.width+16*2+"px",i.style.height=e.height+16*1+64+"px",i.style.left=e.left-16+"px",i.style.top=e.top-64+"px",o&&(o.style.left=r.left+"px",o.style.top=r.top+"px")):(i.style.left="-1000px",i.style.top="-1000px")}}getProps(){return dt(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}renderReact({children:e,component:r,version:i},{Editor:o,VersionStatusList:n,Version:s,EditorUIUndo:a,EditorUIMode:d,React:{useEffect:l,useMemo:h,useState:u},Chakra:{HStack:f,Box:c},Chrome:g,ReactDOM:m,useSDK:W,useSlots:E,useModelObserver:pt}){if(!this.payload)return;let{sdk:T}=W(),[v,ft]=u(),K=T.library;l(()=>ft(K.components.getItem(r)),[r,K]),l(()=>{v==null||v.versions.fetch()},[v]);let gt=h(this.getTarget,[this.props.for]),O=pt(v==null?void 0:v.versions),G=h(()=>(O==null?void 0:O.filter(B=>B.id==i||!i))||[],[O]);if(v)return E(e,({picker:B,children:yt})=>React.createElement(c,{ref:M=>this.wrapper=M},React.createElement(c,{className:"editor-wrapper",position:"absolute",left:0,top:0},React.createElement(o,{datasources:T.datasources,sdk:T,library:T.library,component:v,versions:G,context:{onChromeMeasure:this.onMeasure,onChromeBeforeMeasure:this.onBeforeMeasure,onChromeMeasureElement:this.onChromeMeasureElement,onChromePosition:this.onPosition}},({editor:M,status:bt,isArchivedDisplayed:vt})=>({after:yt,picker:B,chrome:M&&React.createElement(g,null),children:v.reduceVersionRevisions(G).filter(x=>{var L;return vt||!(!((L=x.saved||x.draft)===null||L===void 0)&&L.deletedAt)}).map((x,L)=>React.createElement(c,{key:x.head.id,position:"absolute",left:0,top:0,className:"editor-chrome",p:4,boxShadow:"2xl",pointerEvents:"none"},React.createElement(c,{className:"borders",pointerEvents:"none",left:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(c,{className:"borders",pointerEvents:"none",right:0,width:"4",top:0,bottom:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(c,{className:"borders",pointerEvents:"none",top:0,height:"16",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(c,{className:"borders",pointerEvents:"none",bottom:0,height:"4",left:0,right:0,backdropFilter:"blur(2px)",background:"rgb(244 244 244 / 80%)",position:"absolute"}),React.createElement(s,{version:x.head,node:gt},{left:React.createElement(f,{justifyContent:"space-between"},React.createElement(a,{size:"sm",editor:bt=="ready"?M:null}),React.createElement(d,{size:"sm"})),middle:React.createElement(n,null)})))})))))}isReadyToLoad(){return this.props.component!=null&&this.props.version!=null}};H.register("feaas-editor");function ct(t=this){var e,r;return{part:(t==null?void 0:t.getAttribute("part"))||"picker",slot:(t==null?void 0:t.getAttribute("part"))||"slot",mode:t==null?void 0:t.getAttribute("mode"),frontend:(e=t==null?void 0:t.getContextAttribute("frontend"))!==null&&e!==void 0?e:"https://components.sitecorecloud.io",src:(r=t==null?void 0:t.getAttribute("src"))!==null&&r!==void 0?r:"/assets/picker.js",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,context:void 0,onClose:void 0}}var I=class extends y{getProps(){return ct(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}renderReact({context:e,mode:r,children:i},{Picker:o,React:n,ReactDOM:s}){return n.createElement(o,{mode:r||void 0,onClose:this.props.onClose,context:e},i)}};I.register("feaas-picker");function ut(t=this){var e,r;return{library:(t==null?void 0:t.getAttribute("library"))||"library",mode:t==null?void 0:t.getAttribute("mode"),frontend:(e=t==null?void 0:t.getContextAttribute("frontend"))!==null&&e!==void 0?e:"https://components.sitecorecloud.io",src:(r=t==null?void 0:t.getAttribute("src"))!==null&&r!==void 0?r:"/assets/picker.js",hidden:(t==null?void 0:t.getAttribute("hidden"))!=null,context:null,getToken:null}}var S=class extends y{constructor(){super(...arguments),this.payload=null,this.onClose=()=>{this.removeAttribute("mode")}}getProps(){return ut(this)}render(){let{frontend:e,library:r,getToken:i,src:o,mode:n,context:s}=this.props;this.getAttribute("mode")==null?this.setAttribute("hidden","hidden"):this.removeAttribute("hidden"),this.children.length==0&&(this.innerHTML=`
66
+ <feaas-context library='${r}'>
67
+ <feaas-picker mode='${n}'>
1803
68
  <feaas-loader />
1804
69
  </feaas-context>
1805
- `;
1806
- this.refs.context.set({
1807
- frontend,
1808
- library,
1809
- getToken
1810
- });
1811
- this.refs.picker.set({
1812
- frontend,
1813
- context,
1814
- src,
1815
- mode,
1816
- onClose: this.onClose
1817
- });
1818
- }
1819
- };
1820
- FEAASPickerLazy.observedAttributes = ["library", "mode", "frontend", "src", "context"];
1821
- FEAASPickerLazy.register("feaas-picker-lazy");
1822
-
1823
- // src/components/FEAASContext.tsx
1824
- function FEAASContextProps(element = this) {
1825
- var _a, _b, _c, _d;
1826
- return {
1827
- library: element == null ? void 0 : element.getAttribute("library"),
1828
- src: (_a = element == null ? void 0 : element.getAttribute("src")) != null ? _a : "/assets/context.js",
1829
- frontend: (_b = element == null ? void 0 : element.getAttribute("frontend")) != null ? _b : "https://components.sitecoreclud.io",
1830
- backend: (_c = element == null ? void 0 : element.getAttribute("backend")) != null ? _c : "https://components-api.sitecoreclud.io",
1831
- cdn: (_d = element == null ? void 0 : element.getAttribute("cdn")) != null ? _d : "https://feaascompontsapiprod.blob.core.windows.net",
1832
- getToken: null
1833
- };
1834
- }
1835
- var FEAASContext = class extends FEAASBase {
1836
- getProps() {
1837
- return FEAASContextProps(this);
1838
- }
1839
- load() {
1840
- return import(this.formatURL(this.props.src, this.props.frontend));
1841
- }
1842
- getTheme(theme) {
1843
- return theme;
1844
- }
1845
- getRoot() {
1846
- return this.shadowRoot || this.attachShadow({ mode: "open" });
1847
- }
1848
- getReactRoot() {
1849
- if (!this.reactRoot) {
1850
- this.reactRoot = document.createElement("div");
1851
- this.getRoot().appendChild(this.reactRoot);
1852
- }
1853
- return this.reactRoot;
1854
- }
1855
- nestedCallback(event) {
1856
- super.nestedCallback(event);
1857
- const target = event.composedPath()[0];
1858
- if (target.parentNode != this.getRoot()) {
1859
- this.getRoot().appendChild(target);
1860
- }
1861
- }
1862
- renderReact({ children, library }, { AppContext, Chakra: { Button, Tooltip }, React: React2 }) {
1863
- const portalProps = {
1864
- containerRef: { current: this.getRoot() }
1865
- };
1866
- Tooltip.defaultProps = {
1867
- hasArrow: true,
1868
- placement: "top",
1869
- portalProps
1870
- };
1871
- return /* @__PURE__ */ React2.createElement(AppContext, {
1872
- libraryId: this.props.library,
1873
- container: this.getRoot(),
1874
- getToken: this.props.getToken,
1875
- getTheme: this.getTheme,
1876
- modalProps: {
1877
- portalProps
1878
- },
1879
- chakraProps: {
1880
- cssVarsRoot: ":host",
1881
- resetCSS: true,
1882
- toastOptions: {
1883
- portalProps
1884
- }
1885
- }
1886
- }, children);
1887
- }
1888
- };
1889
- FEAASContext.observedAttributes = ["library", "component", "version", "revision", "hostname", "template"];
1890
- FEAASContext.register("feaas-context");
1891
- export {
1892
- FEAASComponent,
1893
- FEAASComponentsProps,
1894
- FEAASContext,
1895
- FEAASContextProps,
1896
- FEAASEditor,
1897
- FEAASEditorProps,
1898
- FEAASLoader,
1899
- FEAASLoaderProps,
1900
- FEAASPicker,
1901
- FEAASPickerLazy,
1902
- FEAASPickerLazyProps,
1903
- FEAASPickerProps,
1904
- FEAASStylesheet,
1905
- FEAASStylesheetProps,
1906
- autoloadScripts,
1907
- cleanCollectionBit,
1908
- fetchAndRevalidate,
1909
- getFramePosition,
1910
- loadScript,
1911
- normalizeCollectionScope,
1912
- observeDOMElement,
1913
- queryScopes,
1914
- renderComponent,
1915
- renderComponentElement,
1916
- renderComponentPromise,
1917
- renderDOMContent,
1918
- renderDOMElement,
1919
- renderStylesheet,
1920
- renderStylesheetPromise,
1921
- setDOMAttribute
1922
- };
70
+ `),this.refs.context.set({frontend:e,library:r,getToken:i}),this.refs.picker.set({frontend:e,context:s,src:o,mode:n,onClose:this.onClose})}};S.observedAttributes=["library","mode","frontend","src","context"];S.register("feaas-picker-lazy");function ht(t=this){var e,r,i,o;return{library:t==null?void 0:t.getAttribute("library"),src:(e=t==null?void 0:t.getAttribute("src"))!==null&&e!==void 0?e:"/assets/context.js",frontend:(r=t==null?void 0:t.getAttribute("frontend"))!==null&&r!==void 0?r:"https://components.sitecoreclud.io",backend:(i=t==null?void 0:t.getAttribute("backend"))!==null&&i!==void 0?i:"https://components-api.sitecoreclud.io",cdn:(o=t==null?void 0:t.getAttribute("cdn"))!==null&&o!==void 0?o:"https://feaascompontsapiprod.blob.core.windows.net",getToken:null}}var P=class extends y{getProps(){return ht(this)}load(){return import( /*@vite-ignore*/ /* webpackIgnore: true */ this.formatURL(this.props.src,this.props.frontend))}getTheme(e){return e}getRoot(){return this.shadowRoot||this.attachShadow({mode:"open"})}getReactRoot(){return this.reactRoot||(this.reactRoot=document.createElement("div"),this.getRoot().appendChild(this.reactRoot)),this.reactRoot}nestedCallback(e){super.nestedCallback(e);let r=e.composedPath()[0];r.parentNode!=this.getRoot()&&this.getRoot().appendChild(r)}renderReact({children:e,library:r},{AppContext:i,Chakra:{Button:o,Tooltip:n},React:s}){let a={containerRef:{current:this.getRoot()}};return n.defaultProps={hasArrow:!0,placement:"top",portalProps:a},s.createElement(i,{libraryId:this.props.library,container:this.getRoot(),getToken:this.props.getToken,getTheme:this.getTheme,modalProps:{portalProps:a},chakraProps:{cssVarsRoot:":host",resetCSS:!0,toastOptions:{portalProps:a}}},e)}};P.observedAttributes=["library","component","version","revision","hostname","template"];P.register("feaas-context");0&&(module.exports={Base,Component,FEAASBase,FEAASComponent,FEAASComponentsProps,FEAASContext,FEAASContextProps,FEAASEditor,FEAASEditorProps,FEAASLoader,FEAASLoaderProps,FEAASPicker,FEAASPickerLazy,FEAASPickerLazyProps,FEAASPickerProps,FEAASStylesheet,FEAASStylesheetProps,Loader,Stylesheet,autoloadScripts,cleanCollectionBit,fetchAndRevalidate,getFramePosition,loadScript,normalizeCollectionScope,observeDOMElement,queryScopes,renderComponent,renderComponentElement,renderComponentPromise,renderDOMContent,renderDOMElement,renderStylesheet,renderStylesheetPromise,setDOMAttribute});
71
+ //# sourceMappingURL=index.js.map