@link-loom/cloud-sdk 1.0.1

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.
@@ -0,0 +1,4977 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+ var React$1 = require('react');
5
+ var styles = require('@mui/material/styles');
6
+ var Box = require('@mui/material/Box');
7
+ var Typography = require('@mui/material/Typography');
8
+ var CircularProgress = require('@mui/material/CircularProgress');
9
+ var client = require('react-dom/client');
10
+ var Button = require('@mui/material/Button');
11
+ var IconButton = require('@mui/material/IconButton');
12
+ var Chip = require('@mui/material/Chip');
13
+ var SaveIcon = require('@mui/icons-material/Save');
14
+ var BuildIcon = require('@mui/icons-material/Build');
15
+ var PublishIcon = require('@mui/icons-material/Publish');
16
+ var PlayArrowIcon = require('@mui/icons-material/PlayArrow');
17
+ var VisibilityIcon = require('@mui/icons-material/Visibility');
18
+ var ViewSidebarIcon = require('@mui/icons-material/ViewSidebar');
19
+ var ArrowBackIcon = require('@mui/icons-material/ArrowBack');
20
+ var FolderIcon = require('@mui/icons-material/Folder');
21
+ var FolderOpenIcon = require('@mui/icons-material/FolderOpen');
22
+ var InsertDriveFileIcon = require('@mui/icons-material/InsertDriveFile');
23
+ var NoteAddIcon = require('@mui/icons-material/NoteAdd');
24
+ var CreateNewFolderIcon = require('@mui/icons-material/CreateNewFolder');
25
+ var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
26
+ var ChevronRightIcon = require('@mui/icons-material/ChevronRight');
27
+ var Tabs = require('@mui/material/Tabs');
28
+ var Tab = require('@mui/material/Tab');
29
+ var CloseIcon = require('@mui/icons-material/Close');
30
+ var Editor = require('@monaco-editor/react');
31
+ var TextField = require('@mui/material/TextField');
32
+ var Switch = require('@mui/material/Switch');
33
+ var Select = require('@mui/material/Select');
34
+ var MenuItem = require('@mui/material/MenuItem');
35
+ var ChevronLeftIcon = require('@mui/icons-material/ChevronLeft');
36
+ var KeyboardArrowDownIcon = require('@mui/icons-material/KeyboardArrowDown');
37
+ var KeyboardArrowUpIcon = require('@mui/icons-material/KeyboardArrowUp');
38
+ var InputAdornment = require('@mui/material/InputAdornment');
39
+ var SearchIcon = require('@mui/icons-material/Search');
40
+ var AddIcon = require('@mui/icons-material/Add');
41
+ var MoreVertIcon = require('@mui/icons-material/MoreVert');
42
+ var PushPinIcon = require('@mui/icons-material/PushPin');
43
+ var StarIcon = require('@mui/icons-material/Star');
44
+ var Menu = require('@mui/material/Menu');
45
+
46
+ function _arrayLikeToArray(r, a) {
47
+ (null == a || a > r.length) && (a = r.length);
48
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
49
+ return n;
50
+ }
51
+ function _arrayWithHoles(r) {
52
+ if (Array.isArray(r)) return r;
53
+ }
54
+ function _arrayWithoutHoles(r) {
55
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
56
+ }
57
+ function _assertClassBrand(e, t, n) {
58
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
59
+ throw new TypeError("Private element is not present on this object");
60
+ }
61
+ function _assertThisInitialized(e) {
62
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
63
+ return e;
64
+ }
65
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
66
+ try {
67
+ var i = n[a](c),
68
+ u = i.value;
69
+ } catch (n) {
70
+ return void e(n);
71
+ }
72
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
73
+ }
74
+ function _asyncToGenerator(n) {
75
+ return function () {
76
+ var t = this,
77
+ e = arguments;
78
+ return new Promise(function (r, o) {
79
+ var a = n.apply(t, e);
80
+ function _next(n) {
81
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
82
+ }
83
+ function _throw(n) {
84
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
85
+ }
86
+ _next(void 0);
87
+ });
88
+ };
89
+ }
90
+ function _callSuper(t, o, e) {
91
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
92
+ }
93
+ function _checkPrivateRedeclaration(e, t) {
94
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
95
+ }
96
+ function _classCallCheck(a, n) {
97
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
98
+ }
99
+ function _classPrivateMethodInitSpec(e, a) {
100
+ _checkPrivateRedeclaration(e, a), a.add(e);
101
+ }
102
+ function _defineProperties(e, r) {
103
+ for (var t = 0; t < r.length; t++) {
104
+ var o = r[t];
105
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
106
+ }
107
+ }
108
+ function _createClass(e, r, t) {
109
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
110
+ writable: false
111
+ }), e;
112
+ }
113
+ function _createForOfIteratorHelper(r, e) {
114
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
115
+ if (!t) {
116
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
117
+ t && (r = t);
118
+ var n = 0,
119
+ F = function () {};
120
+ return {
121
+ s: F,
122
+ n: function () {
123
+ return n >= r.length ? {
124
+ done: true
125
+ } : {
126
+ done: false,
127
+ value: r[n++]
128
+ };
129
+ },
130
+ e: function (r) {
131
+ throw r;
132
+ },
133
+ f: F
134
+ };
135
+ }
136
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
137
+ }
138
+ var o,
139
+ a = true,
140
+ u = false;
141
+ return {
142
+ s: function () {
143
+ t = t.call(r);
144
+ },
145
+ n: function () {
146
+ var r = t.next();
147
+ return a = r.done, r;
148
+ },
149
+ e: function (r) {
150
+ u = true, o = r;
151
+ },
152
+ f: function () {
153
+ try {
154
+ a || null == t.return || t.return();
155
+ } finally {
156
+ if (u) throw o;
157
+ }
158
+ }
159
+ };
160
+ }
161
+ function _defineProperty(e, r, t) {
162
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
163
+ value: t,
164
+ enumerable: true,
165
+ configurable: true,
166
+ writable: true
167
+ }) : e[r] = t, e;
168
+ }
169
+ function _get$1() {
170
+ return _get$1 = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
171
+ var p = _superPropBase(e, t);
172
+ if (p) {
173
+ var n = Object.getOwnPropertyDescriptor(p, t);
174
+ return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
175
+ }
176
+ }, _get$1.apply(null, arguments);
177
+ }
178
+ function _getPrototypeOf(t) {
179
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
180
+ return t.__proto__ || Object.getPrototypeOf(t);
181
+ }, _getPrototypeOf(t);
182
+ }
183
+ function _inherits(t, e) {
184
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
185
+ t.prototype = Object.create(e && e.prototype, {
186
+ constructor: {
187
+ value: t,
188
+ writable: true,
189
+ configurable: true
190
+ }
191
+ }), Object.defineProperty(t, "prototype", {
192
+ writable: false
193
+ }), e && _setPrototypeOf(t, e);
194
+ }
195
+ function _isNativeReflectConstruct() {
196
+ try {
197
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
198
+ } catch (t) {}
199
+ return (_isNativeReflectConstruct = function () {
200
+ return !!t;
201
+ })();
202
+ }
203
+ function _iterableToArray(r) {
204
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
205
+ }
206
+ function _iterableToArrayLimit(r, l) {
207
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
208
+ if (null != t) {
209
+ var e,
210
+ n,
211
+ i,
212
+ u,
213
+ a = [],
214
+ f = true,
215
+ o = false;
216
+ try {
217
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
218
+ } catch (r) {
219
+ o = true, n = r;
220
+ } finally {
221
+ try {
222
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
223
+ } finally {
224
+ if (o) throw n;
225
+ }
226
+ }
227
+ return a;
228
+ }
229
+ }
230
+ function _nonIterableRest() {
231
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
232
+ }
233
+ function _nonIterableSpread() {
234
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
235
+ }
236
+ function ownKeys(e, r) {
237
+ var t = Object.keys(e);
238
+ if (Object.getOwnPropertySymbols) {
239
+ var o = Object.getOwnPropertySymbols(e);
240
+ r && (o = o.filter(function (r) {
241
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
242
+ })), t.push.apply(t, o);
243
+ }
244
+ return t;
245
+ }
246
+ function _objectSpread2(e) {
247
+ for (var r = 1; r < arguments.length; r++) {
248
+ var t = null != arguments[r] ? arguments[r] : {};
249
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
250
+ _defineProperty(e, r, t[r]);
251
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
252
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
253
+ });
254
+ }
255
+ return e;
256
+ }
257
+ function _possibleConstructorReturn(t, e) {
258
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
259
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
260
+ return _assertThisInitialized(t);
261
+ }
262
+ function _regenerator() {
263
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
264
+ var e,
265
+ t,
266
+ r = "function" == typeof Symbol ? Symbol : {},
267
+ n = r.iterator || "@@iterator",
268
+ o = r.toStringTag || "@@toStringTag";
269
+ function i(r, n, o, i) {
270
+ var c = n && n.prototype instanceof Generator ? n : Generator,
271
+ u = Object.create(c.prototype);
272
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
273
+ var i,
274
+ c,
275
+ u,
276
+ f = 0,
277
+ p = o || [],
278
+ y = false,
279
+ G = {
280
+ p: 0,
281
+ n: 0,
282
+ v: e,
283
+ a: d,
284
+ f: d.bind(e, 4),
285
+ d: function (t, r) {
286
+ return i = t, c = 0, u = e, G.n = r, a;
287
+ }
288
+ };
289
+ function d(r, n) {
290
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
291
+ var o,
292
+ i = p[t],
293
+ d = G.p,
294
+ l = i[2];
295
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
296
+ }
297
+ if (o || r > 1) return a;
298
+ throw y = true, n;
299
+ }
300
+ return function (o, p, l) {
301
+ if (f > 1) throw TypeError("Generator is already running");
302
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
303
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
304
+ try {
305
+ if (f = 2, i) {
306
+ if (c || (o = "next"), t = i[o]) {
307
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
308
+ if (!t.done) return t;
309
+ u = t.value, c < 2 && (c = 0);
310
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
311
+ i = e;
312
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
313
+ } catch (t) {
314
+ i = e, c = 1, u = t;
315
+ } finally {
316
+ f = 1;
317
+ }
318
+ }
319
+ return {
320
+ value: t,
321
+ done: y
322
+ };
323
+ };
324
+ }(r, o, i), true), u;
325
+ }
326
+ var a = {};
327
+ function Generator() {}
328
+ function GeneratorFunction() {}
329
+ function GeneratorFunctionPrototype() {}
330
+ t = Object.getPrototypeOf;
331
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
332
+ return this;
333
+ }), t),
334
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
335
+ function f(e) {
336
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
337
+ }
338
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
339
+ return this;
340
+ }), _regeneratorDefine(u, "toString", function () {
341
+ return "[object Generator]";
342
+ }), (_regenerator = function () {
343
+ return {
344
+ w: i,
345
+ m: f
346
+ };
347
+ })();
348
+ }
349
+ function _regeneratorDefine(e, r, n, t) {
350
+ var i = Object.defineProperty;
351
+ try {
352
+ i({}, "", {});
353
+ } catch (e) {
354
+ i = 0;
355
+ }
356
+ _regeneratorDefine = function (e, r, n, t) {
357
+ function o(r, n) {
358
+ _regeneratorDefine(e, r, function (e) {
359
+ return this._invoke(r, n, e);
360
+ });
361
+ }
362
+ r ? i ? i(e, r, {
363
+ value: n,
364
+ enumerable: !t,
365
+ configurable: !t,
366
+ writable: !t
367
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
368
+ }, _regeneratorDefine(e, r, n, t);
369
+ }
370
+ function _setPrototypeOf(t, e) {
371
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
372
+ return t.__proto__ = e, t;
373
+ }, _setPrototypeOf(t, e);
374
+ }
375
+ function _slicedToArray(r, e) {
376
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
377
+ }
378
+ function _superPropBase(t, o) {
379
+ for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
380
+ return t;
381
+ }
382
+ function _superPropGet(t, o, e, r) {
383
+ var p = _get$1(_getPrototypeOf(t.prototype ), o, e);
384
+ return 2 & r && "function" == typeof p ? function (t) {
385
+ return p.apply(e, t);
386
+ } : p;
387
+ }
388
+ function _toConsumableArray(r) {
389
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
390
+ }
391
+ function _toPrimitive(t, r) {
392
+ if ("object" != typeof t || !t) return t;
393
+ var e = t[Symbol.toPrimitive];
394
+ if (void 0 !== e) {
395
+ var i = e.call(t, r);
396
+ if ("object" != typeof i) return i;
397
+ throw new TypeError("@@toPrimitive must return a primitive value.");
398
+ }
399
+ return ("string" === r ? String : Number)(t);
400
+ }
401
+ function _toPropertyKey(t) {
402
+ var i = _toPrimitive(t, "string");
403
+ return "symbol" == typeof i ? i : i + "";
404
+ }
405
+ function _typeof(o) {
406
+ "@babel/helpers - typeof";
407
+
408
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
409
+ return typeof o;
410
+ } : function (o) {
411
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
412
+ }, _typeof(o);
413
+ }
414
+ function _unsupportedIterableToArray(r, a) {
415
+ if (r) {
416
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
417
+ var t = {}.toString.call(r).slice(8, -1);
418
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
419
+ }
420
+ }
421
+
422
+ var _AppEngineClient_brand = /*#__PURE__*/new WeakSet();
423
+ var AppEngineClient = /*#__PURE__*/function () {
424
+ function AppEngineClient(_ref) {
425
+ var baseUrl = _ref.baseUrl,
426
+ _ref$timeout = _ref.timeout,
427
+ timeout = _ref$timeout === void 0 ? 30000 : _ref$timeout;
428
+ _classCallCheck(this, AppEngineClient);
429
+ // ─── HTTP helpers ────────────────────────────────────────
430
+ _classPrivateMethodInitSpec(this, _AppEngineClient_brand);
431
+ if (!baseUrl) {
432
+ throw new Error('AppEngineClient requires a baseUrl');
433
+ }
434
+ this._baseUrl = baseUrl.replace(/\/$/, '');
435
+ this._http = axios.create({
436
+ baseURL: this._baseUrl,
437
+ timeout: timeout,
438
+ headers: {
439
+ 'Content-Type': 'application/json'
440
+ }
441
+ });
442
+ }
443
+
444
+ // ─── App Definition ──────────────────────────────────────
445
+ return _createClass(AppEngineClient, [{
446
+ key: "getAppDefinition",
447
+ value: function () {
448
+ var _getAppDefinition = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref2) {
449
+ var queryselector, search, page, pageSize, exclude_status, params;
450
+ return _regenerator().w(function (_context) {
451
+ while (1) switch (_context.n) {
452
+ case 0:
453
+ queryselector = _ref2.queryselector, search = _ref2.search, page = _ref2.page, pageSize = _ref2.pageSize, exclude_status = _ref2.exclude_status;
454
+ params = {
455
+ search: search,
456
+ page: page,
457
+ pageSize: pageSize,
458
+ exclude_status: exclude_status
459
+ };
460
+ return _context.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, "/app/definition/".concat(queryselector), params));
461
+ }
462
+ }, _callee, this);
463
+ }));
464
+ function getAppDefinition(_x) {
465
+ return _getAppDefinition.apply(this, arguments);
466
+ }
467
+ return getAppDefinition;
468
+ }()
469
+ }, {
470
+ key: "getAppsCatalog",
471
+ value: function () {
472
+ var _getAppsCatalog = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
473
+ var _ref3,
474
+ owning_product,
475
+ page,
476
+ pageSize,
477
+ params,
478
+ _args2 = arguments;
479
+ return _regenerator().w(function (_context2) {
480
+ while (1) switch (_context2.n) {
481
+ case 0:
482
+ _ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, owning_product = _ref3.owning_product, page = _ref3.page, pageSize = _ref3.pageSize;
483
+ params = {
484
+ owning_product: owning_product,
485
+ page: page,
486
+ pageSize: pageSize
487
+ };
488
+ return _context2.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/definition/catalog/', params));
489
+ }
490
+ }, _callee2, this);
491
+ }));
492
+ function getAppsCatalog() {
493
+ return _getAppsCatalog.apply(this, arguments);
494
+ }
495
+ return getAppsCatalog;
496
+ }()
497
+ }, {
498
+ key: "getFullApp",
499
+ value: function () {
500
+ var _getFullApp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref4) {
501
+ var slug;
502
+ return _regenerator().w(function (_context3) {
503
+ while (1) switch (_context3.n) {
504
+ case 0:
505
+ slug = _ref4.slug;
506
+ return _context3.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/definition/full/', {
507
+ slug: slug
508
+ }));
509
+ }
510
+ }, _callee3, this);
511
+ }));
512
+ function getFullApp(_x2) {
513
+ return _getFullApp.apply(this, arguments);
514
+ }
515
+ return getFullApp;
516
+ }()
517
+ }, {
518
+ key: "getStudioPayload",
519
+ value: function () {
520
+ var _getStudioPayload = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref5) {
521
+ var search;
522
+ return _regenerator().w(function (_context4) {
523
+ while (1) switch (_context4.n) {
524
+ case 0:
525
+ search = _ref5.search;
526
+ return _context4.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/definition/studio/', {
527
+ search: search
528
+ }));
529
+ }
530
+ }, _callee4, this);
531
+ }));
532
+ function getStudioPayload(_x3) {
533
+ return _getStudioPayload.apply(this, arguments);
534
+ }
535
+ return getStudioPayload;
536
+ }()
537
+ }, {
538
+ key: "createAppDefinition",
539
+ value: function () {
540
+ var _createAppDefinition = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(data) {
541
+ return _regenerator().w(function (_context5) {
542
+ while (1) switch (_context5.n) {
543
+ case 0:
544
+ return _context5.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/definition/', data));
545
+ }
546
+ }, _callee5, this);
547
+ }));
548
+ function createAppDefinition(_x4) {
549
+ return _createAppDefinition.apply(this, arguments);
550
+ }
551
+ return createAppDefinition;
552
+ }()
553
+ }, {
554
+ key: "createAppWithScaffold",
555
+ value: function () {
556
+ var _createAppWithScaffold = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(data) {
557
+ return _regenerator().w(function (_context6) {
558
+ while (1) switch (_context6.n) {
559
+ case 0:
560
+ return _context6.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/definition/scaffold/', data));
561
+ }
562
+ }, _callee6, this);
563
+ }));
564
+ function createAppWithScaffold(_x5) {
565
+ return _createAppWithScaffold.apply(this, arguments);
566
+ }
567
+ return createAppWithScaffold;
568
+ }()
569
+ }, {
570
+ key: "updateAppDefinition",
571
+ value: function () {
572
+ var _updateAppDefinition = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(data) {
573
+ return _regenerator().w(function (_context7) {
574
+ while (1) switch (_context7.n) {
575
+ case 0:
576
+ return _context7.a(2, _assertClassBrand(_AppEngineClient_brand, this, _patch).call(this, '/app/definition/', data));
577
+ }
578
+ }, _callee7, this);
579
+ }));
580
+ function updateAppDefinition(_x6) {
581
+ return _updateAppDefinition.apply(this, arguments);
582
+ }
583
+ return updateAppDefinition;
584
+ }()
585
+ }, {
586
+ key: "deleteAppDefinition",
587
+ value: function () {
588
+ var _deleteAppDefinition = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(_ref6) {
589
+ var id;
590
+ return _regenerator().w(function (_context8) {
591
+ while (1) switch (_context8.n) {
592
+ case 0:
593
+ id = _ref6.id;
594
+ return _context8.a(2, _assertClassBrand(_AppEngineClient_brand, this, _delete).call(this, '/app/definition/', {
595
+ id: id
596
+ }));
597
+ }
598
+ }, _callee8, this);
599
+ }));
600
+ function deleteAppDefinition(_x7) {
601
+ return _deleteAppDefinition.apply(this, arguments);
602
+ }
603
+ return deleteAppDefinition;
604
+ }() // ─── App Version ─────────────────────────────────────────
605
+ }, {
606
+ key: "getAppVersion",
607
+ value: function () {
608
+ var _getAppVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref7) {
609
+ var queryselector, search, page, pageSize, params;
610
+ return _regenerator().w(function (_context9) {
611
+ while (1) switch (_context9.n) {
612
+ case 0:
613
+ queryselector = _ref7.queryselector, search = _ref7.search, page = _ref7.page, pageSize = _ref7.pageSize;
614
+ params = {
615
+ search: search,
616
+ page: page,
617
+ pageSize: pageSize
618
+ };
619
+ return _context9.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, "/app/version/".concat(queryselector), params));
620
+ }
621
+ }, _callee9, this);
622
+ }));
623
+ function getAppVersion(_x8) {
624
+ return _getAppVersion.apply(this, arguments);
625
+ }
626
+ return getAppVersion;
627
+ }()
628
+ }, {
629
+ key: "createAppVersion",
630
+ value: function () {
631
+ var _createAppVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(data) {
632
+ return _regenerator().w(function (_context0) {
633
+ while (1) switch (_context0.n) {
634
+ case 0:
635
+ return _context0.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/version/', data));
636
+ }
637
+ }, _callee0, this);
638
+ }));
639
+ function createAppVersion(_x9) {
640
+ return _createAppVersion.apply(this, arguments);
641
+ }
642
+ return createAppVersion;
643
+ }()
644
+ }, {
645
+ key: "updateAppVersion",
646
+ value: function () {
647
+ var _updateAppVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(data) {
648
+ return _regenerator().w(function (_context1) {
649
+ while (1) switch (_context1.n) {
650
+ case 0:
651
+ return _context1.a(2, _assertClassBrand(_AppEngineClient_brand, this, _patch).call(this, '/app/version/', data));
652
+ }
653
+ }, _callee1, this);
654
+ }));
655
+ function updateAppVersion(_x0) {
656
+ return _updateAppVersion.apply(this, arguments);
657
+ }
658
+ return updateAppVersion;
659
+ }()
660
+ }, {
661
+ key: "publishVersion",
662
+ value: function () {
663
+ var _publishVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(_ref8) {
664
+ var app_definition_id, changelog, published_by;
665
+ return _regenerator().w(function (_context10) {
666
+ while (1) switch (_context10.n) {
667
+ case 0:
668
+ app_definition_id = _ref8.app_definition_id, changelog = _ref8.changelog, published_by = _ref8.published_by;
669
+ return _context10.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/version/publish/', {
670
+ app_definition_id: app_definition_id,
671
+ changelog: changelog,
672
+ published_by: published_by
673
+ }));
674
+ }
675
+ }, _callee10, this);
676
+ }));
677
+ function publishVersion(_x1) {
678
+ return _publishVersion.apply(this, arguments);
679
+ }
680
+ return publishVersion;
681
+ }()
682
+ }, {
683
+ key: "activateVersion",
684
+ value: function () {
685
+ var _activateVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(_ref9) {
686
+ var id;
687
+ return _regenerator().w(function (_context11) {
688
+ while (1) switch (_context11.n) {
689
+ case 0:
690
+ id = _ref9.id;
691
+ return _context11.a(2, _assertClassBrand(_AppEngineClient_brand, this, _patch).call(this, '/app/version/activate/', {
692
+ id: id
693
+ }));
694
+ }
695
+ }, _callee11, this);
696
+ }));
697
+ function activateVersion(_x10) {
698
+ return _activateVersion.apply(this, arguments);
699
+ }
700
+ return activateVersion;
701
+ }()
702
+ }, {
703
+ key: "deleteAppVersion",
704
+ value: function () {
705
+ var _deleteAppVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(_ref0) {
706
+ var id;
707
+ return _regenerator().w(function (_context12) {
708
+ while (1) switch (_context12.n) {
709
+ case 0:
710
+ id = _ref0.id;
711
+ return _context12.a(2, _assertClassBrand(_AppEngineClient_brand, this, _delete).call(this, '/app/version/', {
712
+ id: id
713
+ }));
714
+ }
715
+ }, _callee12, this);
716
+ }));
717
+ function deleteAppVersion(_x11) {
718
+ return _deleteAppVersion.apply(this, arguments);
719
+ }
720
+ return deleteAppVersion;
721
+ }() // ─── App File ────────────────────────────────────────────
722
+ }, {
723
+ key: "getAppFile",
724
+ value: function () {
725
+ var _getAppFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(_ref1) {
726
+ var queryselector, search, page, pageSize, params;
727
+ return _regenerator().w(function (_context13) {
728
+ while (1) switch (_context13.n) {
729
+ case 0:
730
+ queryselector = _ref1.queryselector, search = _ref1.search, page = _ref1.page, pageSize = _ref1.pageSize;
731
+ params = {
732
+ search: search,
733
+ page: page,
734
+ pageSize: pageSize
735
+ };
736
+ return _context13.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, "/app/file/".concat(queryselector), params));
737
+ }
738
+ }, _callee13, this);
739
+ }));
740
+ function getAppFile(_x12) {
741
+ return _getAppFile.apply(this, arguments);
742
+ }
743
+ return getAppFile;
744
+ }()
745
+ }, {
746
+ key: "getFileTree",
747
+ value: function () {
748
+ var _getFileTree = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref10) {
749
+ var search;
750
+ return _regenerator().w(function (_context14) {
751
+ while (1) switch (_context14.n) {
752
+ case 0:
753
+ search = _ref10.search;
754
+ return _context14.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/file/tree/', {
755
+ search: search
756
+ }));
757
+ }
758
+ }, _callee14, this);
759
+ }));
760
+ function getFileTree(_x13) {
761
+ return _getFileTree.apply(this, arguments);
762
+ }
763
+ return getFileTree;
764
+ }()
765
+ }, {
766
+ key: "getFileContent",
767
+ value: function () {
768
+ var _getFileContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref11) {
769
+ var search;
770
+ return _regenerator().w(function (_context15) {
771
+ while (1) switch (_context15.n) {
772
+ case 0:
773
+ search = _ref11.search;
774
+ return _context15.a(2, _assertClassBrand(_AppEngineClient_brand, this, _get).call(this, '/app/file/content/', {
775
+ search: search
776
+ }));
777
+ }
778
+ }, _callee15, this);
779
+ }));
780
+ function getFileContent(_x14) {
781
+ return _getFileContent.apply(this, arguments);
782
+ }
783
+ return getFileContent;
784
+ }()
785
+ }, {
786
+ key: "createAppFile",
787
+ value: function () {
788
+ var _createAppFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(data) {
789
+ return _regenerator().w(function (_context16) {
790
+ while (1) switch (_context16.n) {
791
+ case 0:
792
+ return _context16.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/file/', data));
793
+ }
794
+ }, _callee16, this);
795
+ }));
796
+ function createAppFile(_x15) {
797
+ return _createAppFile.apply(this, arguments);
798
+ }
799
+ return createAppFile;
800
+ }()
801
+ }, {
802
+ key: "updateAppFile",
803
+ value: function () {
804
+ var _updateAppFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(data) {
805
+ return _regenerator().w(function (_context17) {
806
+ while (1) switch (_context17.n) {
807
+ case 0:
808
+ return _context17.a(2, _assertClassBrand(_AppEngineClient_brand, this, _patch).call(this, '/app/file/', data));
809
+ }
810
+ }, _callee17, this);
811
+ }));
812
+ function updateAppFile(_x16) {
813
+ return _updateAppFile.apply(this, arguments);
814
+ }
815
+ return updateAppFile;
816
+ }()
817
+ }, {
818
+ key: "deleteAppFile",
819
+ value: function () {
820
+ var _deleteAppFile = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(_ref12) {
821
+ var id;
822
+ return _regenerator().w(function (_context18) {
823
+ while (1) switch (_context18.n) {
824
+ case 0:
825
+ id = _ref12.id;
826
+ return _context18.a(2, _assertClassBrand(_AppEngineClient_brand, this, _delete).call(this, '/app/file/', {
827
+ id: id
828
+ }));
829
+ }
830
+ }, _callee18, this);
831
+ }));
832
+ function deleteAppFile(_x17) {
833
+ return _deleteAppFile.apply(this, arguments);
834
+ }
835
+ return deleteAppFile;
836
+ }()
837
+ }, {
838
+ key: "applyFileChanges",
839
+ value: function () {
840
+ var _applyFileChanges = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref13) {
841
+ var app_definition_id, organization_id, changes;
842
+ return _regenerator().w(function (_context19) {
843
+ while (1) switch (_context19.n) {
844
+ case 0:
845
+ app_definition_id = _ref13.app_definition_id, organization_id = _ref13.organization_id, changes = _ref13.changes;
846
+ return _context19.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/file/apply-changes/', {
847
+ app_definition_id: app_definition_id,
848
+ organization_id: organization_id,
849
+ changes: changes
850
+ }));
851
+ }
852
+ }, _callee19, this);
853
+ }));
854
+ function applyFileChanges(_x18) {
855
+ return _applyFileChanges.apply(this, arguments);
856
+ }
857
+ return applyFileChanges;
858
+ }() // ─── App Build ───────────────────────────────────────────
859
+ }, {
860
+ key: "buildApp",
861
+ value: function () {
862
+ var _buildApp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(_ref14) {
863
+ var slug, app_definition_id;
864
+ return _regenerator().w(function (_context20) {
865
+ while (1) switch (_context20.n) {
866
+ case 0:
867
+ slug = _ref14.slug, app_definition_id = _ref14.app_definition_id;
868
+ return _context20.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/build/single/', {
869
+ slug: slug,
870
+ app_definition_id: app_definition_id
871
+ }));
872
+ }
873
+ }, _callee20, this);
874
+ }));
875
+ function buildApp(_x19) {
876
+ return _buildApp.apply(this, arguments);
877
+ }
878
+ return buildApp;
879
+ }()
880
+ }, {
881
+ key: "buildAllApps",
882
+ value: function () {
883
+ var _buildAllApps = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
884
+ var _ref15,
885
+ owning_product,
886
+ _args21 = arguments;
887
+ return _regenerator().w(function (_context21) {
888
+ while (1) switch (_context21.n) {
889
+ case 0:
890
+ _ref15 = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {}, owning_product = _ref15.owning_product;
891
+ return _context21.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/build/all/', {
892
+ owning_product: owning_product
893
+ }));
894
+ }
895
+ }, _callee21, this);
896
+ }));
897
+ function buildAllApps() {
898
+ return _buildAllApps.apply(this, arguments);
899
+ }
900
+ return buildAllApps;
901
+ }()
902
+ }, {
903
+ key: "buildAndPublish",
904
+ value: function () {
905
+ var _buildAndPublish = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(_ref16) {
906
+ var slug, app_definition_id, changelog, published_by;
907
+ return _regenerator().w(function (_context22) {
908
+ while (1) switch (_context22.n) {
909
+ case 0:
910
+ slug = _ref16.slug, app_definition_id = _ref16.app_definition_id, changelog = _ref16.changelog, published_by = _ref16.published_by;
911
+ return _context22.a(2, _assertClassBrand(_AppEngineClient_brand, this, _post).call(this, '/app/build/publish/', {
912
+ slug: slug,
913
+ app_definition_id: app_definition_id,
914
+ changelog: changelog,
915
+ published_by: published_by
916
+ }));
917
+ }
918
+ }, _callee22, this);
919
+ }));
920
+ function buildAndPublish(_x20) {
921
+ return _buildAndPublish.apply(this, arguments);
922
+ }
923
+ return buildAndPublish;
924
+ }()
925
+ }]);
926
+ }();
927
+ function _get(_x21) {
928
+ return _get2.apply(this, arguments);
929
+ }
930
+ function _get2() {
931
+ _get2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(path) {
932
+ var params,
933
+ cleanParams,
934
+ response,
935
+ _args23 = arguments,
936
+ _t;
937
+ return _regenerator().w(function (_context23) {
938
+ while (1) switch (_context23.p = _context23.n) {
939
+ case 0:
940
+ params = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {};
941
+ _context23.p = 1;
942
+ cleanParams = _assertClassBrand(_AppEngineClient_brand, this, _cleanParams).call(this, params);
943
+ _context23.n = 2;
944
+ return this._http.get(path, {
945
+ params: cleanParams
946
+ });
947
+ case 2:
948
+ response = _context23.v;
949
+ return _context23.a(2, response.data);
950
+ case 3:
951
+ _context23.p = 3;
952
+ _t = _context23.v;
953
+ return _context23.a(2, _assertClassBrand(_AppEngineClient_brand, this, _handleError).call(this, _t));
954
+ }
955
+ }, _callee23, this, [[1, 3]]);
956
+ }));
957
+ return _get2.apply(this, arguments);
958
+ }
959
+ function _post(_x22) {
960
+ return _post2.apply(this, arguments);
961
+ }
962
+ function _post2() {
963
+ _post2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(path) {
964
+ var data,
965
+ response,
966
+ _args24 = arguments,
967
+ _t2;
968
+ return _regenerator().w(function (_context24) {
969
+ while (1) switch (_context24.p = _context24.n) {
970
+ case 0:
971
+ data = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : {};
972
+ _context24.p = 1;
973
+ _context24.n = 2;
974
+ return this._http.post(path, data);
975
+ case 2:
976
+ response = _context24.v;
977
+ return _context24.a(2, response.data);
978
+ case 3:
979
+ _context24.p = 3;
980
+ _t2 = _context24.v;
981
+ return _context24.a(2, _assertClassBrand(_AppEngineClient_brand, this, _handleError).call(this, _t2));
982
+ }
983
+ }, _callee24, this, [[1, 3]]);
984
+ }));
985
+ return _post2.apply(this, arguments);
986
+ }
987
+ function _patch(_x23) {
988
+ return _patch2.apply(this, arguments);
989
+ }
990
+ function _patch2() {
991
+ _patch2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(path) {
992
+ var data,
993
+ response,
994
+ _args25 = arguments,
995
+ _t3;
996
+ return _regenerator().w(function (_context25) {
997
+ while (1) switch (_context25.p = _context25.n) {
998
+ case 0:
999
+ data = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
1000
+ _context25.p = 1;
1001
+ _context25.n = 2;
1002
+ return this._http.patch(path, data);
1003
+ case 2:
1004
+ response = _context25.v;
1005
+ return _context25.a(2, response.data);
1006
+ case 3:
1007
+ _context25.p = 3;
1008
+ _t3 = _context25.v;
1009
+ return _context25.a(2, _assertClassBrand(_AppEngineClient_brand, this, _handleError).call(this, _t3));
1010
+ }
1011
+ }, _callee25, this, [[1, 3]]);
1012
+ }));
1013
+ return _patch2.apply(this, arguments);
1014
+ }
1015
+ function _delete(_x24) {
1016
+ return _delete2.apply(this, arguments);
1017
+ }
1018
+ function _delete2() {
1019
+ _delete2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(path) {
1020
+ var data,
1021
+ response,
1022
+ _args26 = arguments,
1023
+ _t4;
1024
+ return _regenerator().w(function (_context26) {
1025
+ while (1) switch (_context26.p = _context26.n) {
1026
+ case 0:
1027
+ data = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : {};
1028
+ _context26.p = 1;
1029
+ _context26.n = 2;
1030
+ return this._http["delete"](path, {
1031
+ data: data
1032
+ });
1033
+ case 2:
1034
+ response = _context26.v;
1035
+ return _context26.a(2, response.data);
1036
+ case 3:
1037
+ _context26.p = 3;
1038
+ _t4 = _context26.v;
1039
+ return _context26.a(2, _assertClassBrand(_AppEngineClient_brand, this, _handleError).call(this, _t4));
1040
+ }
1041
+ }, _callee26, this, [[1, 3]]);
1042
+ }));
1043
+ return _delete2.apply(this, arguments);
1044
+ }
1045
+ function _cleanParams(params) {
1046
+ var clean = {};
1047
+ for (var _i = 0, _Object$entries = Object.entries(params); _i < _Object$entries.length; _i++) {
1048
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1049
+ key = _Object$entries$_i[0],
1050
+ value = _Object$entries$_i[1];
1051
+ if (value !== undefined && value !== null) {
1052
+ clean[key] = value;
1053
+ }
1054
+ }
1055
+ return clean;
1056
+ }
1057
+ function _handleError(error) {
1058
+ if (error.response) {
1059
+ return error.response.data || {
1060
+ success: false,
1061
+ status: error.response.status,
1062
+ message: error.response.statusText
1063
+ };
1064
+ }
1065
+ return {
1066
+ success: false,
1067
+ status: 500,
1068
+ message: error.message || 'Network error'
1069
+ };
1070
+ }
1071
+
1072
+ var RuntimeContainer = styles.styled('div')(function (_ref) {
1073
+ var $launchMode = _ref.$launchMode;
1074
+ return {
1075
+ width: '100%',
1076
+ height: '100%',
1077
+ flex: $launchMode === 'fullscreen' ? 1 : 'none',
1078
+ minHeight: $launchMode === 'fullscreen' ? 0 : '400px',
1079
+ backgroundColor: '#2B2A33',
1080
+ position: 'relative',
1081
+ display: 'flex',
1082
+ flexDirection: 'column'
1083
+ };
1084
+ });
1085
+ var LoadingState = styles.styled('div')({
1086
+ display: 'flex',
1087
+ flexDirection: 'column',
1088
+ alignItems: 'center',
1089
+ justifyContent: 'center',
1090
+ height: '100%',
1091
+ minHeight: '400px',
1092
+ gap: '16px',
1093
+ color: '#9CA3AF'
1094
+ });
1095
+ var ErrorState = styles.styled('div')({
1096
+ display: 'flex',
1097
+ flexDirection: 'column',
1098
+ alignItems: 'center',
1099
+ justifyContent: 'center',
1100
+ height: '100%',
1101
+ minHeight: '400px',
1102
+ gap: '12px',
1103
+ color: '#EF4444',
1104
+ padding: '24px'
1105
+ });
1106
+ var AppRuntimeHost = function AppRuntimeHost(_ref2) {
1107
+ var appSlug = _ref2.appSlug,
1108
+ routePath = _ref2.routePath,
1109
+ _ref2$launchMode = _ref2.launchMode,
1110
+ launchMode = _ref2$launchMode === void 0 ? 'fullscreen' : _ref2$launchMode,
1111
+ _ref2$inputPayload = _ref2.inputPayload,
1112
+ inputPayload = _ref2$inputPayload === void 0 ? {} : _ref2$inputPayload,
1113
+ appSessionService = _ref2.appSessionService,
1114
+ _ref2$apiBaseUrl = _ref2.apiBaseUrl,
1115
+ apiBaseUrl = _ref2$apiBaseUrl === void 0 ? '' : _ref2$apiBaseUrl,
1116
+ onClose = _ref2.onClose,
1117
+ onSubmitOutput = _ref2.onSubmitOutput,
1118
+ onNavigate = _ref2.onNavigate;
1119
+ var _useState = React$1.useState('loading'),
1120
+ _useState2 = _slicedToArray(_useState, 2),
1121
+ status = _useState2[0],
1122
+ setStatus = _useState2[1];
1123
+ var _useState3 = React$1.useState(null),
1124
+ _useState4 = _slicedToArray(_useState3, 2),
1125
+ error = _useState4[0],
1126
+ setError = _useState4[1];
1127
+ var _useState5 = React$1.useState(null),
1128
+ _useState6 = _slicedToArray(_useState5, 2);
1129
+ _useState6[0];
1130
+ var setSession = _useState6[1];
1131
+ var mountRef = React$1.useRef(null);
1132
+ var rootRef = React$1.useRef(null);
1133
+ var blobUrlRef = React$1.useRef(null);
1134
+ var openSession = React$1.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
1135
+ var response, _response$result, sessionData, version, _t;
1136
+ return _regenerator().w(function (_context) {
1137
+ while (1) switch (_context.p = _context.n) {
1138
+ case 0:
1139
+ if (!(!appSessionService || !appSlug)) {
1140
+ _context.n = 1;
1141
+ break;
1142
+ }
1143
+ return _context.a(2);
1144
+ case 1:
1145
+ setStatus('loading');
1146
+ setError(null);
1147
+ _context.p = 2;
1148
+ _context.n = 3;
1149
+ return appSessionService.open({
1150
+ app_slug: appSlug,
1151
+ route_path: routePath || '/',
1152
+ launch_mode: launchMode,
1153
+ input_payload: inputPayload
1154
+ });
1155
+ case 3:
1156
+ response = _context.v;
1157
+ if (response !== null && response !== void 0 && response.result) {
1158
+ _context.n = 4;
1159
+ break;
1160
+ }
1161
+ throw new Error((response === null || response === void 0 ? void 0 : response.message) || 'Failed to open session');
1162
+ case 4:
1163
+ _response$result = response.result, sessionData = _response$result.session, version = _response$result.app_version;
1164
+ setSession(sessionData);
1165
+ if (version !== null && version !== void 0 && version.build_artifact) {
1166
+ _context.n = 5;
1167
+ break;
1168
+ }
1169
+ throw new Error('No build artifact available. Build and publish the app first.');
1170
+ case 5:
1171
+ _context.n = 6;
1172
+ return loadAndMount(version.build_artifact, sessionData, response.result);
1173
+ case 6:
1174
+ _context.n = 8;
1175
+ break;
1176
+ case 7:
1177
+ _context.p = 7;
1178
+ _t = _context.v;
1179
+ setError(_t.message);
1180
+ setStatus('error');
1181
+ case 8:
1182
+ return _context.a(2);
1183
+ }
1184
+ }, _callee, null, [[2, 7]]);
1185
+ })), [appSessionService, appSlug, routePath, launchMode, inputPayload]);
1186
+ var loadAndMount = /*#__PURE__*/function () {
1187
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(buildArtifact, sessionData, fullPayload) {
1188
+ var _buildArtifact$entryF, entryFile, code, blob, blobUrl, module, AppComponent, inputData, sdk, _t2;
1189
+ return _regenerator().w(function (_context9) {
1190
+ while (1) switch (_context9.p = _context9.n) {
1191
+ case 0:
1192
+ _context9.p = 0;
1193
+ entryFile = Object.keys(buildArtifact).find(function (key) {
1194
+ return key.endsWith('.js') || key.endsWith('.mjs');
1195
+ });
1196
+ if (!(!entryFile || !((_buildArtifact$entryF = buildArtifact[entryFile]) !== null && _buildArtifact$entryF !== void 0 && _buildArtifact$entryF.content))) {
1197
+ _context9.n = 1;
1198
+ break;
1199
+ }
1200
+ throw new Error('No entry file found in build artifacts');
1201
+ case 1:
1202
+ code = buildArtifact[entryFile].content;
1203
+ blob = new Blob([code], {
1204
+ type: 'application/javascript'
1205
+ });
1206
+ blobUrl = URL.createObjectURL(blob);
1207
+ blobUrlRef.current = blobUrl;
1208
+ _context9.n = 2;
1209
+ return import(/* @vite-ignore */blobUrl);
1210
+ case 2:
1211
+ module = _context9.v;
1212
+ AppComponent = module["default"];
1213
+ if (AppComponent) {
1214
+ _context9.n = 3;
1215
+ break;
1216
+ }
1217
+ throw new Error('App module does not export a default component');
1218
+ case 3:
1219
+ inputData = sessionData.input_payload || inputPayload;
1220
+ sdk = {
1221
+ session: {
1222
+ id: sessionData.id,
1223
+ appId: sessionData.app_definition_id,
1224
+ appSlug: sessionData.app_slug,
1225
+ appVersionId: sessionData.app_version_id,
1226
+ launchMode: sessionData.launch_mode,
1227
+ routePath: sessionData.route_path
1228
+ },
1229
+ input: inputData,
1230
+ context: {
1231
+ appDefinition: fullPayload.app_definition || {},
1232
+ appVersion: fullPayload.app_version || {},
1233
+ task: (inputData === null || inputData === void 0 ? void 0 : inputData.task) || null,
1234
+ data: inputData
1235
+ },
1236
+ api: {
1237
+ get: function () {
1238
+ var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(path) {
1239
+ var params,
1240
+ qs,
1241
+ url,
1242
+ res,
1243
+ _args2 = arguments;
1244
+ return _regenerator().w(function (_context2) {
1245
+ while (1) switch (_context2.n) {
1246
+ case 0:
1247
+ params = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
1248
+ qs = new URLSearchParams(params).toString();
1249
+ url = "".concat(apiBaseUrl).concat(path).concat(qs ? '?' + qs : '');
1250
+ _context2.n = 1;
1251
+ return fetch(url, {
1252
+ headers: {
1253
+ 'Content-Type': 'application/json'
1254
+ }
1255
+ });
1256
+ case 1:
1257
+ res = _context2.v;
1258
+ return _context2.a(2, res.json());
1259
+ }
1260
+ }, _callee2);
1261
+ }));
1262
+ function get(_x4) {
1263
+ return _get.apply(this, arguments);
1264
+ }
1265
+ return get;
1266
+ }(),
1267
+ post: function () {
1268
+ var _post = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(path) {
1269
+ var body,
1270
+ res,
1271
+ _args3 = arguments;
1272
+ return _regenerator().w(function (_context3) {
1273
+ while (1) switch (_context3.n) {
1274
+ case 0:
1275
+ body = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
1276
+ _context3.n = 1;
1277
+ return fetch("".concat(apiBaseUrl).concat(path), {
1278
+ method: 'POST',
1279
+ headers: {
1280
+ 'Content-Type': 'application/json'
1281
+ },
1282
+ body: JSON.stringify(body)
1283
+ });
1284
+ case 1:
1285
+ res = _context3.v;
1286
+ return _context3.a(2, res.json());
1287
+ }
1288
+ }, _callee3);
1289
+ }));
1290
+ function post(_x5) {
1291
+ return _post.apply(this, arguments);
1292
+ }
1293
+ return post;
1294
+ }(),
1295
+ patch: function () {
1296
+ var _patch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(path) {
1297
+ var body,
1298
+ res,
1299
+ _args4 = arguments;
1300
+ return _regenerator().w(function (_context4) {
1301
+ while (1) switch (_context4.n) {
1302
+ case 0:
1303
+ body = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
1304
+ _context4.n = 1;
1305
+ return fetch("".concat(apiBaseUrl).concat(path), {
1306
+ method: 'PATCH',
1307
+ headers: {
1308
+ 'Content-Type': 'application/json'
1309
+ },
1310
+ body: JSON.stringify(body)
1311
+ });
1312
+ case 1:
1313
+ res = _context4.v;
1314
+ return _context4.a(2, res.json());
1315
+ }
1316
+ }, _callee4);
1317
+ }));
1318
+ function patch(_x6) {
1319
+ return _patch.apply(this, arguments);
1320
+ }
1321
+ return patch;
1322
+ }(),
1323
+ "delete": function () {
1324
+ var _delete2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(path) {
1325
+ var res;
1326
+ return _regenerator().w(function (_context5) {
1327
+ while (1) switch (_context5.n) {
1328
+ case 0:
1329
+ _context5.n = 1;
1330
+ return fetch("".concat(apiBaseUrl).concat(path), {
1331
+ method: 'DELETE',
1332
+ headers: {
1333
+ 'Content-Type': 'application/json'
1334
+ }
1335
+ });
1336
+ case 1:
1337
+ res = _context5.v;
1338
+ return _context5.a(2, res.json());
1339
+ }
1340
+ }, _callee5);
1341
+ }));
1342
+ function _delete(_x7) {
1343
+ return _delete2.apply(this, arguments);
1344
+ }
1345
+ return _delete;
1346
+ }()
1347
+ },
1348
+ navigate: function navigate(path) {
1349
+ if (onNavigate) onNavigate(path);
1350
+ },
1351
+ saveDraft: function () {
1352
+ var _saveDraft = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(payload) {
1353
+ return _regenerator().w(function (_context6) {
1354
+ while (1) switch (_context6.n) {
1355
+ case 0:
1356
+ if (!appSessionService) {
1357
+ _context6.n = 1;
1358
+ break;
1359
+ }
1360
+ return _context6.a(2, appSessionService.saveDraft({
1361
+ id: sessionData.id,
1362
+ draft_payload: payload
1363
+ }));
1364
+ case 1:
1365
+ return _context6.a(2);
1366
+ }
1367
+ }, _callee6);
1368
+ }));
1369
+ function saveDraft(_x8) {
1370
+ return _saveDraft.apply(this, arguments);
1371
+ }
1372
+ return saveDraft;
1373
+ }(),
1374
+ submitOutput: function () {
1375
+ var _submitOutput = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(payload) {
1376
+ return _regenerator().w(function (_context7) {
1377
+ while (1) switch (_context7.n) {
1378
+ case 0:
1379
+ if (!appSessionService) {
1380
+ _context7.n = 1;
1381
+ break;
1382
+ }
1383
+ _context7.n = 1;
1384
+ return appSessionService.submitOutput({
1385
+ id: sessionData.id,
1386
+ output_payload: payload
1387
+ });
1388
+ case 1:
1389
+ if (onSubmitOutput) onSubmitOutput(payload);
1390
+ case 2:
1391
+ return _context7.a(2);
1392
+ }
1393
+ }, _callee7);
1394
+ }));
1395
+ function submitOutput(_x9) {
1396
+ return _submitOutput.apply(this, arguments);
1397
+ }
1398
+ return submitOutput;
1399
+ }(),
1400
+ close: function close() {
1401
+ if (onClose) onClose();
1402
+ },
1403
+ cancel: function () {
1404
+ var _cancel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(reason) {
1405
+ return _regenerator().w(function (_context8) {
1406
+ while (1) switch (_context8.n) {
1407
+ case 0:
1408
+ if (!appSessionService) {
1409
+ _context8.n = 1;
1410
+ break;
1411
+ }
1412
+ _context8.n = 1;
1413
+ return appSessionService.cancel({
1414
+ id: sessionData.id
1415
+ });
1416
+ case 1:
1417
+ if (onClose) onClose();
1418
+ case 2:
1419
+ return _context8.a(2);
1420
+ }
1421
+ }, _callee8);
1422
+ }));
1423
+ function cancel(_x0) {
1424
+ return _cancel.apply(this, arguments);
1425
+ }
1426
+ return cancel;
1427
+ }()
1428
+ };
1429
+ if (mountRef.current) {
1430
+ rootRef.current = client.createRoot(mountRef.current);
1431
+ rootRef.current.render(/*#__PURE__*/React$1.createElement(AppComponent, {
1432
+ sdk: sdk
1433
+ }));
1434
+ setStatus('running');
1435
+ }
1436
+ _context9.n = 5;
1437
+ break;
1438
+ case 4:
1439
+ _context9.p = 4;
1440
+ _t2 = _context9.v;
1441
+ setError(_t2.message);
1442
+ setStatus('error');
1443
+ case 5:
1444
+ return _context9.a(2);
1445
+ }
1446
+ }, _callee9, null, [[0, 4]]);
1447
+ }));
1448
+ return function loadAndMount(_x, _x2, _x3) {
1449
+ return _ref4.apply(this, arguments);
1450
+ };
1451
+ }();
1452
+ React$1.useEffect(function () {
1453
+ openSession();
1454
+ return function () {
1455
+ if (rootRef.current) {
1456
+ rootRef.current.unmount();
1457
+ rootRef.current = null;
1458
+ }
1459
+ if (blobUrlRef.current) {
1460
+ URL.revokeObjectURL(blobUrlRef.current);
1461
+ blobUrlRef.current = null;
1462
+ }
1463
+ };
1464
+ }, [openSession]);
1465
+ if (status === 'loading') {
1466
+ return /*#__PURE__*/React$1.createElement(RuntimeContainer, {
1467
+ $launchMode: launchMode
1468
+ }, /*#__PURE__*/React$1.createElement(LoadingState, null, /*#__PURE__*/React$1.createElement(CircularProgress, {
1469
+ sx: {
1470
+ color: '#7C3AED'
1471
+ }
1472
+ }), /*#__PURE__*/React$1.createElement(Typography, {
1473
+ sx: {
1474
+ fontSize: '14px'
1475
+ }
1476
+ }, "Loading app...")));
1477
+ }
1478
+ if (status === 'error') {
1479
+ return /*#__PURE__*/React$1.createElement(RuntimeContainer, {
1480
+ $launchMode: launchMode
1481
+ }, /*#__PURE__*/React$1.createElement(ErrorState, null, /*#__PURE__*/React$1.createElement(Typography, {
1482
+ sx: {
1483
+ fontSize: '16px',
1484
+ fontWeight: 500
1485
+ }
1486
+ }, "Failed to load app"), /*#__PURE__*/React$1.createElement(Typography, {
1487
+ sx: {
1488
+ fontSize: '13px',
1489
+ color: '#9CA3AF',
1490
+ textAlign: 'center',
1491
+ maxWidth: '400px'
1492
+ }
1493
+ }, error)));
1494
+ }
1495
+ return /*#__PURE__*/React$1.createElement(RuntimeContainer, {
1496
+ $launchMode: launchMode
1497
+ }, /*#__PURE__*/React$1.createElement("div", {
1498
+ ref: mountRef,
1499
+ style: {
1500
+ width: '100%',
1501
+ height: '100%'
1502
+ }
1503
+ }));
1504
+ };
1505
+
1506
+ var ToolbarContainer = styles.styled('div')({
1507
+ display: 'flex',
1508
+ justifyContent: 'space-between',
1509
+ alignItems: 'center',
1510
+ padding: '8px 16px',
1511
+ backgroundColor: '#1F1E26',
1512
+ borderBottom: '1px solid #6B728040',
1513
+ minHeight: '48px',
1514
+ gap: '12px'
1515
+ });
1516
+ var ActionButton = styles.styled(Button)({
1517
+ textTransform: 'none',
1518
+ fontSize: '12px',
1519
+ borderRadius: '6px',
1520
+ padding: '4px 12px',
1521
+ minWidth: 'auto'
1522
+ });
1523
+ var StudioToolbar = function StudioToolbar(_ref) {
1524
+ var appName = _ref.appName,
1525
+ isSaving = _ref.isSaving,
1526
+ isDirty = _ref.isDirty,
1527
+ buildStatus = _ref.buildStatus,
1528
+ onBack = _ref.onBack,
1529
+ onSave = _ref.onSave,
1530
+ onBuild = _ref.onBuild,
1531
+ onPublish = _ref.onPublish,
1532
+ onPreview = _ref.onPreview,
1533
+ onRun = _ref.onRun,
1534
+ onToggleProperties = _ref.onToggleProperties,
1535
+ isPropertiesOpen = _ref.isPropertiesOpen;
1536
+ return /*#__PURE__*/React$1.createElement(ToolbarContainer, null, /*#__PURE__*/React$1.createElement(Box, {
1537
+ sx: {
1538
+ display: 'flex',
1539
+ alignItems: 'center',
1540
+ gap: '12px'
1541
+ }
1542
+ }, onBack && /*#__PURE__*/React$1.createElement(IconButton, {
1543
+ size: "small",
1544
+ onClick: onBack,
1545
+ sx: {
1546
+ color: '#9CA3AF'
1547
+ }
1548
+ }, /*#__PURE__*/React$1.createElement(ArrowBackIcon, {
1549
+ fontSize: "small"
1550
+ })), /*#__PURE__*/React$1.createElement(Typography, {
1551
+ sx: {
1552
+ color: '#EAEAF0',
1553
+ fontSize: '14px',
1554
+ fontWeight: 600
1555
+ }
1556
+ }, appName || 'Untitled App'), isDirty && /*#__PURE__*/React$1.createElement(Chip, {
1557
+ label: "Unsaved",
1558
+ size: "small",
1559
+ sx: {
1560
+ backgroundColor: '#F59E0B20',
1561
+ color: '#F59E0B',
1562
+ fontSize: '10px',
1563
+ height: '20px'
1564
+ }
1565
+ }), buildStatus && /*#__PURE__*/React$1.createElement(Chip, {
1566
+ label: buildStatus,
1567
+ size: "small",
1568
+ sx: {
1569
+ backgroundColor: buildStatus === 'success' ? '#10B98120' : buildStatus === 'building' ? '#7C3AED20' : buildStatus === 'failed' ? '#EF444420' : '#6B728020',
1570
+ color: buildStatus === 'success' ? '#10B981' : buildStatus === 'building' ? '#7C3AED' : buildStatus === 'failed' ? '#EF4444' : '#6B7280',
1571
+ fontSize: '10px',
1572
+ height: '20px'
1573
+ }
1574
+ })), /*#__PURE__*/React$1.createElement(Box, {
1575
+ sx: {
1576
+ display: 'flex',
1577
+ alignItems: 'center',
1578
+ gap: '8px'
1579
+ }
1580
+ }, onToggleProperties && /*#__PURE__*/React$1.createElement(IconButton, {
1581
+ size: "small",
1582
+ onClick: onToggleProperties,
1583
+ sx: {
1584
+ color: isPropertiesOpen ? '#7C3AED' : '#6B7280'
1585
+ }
1586
+ }, /*#__PURE__*/React$1.createElement(ViewSidebarIcon, {
1587
+ fontSize: "small"
1588
+ })), onSave && /*#__PURE__*/React$1.createElement(ActionButton, {
1589
+ variant: "outlined",
1590
+ startIcon: isSaving ? /*#__PURE__*/React$1.createElement(CircularProgress, {
1591
+ size: 14,
1592
+ sx: {
1593
+ color: '#7C3AED'
1594
+ }
1595
+ }) : /*#__PURE__*/React$1.createElement(SaveIcon, {
1596
+ sx: {
1597
+ fontSize: 14
1598
+ }
1599
+ }),
1600
+ onClick: onSave,
1601
+ disabled: isSaving || !isDirty,
1602
+ sx: {
1603
+ borderColor: '#6B728040',
1604
+ color: '#EAEAF0',
1605
+ '&:hover': {
1606
+ borderColor: '#7C3AED',
1607
+ backgroundColor: '#7C3AED10'
1608
+ },
1609
+ '&.Mui-disabled': {
1610
+ borderColor: '#6B728020',
1611
+ color: '#6B7280'
1612
+ }
1613
+ }
1614
+ }, "Save"), onBuild && /*#__PURE__*/React$1.createElement(ActionButton, {
1615
+ variant: "outlined",
1616
+ startIcon: buildStatus === 'building' ? /*#__PURE__*/React$1.createElement(CircularProgress, {
1617
+ size: 14,
1618
+ sx: {
1619
+ color: '#7C3AED'
1620
+ }
1621
+ }) : /*#__PURE__*/React$1.createElement(BuildIcon, {
1622
+ sx: {
1623
+ fontSize: 14
1624
+ }
1625
+ }),
1626
+ onClick: onBuild,
1627
+ disabled: buildStatus === 'building',
1628
+ sx: {
1629
+ borderColor: '#6B728040',
1630
+ color: '#EAEAF0',
1631
+ '&:hover': {
1632
+ borderColor: '#7C3AED',
1633
+ backgroundColor: '#7C3AED10'
1634
+ },
1635
+ '&.Mui-disabled': {
1636
+ borderColor: '#6B728020',
1637
+ color: '#6B7280'
1638
+ }
1639
+ }
1640
+ }, "Build"), onPreview && /*#__PURE__*/React$1.createElement(ActionButton, {
1641
+ variant: "outlined",
1642
+ startIcon: /*#__PURE__*/React$1.createElement(VisibilityIcon, {
1643
+ sx: {
1644
+ fontSize: 14
1645
+ }
1646
+ }),
1647
+ onClick: onPreview,
1648
+ sx: {
1649
+ borderColor: '#6B728040',
1650
+ color: '#EAEAF0',
1651
+ '&:hover': {
1652
+ borderColor: '#7C3AED',
1653
+ backgroundColor: '#7C3AED10'
1654
+ }
1655
+ }
1656
+ }, "Preview"), onPublish && /*#__PURE__*/React$1.createElement(ActionButton, {
1657
+ variant: "contained",
1658
+ startIcon: /*#__PURE__*/React$1.createElement(PublishIcon, {
1659
+ sx: {
1660
+ fontSize: 14
1661
+ }
1662
+ }),
1663
+ onClick: onPublish,
1664
+ sx: {
1665
+ backgroundColor: '#7C3AED',
1666
+ '&:hover': {
1667
+ backgroundColor: '#6D28D9'
1668
+ }
1669
+ }
1670
+ }, "Publish"), onRun && /*#__PURE__*/React$1.createElement(ActionButton, {
1671
+ variant: "contained",
1672
+ startIcon: /*#__PURE__*/React$1.createElement(PlayArrowIcon, {
1673
+ sx: {
1674
+ fontSize: 14
1675
+ }
1676
+ }),
1677
+ onClick: onRun,
1678
+ sx: {
1679
+ backgroundColor: '#10B981',
1680
+ '&:hover': {
1681
+ backgroundColor: '#059669'
1682
+ }
1683
+ }
1684
+ }, "Run")));
1685
+ };
1686
+
1687
+ var PanelContainer$2 = styles.styled('div')({
1688
+ height: '100%',
1689
+ backgroundColor: '#1F1E26',
1690
+ borderRight: '1px solid #6B728040',
1691
+ display: 'flex',
1692
+ flexDirection: 'column',
1693
+ overflow: 'hidden'
1694
+ });
1695
+ var PanelHeader$2 = styles.styled('div')({
1696
+ display: 'flex',
1697
+ justifyContent: 'space-between',
1698
+ alignItems: 'center',
1699
+ padding: '8px 12px',
1700
+ borderBottom: '1px solid #6B728040',
1701
+ minHeight: '36px'
1702
+ });
1703
+ var TreeContainer = styles.styled('div')({
1704
+ flex: 1,
1705
+ overflowY: 'auto',
1706
+ padding: '4px 0'
1707
+ });
1708
+ var TreeItem = styles.styled('div')(function (_ref) {
1709
+ var $depth = _ref.$depth,
1710
+ $isActive = _ref.$isActive;
1711
+ return {
1712
+ display: 'flex',
1713
+ alignItems: 'center',
1714
+ gap: '4px',
1715
+ padding: "3px 8px 3px ".concat(8 + $depth * 16, "px"),
1716
+ cursor: 'pointer',
1717
+ fontSize: '12px',
1718
+ color: $isActive ? '#EAEAF0' : '#9CA3AF',
1719
+ backgroundColor: $isActive ? '#7C3AED20' : 'transparent',
1720
+ '&:hover': {
1721
+ backgroundColor: $isActive ? '#7C3AED20' : '#2B2A33'
1722
+ }
1723
+ };
1724
+ });
1725
+ var FileExplorer = function FileExplorer(_ref2) {
1726
+ var _ref2$fileTree = _ref2.fileTree,
1727
+ fileTree = _ref2$fileTree === void 0 ? [] : _ref2$fileTree,
1728
+ activeFilePath = _ref2.activeFilePath,
1729
+ onFileSelect = _ref2.onFileSelect,
1730
+ onCreateFile = _ref2.onCreateFile,
1731
+ onCreateFolder = _ref2.onCreateFolder;
1732
+ var _useState = React$1.useState(new Set(['/src', '/src/components', '/src/views'])),
1733
+ _useState2 = _slicedToArray(_useState, 2),
1734
+ expandedFolders = _useState2[0],
1735
+ setExpandedFolders = _useState2[1];
1736
+ var tree = React$1.useMemo(function () {
1737
+ return buildTree(fileTree);
1738
+ }, [fileTree]);
1739
+ var toggleFolder = function toggleFolder(path) {
1740
+ setExpandedFolders(function (prev) {
1741
+ var next = new Set(prev);
1742
+ if (next.has(path)) {
1743
+ next["delete"](path);
1744
+ } else {
1745
+ next.add(path);
1746
+ }
1747
+ return next;
1748
+ });
1749
+ };
1750
+ var handleItemClick = function handleItemClick(item) {
1751
+ if (item.kind === 'folder') {
1752
+ toggleFolder(item.path);
1753
+ } else if (onFileSelect) {
1754
+ onFileSelect(item);
1755
+ }
1756
+ };
1757
+ var _renderTree = function renderTree(nodes) {
1758
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1759
+ return nodes.map(function (node) {
1760
+ var _node$children;
1761
+ var isFolder = node.kind === 'folder';
1762
+ var isExpanded = expandedFolders.has(node.path);
1763
+ var isActive = node.path === activeFilePath;
1764
+ return /*#__PURE__*/React$1.createElement(React$1.Fragment, {
1765
+ key: node.path
1766
+ }, /*#__PURE__*/React$1.createElement(TreeItem, {
1767
+ $depth: depth,
1768
+ $isActive: isActive,
1769
+ onClick: function onClick() {
1770
+ return handleItemClick(node);
1771
+ }
1772
+ }, isFolder ? isExpanded ? /*#__PURE__*/React$1.createElement(ExpandMoreIcon, {
1773
+ sx: {
1774
+ fontSize: 14,
1775
+ color: '#6B7280'
1776
+ }
1777
+ }) : /*#__PURE__*/React$1.createElement(ChevronRightIcon, {
1778
+ sx: {
1779
+ fontSize: 14,
1780
+ color: '#6B7280'
1781
+ }
1782
+ }) : /*#__PURE__*/React$1.createElement("span", {
1783
+ style: {
1784
+ width: 14
1785
+ }
1786
+ }), isFolder ? isExpanded ? /*#__PURE__*/React$1.createElement(FolderOpenIcon, {
1787
+ sx: {
1788
+ fontSize: 14,
1789
+ color: '#F59E0B'
1790
+ }
1791
+ }) : /*#__PURE__*/React$1.createElement(FolderIcon, {
1792
+ sx: {
1793
+ fontSize: 14,
1794
+ color: '#F59E0B'
1795
+ }
1796
+ }) : /*#__PURE__*/React$1.createElement(InsertDriveFileIcon, {
1797
+ sx: {
1798
+ fontSize: 14,
1799
+ color: getFileColor(node.language)
1800
+ }
1801
+ }), /*#__PURE__*/React$1.createElement(Typography, {
1802
+ sx: {
1803
+ fontSize: '12px',
1804
+ color: 'inherit',
1805
+ whiteSpace: 'nowrap',
1806
+ overflow: 'hidden',
1807
+ textOverflow: 'ellipsis'
1808
+ }
1809
+ }, node.name)), isFolder && isExpanded && ((_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.length) > 0 && _renderTree(node.children, depth + 1));
1810
+ });
1811
+ };
1812
+ return /*#__PURE__*/React$1.createElement(PanelContainer$2, null, /*#__PURE__*/React$1.createElement(PanelHeader$2, null, /*#__PURE__*/React$1.createElement(Typography, {
1813
+ sx: {
1814
+ color: '#9CA3AF',
1815
+ fontSize: '11px',
1816
+ fontWeight: 600,
1817
+ textTransform: 'uppercase',
1818
+ letterSpacing: '0.5px'
1819
+ }
1820
+ }, "Explorer"), /*#__PURE__*/React$1.createElement(Box, {
1821
+ sx: {
1822
+ display: 'flex',
1823
+ gap: '2px'
1824
+ }
1825
+ }, onCreateFile && /*#__PURE__*/React$1.createElement(IconButton, {
1826
+ size: "small",
1827
+ onClick: onCreateFile,
1828
+ sx: {
1829
+ color: '#6B7280',
1830
+ padding: '2px'
1831
+ }
1832
+ }, /*#__PURE__*/React$1.createElement(NoteAddIcon, {
1833
+ sx: {
1834
+ fontSize: 16
1835
+ }
1836
+ })), onCreateFolder && /*#__PURE__*/React$1.createElement(IconButton, {
1837
+ size: "small",
1838
+ onClick: onCreateFolder,
1839
+ sx: {
1840
+ color: '#6B7280',
1841
+ padding: '2px'
1842
+ }
1843
+ }, /*#__PURE__*/React$1.createElement(CreateNewFolderIcon, {
1844
+ sx: {
1845
+ fontSize: 16
1846
+ }
1847
+ })))), /*#__PURE__*/React$1.createElement(TreeContainer, null, _renderTree(tree)));
1848
+ };
1849
+ function buildTree(files) {
1850
+ var root = [];
1851
+ var folderMap = {};
1852
+ var folders = files.filter(function (f) {
1853
+ return f.kind === 'folder';
1854
+ }).sort(function (a, b) {
1855
+ return a.path.localeCompare(b.path);
1856
+ });
1857
+ var fileItems = files.filter(function (f) {
1858
+ return f.kind !== 'folder';
1859
+ }).sort(function (a, b) {
1860
+ return a.path.localeCompare(b.path);
1861
+ });
1862
+ var _iterator = _createForOfIteratorHelper(folders),
1863
+ _step;
1864
+ try {
1865
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1866
+ var folder = _step.value;
1867
+ folderMap[folder.path] = _objectSpread2(_objectSpread2({}, folder), {}, {
1868
+ children: []
1869
+ });
1870
+ }
1871
+ } catch (err) {
1872
+ _iterator.e(err);
1873
+ } finally {
1874
+ _iterator.f();
1875
+ }
1876
+ var _iterator2 = _createForOfIteratorHelper(fileItems),
1877
+ _step2;
1878
+ try {
1879
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1880
+ var file = _step2.value;
1881
+ var parentPath = file.parent_path || '/';
1882
+ if (folderMap[parentPath]) {
1883
+ folderMap[parentPath].children.push(file);
1884
+ }
1885
+ }
1886
+ } catch (err) {
1887
+ _iterator2.e(err);
1888
+ } finally {
1889
+ _iterator2.f();
1890
+ }
1891
+ var _iterator3 = _createForOfIteratorHelper(folders),
1892
+ _step3;
1893
+ try {
1894
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1895
+ var _folder = _step3.value;
1896
+ var _parentPath = _folder.parent_path || null;
1897
+ if (_parentPath && folderMap[_parentPath]) {
1898
+ folderMap[_parentPath].children.unshift(folderMap[_folder.path]);
1899
+ } else {
1900
+ root.push(folderMap[_folder.path]);
1901
+ }
1902
+ }
1903
+ } catch (err) {
1904
+ _iterator3.e(err);
1905
+ } finally {
1906
+ _iterator3.f();
1907
+ }
1908
+ var orphanFiles = fileItems.filter(function (f) {
1909
+ return !f.parent_path || f.parent_path === '/';
1910
+ });
1911
+ root.push.apply(root, _toConsumableArray(orphanFiles));
1912
+ return root;
1913
+ }
1914
+ function getFileColor(language) {
1915
+ var colors = {
1916
+ jsx: '#61DAFB',
1917
+ js: '#F7DF1E',
1918
+ css: '#264DE4',
1919
+ json: '#6B7280',
1920
+ html: '#E34F26'
1921
+ };
1922
+ return colors[language] || '#6B7280';
1923
+ }
1924
+
1925
+ var EditorContainer = styles.styled('div')({
1926
+ height: '100%',
1927
+ display: 'flex',
1928
+ flexDirection: 'column',
1929
+ backgroundColor: '#1E1E1E',
1930
+ overflow: 'hidden'
1931
+ });
1932
+ var TabsContainer = styles.styled('div')({
1933
+ backgroundColor: '#252526',
1934
+ borderBottom: '1px solid #6B728040',
1935
+ minHeight: '35px'
1936
+ });
1937
+ var EditorWrapper = styles.styled('div')({
1938
+ flex: 1,
1939
+ overflow: 'hidden'
1940
+ });
1941
+ var EmptyEditor = styles.styled('div')({
1942
+ display: 'flex',
1943
+ alignItems: 'center',
1944
+ justifyContent: 'center',
1945
+ height: '100%',
1946
+ color: '#6B7280'
1947
+ });
1948
+ var StyledTab = styles.styled(Tab)(function (_ref) {
1949
+ var $isDirty = _ref.$isDirty;
1950
+ return {
1951
+ minHeight: '35px',
1952
+ padding: '0 12px',
1953
+ textTransform: 'none',
1954
+ fontSize: '12px',
1955
+ color: '#9CA3AF',
1956
+ '&.Mui-selected': {
1957
+ color: '#EAEAF0',
1958
+ backgroundColor: '#1E1E1E'
1959
+ },
1960
+ '& .tab-label': {
1961
+ display: 'flex',
1962
+ alignItems: 'center',
1963
+ gap: '4px'
1964
+ },
1965
+ '& .dirty-indicator': {
1966
+ display: $isDirty ? 'inline-block' : 'none',
1967
+ width: '6px',
1968
+ height: '6px',
1969
+ borderRadius: '50%',
1970
+ backgroundColor: '#EAEAF0'
1971
+ }
1972
+ };
1973
+ });
1974
+ var EditorArea = function EditorArea(_ref2) {
1975
+ var _ref2$openFiles = _ref2.openFiles,
1976
+ openFiles = _ref2$openFiles === void 0 ? [] : _ref2$openFiles,
1977
+ activeFilePath = _ref2.activeFilePath,
1978
+ onTabChange = _ref2.onTabChange,
1979
+ onTabClose = _ref2.onTabClose,
1980
+ onContentChange = _ref2.onContentChange;
1981
+ var activeFile = openFiles.find(function (f) {
1982
+ return f.path === activeFilePath;
1983
+ });
1984
+ var activeIndex = openFiles.findIndex(function (f) {
1985
+ return f.path === activeFilePath;
1986
+ });
1987
+ var handleTabChange = function handleTabChange(event, newIndex) {
1988
+ if (onTabChange && openFiles[newIndex]) {
1989
+ onTabChange(openFiles[newIndex].path);
1990
+ }
1991
+ };
1992
+ var handleTabClose = function handleTabClose(event, filePath) {
1993
+ event.stopPropagation();
1994
+ if (onTabClose) {
1995
+ onTabClose(filePath);
1996
+ }
1997
+ };
1998
+ var handleEditorChange = React$1.useCallback(function (value) {
1999
+ if (onContentChange && activeFilePath) {
2000
+ onContentChange(activeFilePath, value);
2001
+ }
2002
+ }, [onContentChange, activeFilePath]);
2003
+ var getLanguage = function getLanguage(filePath) {
2004
+ if (!filePath) return 'javascript';
2005
+ if (filePath.endsWith('.jsx') || filePath.endsWith('.tsx')) return 'javascript';
2006
+ if (filePath.endsWith('.js') || filePath.endsWith('.ts')) return 'javascript';
2007
+ if (filePath.endsWith('.css')) return 'css';
2008
+ if (filePath.endsWith('.json')) return 'json';
2009
+ if (filePath.endsWith('.html')) return 'html';
2010
+ return 'plaintext';
2011
+ };
2012
+ return /*#__PURE__*/React$1.createElement(EditorContainer, null, openFiles.length > 0 ? /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(TabsContainer, null, /*#__PURE__*/React$1.createElement(Tabs, {
2013
+ value: activeIndex >= 0 ? activeIndex : 0,
2014
+ onChange: handleTabChange,
2015
+ variant: "scrollable",
2016
+ scrollButtons: "auto",
2017
+ sx: {
2018
+ minHeight: '35px',
2019
+ '& .MuiTabs-indicator': {
2020
+ backgroundColor: '#7C3AED',
2021
+ height: '2px'
2022
+ },
2023
+ '& .MuiTabs-scrollButtons': {
2024
+ color: '#6B7280'
2025
+ }
2026
+ }
2027
+ }, openFiles.map(function (file) {
2028
+ return /*#__PURE__*/React$1.createElement(StyledTab, {
2029
+ key: file.path,
2030
+ $isDirty: file.isDirty,
2031
+ label: /*#__PURE__*/React$1.createElement("span", {
2032
+ className: "tab-label"
2033
+ }, /*#__PURE__*/React$1.createElement("span", {
2034
+ className: "dirty-indicator"
2035
+ }), file.name || file.path.split('/').pop(), /*#__PURE__*/React$1.createElement(IconButton, {
2036
+ size: "small",
2037
+ onClick: function onClick(e) {
2038
+ return handleTabClose(e, file.path);
2039
+ },
2040
+ sx: {
2041
+ color: '#6B7280',
2042
+ padding: '1px',
2043
+ ml: '4px',
2044
+ '&:hover': {
2045
+ color: '#EAEAF0'
2046
+ }
2047
+ }
2048
+ }, /*#__PURE__*/React$1.createElement(CloseIcon, {
2049
+ sx: {
2050
+ fontSize: 12
2051
+ }
2052
+ })))
2053
+ });
2054
+ }))), /*#__PURE__*/React$1.createElement(EditorWrapper, null, activeFile && /*#__PURE__*/React$1.createElement(Editor, {
2055
+ height: "100%",
2056
+ language: getLanguage(activeFile.path),
2057
+ value: activeFile.content || '',
2058
+ onChange: handleEditorChange,
2059
+ theme: "vs-dark",
2060
+ options: {
2061
+ minimap: {
2062
+ enabled: true
2063
+ },
2064
+ fontSize: 13,
2065
+ lineNumbers: 'on',
2066
+ scrollBeyondLastLine: false,
2067
+ wordWrap: 'on',
2068
+ tabSize: 2,
2069
+ automaticLayout: true,
2070
+ padding: {
2071
+ top: 8
2072
+ }
2073
+ }
2074
+ }))) : /*#__PURE__*/React$1.createElement(EmptyEditor, null, /*#__PURE__*/React$1.createElement(Box, {
2075
+ sx: {
2076
+ textAlign: 'center'
2077
+ }
2078
+ }, /*#__PURE__*/React$1.createElement(Typography, {
2079
+ sx: {
2080
+ fontSize: '14px',
2081
+ mb: 1
2082
+ }
2083
+ }, "No file open"), /*#__PURE__*/React$1.createElement(Typography, {
2084
+ sx: {
2085
+ fontSize: '12px'
2086
+ }
2087
+ }, "Select a file from the explorer to start editing"))));
2088
+ };
2089
+
2090
+ var PanelContainer$1 = styles.styled('div')(function (_ref) {
2091
+ var $isOpen = _ref.$isOpen;
2092
+ return {
2093
+ height: '100%',
2094
+ width: $isOpen ? '300px' : '0px',
2095
+ minWidth: $isOpen ? '300px' : '0px',
2096
+ backgroundColor: '#1F1E26',
2097
+ borderLeft: $isOpen ? '1px solid #6B728040' : 'none',
2098
+ display: 'flex',
2099
+ flexDirection: 'column',
2100
+ overflow: 'hidden',
2101
+ transition: 'width 0.2s, min-width 0.2s'
2102
+ };
2103
+ });
2104
+ var PanelHeader$1 = styles.styled('div')({
2105
+ display: 'flex',
2106
+ justifyContent: 'space-between',
2107
+ alignItems: 'center',
2108
+ padding: '8px 12px',
2109
+ borderBottom: '1px solid #6B728040',
2110
+ minHeight: '36px'
2111
+ });
2112
+ var PanelContent$1 = styles.styled('div')({
2113
+ flex: 1,
2114
+ overflowY: 'auto',
2115
+ padding: '12px'
2116
+ });
2117
+ var FieldGroup = styles.styled('div')({
2118
+ marginBottom: '16px'
2119
+ });
2120
+ var FieldLabel = styles.styled(Typography)({
2121
+ color: '#9CA3AF',
2122
+ fontSize: '11px',
2123
+ fontWeight: 600,
2124
+ textTransform: 'uppercase',
2125
+ letterSpacing: '0.5px',
2126
+ marginBottom: '6px'
2127
+ });
2128
+ var inputSx = {
2129
+ '& .MuiOutlinedInput-root': {
2130
+ backgroundColor: '#2B2A33',
2131
+ color: '#EAEAF0',
2132
+ fontSize: '13px',
2133
+ '& fieldset': {
2134
+ borderColor: '#6B728040'
2135
+ },
2136
+ '&:hover fieldset': {
2137
+ borderColor: '#7C3AED'
2138
+ },
2139
+ '&.Mui-focused fieldset': {
2140
+ borderColor: '#7C3AED'
2141
+ }
2142
+ }
2143
+ };
2144
+ var selectSx = {
2145
+ backgroundColor: '#2B2A33',
2146
+ color: '#EAEAF0',
2147
+ fontSize: '13px',
2148
+ '& fieldset': {
2149
+ borderColor: '#6B728040'
2150
+ },
2151
+ '&:hover fieldset': {
2152
+ borderColor: '#7C3AED'
2153
+ },
2154
+ '&.Mui-focused fieldset': {
2155
+ borderColor: '#7C3AED'
2156
+ },
2157
+ '& .MuiSelect-icon': {
2158
+ color: '#6B7280'
2159
+ }
2160
+ };
2161
+ var PropertiesPanel = function PropertiesPanel(_ref2) {
2162
+ var _appDefinition$tags, _appDefinition$manife, _appDefinition$manife2, _appDefinition$manife3, _appDefinition$manife4, _appDefinition$manife5, _appDefinition$manife6, _appDefinition$routes;
2163
+ var _ref2$isOpen = _ref2.isOpen,
2164
+ isOpen = _ref2$isOpen === void 0 ? true : _ref2$isOpen,
2165
+ onClose = _ref2.onClose,
2166
+ appDefinition = _ref2.appDefinition,
2167
+ onUpdateDefinition = _ref2.onUpdateDefinition;
2168
+ var _useState = React$1.useState(0),
2169
+ _useState2 = _slicedToArray(_useState, 2),
2170
+ activeTab = _useState2[0],
2171
+ setActiveTab = _useState2[1];
2172
+ var handleFieldChange = function handleFieldChange(field, value) {
2173
+ if (onUpdateDefinition) {
2174
+ onUpdateDefinition(_objectSpread2(_objectSpread2({}, appDefinition), {}, _defineProperty({}, field, value)));
2175
+ }
2176
+ };
2177
+ var handleManifestFieldChange = function handleManifestFieldChange(field, value) {
2178
+ if (!onUpdateDefinition) return;
2179
+ var updatedManifest = _objectSpread2(_objectSpread2({}, (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.manifest) || {}), {}, _defineProperty({}, field, value));
2180
+ if (field === 'launcher_visibility') {
2181
+ updatedManifest.launcher_visible = value === 'visible';
2182
+ }
2183
+ onUpdateDefinition(_objectSpread2(_objectSpread2({}, appDefinition), {}, {
2184
+ manifest: updatedManifest
2185
+ }));
2186
+ };
2187
+ return /*#__PURE__*/React$1.createElement(PanelContainer$1, {
2188
+ $isOpen: isOpen
2189
+ }, /*#__PURE__*/React$1.createElement(PanelHeader$1, null, /*#__PURE__*/React$1.createElement(Typography, {
2190
+ sx: {
2191
+ color: '#9CA3AF',
2192
+ fontSize: '11px',
2193
+ fontWeight: 600,
2194
+ textTransform: 'uppercase',
2195
+ letterSpacing: '0.5px'
2196
+ }
2197
+ }, "Properties"), onClose && /*#__PURE__*/React$1.createElement(IconButton, {
2198
+ size: "small",
2199
+ onClick: onClose,
2200
+ sx: {
2201
+ color: '#6B7280',
2202
+ padding: '2px'
2203
+ }
2204
+ }, /*#__PURE__*/React$1.createElement(ChevronLeftIcon, {
2205
+ sx: {
2206
+ fontSize: 16,
2207
+ transform: 'rotate(180deg)'
2208
+ }
2209
+ }))), /*#__PURE__*/React$1.createElement(Tabs, {
2210
+ value: activeTab,
2211
+ onChange: function onChange(e, v) {
2212
+ return setActiveTab(v);
2213
+ },
2214
+ variant: "fullWidth",
2215
+ sx: {
2216
+ minHeight: '32px',
2217
+ borderBottom: '1px solid #6B728040',
2218
+ '& .MuiTab-root': {
2219
+ minHeight: '32px',
2220
+ fontSize: '11px',
2221
+ textTransform: 'none',
2222
+ color: '#9CA3AF'
2223
+ },
2224
+ '& .Mui-selected': {
2225
+ color: '#EAEAF0'
2226
+ },
2227
+ '& .MuiTabs-indicator': {
2228
+ backgroundColor: '#7C3AED'
2229
+ }
2230
+ }
2231
+ }, /*#__PURE__*/React$1.createElement(Tab, {
2232
+ label: "General"
2233
+ }), /*#__PURE__*/React$1.createElement(Tab, {
2234
+ label: "Manifest"
2235
+ }), /*#__PURE__*/React$1.createElement(Tab, {
2236
+ label: "Routes"
2237
+ })), /*#__PURE__*/React$1.createElement(PanelContent$1, null, activeTab === 0 && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Name"), /*#__PURE__*/React$1.createElement(TextField, {
2238
+ fullWidth: true,
2239
+ size: "small",
2240
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.name) || '',
2241
+ onChange: function onChange(e) {
2242
+ return handleFieldChange('name', e.target.value);
2243
+ },
2244
+ sx: inputSx
2245
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Slug"), /*#__PURE__*/React$1.createElement(TextField, {
2246
+ fullWidth: true,
2247
+ size: "small",
2248
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.slug) || '',
2249
+ onChange: function onChange(e) {
2250
+ return handleFieldChange('slug', e.target.value);
2251
+ },
2252
+ sx: inputSx
2253
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Description"), /*#__PURE__*/React$1.createElement(TextField, {
2254
+ fullWidth: true,
2255
+ size: "small",
2256
+ multiline: true,
2257
+ rows: 3,
2258
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.description) || '',
2259
+ onChange: function onChange(e) {
2260
+ return handleFieldChange('description', e.target.value);
2261
+ },
2262
+ sx: inputSx
2263
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Category"), /*#__PURE__*/React$1.createElement(TextField, {
2264
+ fullWidth: true,
2265
+ size: "small",
2266
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.category) || '',
2267
+ onChange: function onChange(e) {
2268
+ return handleFieldChange('category', e.target.value);
2269
+ },
2270
+ sx: inputSx
2271
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Icon"), /*#__PURE__*/React$1.createElement(TextField, {
2272
+ fullWidth: true,
2273
+ size: "small",
2274
+ value: (appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.icon) || '',
2275
+ onChange: function onChange(e) {
2276
+ return handleFieldChange('icon', e.target.value);
2277
+ },
2278
+ sx: inputSx
2279
+ })), (appDefinition === null || appDefinition === void 0 || (_appDefinition$tags = appDefinition.tags) === null || _appDefinition$tags === void 0 ? void 0 : _appDefinition$tags.length) > 0 && /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Tags"), /*#__PURE__*/React$1.createElement(Box, {
2280
+ sx: {
2281
+ display: 'flex',
2282
+ flexWrap: 'wrap',
2283
+ gap: '4px'
2284
+ }
2285
+ }, appDefinition.tags.map(function (tag, i) {
2286
+ return /*#__PURE__*/React$1.createElement(Chip, {
2287
+ key: i,
2288
+ label: tag,
2289
+ size: "small",
2290
+ sx: {
2291
+ backgroundColor: '#7C3AED20',
2292
+ color: '#A78BFA',
2293
+ fontSize: '11px',
2294
+ height: '22px'
2295
+ }
2296
+ });
2297
+ })))), activeTab === 1 && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Kind"), /*#__PURE__*/React$1.createElement(Select, {
2298
+ fullWidth: true,
2299
+ size: "small",
2300
+ value: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife = appDefinition.manifest) === null || _appDefinition$manife === void 0 ? void 0 : _appDefinition$manife.kind) || 'workspace',
2301
+ onChange: function onChange(e) {
2302
+ return handleManifestFieldChange('kind', e.target.value);
2303
+ },
2304
+ sx: selectSx
2305
+ }, /*#__PURE__*/React$1.createElement(MenuItem, {
2306
+ value: "workspace"
2307
+ }, "Workspace"), /*#__PURE__*/React$1.createElement(MenuItem, {
2308
+ value: "utility"
2309
+ }, "Utility"))), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Launcher Visibility"), /*#__PURE__*/React$1.createElement(Select, {
2310
+ fullWidth: true,
2311
+ size: "small",
2312
+ value: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife2 = appDefinition.manifest) === null || _appDefinition$manife2 === void 0 ? void 0 : _appDefinition$manife2.launcher_visibility) || 'visible',
2313
+ onChange: function onChange(e) {
2314
+ return handleManifestFieldChange('launcher_visibility', e.target.value);
2315
+ },
2316
+ sx: selectSx
2317
+ }, /*#__PURE__*/React$1.createElement(MenuItem, {
2318
+ value: "visible"
2319
+ }, "Visible"), /*#__PURE__*/React$1.createElement(MenuItem, {
2320
+ value: "hidden"
2321
+ }, "Hidden"), /*#__PURE__*/React$1.createElement(MenuItem, {
2322
+ value: "system"
2323
+ }, "System"))), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Entry Behavior"), /*#__PURE__*/React$1.createElement(Select, {
2324
+ fullWidth: true,
2325
+ size: "small",
2326
+ value: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife3 = appDefinition.manifest) === null || _appDefinition$manife3 === void 0 ? void 0 : _appDefinition$manife3.entry_behavior) || 'home',
2327
+ onChange: function onChange(e) {
2328
+ return handleManifestFieldChange('entry_behavior', e.target.value);
2329
+ },
2330
+ sx: selectSx
2331
+ }, /*#__PURE__*/React$1.createElement(MenuItem, {
2332
+ value: "home"
2333
+ }, "Home"), /*#__PURE__*/React$1.createElement(MenuItem, {
2334
+ value: "context-required"
2335
+ }, "Context Required"), /*#__PURE__*/React$1.createElement(MenuItem, {
2336
+ value: "route-only"
2337
+ }, "Route Only"))), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Pinnable"), /*#__PURE__*/React$1.createElement(Switch, {
2338
+ checked: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife4 = appDefinition.manifest) === null || _appDefinition$manife4 === void 0 ? void 0 : _appDefinition$manife4.pinnable) !== false,
2339
+ onChange: function onChange(e) {
2340
+ return handleManifestFieldChange('pinnable', e.target.checked);
2341
+ },
2342
+ size: "small",
2343
+ sx: {
2344
+ '& .Mui-checked': {
2345
+ color: '#7C3AED'
2346
+ },
2347
+ '& .Mui-checked + .MuiSwitch-track': {
2348
+ backgroundColor: '#7C3AED'
2349
+ }
2350
+ }
2351
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Requires Context"), /*#__PURE__*/React$1.createElement(Switch, {
2352
+ checked: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife5 = appDefinition.manifest) === null || _appDefinition$manife5 === void 0 ? void 0 : _appDefinition$manife5.requires_context) || false,
2353
+ onChange: function onChange(e) {
2354
+ return handleManifestFieldChange('requires_context', e.target.checked);
2355
+ },
2356
+ size: "small",
2357
+ sx: {
2358
+ '& .Mui-checked': {
2359
+ color: '#7C3AED'
2360
+ },
2361
+ '& .Mui-checked + .MuiSwitch-track': {
2362
+ backgroundColor: '#7C3AED'
2363
+ }
2364
+ }
2365
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Entry Route"), /*#__PURE__*/React$1.createElement(TextField, {
2366
+ fullWidth: true,
2367
+ size: "small",
2368
+ value: (appDefinition === null || appDefinition === void 0 || (_appDefinition$manife6 = appDefinition.manifest) === null || _appDefinition$manife6 === void 0 ? void 0 : _appDefinition$manife6.entry_route) || '/',
2369
+ onChange: function onChange(e) {
2370
+ return handleManifestFieldChange('entry_route', e.target.value);
2371
+ },
2372
+ sx: inputSx
2373
+ })), /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Advanced (JSON)"), /*#__PURE__*/React$1.createElement(TextField, {
2374
+ fullWidth: true,
2375
+ size: "small",
2376
+ multiline: true,
2377
+ rows: 6,
2378
+ value: appDefinition !== null && appDefinition !== void 0 && appDefinition.manifest ? JSON.stringify(appDefinition.manifest, null, 2) : '{}',
2379
+ onChange: function onChange(e) {
2380
+ try {
2381
+ handleFieldChange('manifest', JSON.parse(e.target.value));
2382
+ } catch (_) {/* ignore parse errors during typing */}
2383
+ },
2384
+ sx: _objectSpread2(_objectSpread2({}, inputSx), {}, {
2385
+ '& .MuiOutlinedInput-root': _objectSpread2(_objectSpread2({}, inputSx['& .MuiOutlinedInput-root']), {}, {
2386
+ fontFamily: 'monospace',
2387
+ fontSize: '12px'
2388
+ })
2389
+ })
2390
+ }))), activeTab === 2 && /*#__PURE__*/React$1.createElement(FieldGroup, null, /*#__PURE__*/React$1.createElement(FieldLabel, null, "Routes"), (appDefinition === null || appDefinition === void 0 || (_appDefinition$routes = appDefinition.routes) === null || _appDefinition$routes === void 0 ? void 0 : _appDefinition$routes.length) > 0 ? appDefinition.routes.map(function (route, i) {
2391
+ return /*#__PURE__*/React$1.createElement(Box, {
2392
+ key: i,
2393
+ sx: {
2394
+ mb: 1,
2395
+ p: 1,
2396
+ backgroundColor: '#2B2A33',
2397
+ borderRadius: '6px'
2398
+ }
2399
+ }, /*#__PURE__*/React$1.createElement(Typography, {
2400
+ sx: {
2401
+ color: '#EAEAF0',
2402
+ fontSize: '12px',
2403
+ fontWeight: 500
2404
+ }
2405
+ }, route.path || '/'), /*#__PURE__*/React$1.createElement(Typography, {
2406
+ sx: {
2407
+ color: '#9CA3AF',
2408
+ fontSize: '11px'
2409
+ }
2410
+ }, route.name || 'Unnamed route'));
2411
+ }) : /*#__PURE__*/React$1.createElement(Typography, {
2412
+ sx: {
2413
+ color: '#6B7280',
2414
+ fontSize: '12px'
2415
+ }
2416
+ }, "No routes defined"))));
2417
+ };
2418
+
2419
+ var PanelContainer = styles.styled('div')(function (_ref) {
2420
+ var $isOpen = _ref.$isOpen,
2421
+ $height = _ref.$height;
2422
+ return {
2423
+ height: $isOpen ? "".concat($height, "px") : '35px',
2424
+ backgroundColor: '#1F1E26',
2425
+ borderTop: '1px solid #6B728040',
2426
+ display: 'flex',
2427
+ flexDirection: 'column',
2428
+ overflow: 'hidden',
2429
+ transition: 'height 0.2s'
2430
+ };
2431
+ });
2432
+ var PanelHeader = styles.styled('div')({
2433
+ display: 'flex',
2434
+ justifyContent: 'space-between',
2435
+ alignItems: 'center',
2436
+ minHeight: '35px',
2437
+ borderBottom: '1px solid #6B728040'
2438
+ });
2439
+ var PanelContent = styles.styled('div')({
2440
+ flex: 1,
2441
+ overflowY: 'auto',
2442
+ padding: '8px 12px',
2443
+ fontFamily: "'JetBrains Mono', 'Fira Code', monospace",
2444
+ fontSize: '12px',
2445
+ lineHeight: 1.6
2446
+ });
2447
+ var LogLine = styles.styled('div')(function (_ref2) {
2448
+ var $level = _ref2.$level;
2449
+ return {
2450
+ color: $level === 'error' ? '#EF4444' : $level === 'warning' ? '#F59E0B' : $level === 'success' ? '#10B981' : '#9CA3AF',
2451
+ whiteSpace: 'pre-wrap',
2452
+ wordBreak: 'break-all'
2453
+ };
2454
+ });
2455
+ var BottomPanel = function BottomPanel(_ref3) {
2456
+ var _ref3$buildLog = _ref3.buildLog,
2457
+ buildLog = _ref3$buildLog === void 0 ? '' : _ref3$buildLog,
2458
+ _ref3$buildErrors = _ref3.buildErrors,
2459
+ buildErrors = _ref3$buildErrors === void 0 ? [] : _ref3$buildErrors,
2460
+ controlledIsOpen = _ref3.isOpen,
2461
+ onToggle = _ref3.onToggle,
2462
+ _ref3$height = _ref3.height,
2463
+ height = _ref3$height === void 0 ? 200 : _ref3$height;
2464
+ var _useState = React$1.useState(false),
2465
+ _useState2 = _slicedToArray(_useState, 2),
2466
+ internalIsOpen = _useState2[0],
2467
+ setInternalIsOpen = _useState2[1];
2468
+ var _useState3 = React$1.useState(0),
2469
+ _useState4 = _slicedToArray(_useState3, 2),
2470
+ activeTab = _useState4[0],
2471
+ setActiveTab = _useState4[1];
2472
+ var isOpen = controlledIsOpen !== undefined ? controlledIsOpen : internalIsOpen;
2473
+ var handleToggle = function handleToggle() {
2474
+ if (onToggle) {
2475
+ onToggle(!isOpen);
2476
+ } else {
2477
+ setInternalIsOpen(!internalIsOpen);
2478
+ }
2479
+ };
2480
+ var logLines = buildLog ? buildLog.split('\n').filter(Boolean) : [];
2481
+ return /*#__PURE__*/React$1.createElement(PanelContainer, {
2482
+ $isOpen: isOpen,
2483
+ $height: height
2484
+ }, /*#__PURE__*/React$1.createElement(PanelHeader, null, /*#__PURE__*/React$1.createElement(Tabs, {
2485
+ value: activeTab,
2486
+ onChange: function onChange(e, v) {
2487
+ return setActiveTab(v);
2488
+ },
2489
+ sx: {
2490
+ minHeight: '35px',
2491
+ '& .MuiTab-root': {
2492
+ minHeight: '35px',
2493
+ fontSize: '11px',
2494
+ textTransform: 'none',
2495
+ color: '#9CA3AF',
2496
+ padding: '0 16px'
2497
+ },
2498
+ '& .Mui-selected': {
2499
+ color: '#EAEAF0'
2500
+ },
2501
+ '& .MuiTabs-indicator': {
2502
+ backgroundColor: '#7C3AED'
2503
+ }
2504
+ }
2505
+ }, /*#__PURE__*/React$1.createElement(Tab, {
2506
+ label: "Build Output".concat(logLines.length ? " (".concat(logLines.length, ")") : '')
2507
+ }), /*#__PURE__*/React$1.createElement(Tab, {
2508
+ label: "Problems".concat(buildErrors.length ? " (".concat(buildErrors.length, ")") : '')
2509
+ })), /*#__PURE__*/React$1.createElement(IconButton, {
2510
+ size: "small",
2511
+ onClick: handleToggle,
2512
+ sx: {
2513
+ color: '#6B7280',
2514
+ mr: 1
2515
+ }
2516
+ }, isOpen ? /*#__PURE__*/React$1.createElement(KeyboardArrowDownIcon, {
2517
+ fontSize: "small"
2518
+ }) : /*#__PURE__*/React$1.createElement(KeyboardArrowUpIcon, {
2519
+ fontSize: "small"
2520
+ }))), /*#__PURE__*/React$1.createElement(PanelContent, null, activeTab === 0 && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, logLines.length > 0 ? logLines.map(function (line, index) {
2521
+ var level = 'info';
2522
+ if (line.toLowerCase().includes('error')) level = 'error';else if (line.toLowerCase().includes('warn')) level = 'warning';else if (line.toLowerCase().includes('success') || line.toLowerCase().includes('built')) level = 'success';
2523
+ return /*#__PURE__*/React$1.createElement(LogLine, {
2524
+ key: index,
2525
+ $level: level
2526
+ }, line);
2527
+ }) : /*#__PURE__*/React$1.createElement(LogLine, {
2528
+ $level: "info"
2529
+ }, "No build output yet. Click \"Build\" to compile the app.")), activeTab === 1 && /*#__PURE__*/React$1.createElement(React$1.Fragment, null, buildErrors.length > 0 ? buildErrors.map(function (error, index) {
2530
+ return /*#__PURE__*/React$1.createElement(LogLine, {
2531
+ key: index,
2532
+ $level: "error"
2533
+ }, error);
2534
+ }) : /*#__PURE__*/React$1.createElement(LogLine, {
2535
+ $level: "success"
2536
+ }, "No problems detected."))));
2537
+ };
2538
+
2539
+ var StudioContainer = styles.styled('div')({
2540
+ height: '100%',
2541
+ display: 'flex',
2542
+ flexDirection: 'column',
2543
+ backgroundColor: '#1E1E1E',
2544
+ overflow: 'hidden'
2545
+ });
2546
+ var MainContent = styles.styled('div')({
2547
+ flex: 1,
2548
+ display: 'flex',
2549
+ overflow: 'hidden'
2550
+ });
2551
+ var FileExplorerWrapper = styles.styled('div')({
2552
+ width: '240px',
2553
+ minWidth: '240px',
2554
+ height: '100%'
2555
+ });
2556
+ var CenterArea = styles.styled('div')({
2557
+ flex: 1,
2558
+ display: 'flex',
2559
+ flexDirection: 'column',
2560
+ overflow: 'hidden'
2561
+ });
2562
+ var AppStudio = function AppStudio(_ref) {
2563
+ var appDefinitionId = _ref.appDefinitionId,
2564
+ appDefinitionService = _ref.appDefinitionService,
2565
+ appFileService = _ref.appFileService,
2566
+ appVersionService = _ref.appVersionService,
2567
+ appBuildService = _ref.appBuildService,
2568
+ onBack = _ref.onBack,
2569
+ onRun = _ref.onRun;
2570
+ _ref.onNavigateToRuntime;
2571
+ var _useState = React$1.useState(null),
2572
+ _useState2 = _slicedToArray(_useState, 2),
2573
+ appDefinition = _useState2[0],
2574
+ setAppDefinition = _useState2[1];
2575
+ var _useState3 = React$1.useState([]),
2576
+ _useState4 = _slicedToArray(_useState3, 2),
2577
+ fileTree = _useState4[0],
2578
+ setFileTree = _useState4[1];
2579
+ var _useState5 = React$1.useState([]),
2580
+ _useState6 = _slicedToArray(_useState5, 2),
2581
+ openFiles = _useState6[0],
2582
+ setOpenFiles = _useState6[1];
2583
+ var _useState7 = React$1.useState(null),
2584
+ _useState8 = _slicedToArray(_useState7, 2),
2585
+ activeFilePath = _useState8[0],
2586
+ setActiveFilePath = _useState8[1];
2587
+ var _useState9 = React$1.useState(false),
2588
+ _useState0 = _slicedToArray(_useState9, 2),
2589
+ isSaving = _useState0[0],
2590
+ setIsSaving = _useState0[1];
2591
+ var _useState1 = React$1.useState(null),
2592
+ _useState10 = _slicedToArray(_useState1, 2),
2593
+ buildStatus = _useState10[0],
2594
+ setBuildStatus = _useState10[1];
2595
+ var _useState11 = React$1.useState(''),
2596
+ _useState12 = _slicedToArray(_useState11, 2),
2597
+ buildLog = _useState12[0],
2598
+ setBuildLog = _useState12[1];
2599
+ var _useState13 = React$1.useState([]),
2600
+ _useState14 = _slicedToArray(_useState13, 2),
2601
+ buildErrors = _useState14[0],
2602
+ setBuildErrors = _useState14[1];
2603
+ var _useState15 = React$1.useState(true),
2604
+ _useState16 = _slicedToArray(_useState15, 2),
2605
+ isPropertiesOpen = _useState16[0],
2606
+ setIsPropertiesOpen = _useState16[1];
2607
+ var _useState17 = React$1.useState(false),
2608
+ _useState18 = _slicedToArray(_useState17, 2),
2609
+ isBottomPanelOpen = _useState18[0],
2610
+ setIsBottomPanelOpen = _useState18[1];
2611
+ var isDirty = openFiles.some(function (f) {
2612
+ return f.isDirty;
2613
+ });
2614
+ var definitionDirtyRef = React$1.useRef(false);
2615
+ var loadStudioPayload = React$1.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
2616
+ var response, _t;
2617
+ return _regenerator().w(function (_context) {
2618
+ while (1) switch (_context.p = _context.n) {
2619
+ case 0:
2620
+ if (!(!appDefinitionService || !appDefinitionId)) {
2621
+ _context.n = 1;
2622
+ break;
2623
+ }
2624
+ return _context.a(2);
2625
+ case 1:
2626
+ _context.p = 1;
2627
+ _context.n = 2;
2628
+ return appDefinitionService.getStudioPayload({
2629
+ id: appDefinitionId
2630
+ });
2631
+ case 2:
2632
+ response = _context.v;
2633
+ if (response !== null && response !== void 0 && response.result) {
2634
+ setAppDefinition(response.result.definition);
2635
+ setFileTree(response.result.file_tree || []);
2636
+ }
2637
+ _context.n = 4;
2638
+ break;
2639
+ case 3:
2640
+ _context.p = 3;
2641
+ _t = _context.v;
2642
+ console.error('Failed to load studio payload:', _t);
2643
+ case 4:
2644
+ return _context.a(2);
2645
+ }
2646
+ }, _callee, null, [[1, 3]]);
2647
+ })), [appDefinitionService, appDefinitionId]);
2648
+ React$1.useEffect(function () {
2649
+ loadStudioPayload();
2650
+ }, [loadStudioPayload]);
2651
+ var handleFileSelect = React$1.useCallback(/*#__PURE__*/function () {
2652
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(file) {
2653
+ var existing, content, response, _t2;
2654
+ return _regenerator().w(function (_context2) {
2655
+ while (1) switch (_context2.p = _context2.n) {
2656
+ case 0:
2657
+ if (!(file.kind === 'folder')) {
2658
+ _context2.n = 1;
2659
+ break;
2660
+ }
2661
+ return _context2.a(2);
2662
+ case 1:
2663
+ existing = openFiles.find(function (f) {
2664
+ return f.path === file.path;
2665
+ });
2666
+ if (!existing) {
2667
+ _context2.n = 2;
2668
+ break;
2669
+ }
2670
+ setActiveFilePath(file.path);
2671
+ return _context2.a(2);
2672
+ case 2:
2673
+ content = file.content;
2674
+ if (!(content === undefined || content === null)) {
2675
+ _context2.n = 6;
2676
+ break;
2677
+ }
2678
+ _context2.p = 3;
2679
+ _context2.n = 4;
2680
+ return appFileService.getFileContent({
2681
+ search: file.id
2682
+ });
2683
+ case 4:
2684
+ response = _context2.v;
2685
+ if (response !== null && response !== void 0 && response.result) {
2686
+ content = response.result.content || '';
2687
+ }
2688
+ _context2.n = 6;
2689
+ break;
2690
+ case 5:
2691
+ _context2.p = 5;
2692
+ _t2 = _context2.v;
2693
+ console.error('Failed to load file content:', _t2);
2694
+ content = '';
2695
+ case 6:
2696
+ setOpenFiles(function (prev) {
2697
+ return [].concat(_toConsumableArray(prev), [_objectSpread2(_objectSpread2({}, file), {}, {
2698
+ content: content,
2699
+ isDirty: false,
2700
+ originalContent: content
2701
+ })]);
2702
+ });
2703
+ setActiveFilePath(file.path);
2704
+ case 7:
2705
+ return _context2.a(2);
2706
+ }
2707
+ }, _callee2, null, [[3, 5]]);
2708
+ }));
2709
+ return function (_x) {
2710
+ return _ref3.apply(this, arguments);
2711
+ };
2712
+ }(), [openFiles, appFileService]);
2713
+ var handleContentChange = React$1.useCallback(function (filePath, newContent) {
2714
+ setOpenFiles(function (prev) {
2715
+ return prev.map(function (f) {
2716
+ if (f.path !== filePath) return f;
2717
+ return _objectSpread2(_objectSpread2({}, f), {}, {
2718
+ content: newContent,
2719
+ isDirty: newContent !== f.originalContent
2720
+ });
2721
+ });
2722
+ });
2723
+ }, []);
2724
+ var handleTabChange = React$1.useCallback(function (filePath) {
2725
+ setActiveFilePath(filePath);
2726
+ }, []);
2727
+ var handleTabClose = React$1.useCallback(function (filePath) {
2728
+ setOpenFiles(function (prev) {
2729
+ var next = prev.filter(function (f) {
2730
+ return f.path !== filePath;
2731
+ });
2732
+ if (filePath === activeFilePath) {
2733
+ var _next$Math$min;
2734
+ var closedIndex = prev.findIndex(function (f) {
2735
+ return f.path === filePath;
2736
+ });
2737
+ var newActive = ((_next$Math$min = next[Math.min(closedIndex, next.length - 1)]) === null || _next$Math$min === void 0 ? void 0 : _next$Math$min.path) || null;
2738
+ setActiveFilePath(newActive);
2739
+ }
2740
+ return next;
2741
+ });
2742
+ }, [activeFilePath]);
2743
+ var handleSave = React$1.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
2744
+ var dirtyFiles, changes, _t3;
2745
+ return _regenerator().w(function (_context3) {
2746
+ while (1) switch (_context3.p = _context3.n) {
2747
+ case 0:
2748
+ if (appFileService) {
2749
+ _context3.n = 1;
2750
+ break;
2751
+ }
2752
+ return _context3.a(2);
2753
+ case 1:
2754
+ setIsSaving(true);
2755
+ _context3.p = 2;
2756
+ dirtyFiles = openFiles.filter(function (f) {
2757
+ return f.isDirty;
2758
+ });
2759
+ changes = dirtyFiles.map(function (f) {
2760
+ return {
2761
+ operation: 'update',
2762
+ id: f.id,
2763
+ path: f.path,
2764
+ content: f.content
2765
+ };
2766
+ });
2767
+ if (!(changes.length > 0)) {
2768
+ _context3.n = 4;
2769
+ break;
2770
+ }
2771
+ _context3.n = 3;
2772
+ return appFileService.applyChanges({
2773
+ app_definition_id: appDefinitionId,
2774
+ changes: changes
2775
+ });
2776
+ case 3:
2777
+ setOpenFiles(function (prev) {
2778
+ return prev.map(function (f) {
2779
+ return f.isDirty ? _objectSpread2(_objectSpread2({}, f), {}, {
2780
+ isDirty: false,
2781
+ originalContent: f.content
2782
+ }) : f;
2783
+ });
2784
+ });
2785
+ case 4:
2786
+ if (!(definitionDirtyRef.current && appDefinitionService)) {
2787
+ _context3.n = 6;
2788
+ break;
2789
+ }
2790
+ _context3.n = 5;
2791
+ return appDefinitionService.update(appDefinition);
2792
+ case 5:
2793
+ definitionDirtyRef.current = false;
2794
+ case 6:
2795
+ _context3.n = 8;
2796
+ break;
2797
+ case 7:
2798
+ _context3.p = 7;
2799
+ _t3 = _context3.v;
2800
+ console.error('Failed to save:', _t3);
2801
+ case 8:
2802
+ _context3.p = 8;
2803
+ setIsSaving(false);
2804
+ return _context3.f(8);
2805
+ case 9:
2806
+ return _context3.a(2);
2807
+ }
2808
+ }, _callee3, null, [[2, 7, 8, 9]]);
2809
+ })), [openFiles, appFileService, appDefinitionId, appDefinitionService, appDefinition]);
2810
+ var handleBuild = React$1.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
2811
+ var response, _t4;
2812
+ return _regenerator().w(function (_context4) {
2813
+ while (1) switch (_context4.p = _context4.n) {
2814
+ case 0:
2815
+ if (appBuildService) {
2816
+ _context4.n = 1;
2817
+ break;
2818
+ }
2819
+ return _context4.a(2);
2820
+ case 1:
2821
+ setBuildStatus('building');
2822
+ setBuildLog('');
2823
+ setBuildErrors([]);
2824
+ setIsBottomPanelOpen(true);
2825
+ _context4.p = 2;
2826
+ _context4.n = 3;
2827
+ return appBuildService.build({
2828
+ app_definition_id: appDefinitionId,
2829
+ organization_id: appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.organization_id
2830
+ });
2831
+ case 3:
2832
+ response = _context4.v;
2833
+ if (response !== null && response !== void 0 && response.result) {
2834
+ setBuildStatus(response.result.build_status || 'success');
2835
+ setBuildLog(response.result.build_log || 'Build completed successfully');
2836
+ } else {
2837
+ setBuildStatus('failed');
2838
+ setBuildErrors([(response === null || response === void 0 ? void 0 : response.message) || 'Build failed']);
2839
+ }
2840
+ _context4.n = 5;
2841
+ break;
2842
+ case 4:
2843
+ _context4.p = 4;
2844
+ _t4 = _context4.v;
2845
+ setBuildStatus('failed');
2846
+ setBuildErrors([_t4.message || 'Build failed']);
2847
+ case 5:
2848
+ return _context4.a(2);
2849
+ }
2850
+ }, _callee4, null, [[2, 4]]);
2851
+ })), [appBuildService, appDefinitionId, appDefinition]);
2852
+ var handlePublish = React$1.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
2853
+ var response, _t5;
2854
+ return _regenerator().w(function (_context5) {
2855
+ while (1) switch (_context5.p = _context5.n) {
2856
+ case 0:
2857
+ if (appVersionService) {
2858
+ _context5.n = 1;
2859
+ break;
2860
+ }
2861
+ return _context5.a(2);
2862
+ case 1:
2863
+ _context5.p = 1;
2864
+ _context5.n = 2;
2865
+ return appVersionService.publish({
2866
+ app_definition_id: appDefinitionId
2867
+ });
2868
+ case 2:
2869
+ response = _context5.v;
2870
+ if (response !== null && response !== void 0 && response.result) {
2871
+ setBuildLog(function (prev) {
2872
+ return prev + '\nVersion published successfully: ' + (response.result.version || '');
2873
+ });
2874
+ }
2875
+ _context5.n = 4;
2876
+ break;
2877
+ case 3:
2878
+ _context5.p = 3;
2879
+ _t5 = _context5.v;
2880
+ console.error('Failed to publish:', _t5);
2881
+ case 4:
2882
+ return _context5.a(2);
2883
+ }
2884
+ }, _callee5, null, [[1, 3]]);
2885
+ })), [appVersionService, appDefinitionId]);
2886
+ var handleUpdateDefinition = React$1.useCallback(function (updated) {
2887
+ setAppDefinition(updated);
2888
+ definitionDirtyRef.current = true;
2889
+ }, []);
2890
+ return /*#__PURE__*/React$1.createElement(StudioContainer, null, /*#__PURE__*/React$1.createElement(StudioToolbar, {
2891
+ appName: appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.name,
2892
+ isSaving: isSaving,
2893
+ isDirty: isDirty || definitionDirtyRef.current,
2894
+ buildStatus: buildStatus,
2895
+ onBack: onBack,
2896
+ onSave: handleSave,
2897
+ onBuild: handleBuild,
2898
+ onPublish: handlePublish,
2899
+ onRun: onRun,
2900
+ onToggleProperties: function onToggleProperties() {
2901
+ return setIsPropertiesOpen(!isPropertiesOpen);
2902
+ },
2903
+ isPropertiesOpen: isPropertiesOpen
2904
+ }), /*#__PURE__*/React$1.createElement(MainContent, null, /*#__PURE__*/React$1.createElement(FileExplorerWrapper, null, /*#__PURE__*/React$1.createElement(FileExplorer, {
2905
+ fileTree: fileTree,
2906
+ activeFilePath: activeFilePath,
2907
+ onFileSelect: handleFileSelect
2908
+ })), /*#__PURE__*/React$1.createElement(CenterArea, null, /*#__PURE__*/React$1.createElement(Box, {
2909
+ sx: {
2910
+ flex: 1,
2911
+ overflow: 'hidden'
2912
+ }
2913
+ }, /*#__PURE__*/React$1.createElement(EditorArea, {
2914
+ openFiles: openFiles,
2915
+ activeFilePath: activeFilePath,
2916
+ onTabChange: handleTabChange,
2917
+ onTabClose: handleTabClose,
2918
+ onContentChange: handleContentChange
2919
+ })), /*#__PURE__*/React$1.createElement(BottomPanel, {
2920
+ buildLog: buildLog,
2921
+ buildErrors: buildErrors,
2922
+ isOpen: isBottomPanelOpen,
2923
+ onToggle: setIsBottomPanelOpen
2924
+ })), /*#__PURE__*/React$1.createElement(PropertiesPanel, {
2925
+ isOpen: isPropertiesOpen,
2926
+ onClose: function onClose() {
2927
+ return setIsPropertiesOpen(false);
2928
+ },
2929
+ appDefinition: appDefinition,
2930
+ onUpdateDefinition: handleUpdateDefinition
2931
+ })));
2932
+ };
2933
+
2934
+ var CardContainer = styles.styled('div')(function (_ref) {
2935
+ _ref.theme;
2936
+ return {
2937
+ backgroundColor: '#2B2A33',
2938
+ border: '1px solid #6B728040',
2939
+ borderRadius: '12px',
2940
+ padding: '20px',
2941
+ cursor: 'pointer',
2942
+ transition: 'border-color 0.2s, box-shadow 0.2s',
2943
+ display: 'flex',
2944
+ flexDirection: 'column',
2945
+ gap: '12px',
2946
+ minHeight: '160px',
2947
+ '&:hover': {
2948
+ borderColor: '#7C3AED',
2949
+ boxShadow: '0 0 0 1px #7C3AED40'
2950
+ }
2951
+ };
2952
+ });
2953
+ var AppIcon = styles.styled('div')(function (_ref2) {
2954
+ var $color = _ref2.$color;
2955
+ return {
2956
+ width: '40px',
2957
+ height: '40px',
2958
+ borderRadius: '10px',
2959
+ backgroundColor: $color || '#7C3AED20',
2960
+ display: 'flex',
2961
+ alignItems: 'center',
2962
+ justifyContent: 'center',
2963
+ fontSize: '20px'
2964
+ };
2965
+ });
2966
+ var AppCatalogCard = function AppCatalogCard(_ref3) {
2967
+ var _app$manifest;
2968
+ var app = _ref3.app,
2969
+ onOpen = _ref3.onOpen,
2970
+ onEdit = _ref3.onEdit,
2971
+ onDelete = _ref3.onDelete,
2972
+ onPin = _ref3.onPin,
2973
+ onFavorite = _ref3.onFavorite,
2974
+ preference = _ref3.preference;
2975
+ var _useState = React$1.useState(null),
2976
+ _useState2 = _slicedToArray(_useState, 2),
2977
+ anchorEl = _useState2[0],
2978
+ setAnchorEl = _useState2[1];
2979
+ var handleMenuOpen = function handleMenuOpen(event) {
2980
+ event.stopPropagation();
2981
+ setAnchorEl(event.currentTarget);
2982
+ };
2983
+ var handleMenuClose = function handleMenuClose() {
2984
+ setAnchorEl(null);
2985
+ };
2986
+ var handleOpen = function handleOpen() {
2987
+ if (onOpen) {
2988
+ onOpen(app);
2989
+ }
2990
+ };
2991
+ var handleEdit = function handleEdit() {
2992
+ handleMenuClose();
2993
+ if (onEdit) {
2994
+ onEdit(app);
2995
+ }
2996
+ };
2997
+ var handleDelete = function handleDelete() {
2998
+ handleMenuClose();
2999
+ if (onDelete) {
3000
+ onDelete(app);
3001
+ }
3002
+ };
3003
+ var isPinnable = (app === null || app === void 0 || (_app$manifest = app.manifest) === null || _app$manifest === void 0 ? void 0 : _app$manifest.pinnable) !== false;
3004
+ var handlePin = function handlePin(event) {
3005
+ event.stopPropagation();
3006
+ if (onPin && isPinnable) {
3007
+ onPin(app, !(preference !== null && preference !== void 0 && preference.is_pinned));
3008
+ }
3009
+ };
3010
+ var handleFavorite = function handleFavorite(event) {
3011
+ event.stopPropagation();
3012
+ if (onFavorite) {
3013
+ onFavorite(app, !(preference !== null && preference !== void 0 && preference.is_favorite));
3014
+ }
3015
+ };
3016
+ return /*#__PURE__*/React$1.createElement(CardContainer, {
3017
+ onClick: handleOpen
3018
+ }, /*#__PURE__*/React$1.createElement(Box, {
3019
+ sx: {
3020
+ display: 'flex',
3021
+ justifyContent: 'space-between',
3022
+ alignItems: 'flex-start'
3023
+ }
3024
+ }, /*#__PURE__*/React$1.createElement(AppIcon, {
3025
+ $color: app !== null && app !== void 0 && app.icon ? undefined : '#7C3AED20'
3026
+ }, (app === null || app === void 0 ? void 0 : app.icon) || '📱'), /*#__PURE__*/React$1.createElement(Box, {
3027
+ sx: {
3028
+ display: 'flex',
3029
+ gap: '4px'
3030
+ }
3031
+ }, onFavorite && /*#__PURE__*/React$1.createElement(IconButton, {
3032
+ size: "small",
3033
+ onClick: handleFavorite,
3034
+ sx: {
3035
+ color: preference !== null && preference !== void 0 && preference.is_favorite ? '#F59E0B' : '#6B7280'
3036
+ }
3037
+ }, /*#__PURE__*/React$1.createElement(StarIcon, {
3038
+ fontSize: "small"
3039
+ })), onPin && isPinnable && /*#__PURE__*/React$1.createElement(IconButton, {
3040
+ size: "small",
3041
+ onClick: handlePin,
3042
+ sx: {
3043
+ color: preference !== null && preference !== void 0 && preference.is_pinned ? '#7C3AED' : '#6B7280'
3044
+ }
3045
+ }, /*#__PURE__*/React$1.createElement(PushPinIcon, {
3046
+ fontSize: "small"
3047
+ })), /*#__PURE__*/React$1.createElement(IconButton, {
3048
+ size: "small",
3049
+ onClick: handleMenuOpen,
3050
+ sx: {
3051
+ color: '#6B7280'
3052
+ }
3053
+ }, /*#__PURE__*/React$1.createElement(MoreVertIcon, {
3054
+ fontSize: "small"
3055
+ })))), /*#__PURE__*/React$1.createElement(Box, {
3056
+ sx: {
3057
+ flex: 1
3058
+ }
3059
+ }, /*#__PURE__*/React$1.createElement(Typography, {
3060
+ sx: {
3061
+ color: '#EAEAF0',
3062
+ fontWeight: 600,
3063
+ fontSize: '14px',
3064
+ mb: '4px'
3065
+ }
3066
+ }, (app === null || app === void 0 ? void 0 : app.name) || 'Untitled App'), /*#__PURE__*/React$1.createElement(Typography, {
3067
+ sx: {
3068
+ color: '#9CA3AF',
3069
+ fontSize: '12px',
3070
+ lineHeight: 1.4,
3071
+ display: '-webkit-box',
3072
+ WebkitLineClamp: 2,
3073
+ WebkitBoxOrient: 'vertical',
3074
+ overflow: 'hidden'
3075
+ }
3076
+ }, (app === null || app === void 0 ? void 0 : app.description) || 'No description')), (app === null || app === void 0 ? void 0 : app.category) && /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Chip, {
3077
+ label: app.category,
3078
+ size: "small",
3079
+ sx: {
3080
+ backgroundColor: '#7C3AED20',
3081
+ color: '#A78BFA',
3082
+ fontSize: '11px',
3083
+ height: '22px'
3084
+ }
3085
+ })), /*#__PURE__*/React$1.createElement(Menu, {
3086
+ anchorEl: anchorEl,
3087
+ open: Boolean(anchorEl),
3088
+ onClose: handleMenuClose
3089
+ }, /*#__PURE__*/React$1.createElement(MenuItem, {
3090
+ onClick: handleOpen
3091
+ }, "Open"), /*#__PURE__*/React$1.createElement(MenuItem, {
3092
+ onClick: handleEdit
3093
+ }, "Edit in Studio"), /*#__PURE__*/React$1.createElement(MenuItem, {
3094
+ onClick: handleDelete,
3095
+ sx: {
3096
+ color: '#EF4444'
3097
+ }
3098
+ }, "Delete")));
3099
+ };
3100
+
3101
+ var GridContainer = styles.styled('div')({
3102
+ display: 'grid',
3103
+ gridTemplateColumns: 'repeat(auto-fill, minmax(260px, 1fr))',
3104
+ gap: '16px'
3105
+ });
3106
+ var EmptyState = styles.styled('div')({
3107
+ display: 'flex',
3108
+ flexDirection: 'column',
3109
+ alignItems: 'center',
3110
+ justifyContent: 'center',
3111
+ padding: '64px 24px',
3112
+ color: '#9CA3AF',
3113
+ gap: '16px'
3114
+ });
3115
+ var AppCatalogGrid = function AppCatalogGrid(_ref) {
3116
+ var appDefinitionService = _ref.appDefinitionService,
3117
+ appPreferenceService = _ref.appPreferenceService,
3118
+ onOpenApp = _ref.onOpenApp,
3119
+ onEditApp = _ref.onEditApp,
3120
+ onCreateApp = _ref.onCreateApp,
3121
+ onDeleteApp = _ref.onDeleteApp,
3122
+ onPinApp = _ref.onPinApp,
3123
+ onFavoriteApp = _ref.onFavoriteApp,
3124
+ onPreferencesLoaded = _ref.onPreferencesLoaded,
3125
+ organizationId = _ref.organizationId;
3126
+ var _useState = React$1.useState([]),
3127
+ _useState2 = _slicedToArray(_useState, 2),
3128
+ apps = _useState2[0],
3129
+ setApps = _useState2[1];
3130
+ var _useState3 = React$1.useState({}),
3131
+ _useState4 = _slicedToArray(_useState3, 2),
3132
+ preferences = _useState4[0],
3133
+ setPreferences = _useState4[1];
3134
+ var _useState5 = React$1.useState(''),
3135
+ _useState6 = _slicedToArray(_useState5, 2),
3136
+ searchQuery = _useState6[0],
3137
+ setSearchQuery = _useState6[1];
3138
+ var _useState7 = React$1.useState('all'),
3139
+ _useState8 = _slicedToArray(_useState7, 2),
3140
+ kindFilter = _useState8[0],
3141
+ setKindFilter = _useState8[1];
3142
+ var _useState9 = React$1.useState(true),
3143
+ _useState0 = _slicedToArray(_useState9, 2),
3144
+ isLoading = _useState0[0],
3145
+ setIsLoading = _useState0[1];
3146
+ var loadApps = React$1.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
3147
+ var _response$result, queryParams, response, _t;
3148
+ return _regenerator().w(function (_context) {
3149
+ while (1) switch (_context.p = _context.n) {
3150
+ case 0:
3151
+ if (appDefinitionService) {
3152
+ _context.n = 1;
3153
+ break;
3154
+ }
3155
+ return _context.a(2);
3156
+ case 1:
3157
+ setIsLoading(true);
3158
+ _context.p = 2;
3159
+ queryParams = {
3160
+ queryselector: 'all',
3161
+ exclude_status: 'deleted'
3162
+ };
3163
+ if (organizationId) {
3164
+ queryParams.queryselector = 'organization-id';
3165
+ queryParams.search = organizationId;
3166
+ }
3167
+ _context.n = 3;
3168
+ return appDefinitionService.get(queryParams);
3169
+ case 3:
3170
+ response = _context.v;
3171
+ if (response !== null && response !== void 0 && (_response$result = response.result) !== null && _response$result !== void 0 && _response$result.items) {
3172
+ setApps(response.result.items);
3173
+ }
3174
+ _context.n = 5;
3175
+ break;
3176
+ case 4:
3177
+ _context.p = 4;
3178
+ _t = _context.v;
3179
+ console.error('Failed to load apps:', _t);
3180
+ case 5:
3181
+ _context.p = 5;
3182
+ setIsLoading(false);
3183
+ return _context.f(5);
3184
+ case 6:
3185
+ return _context.a(2);
3186
+ }
3187
+ }, _callee, null, [[2, 4, 5, 6]]);
3188
+ })), [appDefinitionService, organizationId]);
3189
+ var loadPreferences = React$1.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
3190
+ var _response$result2, response, prefsMap, _iterator, _step, pref, _t2;
3191
+ return _regenerator().w(function (_context2) {
3192
+ while (1) switch (_context2.p = _context2.n) {
3193
+ case 0:
3194
+ if (appPreferenceService) {
3195
+ _context2.n = 1;
3196
+ break;
3197
+ }
3198
+ return _context2.a(2);
3199
+ case 1:
3200
+ _context2.p = 1;
3201
+ _context2.n = 2;
3202
+ return appPreferenceService.get({
3203
+ queryselector: 'all',
3204
+ exclude_status: 'deleted'
3205
+ });
3206
+ case 2:
3207
+ response = _context2.v;
3208
+ if (response !== null && response !== void 0 && (_response$result2 = response.result) !== null && _response$result2 !== void 0 && _response$result2.items) {
3209
+ prefsMap = {};
3210
+ _iterator = _createForOfIteratorHelper(response.result.items);
3211
+ try {
3212
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
3213
+ pref = _step.value;
3214
+ prefsMap[pref.app_definition_id] = pref;
3215
+ }
3216
+ } catch (err) {
3217
+ _iterator.e(err);
3218
+ } finally {
3219
+ _iterator.f();
3220
+ }
3221
+ setPreferences(prefsMap);
3222
+ if (onPreferencesLoaded) {
3223
+ onPreferencesLoaded(prefsMap);
3224
+ }
3225
+ }
3226
+ _context2.n = 4;
3227
+ break;
3228
+ case 3:
3229
+ _context2.p = 3;
3230
+ _t2 = _context2.v;
3231
+ console.error('Failed to load preferences:', _t2);
3232
+ case 4:
3233
+ return _context2.a(2);
3234
+ }
3235
+ }, _callee2, null, [[1, 3]]);
3236
+ })), [appPreferenceService, onPreferencesLoaded]);
3237
+ React$1.useEffect(function () {
3238
+ loadApps();
3239
+ loadPreferences();
3240
+ }, [loadApps, loadPreferences]);
3241
+ var filteredApps = apps.filter(function (app) {
3242
+ var _app$manifest, _app$manifest2, _app$name, _app$description, _app$category, _app$slug;
3243
+ var appKind = ((_app$manifest = app.manifest) === null || _app$manifest === void 0 ? void 0 : _app$manifest.kind) || 'workspace';
3244
+ var launcherVisibility = ((_app$manifest2 = app.manifest) === null || _app$manifest2 === void 0 ? void 0 : _app$manifest2.launcher_visibility) || 'visible';
3245
+ if (kindFilter === 'workspace' && appKind !== 'workspace') return false;
3246
+ if (kindFilter === 'utility' && appKind !== 'utility') return false;
3247
+ if (kindFilter === 'all' && launcherVisibility === 'system') return false;
3248
+ if (!searchQuery) return true;
3249
+ var query = searchQuery.toLowerCase();
3250
+ return ((_app$name = app.name) === null || _app$name === void 0 ? void 0 : _app$name.toLowerCase().includes(query)) || ((_app$description = app.description) === null || _app$description === void 0 ? void 0 : _app$description.toLowerCase().includes(query)) || ((_app$category = app.category) === null || _app$category === void 0 ? void 0 : _app$category.toLowerCase().includes(query)) || ((_app$slug = app.slug) === null || _app$slug === void 0 ? void 0 : _app$slug.toLowerCase().includes(query));
3251
+ });
3252
+ var handleCreateApp = /*#__PURE__*/function () {
3253
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
3254
+ return _regenerator().w(function (_context3) {
3255
+ while (1) switch (_context3.n) {
3256
+ case 0:
3257
+ if (!onCreateApp) {
3258
+ _context3.n = 2;
3259
+ break;
3260
+ }
3261
+ _context3.n = 1;
3262
+ return onCreateApp();
3263
+ case 1:
3264
+ loadApps();
3265
+ case 2:
3266
+ return _context3.a(2);
3267
+ }
3268
+ }, _callee3);
3269
+ }));
3270
+ return function handleCreateApp() {
3271
+ return _ref4.apply(this, arguments);
3272
+ };
3273
+ }();
3274
+ var handleDeleteApp = /*#__PURE__*/function () {
3275
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(app) {
3276
+ return _regenerator().w(function (_context4) {
3277
+ while (1) switch (_context4.n) {
3278
+ case 0:
3279
+ if (!onDeleteApp) {
3280
+ _context4.n = 2;
3281
+ break;
3282
+ }
3283
+ _context4.n = 1;
3284
+ return onDeleteApp(app);
3285
+ case 1:
3286
+ loadApps();
3287
+ case 2:
3288
+ return _context4.a(2);
3289
+ }
3290
+ }, _callee4);
3291
+ }));
3292
+ return function handleDeleteApp(_x) {
3293
+ return _ref5.apply(this, arguments);
3294
+ };
3295
+ }();
3296
+ var handlePinApp = /*#__PURE__*/function () {
3297
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(app, isPinned) {
3298
+ return _regenerator().w(function (_context5) {
3299
+ while (1) switch (_context5.n) {
3300
+ case 0:
3301
+ if (!onPinApp) {
3302
+ _context5.n = 2;
3303
+ break;
3304
+ }
3305
+ _context5.n = 1;
3306
+ return onPinApp(app, isPinned);
3307
+ case 1:
3308
+ loadPreferences();
3309
+ case 2:
3310
+ return _context5.a(2);
3311
+ }
3312
+ }, _callee5);
3313
+ }));
3314
+ return function handlePinApp(_x2, _x3) {
3315
+ return _ref6.apply(this, arguments);
3316
+ };
3317
+ }();
3318
+ var handleFavoriteApp = /*#__PURE__*/function () {
3319
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(app, isFavorite) {
3320
+ return _regenerator().w(function (_context6) {
3321
+ while (1) switch (_context6.n) {
3322
+ case 0:
3323
+ if (!onFavoriteApp) {
3324
+ _context6.n = 2;
3325
+ break;
3326
+ }
3327
+ _context6.n = 1;
3328
+ return onFavoriteApp(app, isFavorite);
3329
+ case 1:
3330
+ loadPreferences();
3331
+ case 2:
3332
+ return _context6.a(2);
3333
+ }
3334
+ }, _callee6);
3335
+ }));
3336
+ return function handleFavoriteApp(_x4, _x5) {
3337
+ return _ref7.apply(this, arguments);
3338
+ };
3339
+ }();
3340
+ return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Tabs, {
3341
+ value: kindFilter,
3342
+ onChange: function onChange(e, value) {
3343
+ return setKindFilter(value);
3344
+ },
3345
+ sx: {
3346
+ mb: 2,
3347
+ minHeight: '36px',
3348
+ '& .MuiTab-root': {
3349
+ minHeight: '36px',
3350
+ textTransform: 'none',
3351
+ color: '#9CA3AF',
3352
+ fontSize: '13px',
3353
+ '&.Mui-selected': {
3354
+ color: '#A78BFA'
3355
+ }
3356
+ },
3357
+ '& .MuiTabs-indicator': {
3358
+ backgroundColor: '#7C3AED'
3359
+ }
3360
+ }
3361
+ }, /*#__PURE__*/React$1.createElement(Tab, {
3362
+ label: "All Apps",
3363
+ value: "all"
3364
+ }), /*#__PURE__*/React$1.createElement(Tab, {
3365
+ label: "Workspaces",
3366
+ value: "workspace"
3367
+ }), /*#__PURE__*/React$1.createElement(Tab, {
3368
+ label: "Utilities",
3369
+ value: "utility"
3370
+ })), /*#__PURE__*/React$1.createElement(Box, {
3371
+ sx: {
3372
+ display: 'flex',
3373
+ justifyContent: 'space-between',
3374
+ alignItems: 'center',
3375
+ mb: 3
3376
+ }
3377
+ }, /*#__PURE__*/React$1.createElement(TextField, {
3378
+ placeholder: "Search apps...",
3379
+ size: "small",
3380
+ value: searchQuery,
3381
+ onChange: function onChange(e) {
3382
+ return setSearchQuery(e.target.value);
3383
+ },
3384
+ InputProps: {
3385
+ startAdornment: /*#__PURE__*/React$1.createElement(InputAdornment, {
3386
+ position: "start"
3387
+ }, /*#__PURE__*/React$1.createElement(SearchIcon, {
3388
+ sx: {
3389
+ color: '#6B7280'
3390
+ }
3391
+ }))
3392
+ },
3393
+ sx: {
3394
+ width: '320px',
3395
+ '& .MuiOutlinedInput-root': {
3396
+ backgroundColor: '#1F1E26',
3397
+ color: '#EAEAF0',
3398
+ borderRadius: '8px',
3399
+ '& fieldset': {
3400
+ borderColor: '#6B728040'
3401
+ },
3402
+ '&:hover fieldset': {
3403
+ borderColor: '#7C3AED'
3404
+ },
3405
+ '&.Mui-focused fieldset': {
3406
+ borderColor: '#7C3AED'
3407
+ }
3408
+ }
3409
+ }
3410
+ }), onCreateApp && /*#__PURE__*/React$1.createElement(Button, {
3411
+ variant: "contained",
3412
+ startIcon: /*#__PURE__*/React$1.createElement(AddIcon, null),
3413
+ onClick: handleCreateApp,
3414
+ sx: {
3415
+ backgroundColor: '#7C3AED',
3416
+ '&:hover': {
3417
+ backgroundColor: '#6D28D9'
3418
+ },
3419
+ textTransform: 'none',
3420
+ borderRadius: '8px'
3421
+ }
3422
+ }, "New App")), isLoading ? /*#__PURE__*/React$1.createElement(Box, {
3423
+ sx: {
3424
+ display: 'flex',
3425
+ justifyContent: 'center',
3426
+ py: 8
3427
+ }
3428
+ }, /*#__PURE__*/React$1.createElement(CircularProgress, {
3429
+ sx: {
3430
+ color: '#7C3AED'
3431
+ }
3432
+ })) : filteredApps.length === 0 ? /*#__PURE__*/React$1.createElement(EmptyState, null, /*#__PURE__*/React$1.createElement(Typography, {
3433
+ sx: {
3434
+ fontSize: '16px',
3435
+ fontWeight: 500
3436
+ }
3437
+ }, searchQuery ? 'No apps match your search' : 'No apps yet'), /*#__PURE__*/React$1.createElement(Typography, {
3438
+ sx: {
3439
+ fontSize: '13px'
3440
+ }
3441
+ }, searchQuery ? 'Try a different search term' : 'Create your first app to get started'), !searchQuery && onCreateApp && /*#__PURE__*/React$1.createElement(Button, {
3442
+ variant: "outlined",
3443
+ startIcon: /*#__PURE__*/React$1.createElement(AddIcon, null),
3444
+ onClick: handleCreateApp,
3445
+ sx: {
3446
+ borderColor: '#7C3AED',
3447
+ color: '#7C3AED',
3448
+ '&:hover': {
3449
+ borderColor: '#6D28D9',
3450
+ backgroundColor: '#7C3AED10'
3451
+ },
3452
+ textTransform: 'none',
3453
+ mt: 1
3454
+ }
3455
+ }, "Create App")) : /*#__PURE__*/React$1.createElement(GridContainer, null, filteredApps.map(function (app) {
3456
+ return /*#__PURE__*/React$1.createElement(AppCatalogCard, {
3457
+ key: app.id,
3458
+ app: app,
3459
+ preference: preferences[app.id],
3460
+ onOpen: onOpenApp,
3461
+ onEdit: onEditApp,
3462
+ onDelete: handleDeleteApp,
3463
+ onPin: onPinApp ? handlePinApp : undefined,
3464
+ onFavorite: onFavoriteApp ? handleFavoriteApp : undefined
3465
+ });
3466
+ })));
3467
+ };
3468
+
3469
+ var BaseApi = /*#__PURE__*/function () {
3470
+ function BaseApi() {
3471
+ _classCallCheck(this, BaseApi);
3472
+ this.api_key = null;
3473
+ this.client = null;
3474
+ this.serviceEndpoints = {
3475
+ baseUrlProduction: process.env.VERIPASS_PRODUCTION_SERVICE_URL,
3476
+ baseUrlDevelopment: process.env.VERIPASS_DEVELOPMENT_SERVICE_URL,
3477
+ baseUrlLocal: process.env.VERIPASS_LOCAL_SERVICE_URL,
3478
+ get: '',
3479
+ create: '',
3480
+ update: '',
3481
+ "delete": '',
3482
+ patch: '',
3483
+ put: ''
3484
+ };
3485
+ this.settings = {};
3486
+ }
3487
+
3488
+ /**
3489
+ * Initializes and returns an Axios client instance with the necessary headers and configurations.
3490
+ *
3491
+ * @returns {Object} Axios client instance.
3492
+ */
3493
+ return _createClass(BaseApi, [{
3494
+ key: "request",
3495
+ value: function request() {
3496
+ var headers = {
3497
+ Accept: 'application/json'
3498
+ };
3499
+ if (this.api_key) {
3500
+ headers['api-key'] = this.api_key;
3501
+ }
3502
+ this.client = axios.create({
3503
+ baseURL: this.api_url,
3504
+ timeout: 31000,
3505
+ headers: headers
3506
+ });
3507
+ return this.client;
3508
+ }
3509
+ }, {
3510
+ key: "urlBuilder",
3511
+ value: function urlBuilder(_ref) {
3512
+ var _this$settings;
3513
+ var endpoint = _ref.endpoint;
3514
+ var environment = ((_this$settings = this.settings) === null || _this$settings === void 0 ? void 0 : _this$settings.environment) || 'production';
3515
+ var baseUrl = '';
3516
+ switch (environment) {
3517
+ case 'local':
3518
+ baseUrl = this.serviceEndpoints.baseUrlLocal;
3519
+ break;
3520
+ case 'development':
3521
+ baseUrl = this.serviceEndpoints.baseUrlDevelopment;
3522
+ break;
3523
+ case 'production':
3524
+ default:
3525
+ baseUrl = this.serviceEndpoints.baseUrlProduction;
3526
+ break;
3527
+ }
3528
+ return "".concat(baseUrl).concat(endpoint);
3529
+ }
3530
+
3531
+ /**
3532
+ * Serializes a nested object into a query string format.
3533
+ *
3534
+ * @param {Object} obj The object to be serialized.
3535
+ * @param {string} [prefix] Prefix for nested properties in the object.
3536
+ * @returns {string} Serialized query string.
3537
+ */
3538
+ }, {
3539
+ key: "serializerOjectToQueryString",
3540
+ value: function serializerOjectToQueryString(obj, prefix) {
3541
+ if (obj && _typeof(obj) === 'object') {
3542
+ var serializedArr = [];
3543
+ var key = {};
3544
+ for (key in obj) {
3545
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
3546
+ var k = prefix ? prefix + '[' + key + ']' : key;
3547
+ var value = obj[key] || null;
3548
+ serializedArr.push(value !== null && _typeof(value) === 'object' ? this.serializerOjectToQueryString(value, k) : encodeURIComponent(k) + '=' + encodeURIComponent(value));
3549
+ }
3550
+ }
3551
+ return serializedArr.join('&');
3552
+ }
3553
+ }
3554
+
3555
+ /**
3556
+ * Converts an object into a query string format.
3557
+ *
3558
+ * @param {Object} obj The object to be converted.
3559
+ * @returns {string} Query string starting with '?' or an empty string if the object is not valid.
3560
+ */
3561
+ }, {
3562
+ key: "objectToQueryString",
3563
+ value: function objectToQueryString(obj) {
3564
+ if (obj && _typeof(obj) === 'object') {
3565
+ var result = this.serializerOjectToQueryString(obj);
3566
+ return "?".concat(result);
3567
+ } else {
3568
+ return '';
3569
+ }
3570
+ }
3571
+
3572
+ /**
3573
+ * Execute a query to filter by parameters
3574
+ * @param {Object} payload Provides all information to get an entity by parameters
3575
+ * @param {string} payload.queryselector Is the selector of filter
3576
+ * @param {*} settings Configuration settings for the request
3577
+ * @returns an object to be processed
3578
+ */
3579
+ }, {
3580
+ key: "getByParameters",
3581
+ value: (function () {
3582
+ var _getByParameters = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload, settings) {
3583
+ var parameters, endpoint, url, result, _t;
3584
+ return _regenerator().w(function (_context) {
3585
+ while (1) switch (_context.p = _context.n) {
3586
+ case 0:
3587
+ _context.p = 0;
3588
+ if (payload) {
3589
+ _context.n = 1;
3590
+ break;
3591
+ }
3592
+ return _context.a(2, null);
3593
+ case 1:
3594
+ if (payload.queryselector) {
3595
+ _context.n = 2;
3596
+ break;
3597
+ }
3598
+ console.error('Provide a query selector to query');
3599
+ return _context.a(2, null);
3600
+ case 2:
3601
+ parameters = this.objectToQueryString(payload);
3602
+ endpoint = this.urlBuilder({
3603
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.get
3604
+ });
3605
+ url = "".concat(endpoint).concat(payload.queryselector).concat(parameters);
3606
+ _context.n = 3;
3607
+ return this.request().get(url);
3608
+ case 3:
3609
+ result = _context.v;
3610
+ return _context.a(2, result.data);
3611
+ case 4:
3612
+ _context.p = 4;
3613
+ _t = _context.v;
3614
+ console.error(_t);
3615
+ return _context.a(2, _t === null || _t === void 0 ? void 0 : _t.body);
3616
+ }
3617
+ }, _callee, this, [[0, 4]]);
3618
+ }));
3619
+ function getByParameters(_x, _x2) {
3620
+ return _getByParameters.apply(this, arguments);
3621
+ }
3622
+ return getByParameters;
3623
+ }()
3624
+ /**
3625
+ * Execute a create query into backend service
3626
+ * @param {*} payload
3627
+ * @param {*} settings Configuration settings for the request
3628
+ * @returns
3629
+ */
3630
+ )
3631
+ }, {
3632
+ key: "create",
3633
+ value: (function () {
3634
+ var _create = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload, settings) {
3635
+ var endpoint, result, _error$response, _t2;
3636
+ return _regenerator().w(function (_context2) {
3637
+ while (1) switch (_context2.p = _context2.n) {
3638
+ case 0:
3639
+ _context2.p = 0;
3640
+ if (payload) {
3641
+ _context2.n = 1;
3642
+ break;
3643
+ }
3644
+ return _context2.a(2, null);
3645
+ case 1:
3646
+ endpoint = this.urlBuilder({
3647
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.create
3648
+ });
3649
+ _context2.n = 2;
3650
+ return this.request().post(endpoint, payload);
3651
+ case 2:
3652
+ result = _context2.v;
3653
+ return _context2.a(2, result.data);
3654
+ case 3:
3655
+ _context2.p = 3;
3656
+ _t2 = _context2.v;
3657
+ console.error(_t2);
3658
+ return _context2.a(2, (_t2 === null || _t2 === void 0 || (_error$response = _t2.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || null);
3659
+ }
3660
+ }, _callee2, this, [[0, 3]]);
3661
+ }));
3662
+ function create(_x3, _x4) {
3663
+ return _create.apply(this, arguments);
3664
+ }
3665
+ return create;
3666
+ }()
3667
+ /**
3668
+ * Execute an update query into backend service
3669
+ * @param {*} payload
3670
+ * @param {*} settings Configuration settings for the request
3671
+ * @returns
3672
+ */
3673
+ )
3674
+ }, {
3675
+ key: "update",
3676
+ value: (function () {
3677
+ var _update = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload, settings) {
3678
+ var endpoint, result, _t3;
3679
+ return _regenerator().w(function (_context3) {
3680
+ while (1) switch (_context3.p = _context3.n) {
3681
+ case 0:
3682
+ _context3.p = 0;
3683
+ if (payload) {
3684
+ _context3.n = 1;
3685
+ break;
3686
+ }
3687
+ return _context3.a(2, null);
3688
+ case 1:
3689
+ endpoint = this.urlBuilder({
3690
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.update
3691
+ });
3692
+ _context3.n = 2;
3693
+ return this.request().patch(endpoint, payload);
3694
+ case 2:
3695
+ result = _context3.v;
3696
+ return _context3.a(2, result.data);
3697
+ case 3:
3698
+ _context3.p = 3;
3699
+ _t3 = _context3.v;
3700
+ console.error(_t3);
3701
+ return _context3.a(2, _t3 === null || _t3 === void 0 ? void 0 : _t3.body);
3702
+ }
3703
+ }, _callee3, this, [[0, 3]]);
3704
+ }));
3705
+ function update(_x5, _x6) {
3706
+ return _update.apply(this, arguments);
3707
+ }
3708
+ return update;
3709
+ }()
3710
+ /**
3711
+ * Execute a delete query into backend service
3712
+ * @param {*} payload
3713
+ * @param {*} settings Configuration settings for the request
3714
+ * @returns
3715
+ */
3716
+ )
3717
+ }, {
3718
+ key: "delete",
3719
+ value: (function () {
3720
+ var _delete2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(payload, settings) {
3721
+ var endpoint, result, _t4;
3722
+ return _regenerator().w(function (_context4) {
3723
+ while (1) switch (_context4.p = _context4.n) {
3724
+ case 0:
3725
+ _context4.p = 0;
3726
+ if (payload) {
3727
+ _context4.n = 1;
3728
+ break;
3729
+ }
3730
+ return _context4.a(2, null);
3731
+ case 1:
3732
+ endpoint = this.urlBuilder({
3733
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints["delete"]
3734
+ });
3735
+ _context4.n = 2;
3736
+ return this.request()["delete"](endpoint, {
3737
+ data: payload
3738
+ });
3739
+ case 2:
3740
+ result = _context4.v;
3741
+ return _context4.a(2, result.data);
3742
+ case 3:
3743
+ _context4.p = 3;
3744
+ _t4 = _context4.v;
3745
+ console.error(_t4);
3746
+ return _context4.a(2, _t4 === null || _t4 === void 0 ? void 0 : _t4.body);
3747
+ }
3748
+ }, _callee4, this, [[0, 3]]);
3749
+ }));
3750
+ function _delete(_x7, _x8) {
3751
+ return _delete2.apply(this, arguments);
3752
+ }
3753
+ return _delete;
3754
+ }()
3755
+ /**
3756
+ * Execute a post query
3757
+ * @param {*} payload Define what data need to be posted
3758
+ * @param {*} settings Configuration settings for the request
3759
+ * @returns
3760
+ */
3761
+ )
3762
+ }, {
3763
+ key: "post",
3764
+ value: (function () {
3765
+ var _post = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(payload, settings) {
3766
+ var endpoint, result, _error$response2, _t5;
3767
+ return _regenerator().w(function (_context5) {
3768
+ while (1) switch (_context5.p = _context5.n) {
3769
+ case 0:
3770
+ _context5.p = 0;
3771
+ if (payload) {
3772
+ _context5.n = 1;
3773
+ break;
3774
+ }
3775
+ return _context5.a(2, null);
3776
+ case 1:
3777
+ endpoint = this.urlBuilder({
3778
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.post
3779
+ });
3780
+ _context5.n = 2;
3781
+ return this.request().post(endpoint, payload);
3782
+ case 2:
3783
+ result = _context5.v;
3784
+ return _context5.a(2, result.data);
3785
+ case 3:
3786
+ _context5.p = 3;
3787
+ _t5 = _context5.v;
3788
+ console.error(_t5);
3789
+ return _context5.a(2, _t5 === null || _t5 === void 0 || (_error$response2 = _t5.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
3790
+ }
3791
+ }, _callee5, this, [[0, 3]]);
3792
+ }));
3793
+ function post(_x9, _x0) {
3794
+ return _post.apply(this, arguments);
3795
+ }
3796
+ return post;
3797
+ }()
3798
+ /**
3799
+ * Execute a put query
3800
+ * @param {*} payload Define what data need to be posted
3801
+ * @param {*} settings Configuration settings for the request
3802
+ * @returns
3803
+ */
3804
+ )
3805
+ }, {
3806
+ key: "put",
3807
+ value: (function () {
3808
+ var _put = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(payload, settings) {
3809
+ var endpoint, result, _error$response3, _t6;
3810
+ return _regenerator().w(function (_context6) {
3811
+ while (1) switch (_context6.p = _context6.n) {
3812
+ case 0:
3813
+ _context6.p = 0;
3814
+ if (payload) {
3815
+ _context6.n = 1;
3816
+ break;
3817
+ }
3818
+ return _context6.a(2, null);
3819
+ case 1:
3820
+ endpoint = this.urlBuilder({
3821
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.put
3822
+ });
3823
+ _context6.n = 2;
3824
+ return this.request().put(endpoint, payload);
3825
+ case 2:
3826
+ result = _context6.v;
3827
+ return _context6.a(2, result.data);
3828
+ case 3:
3829
+ _context6.p = 3;
3830
+ _t6 = _context6.v;
3831
+ console.error(_t6);
3832
+ return _context6.a(2, _t6 === null || _t6 === void 0 || (_error$response3 = _t6.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data);
3833
+ }
3834
+ }, _callee6, this, [[0, 3]]);
3835
+ }));
3836
+ function put(_x1, _x10) {
3837
+ return _put.apply(this, arguments);
3838
+ }
3839
+ return put;
3840
+ }()
3841
+ /**
3842
+ * Execute a patch query
3843
+ * @param {*} payload Define what data need to be posted
3844
+ * @param {*} settings Configuration settings for the request
3845
+ * @returns
3846
+ */
3847
+ )
3848
+ }, {
3849
+ key: "patch",
3850
+ value: (function () {
3851
+ var _patch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(payload, settings) {
3852
+ var endpoint, result, _error$response4, _t7;
3853
+ return _regenerator().w(function (_context7) {
3854
+ while (1) switch (_context7.p = _context7.n) {
3855
+ case 0:
3856
+ _context7.p = 0;
3857
+ if (payload) {
3858
+ _context7.n = 1;
3859
+ break;
3860
+ }
3861
+ return _context7.a(2, null);
3862
+ case 1:
3863
+ endpoint = this.urlBuilder({
3864
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.patch
3865
+ });
3866
+ _context7.n = 2;
3867
+ return this.request().patch(endpoint, payload);
3868
+ case 2:
3869
+ result = _context7.v;
3870
+ return _context7.a(2, result.data);
3871
+ case 3:
3872
+ _context7.p = 3;
3873
+ _t7 = _context7.v;
3874
+ console.error(_t7);
3875
+ return _context7.a(2, _t7 === null || _t7 === void 0 || (_error$response4 = _t7.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.data);
3876
+ }
3877
+ }, _callee7, this, [[0, 3]]);
3878
+ }));
3879
+ function patch(_x11, _x12) {
3880
+ return _patch.apply(this, arguments);
3881
+ }
3882
+ return patch;
3883
+ }()
3884
+ /**
3885
+ * Execute a query get query
3886
+ * @param {*} payload
3887
+ * @param {*} endpoint
3888
+ * @returns
3889
+ */
3890
+ )
3891
+ }, {
3892
+ key: "get",
3893
+ value: (function () {
3894
+ var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(payload, settings) {
3895
+ var parameters, endpoint, result, _t8;
3896
+ return _regenerator().w(function (_context8) {
3897
+ while (1) switch (_context8.p = _context8.n) {
3898
+ case 0:
3899
+ _context8.p = 0;
3900
+ if (payload) {
3901
+ _context8.n = 1;
3902
+ break;
3903
+ }
3904
+ return _context8.a(2, null);
3905
+ case 1:
3906
+ parameters = this.objectToQueryString(payload);
3907
+ endpoint = this.urlBuilder({
3908
+ endpoint: (settings === null || settings === void 0 ? void 0 : settings.endpoint) || this.serviceEndpoints.post
3909
+ });
3910
+ _context8.n = 2;
3911
+ return this.request().get("".concat(endpoint).concat(parameters));
3912
+ case 2:
3913
+ result = _context8.v;
3914
+ return _context8.a(2, result.data);
3915
+ case 3:
3916
+ _context8.p = 3;
3917
+ _t8 = _context8.v;
3918
+ console.error(_t8);
3919
+ return _context8.a(2, _t8 === null || _t8 === void 0 ? void 0 : _t8.body);
3920
+ }
3921
+ }, _callee8, this, [[0, 3]]);
3922
+ }));
3923
+ function get(_x13, _x14) {
3924
+ return _get.apply(this, arguments);
3925
+ }
3926
+ return get;
3927
+ }())
3928
+ }]);
3929
+ }();
3930
+
3931
+ var AppEngineAppDefinitionService = /*#__PURE__*/function (_BaseApi) {
3932
+ function AppEngineAppDefinitionService(args) {
3933
+ var _this;
3934
+ _classCallCheck(this, AppEngineAppDefinitionService);
3935
+ _this = _callSuper(this, AppEngineAppDefinitionService, [args]);
3936
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
3937
+ _this.service_uri = {
3938
+ get: '/app-engine/definition',
3939
+ create: '/app-engine/definition',
3940
+ update: '/app-engine/definition',
3941
+ "delete": '/app-engine/definition',
3942
+ createWithScaffold: '/app-engine/definition/scaffold',
3943
+ studioPayload: '/app-engine/definition/studio',
3944
+ catalog: '/app-engine/definition/catalog',
3945
+ fullApp: '/app-engine/definition/full',
3946
+ provision: '/app-engine/definition/provision'
3947
+ };
3948
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
3949
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || undefined.VITE_LOOM_CLOUD_BACKEND_URL || '';
3950
+ if (baseUrl) {
3951
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
3952
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
3953
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
3954
+ }
3955
+ return _this;
3956
+ }
3957
+ _inherits(AppEngineAppDefinitionService, _BaseApi);
3958
+ return _createClass(AppEngineAppDefinitionService, [{
3959
+ key: "createWithScaffold",
3960
+ value: function () {
3961
+ var _createWithScaffold = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
3962
+ return _regenerator().w(function (_context) {
3963
+ while (1) switch (_context.n) {
3964
+ case 0:
3965
+ return _context.a(2, _superPropGet(AppEngineAppDefinitionService, "post", this, 3)([payload, {
3966
+ endpoint: this.service_uri.createWithScaffold
3967
+ }]));
3968
+ }
3969
+ }, _callee, this);
3970
+ }));
3971
+ function createWithScaffold(_x) {
3972
+ return _createWithScaffold.apply(this, arguments);
3973
+ }
3974
+ return createWithScaffold;
3975
+ }()
3976
+ }, {
3977
+ key: "getStudioPayload",
3978
+ value: function () {
3979
+ var _getStudioPayload = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
3980
+ return _regenerator().w(function (_context2) {
3981
+ while (1) switch (_context2.n) {
3982
+ case 0:
3983
+ return _context2.a(2, _superPropGet(AppEngineAppDefinitionService, "get", this, 3)([payload, {
3984
+ endpoint: this.service_uri.studioPayload
3985
+ }]));
3986
+ }
3987
+ }, _callee2, this);
3988
+ }));
3989
+ function getStudioPayload(_x2) {
3990
+ return _getStudioPayload.apply(this, arguments);
3991
+ }
3992
+ return getStudioPayload;
3993
+ }()
3994
+ }, {
3995
+ key: "getCatalog",
3996
+ value: function () {
3997
+ var _getCatalog = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload) {
3998
+ return _regenerator().w(function (_context3) {
3999
+ while (1) switch (_context3.n) {
4000
+ case 0:
4001
+ return _context3.a(2, _superPropGet(AppEngineAppDefinitionService, "get", this, 3)([payload, {
4002
+ endpoint: this.service_uri.catalog
4003
+ }]));
4004
+ }
4005
+ }, _callee3, this);
4006
+ }));
4007
+ function getCatalog(_x3) {
4008
+ return _getCatalog.apply(this, arguments);
4009
+ }
4010
+ return getCatalog;
4011
+ }()
4012
+ }, {
4013
+ key: "getFullApp",
4014
+ value: function () {
4015
+ var _getFullApp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(payload) {
4016
+ return _regenerator().w(function (_context4) {
4017
+ while (1) switch (_context4.n) {
4018
+ case 0:
4019
+ return _context4.a(2, _superPropGet(AppEngineAppDefinitionService, "get", this, 3)([payload, {
4020
+ endpoint: this.service_uri.fullApp
4021
+ }]));
4022
+ }
4023
+ }, _callee4, this);
4024
+ }));
4025
+ function getFullApp(_x4) {
4026
+ return _getFullApp.apply(this, arguments);
4027
+ }
4028
+ return getFullApp;
4029
+ }()
4030
+ }, {
4031
+ key: "provision",
4032
+ value: function () {
4033
+ var _provision = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(payload) {
4034
+ return _regenerator().w(function (_context5) {
4035
+ while (1) switch (_context5.n) {
4036
+ case 0:
4037
+ return _context5.a(2, _superPropGet(AppEngineAppDefinitionService, "post", this, 3)([payload, {
4038
+ endpoint: this.service_uri.provision
4039
+ }]));
4040
+ }
4041
+ }, _callee5, this);
4042
+ }));
4043
+ function provision(_x5) {
4044
+ return _provision.apply(this, arguments);
4045
+ }
4046
+ return provision;
4047
+ }()
4048
+ }]);
4049
+ }(BaseApi);
4050
+
4051
+ var AppEngineAppVersionService = /*#__PURE__*/function (_BaseApi) {
4052
+ function AppEngineAppVersionService(args) {
4053
+ var _this;
4054
+ _classCallCheck(this, AppEngineAppVersionService);
4055
+ _this = _callSuper(this, AppEngineAppVersionService, [args]);
4056
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4057
+ _this.service_uri = {
4058
+ get: '/app-engine/version',
4059
+ create: '/app-engine/version',
4060
+ update: '/app-engine/version',
4061
+ "delete": '/app-engine/version',
4062
+ publish: '/app-engine/version/publish',
4063
+ activate: '/app-engine/version/activate'
4064
+ };
4065
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4066
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || undefined.VITE_LOOM_CLOUD_BACKEND_URL || '';
4067
+ if (baseUrl) {
4068
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4069
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4070
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4071
+ }
4072
+ return _this;
4073
+ }
4074
+ _inherits(AppEngineAppVersionService, _BaseApi);
4075
+ return _createClass(AppEngineAppVersionService, [{
4076
+ key: "publish",
4077
+ value: function () {
4078
+ var _publish = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4079
+ return _regenerator().w(function (_context) {
4080
+ while (1) switch (_context.n) {
4081
+ case 0:
4082
+ return _context.a(2, _superPropGet(AppEngineAppVersionService, "post", this, 3)([payload, {
4083
+ endpoint: this.service_uri.publish
4084
+ }]));
4085
+ }
4086
+ }, _callee, this);
4087
+ }));
4088
+ function publish(_x) {
4089
+ return _publish.apply(this, arguments);
4090
+ }
4091
+ return publish;
4092
+ }()
4093
+ }, {
4094
+ key: "activate",
4095
+ value: function () {
4096
+ var _activate = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
4097
+ return _regenerator().w(function (_context2) {
4098
+ while (1) switch (_context2.n) {
4099
+ case 0:
4100
+ return _context2.a(2, _superPropGet(AppEngineAppVersionService, "patch", this, 3)([payload, {
4101
+ endpoint: this.service_uri.activate
4102
+ }]));
4103
+ }
4104
+ }, _callee2, this);
4105
+ }));
4106
+ function activate(_x2) {
4107
+ return _activate.apply(this, arguments);
4108
+ }
4109
+ return activate;
4110
+ }()
4111
+ }]);
4112
+ }(BaseApi);
4113
+
4114
+ var AppEngineAppFileService = /*#__PURE__*/function (_BaseApi) {
4115
+ function AppEngineAppFileService(args) {
4116
+ var _this;
4117
+ _classCallCheck(this, AppEngineAppFileService);
4118
+ _this = _callSuper(this, AppEngineAppFileService, [args]);
4119
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4120
+ _this.service_uri = {
4121
+ get: '/app-engine/file',
4122
+ create: '/app-engine/file',
4123
+ update: '/app-engine/file',
4124
+ "delete": '/app-engine/file',
4125
+ content: '/app-engine/file/content',
4126
+ tree: '/app-engine/file/tree',
4127
+ applyChanges: '/app-engine/file/apply-changes'
4128
+ };
4129
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4130
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || undefined.VITE_LOOM_CLOUD_BACKEND_URL || '';
4131
+ if (baseUrl) {
4132
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4133
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4134
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4135
+ }
4136
+ return _this;
4137
+ }
4138
+ _inherits(AppEngineAppFileService, _BaseApi);
4139
+ return _createClass(AppEngineAppFileService, [{
4140
+ key: "getFileContent",
4141
+ value: function () {
4142
+ var _getFileContent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4143
+ return _regenerator().w(function (_context) {
4144
+ while (1) switch (_context.n) {
4145
+ case 0:
4146
+ return _context.a(2, _superPropGet(AppEngineAppFileService, "get", this, 3)([payload, {
4147
+ endpoint: this.service_uri.content
4148
+ }]));
4149
+ }
4150
+ }, _callee, this);
4151
+ }));
4152
+ function getFileContent(_x) {
4153
+ return _getFileContent.apply(this, arguments);
4154
+ }
4155
+ return getFileContent;
4156
+ }()
4157
+ }, {
4158
+ key: "getFileTree",
4159
+ value: function () {
4160
+ var _getFileTree = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
4161
+ return _regenerator().w(function (_context2) {
4162
+ while (1) switch (_context2.n) {
4163
+ case 0:
4164
+ return _context2.a(2, _superPropGet(AppEngineAppFileService, "get", this, 3)([payload, {
4165
+ endpoint: this.service_uri.tree
4166
+ }]));
4167
+ }
4168
+ }, _callee2, this);
4169
+ }));
4170
+ function getFileTree(_x2) {
4171
+ return _getFileTree.apply(this, arguments);
4172
+ }
4173
+ return getFileTree;
4174
+ }()
4175
+ }, {
4176
+ key: "applyChanges",
4177
+ value: function () {
4178
+ var _applyChanges = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload) {
4179
+ return _regenerator().w(function (_context3) {
4180
+ while (1) switch (_context3.n) {
4181
+ case 0:
4182
+ return _context3.a(2, _superPropGet(AppEngineAppFileService, "post", this, 3)([payload, {
4183
+ endpoint: this.service_uri.applyChanges
4184
+ }]));
4185
+ }
4186
+ }, _callee3, this);
4187
+ }));
4188
+ function applyChanges(_x3) {
4189
+ return _applyChanges.apply(this, arguments);
4190
+ }
4191
+ return applyChanges;
4192
+ }()
4193
+ }]);
4194
+ }(BaseApi);
4195
+
4196
+ var AppEngineAppBuildService = /*#__PURE__*/function (_BaseApi) {
4197
+ function AppEngineAppBuildService(args) {
4198
+ var _this;
4199
+ _classCallCheck(this, AppEngineAppBuildService);
4200
+ _this = _callSuper(this, AppEngineAppBuildService, [args]);
4201
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4202
+ _this.service_uri = {
4203
+ buildSingle: '/app-engine/build/single',
4204
+ buildAll: '/app-engine/build/all',
4205
+ buildAndPublish: '/app-engine/build/publish'
4206
+ };
4207
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4208
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || undefined.VITE_LOOM_CLOUD_BACKEND_URL || '';
4209
+ if (baseUrl) {
4210
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4211
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4212
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4213
+ }
4214
+ return _this;
4215
+ }
4216
+ _inherits(AppEngineAppBuildService, _BaseApi);
4217
+ return _createClass(AppEngineAppBuildService, [{
4218
+ key: "buildSingle",
4219
+ value: function () {
4220
+ var _buildSingle = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4221
+ return _regenerator().w(function (_context) {
4222
+ while (1) switch (_context.n) {
4223
+ case 0:
4224
+ return _context.a(2, _superPropGet(AppEngineAppBuildService, "post", this, 3)([payload, {
4225
+ endpoint: this.service_uri.buildSingle
4226
+ }]));
4227
+ }
4228
+ }, _callee, this);
4229
+ }));
4230
+ function buildSingle(_x) {
4231
+ return _buildSingle.apply(this, arguments);
4232
+ }
4233
+ return buildSingle;
4234
+ }()
4235
+ }, {
4236
+ key: "buildAll",
4237
+ value: function () {
4238
+ var _buildAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
4239
+ return _regenerator().w(function (_context2) {
4240
+ while (1) switch (_context2.n) {
4241
+ case 0:
4242
+ return _context2.a(2, _superPropGet(AppEngineAppBuildService, "post", this, 3)([payload, {
4243
+ endpoint: this.service_uri.buildAll
4244
+ }]));
4245
+ }
4246
+ }, _callee2, this);
4247
+ }));
4248
+ function buildAll(_x2) {
4249
+ return _buildAll.apply(this, arguments);
4250
+ }
4251
+ return buildAll;
4252
+ }()
4253
+ }, {
4254
+ key: "buildAndPublish",
4255
+ value: function () {
4256
+ var _buildAndPublish = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload) {
4257
+ return _regenerator().w(function (_context3) {
4258
+ while (1) switch (_context3.n) {
4259
+ case 0:
4260
+ return _context3.a(2, _superPropGet(AppEngineAppBuildService, "post", this, 3)([payload, {
4261
+ endpoint: this.service_uri.buildAndPublish
4262
+ }]));
4263
+ }
4264
+ }, _callee3, this);
4265
+ }));
4266
+ function buildAndPublish(_x3) {
4267
+ return _buildAndPublish.apply(this, arguments);
4268
+ }
4269
+ return buildAndPublish;
4270
+ }()
4271
+ }]);
4272
+ }(BaseApi);
4273
+
4274
+ var AppEngineAppSessionService = /*#__PURE__*/function (_BaseApi) {
4275
+ function AppEngineAppSessionService(args) {
4276
+ var _this;
4277
+ _classCallCheck(this, AppEngineAppSessionService);
4278
+ _this = _callSuper(this, AppEngineAppSessionService, [args]);
4279
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4280
+ _this.service_uri = {
4281
+ get: '/app-engine/session',
4282
+ create: '/app-engine/session',
4283
+ update: '/app-engine/session',
4284
+ "delete": '/app-engine/session',
4285
+ open: '/app-engine/session/open',
4286
+ saveDraft: '/app-engine/session/save-draft',
4287
+ submitOutput: '/app-engine/session/submit-output',
4288
+ cancel: '/app-engine/session/cancel'
4289
+ };
4290
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4291
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || undefined.VITE_LOOM_CLOUD_BACKEND_URL || '';
4292
+ if (baseUrl) {
4293
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4294
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4295
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4296
+ }
4297
+ return _this;
4298
+ }
4299
+ _inherits(AppEngineAppSessionService, _BaseApi);
4300
+ return _createClass(AppEngineAppSessionService, [{
4301
+ key: "open",
4302
+ value: function () {
4303
+ var _open = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4304
+ return _regenerator().w(function (_context) {
4305
+ while (1) switch (_context.n) {
4306
+ case 0:
4307
+ return _context.a(2, _superPropGet(AppEngineAppSessionService, "post", this, 3)([payload, {
4308
+ endpoint: this.service_uri.open
4309
+ }]));
4310
+ }
4311
+ }, _callee, this);
4312
+ }));
4313
+ function open(_x) {
4314
+ return _open.apply(this, arguments);
4315
+ }
4316
+ return open;
4317
+ }()
4318
+ }, {
4319
+ key: "saveDraft",
4320
+ value: function () {
4321
+ var _saveDraft = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(payload) {
4322
+ return _regenerator().w(function (_context2) {
4323
+ while (1) switch (_context2.n) {
4324
+ case 0:
4325
+ return _context2.a(2, _superPropGet(AppEngineAppSessionService, "patch", this, 3)([payload, {
4326
+ endpoint: this.service_uri.saveDraft
4327
+ }]));
4328
+ }
4329
+ }, _callee2, this);
4330
+ }));
4331
+ function saveDraft(_x2) {
4332
+ return _saveDraft.apply(this, arguments);
4333
+ }
4334
+ return saveDraft;
4335
+ }()
4336
+ }, {
4337
+ key: "submitOutput",
4338
+ value: function () {
4339
+ var _submitOutput = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(payload) {
4340
+ return _regenerator().w(function (_context3) {
4341
+ while (1) switch (_context3.n) {
4342
+ case 0:
4343
+ return _context3.a(2, _superPropGet(AppEngineAppSessionService, "patch", this, 3)([payload, {
4344
+ endpoint: this.service_uri.submitOutput
4345
+ }]));
4346
+ }
4347
+ }, _callee3, this);
4348
+ }));
4349
+ function submitOutput(_x3) {
4350
+ return _submitOutput.apply(this, arguments);
4351
+ }
4352
+ return submitOutput;
4353
+ }()
4354
+ }, {
4355
+ key: "cancel",
4356
+ value: function () {
4357
+ var _cancel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(payload) {
4358
+ return _regenerator().w(function (_context4) {
4359
+ while (1) switch (_context4.n) {
4360
+ case 0:
4361
+ return _context4.a(2, _superPropGet(AppEngineAppSessionService, "patch", this, 3)([payload, {
4362
+ endpoint: this.service_uri.cancel
4363
+ }]));
4364
+ }
4365
+ }, _callee4, this);
4366
+ }));
4367
+ function cancel(_x4) {
4368
+ return _cancel.apply(this, arguments);
4369
+ }
4370
+ return cancel;
4371
+ }()
4372
+ }]);
4373
+ }(BaseApi);
4374
+
4375
+ var AppEngineAppPreferenceService = /*#__PURE__*/function (_BaseApi) {
4376
+ function AppEngineAppPreferenceService(args) {
4377
+ var _this;
4378
+ _classCallCheck(this, AppEngineAppPreferenceService);
4379
+ _this = _callSuper(this, AppEngineAppPreferenceService, [args]);
4380
+ _this.api_key = (args === null || args === void 0 ? void 0 : args.apiKey) || '';
4381
+ _this.service_uri = {
4382
+ get: '/app-engine/preference',
4383
+ create: '/app-engine/preference',
4384
+ update: '/app-engine/preference',
4385
+ "delete": '/app-engine/preference'
4386
+ };
4387
+ _this.settings = (args === null || args === void 0 ? void 0 : args.settings) || {};
4388
+ var baseUrl = (args === null || args === void 0 ? void 0 : args.baseUrl) || undefined.VITE_LOOM_CLOUD_BACKEND_URL || '';
4389
+ if (baseUrl) {
4390
+ _this.serviceEndpoints.baseUrlProduction = baseUrl;
4391
+ _this.serviceEndpoints.baseUrlDevelopment = baseUrl;
4392
+ _this.serviceEndpoints.baseUrlLocal = baseUrl;
4393
+ }
4394
+ return _this;
4395
+ }
4396
+ _inherits(AppEngineAppPreferenceService, _BaseApi);
4397
+ return _createClass(AppEngineAppPreferenceService);
4398
+ }(BaseApi);
4399
+
4400
+ var AppEngineSDKContext = /*#__PURE__*/React$1.createContext(null);
4401
+ var AppEngineSDKProvider = function AppEngineSDKProvider(_ref) {
4402
+ var baseUrl = _ref.baseUrl,
4403
+ children = _ref.children;
4404
+ var services = React$1.useMemo(function () {
4405
+ var config = baseUrl ? {
4406
+ baseUrl: baseUrl
4407
+ } : {};
4408
+ return {
4409
+ appDefinitionService: new AppEngineAppDefinitionService(config),
4410
+ appVersionService: new AppEngineAppVersionService(config),
4411
+ appFileService: new AppEngineAppFileService(config),
4412
+ appBuildService: new AppEngineAppBuildService(config),
4413
+ appSessionService: new AppEngineAppSessionService(config),
4414
+ appPreferenceService: new AppEngineAppPreferenceService(config)
4415
+ };
4416
+ }, [baseUrl]);
4417
+ return /*#__PURE__*/React$1.createElement(AppEngineSDKContext.Provider, {
4418
+ value: services
4419
+ }, children);
4420
+ };
4421
+ var useAppEngineSDK = function useAppEngineSDK() {
4422
+ var context = React$1.useContext(AppEngineSDKContext);
4423
+ if (!context) {
4424
+ throw new Error('useAppEngineSDK must be used within an AppEngineSDKProvider');
4425
+ }
4426
+ return context;
4427
+ };
4428
+
4429
+ function useAppStudio(_ref) {
4430
+ var appDefinitionService = _ref.appDefinitionService,
4431
+ appFileService = _ref.appFileService,
4432
+ appVersionService = _ref.appVersionService,
4433
+ appBuildService = _ref.appBuildService;
4434
+ var _useState = React$1.useState(null),
4435
+ _useState2 = _slicedToArray(_useState, 2),
4436
+ appDefinition = _useState2[0],
4437
+ setAppDefinition = _useState2[1];
4438
+ var _useState3 = React$1.useState([]),
4439
+ _useState4 = _slicedToArray(_useState3, 2),
4440
+ fileTree = _useState4[0],
4441
+ setFileTree = _useState4[1];
4442
+ var _useState5 = React$1.useState([]),
4443
+ _useState6 = _slicedToArray(_useState5, 2),
4444
+ openFiles = _useState6[0],
4445
+ setOpenFiles = _useState6[1];
4446
+ var _useState7 = React$1.useState(null),
4447
+ _useState8 = _slicedToArray(_useState7, 2),
4448
+ activeFilePath = _useState8[0],
4449
+ setActiveFilePath = _useState8[1];
4450
+ var _useState9 = React$1.useState(false),
4451
+ _useState0 = _slicedToArray(_useState9, 2),
4452
+ isSaving = _useState0[0],
4453
+ setIsSaving = _useState0[1];
4454
+ var _useState1 = React$1.useState(null),
4455
+ _useState10 = _slicedToArray(_useState1, 2),
4456
+ buildStatus = _useState10[0],
4457
+ setBuildStatus = _useState10[1];
4458
+ var _useState11 = React$1.useState(''),
4459
+ _useState12 = _slicedToArray(_useState11, 2),
4460
+ buildLog = _useState12[0],
4461
+ setBuildLog = _useState12[1];
4462
+ var _useState13 = React$1.useState([]),
4463
+ _useState14 = _slicedToArray(_useState13, 2),
4464
+ buildErrors = _useState14[0],
4465
+ setBuildErrors = _useState14[1];
4466
+ var definitionDirtyRef = React$1.useRef(false);
4467
+ var isDirty = openFiles.some(function (f) {
4468
+ return f.isDirty;
4469
+ }) || definitionDirtyRef.current;
4470
+ var loadStudioPayload = React$1.useCallback(/*#__PURE__*/function () {
4471
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(appDefinitionId) {
4472
+ var response, _t;
4473
+ return _regenerator().w(function (_context) {
4474
+ while (1) switch (_context.p = _context.n) {
4475
+ case 0:
4476
+ if (!(!appDefinitionService || !appDefinitionId)) {
4477
+ _context.n = 1;
4478
+ break;
4479
+ }
4480
+ return _context.a(2);
4481
+ case 1:
4482
+ _context.p = 1;
4483
+ _context.n = 2;
4484
+ return appDefinitionService.getStudioPayload({
4485
+ id: appDefinitionId
4486
+ });
4487
+ case 2:
4488
+ response = _context.v;
4489
+ if (response !== null && response !== void 0 && response.result) {
4490
+ setAppDefinition(response.result.definition);
4491
+ setFileTree(response.result.file_tree || []);
4492
+ }
4493
+ _context.n = 4;
4494
+ break;
4495
+ case 3:
4496
+ _context.p = 3;
4497
+ _t = _context.v;
4498
+ console.error('Failed to load studio payload:', _t);
4499
+ case 4:
4500
+ return _context.a(2);
4501
+ }
4502
+ }, _callee, null, [[1, 3]]);
4503
+ }));
4504
+ return function (_x) {
4505
+ return _ref2.apply(this, arguments);
4506
+ };
4507
+ }(), [appDefinitionService]);
4508
+ var openFile = React$1.useCallback(/*#__PURE__*/function () {
4509
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(file) {
4510
+ var existing, content, _response$result, response, _t2;
4511
+ return _regenerator().w(function (_context2) {
4512
+ while (1) switch (_context2.p = _context2.n) {
4513
+ case 0:
4514
+ if (!(file.kind === 'folder')) {
4515
+ _context2.n = 1;
4516
+ break;
4517
+ }
4518
+ return _context2.a(2);
4519
+ case 1:
4520
+ existing = openFiles.find(function (f) {
4521
+ return f.path === file.path;
4522
+ });
4523
+ if (!existing) {
4524
+ _context2.n = 2;
4525
+ break;
4526
+ }
4527
+ setActiveFilePath(file.path);
4528
+ return _context2.a(2);
4529
+ case 2:
4530
+ content = file.content;
4531
+ if (!(content === undefined || content === null)) {
4532
+ _context2.n = 6;
4533
+ break;
4534
+ }
4535
+ _context2.p = 3;
4536
+ _context2.n = 4;
4537
+ return appFileService === null || appFileService === void 0 ? void 0 : appFileService.getFileContent({
4538
+ search: file.id
4539
+ });
4540
+ case 4:
4541
+ response = _context2.v;
4542
+ content = (response === null || response === void 0 || (_response$result = response.result) === null || _response$result === void 0 ? void 0 : _response$result.content) || '';
4543
+ _context2.n = 6;
4544
+ break;
4545
+ case 5:
4546
+ _context2.p = 5;
4547
+ _t2 = _context2.v;
4548
+ console.error('Failed to load file content:', _t2);
4549
+ content = '';
4550
+ case 6:
4551
+ setOpenFiles(function (prev) {
4552
+ return [].concat(_toConsumableArray(prev), [_objectSpread2(_objectSpread2({}, file), {}, {
4553
+ content: content,
4554
+ isDirty: false,
4555
+ originalContent: content
4556
+ })]);
4557
+ });
4558
+ setActiveFilePath(file.path);
4559
+ case 7:
4560
+ return _context2.a(2);
4561
+ }
4562
+ }, _callee2, null, [[3, 5]]);
4563
+ }));
4564
+ return function (_x2) {
4565
+ return _ref3.apply(this, arguments);
4566
+ };
4567
+ }(), [openFiles, appFileService]);
4568
+ var updateFileContent = React$1.useCallback(function (filePath, newContent) {
4569
+ setOpenFiles(function (prev) {
4570
+ return prev.map(function (f) {
4571
+ if (f.path !== filePath) return f;
4572
+ return _objectSpread2(_objectSpread2({}, f), {}, {
4573
+ content: newContent,
4574
+ isDirty: newContent !== f.originalContent
4575
+ });
4576
+ });
4577
+ });
4578
+ }, []);
4579
+ var closeFile = React$1.useCallback(function (filePath) {
4580
+ setOpenFiles(function (prev) {
4581
+ var next = prev.filter(function (f) {
4582
+ return f.path !== filePath;
4583
+ });
4584
+ if (filePath === activeFilePath) {
4585
+ var _next$Math$min;
4586
+ var closedIndex = prev.findIndex(function (f) {
4587
+ return f.path === filePath;
4588
+ });
4589
+ setActiveFilePath(((_next$Math$min = next[Math.min(closedIndex, next.length - 1)]) === null || _next$Math$min === void 0 ? void 0 : _next$Math$min.path) || null);
4590
+ }
4591
+ return next;
4592
+ });
4593
+ }, [activeFilePath]);
4594
+ var save = React$1.useCallback(/*#__PURE__*/function () {
4595
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(appDefinitionId) {
4596
+ var dirtyFiles, _t3;
4597
+ return _regenerator().w(function (_context3) {
4598
+ while (1) switch (_context3.p = _context3.n) {
4599
+ case 0:
4600
+ if (appFileService) {
4601
+ _context3.n = 1;
4602
+ break;
4603
+ }
4604
+ return _context3.a(2);
4605
+ case 1:
4606
+ setIsSaving(true);
4607
+ _context3.p = 2;
4608
+ dirtyFiles = openFiles.filter(function (f) {
4609
+ return f.isDirty;
4610
+ });
4611
+ if (!(dirtyFiles.length > 0)) {
4612
+ _context3.n = 4;
4613
+ break;
4614
+ }
4615
+ _context3.n = 3;
4616
+ return appFileService.applyChanges({
4617
+ app_definition_id: appDefinitionId,
4618
+ changes: dirtyFiles.map(function (f) {
4619
+ return {
4620
+ operation: 'update',
4621
+ id: f.id,
4622
+ path: f.path,
4623
+ content: f.content
4624
+ };
4625
+ })
4626
+ });
4627
+ case 3:
4628
+ setOpenFiles(function (prev) {
4629
+ return prev.map(function (f) {
4630
+ return f.isDirty ? _objectSpread2(_objectSpread2({}, f), {}, {
4631
+ isDirty: false,
4632
+ originalContent: f.content
4633
+ }) : f;
4634
+ });
4635
+ });
4636
+ case 4:
4637
+ if (!(definitionDirtyRef.current && appDefinitionService)) {
4638
+ _context3.n = 6;
4639
+ break;
4640
+ }
4641
+ _context3.n = 5;
4642
+ return appDefinitionService.update(appDefinition);
4643
+ case 5:
4644
+ definitionDirtyRef.current = false;
4645
+ case 6:
4646
+ _context3.n = 8;
4647
+ break;
4648
+ case 7:
4649
+ _context3.p = 7;
4650
+ _t3 = _context3.v;
4651
+ console.error('Failed to save:', _t3);
4652
+ case 8:
4653
+ _context3.p = 8;
4654
+ setIsSaving(false);
4655
+ return _context3.f(8);
4656
+ case 9:
4657
+ return _context3.a(2);
4658
+ }
4659
+ }, _callee3, null, [[2, 7, 8, 9]]);
4660
+ }));
4661
+ return function (_x3) {
4662
+ return _ref4.apply(this, arguments);
4663
+ };
4664
+ }(), [openFiles, appFileService, appDefinitionService, appDefinition]);
4665
+ var build = React$1.useCallback(/*#__PURE__*/function () {
4666
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(appDefinitionId) {
4667
+ var _response$result2, response, _t4;
4668
+ return _regenerator().w(function (_context4) {
4669
+ while (1) switch (_context4.p = _context4.n) {
4670
+ case 0:
4671
+ if (appBuildService) {
4672
+ _context4.n = 1;
4673
+ break;
4674
+ }
4675
+ return _context4.a(2);
4676
+ case 1:
4677
+ setBuildStatus('building');
4678
+ setBuildLog('');
4679
+ setBuildErrors([]);
4680
+ _context4.p = 2;
4681
+ _context4.n = 3;
4682
+ return appBuildService.build({
4683
+ app_definition_id: appDefinitionId,
4684
+ organization_id: appDefinition === null || appDefinition === void 0 ? void 0 : appDefinition.organization_id
4685
+ });
4686
+ case 3:
4687
+ response = _context4.v;
4688
+ setBuildStatus(response !== null && response !== void 0 && response.result ? 'success' : 'failed');
4689
+ setBuildLog((response === null || response === void 0 || (_response$result2 = response.result) === null || _response$result2 === void 0 ? void 0 : _response$result2.build_log) || '');
4690
+ _context4.n = 5;
4691
+ break;
4692
+ case 4:
4693
+ _context4.p = 4;
4694
+ _t4 = _context4.v;
4695
+ setBuildStatus('failed');
4696
+ setBuildErrors([_t4.message]);
4697
+ case 5:
4698
+ return _context4.a(2);
4699
+ }
4700
+ }, _callee4, null, [[2, 4]]);
4701
+ }));
4702
+ return function (_x4) {
4703
+ return _ref5.apply(this, arguments);
4704
+ };
4705
+ }(), [appBuildService, appDefinition]);
4706
+ var publish = React$1.useCallback(/*#__PURE__*/function () {
4707
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(appDefinitionId) {
4708
+ var _t5;
4709
+ return _regenerator().w(function (_context5) {
4710
+ while (1) switch (_context5.p = _context5.n) {
4711
+ case 0:
4712
+ if (appVersionService) {
4713
+ _context5.n = 1;
4714
+ break;
4715
+ }
4716
+ return _context5.a(2);
4717
+ case 1:
4718
+ _context5.p = 1;
4719
+ _context5.n = 2;
4720
+ return appVersionService.publish({
4721
+ app_definition_id: appDefinitionId
4722
+ });
4723
+ case 2:
4724
+ _context5.n = 4;
4725
+ break;
4726
+ case 3:
4727
+ _context5.p = 3;
4728
+ _t5 = _context5.v;
4729
+ console.error('Failed to publish:', _t5);
4730
+ case 4:
4731
+ return _context5.a(2);
4732
+ }
4733
+ }, _callee5, null, [[1, 3]]);
4734
+ }));
4735
+ return function (_x5) {
4736
+ return _ref6.apply(this, arguments);
4737
+ };
4738
+ }(), [appVersionService]);
4739
+ var updateDefinition = React$1.useCallback(function (updated) {
4740
+ setAppDefinition(updated);
4741
+ definitionDirtyRef.current = true;
4742
+ }, []);
4743
+ return {
4744
+ appDefinition: appDefinition,
4745
+ fileTree: fileTree,
4746
+ openFiles: openFiles,
4747
+ activeFilePath: activeFilePath,
4748
+ isSaving: isSaving,
4749
+ isDirty: isDirty,
4750
+ buildStatus: buildStatus,
4751
+ buildLog: buildLog,
4752
+ buildErrors: buildErrors,
4753
+ setActiveFilePath: setActiveFilePath,
4754
+ loadStudioPayload: loadStudioPayload,
4755
+ openFile: openFile,
4756
+ updateFileContent: updateFileContent,
4757
+ closeFile: closeFile,
4758
+ save: save,
4759
+ build: build,
4760
+ publish: publish,
4761
+ updateDefinition: updateDefinition
4762
+ };
4763
+ }
4764
+
4765
+ function useAppRuntime(_ref) {
4766
+ var appSessionService = _ref.appSessionService;
4767
+ var _useState = React$1.useState('idle'),
4768
+ _useState2 = _slicedToArray(_useState, 2),
4769
+ status = _useState2[0],
4770
+ setStatus = _useState2[1];
4771
+ var _useState3 = React$1.useState(null),
4772
+ _useState4 = _slicedToArray(_useState3, 2),
4773
+ error = _useState4[0],
4774
+ setError = _useState4[1];
4775
+ var _useState5 = React$1.useState(null),
4776
+ _useState6 = _slicedToArray(_useState5, 2),
4777
+ session = _useState6[0],
4778
+ setSession = _useState6[1];
4779
+ var mountRef = React$1.useRef(null);
4780
+ var rootRef = React$1.useRef(null);
4781
+ var blobUrlRef = React$1.useRef(null);
4782
+ var cleanup = React$1.useCallback(function () {
4783
+ if (rootRef.current) {
4784
+ rootRef.current.unmount();
4785
+ rootRef.current = null;
4786
+ }
4787
+ if (blobUrlRef.current) {
4788
+ URL.revokeObjectURL(blobUrlRef.current);
4789
+ blobUrlRef.current = null;
4790
+ }
4791
+ }, []);
4792
+ var openApp = React$1.useCallback(/*#__PURE__*/function () {
4793
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref2) {
4794
+ var appSlug, routePath, launchMode, inputPayload, onSubmitOutput, onClose, onNavigate, _version$build_artifa, response, _response$result, sessionData, version, entryFile, blob, module, AppComponent, sdk, _t;
4795
+ return _regenerator().w(function (_context3) {
4796
+ while (1) switch (_context3.p = _context3.n) {
4797
+ case 0:
4798
+ appSlug = _ref2.appSlug, routePath = _ref2.routePath, launchMode = _ref2.launchMode, inputPayload = _ref2.inputPayload, onSubmitOutput = _ref2.onSubmitOutput, onClose = _ref2.onClose, onNavigate = _ref2.onNavigate;
4799
+ if (!(!appSessionService || !appSlug)) {
4800
+ _context3.n = 1;
4801
+ break;
4802
+ }
4803
+ return _context3.a(2);
4804
+ case 1:
4805
+ cleanup();
4806
+ setStatus('loading');
4807
+ setError(null);
4808
+ _context3.p = 2;
4809
+ _context3.n = 3;
4810
+ return appSessionService.open({
4811
+ app_slug: appSlug,
4812
+ route_path: routePath || '/',
4813
+ launch_mode: launchMode || 'fullscreen',
4814
+ input_payload: inputPayload || {}
4815
+ });
4816
+ case 3:
4817
+ response = _context3.v;
4818
+ if (response !== null && response !== void 0 && response.result) {
4819
+ _context3.n = 4;
4820
+ break;
4821
+ }
4822
+ throw new Error((response === null || response === void 0 ? void 0 : response.message) || 'Failed to open session');
4823
+ case 4:
4824
+ _response$result = response.result, sessionData = _response$result.session, version = _response$result.app_version;
4825
+ setSession(sessionData);
4826
+ if (version !== null && version !== void 0 && version.build_artifact) {
4827
+ _context3.n = 5;
4828
+ break;
4829
+ }
4830
+ throw new Error('No build artifact available');
4831
+ case 5:
4832
+ entryFile = Object.keys(version.build_artifact).find(function (key) {
4833
+ return key.endsWith('.js') || key.endsWith('.mjs');
4834
+ });
4835
+ if (!(!entryFile || !((_version$build_artifa = version.build_artifact[entryFile]) !== null && _version$build_artifa !== void 0 && _version$build_artifa.content))) {
4836
+ _context3.n = 6;
4837
+ break;
4838
+ }
4839
+ throw new Error('No entry file found in build artifacts');
4840
+ case 6:
4841
+ blob = new Blob([version.build_artifact[entryFile].content], {
4842
+ type: 'application/javascript'
4843
+ });
4844
+ blobUrlRef.current = URL.createObjectURL(blob);
4845
+ _context3.n = 7;
4846
+ return import(/* @vite-ignore */blobUrlRef.current);
4847
+ case 7:
4848
+ module = _context3.v;
4849
+ AppComponent = module["default"];
4850
+ if (AppComponent) {
4851
+ _context3.n = 8;
4852
+ break;
4853
+ }
4854
+ throw new Error('App module does not export a default component');
4855
+ case 8:
4856
+ sdk = {
4857
+ session: {
4858
+ id: sessionData.id,
4859
+ appId: sessionData.app_definition_id,
4860
+ appSlug: sessionData.app_slug,
4861
+ appVersionId: sessionData.app_version_id,
4862
+ launchMode: sessionData.launch_mode,
4863
+ routePath: sessionData.route_path
4864
+ },
4865
+ input: sessionData.input_payload || inputPayload || {},
4866
+ navigate: function navigate(path) {
4867
+ return onNavigate === null || onNavigate === void 0 ? void 0 : onNavigate(path);
4868
+ },
4869
+ saveDraft: function saveDraft(payload) {
4870
+ return appSessionService === null || appSessionService === void 0 ? void 0 : appSessionService.saveDraft({
4871
+ id: sessionData.id,
4872
+ draft_payload: payload
4873
+ });
4874
+ },
4875
+ submitOutput: function () {
4876
+ var _submitOutput = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(payload) {
4877
+ return _regenerator().w(function (_context) {
4878
+ while (1) switch (_context.n) {
4879
+ case 0:
4880
+ _context.n = 1;
4881
+ return appSessionService === null || appSessionService === void 0 ? void 0 : appSessionService.submitOutput({
4882
+ id: sessionData.id,
4883
+ output_payload: payload
4884
+ });
4885
+ case 1:
4886
+ onSubmitOutput === null || onSubmitOutput === void 0 || onSubmitOutput(payload);
4887
+ case 2:
4888
+ return _context.a(2);
4889
+ }
4890
+ }, _callee);
4891
+ }));
4892
+ function submitOutput(_x2) {
4893
+ return _submitOutput.apply(this, arguments);
4894
+ }
4895
+ return submitOutput;
4896
+ }(),
4897
+ close: function close() {
4898
+ return onClose === null || onClose === void 0 ? void 0 : onClose();
4899
+ },
4900
+ cancel: function () {
4901
+ var _cancel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
4902
+ return _regenerator().w(function (_context2) {
4903
+ while (1) switch (_context2.n) {
4904
+ case 0:
4905
+ _context2.n = 1;
4906
+ return appSessionService === null || appSessionService === void 0 ? void 0 : appSessionService.cancel({
4907
+ id: sessionData.id
4908
+ });
4909
+ case 1:
4910
+ onClose === null || onClose === void 0 || onClose();
4911
+ case 2:
4912
+ return _context2.a(2);
4913
+ }
4914
+ }, _callee2);
4915
+ }));
4916
+ function cancel() {
4917
+ return _cancel.apply(this, arguments);
4918
+ }
4919
+ return cancel;
4920
+ }()
4921
+ };
4922
+ return _context3.a(2, {
4923
+ AppComponent: AppComponent,
4924
+ sdk: sdk
4925
+ });
4926
+ case 9:
4927
+ _context3.p = 9;
4928
+ _t = _context3.v;
4929
+ setError(_t.message);
4930
+ setStatus('error');
4931
+ return _context3.a(2, null);
4932
+ }
4933
+ }, _callee3, null, [[2, 9]]);
4934
+ }));
4935
+ return function (_x) {
4936
+ return _ref3.apply(this, arguments);
4937
+ };
4938
+ }(), [appSessionService, cleanup]);
4939
+ var mountApp = React$1.useCallback(function (containerRef, AppComponent, sdk) {
4940
+ if (!(containerRef !== null && containerRef !== void 0 && containerRef.current) || !AppComponent) return;
4941
+ cleanup();
4942
+ mountRef.current = containerRef.current;
4943
+ rootRef.current = client.createRoot(containerRef.current);
4944
+ rootRef.current.render(/*#__PURE__*/React.createElement(AppComponent, {
4945
+ sdk: sdk
4946
+ }));
4947
+ setStatus('running');
4948
+ }, [cleanup]);
4949
+ React$1.useEffect(function () {
4950
+ return cleanup;
4951
+ }, [cleanup]);
4952
+ return {
4953
+ status: status,
4954
+ error: error,
4955
+ session: session,
4956
+ openApp: openApp,
4957
+ mountApp: mountApp,
4958
+ cleanup: cleanup
4959
+ };
4960
+ }
4961
+
4962
+ exports.AppCatalogCardComponent = AppCatalogCard;
4963
+ exports.AppCatalogGridComponent = AppCatalogGrid;
4964
+ exports.AppEngineAppBuildService = AppEngineAppBuildService;
4965
+ exports.AppEngineAppDefinitionService = AppEngineAppDefinitionService;
4966
+ exports.AppEngineAppFileService = AppEngineAppFileService;
4967
+ exports.AppEngineAppPreferenceService = AppEngineAppPreferenceService;
4968
+ exports.AppEngineAppSessionService = AppEngineAppSessionService;
4969
+ exports.AppEngineAppVersionService = AppEngineAppVersionService;
4970
+ exports.AppEngineClient = AppEngineClient;
4971
+ exports.AppEngineSDKProvider = AppEngineSDKProvider;
4972
+ exports.AppRuntimeHostComponent = AppRuntimeHost;
4973
+ exports.AppStudioComponent = AppStudio;
4974
+ exports.useAppEngineSDK = useAppEngineSDK;
4975
+ exports.useAppRuntime = useAppRuntime;
4976
+ exports.useAppStudio = useAppStudio;
4977
+ //# sourceMappingURL=cloud-sdk.cjs.cjs.map