@abtnode/ux 1.16.18-beta-adeeb0b3 → 1.16.18-beta-aa01bd8e

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,1131 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = AddComponentCore;
7
+ var _react = require("react");
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _reactRouterDom = require("react-router-dom");
10
+ var _uniqBy = _interopRequireDefault(require("lodash/uniqBy"));
11
+ var _flatten = _interopRequireDefault(require("lodash/flatten"));
12
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
13
+ var _isNil = _interopRequireDefault(require("lodash/isNil"));
14
+ var _pageHeader = _interopRequireDefault(require("@blocklet/launcher-layout/lib/page-header"));
15
+ var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
16
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
17
+ var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
18
+ var _Link = _interopRequireDefault(require("@mui/icons-material/Link"));
19
+ var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
20
+ var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
21
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
22
+ var _context = require("@arcblock/ux/lib/Locale/context");
23
+ var _constant = require("@blocklet/constant");
24
+ var _launcherLayout = _interopRequireDefault(require("@blocklet/launcher-layout"));
25
+ var _step = require("@blocklet/launcher-layout/lib/context/step");
26
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
27
+ var _constant2 = require("@abtnode/constant");
28
+ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
29
+ var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
30
+ var _AnimationWaiter = _interopRequireDefault(require("@arcblock/ux/lib/AnimationWaiter"));
31
+ var _launchResultMessage = _interopRequireDefault(require("@blocklet/launcher-layout/lib/launch-result-message"));
32
+ var _util = require("@blocklet/meta/lib/util");
33
+ var _urlPathFriendly = _interopRequireDefault(require("@blocklet/meta/lib/url-path-friendly"));
34
+ var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
35
+ var _node = require("../../contexts/node");
36
+ var _blocklet = require("../../contexts/blocklet");
37
+ var _util2 = require("../../util");
38
+ var _schemaForm = _interopRequireDefault(require("../../schema-form"));
39
+ var _required = _interopRequireDefault(require("../../form/required"));
40
+ var _purchase = require("../purchase");
41
+ var _util3 = require("../router/util");
42
+ var _agreement = _interopRequireDefault(require("../agreement"));
43
+ var _installFromUrl = _interopRequireDefault(require("../install-from-url"));
44
+ var _selectStore = _interopRequireDefault(require("./select-store"));
45
+ var _storeBlockletList = _interopRequireDefault(require("./store-blocklet-list"));
46
+ var _spaceConnector = _interopRequireDefault(require("./space-connector"));
47
+ var _jsxRuntime = require("react/jsx-runtime");
48
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
49
+ const _excluded = ["name", "validation"],
50
+ _excluded2 = ["default", "key"];
51
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
52
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
53
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
54
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
55
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
56
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
57
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
58
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
59
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint-disable react/no-unstable-nested-components */
60
+ const requirePurchase = meta => meta.inStore && (0, _util.isFreeBlocklet)(meta) === false;
61
+ const getDIDSpaceCapability = meta => {
62
+ var _meta$capabilities;
63
+ return meta === null || meta === void 0 ? void 0 : (_meta$capabilities = meta.capabilities) === null || _meta$capabilities === void 0 ? void 0 : _meta$capabilities.didSpace;
64
+ };
65
+ /**
66
+ * @description
67
+ * @param {import('@abtnode/client').BlockletState} blocklet
68
+ * @return {string}
69
+ */
70
+ const getDIDSpaceEndpoint = blocklet => {
71
+ var _blocklet$configs, _blocklet$configs$fin;
72
+ return (blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$configs = blocklet.configs) === null || _blocklet$configs === void 0 ? void 0 : (_blocklet$configs$fin = _blocklet$configs.find(item => item.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACE_ENDPOINT)) === null || _blocklet$configs$fin === void 0 ? void 0 : _blocklet$configs$fin.value) || null;
73
+ };
74
+ const hasRequiredEnvironments = meta => (meta.environments || []).some(x => x.required);
75
+ const hasMissRequiredConfigs = (configsList, sharedValueMap) => {
76
+ return configsList === null || configsList === void 0 ? void 0 : configsList.some(item => {
77
+ return item.required && !sharedValueMap[item.key];
78
+ });
79
+ };
80
+ const getConfirmText = _ref => {
81
+ let {
82
+ params,
83
+ blocklet,
84
+ t
85
+ } = _ref;
86
+ const name = params.title || params.name;
87
+ if (!name) {
88
+ return t('common.next');
89
+ }
90
+ const exist = ((blocklet === null || blocklet === void 0 ? void 0 : blocklet.children) || []).find(x => x.meta.bundleDid === params.bundleDid);
91
+ if (!exist) {
92
+ return t('blocklet.component.addNext', {
93
+ name
94
+ });
95
+ }
96
+ return t('blocklet.component.upgradeNext', {
97
+ name
98
+ });
99
+ };
100
+ const StepContent = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
101
+ let {
102
+ meta,
103
+ isMobile,
104
+ onStepChange
105
+ } = _ref2;
106
+ const {
107
+ steps,
108
+ activeStep,
109
+ setActiveStepByKey,
110
+ setActiveStepByIndex
111
+ } = (0, _step.useStepContext)();
112
+ const {
113
+ t,
114
+ locale
115
+ } = (0, _context.useLocaleContext)();
116
+ const step = steps[activeStep];
117
+ (0, _react.useEffect)(() => {
118
+ onStepChange(activeStep);
119
+ }, [onStepChange, activeStep]);
120
+
121
+ // expose the func and activeStep
122
+ (0, _react.useImperativeHandle)(ref, () => ({
123
+ setActiveStepByKey,
124
+ setActiveStepByIndex
125
+ }));
126
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ContentWrapper, {
127
+ component: "div",
128
+ className: isMobile ? 'mobileStyle' : '',
129
+ sx: {
130
+ height: '100%'
131
+ },
132
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_launcherLayout.default, {
133
+ locale: locale,
134
+ blockletMeta: _objectSpread({
135
+ title: ' '
136
+ }, meta),
137
+ pcWidth: "100%",
138
+ pcHeight: "100%",
139
+ logoUrl: meta && meta.logo && meta.registryUrl ? (0, _util2.getBlockletLogoUrl)({
140
+ did: meta.did,
141
+ baseUrl: meta.registryUrl,
142
+ logoPath: meta.logo
143
+ }) : null,
144
+ stepTip: t('blocklet.component.add'),
145
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RightContent, {
146
+ children: step !== null && step !== void 0 && step.body && typeof step.body === 'function' ? step.body() : step.body
147
+ })
148
+ })
149
+ });
150
+ });
151
+ StepContent.propTypes = {
152
+ meta: _propTypes.default.any,
153
+ onStepChange: _propTypes.default.func.isRequired,
154
+ isMobile: _propTypes.default.bool.isRequired
155
+ };
156
+ StepContent.defaultProps = {
157
+ meta: null
158
+ };
159
+ const postInstalledMessage = componentDid => {
160
+ // send event to parent window
161
+ window.parent.postMessage({
162
+ event: 'component.installed',
163
+ componentDid
164
+ }, '*');
165
+ };
166
+ function AddComponentCore(_ref3) {
167
+ var _blocklet$meta2, _blocklet$meta3, _blocklet$meta4, _purchaseRef$current, _purchaseRef$current$, _purchaseRef$current2, _purchaseRef$current3;
168
+ let {
169
+ onClose,
170
+ mode,
171
+ stores,
172
+ resourceType,
173
+ storageKey
174
+ } = _ref3;
175
+ const {
176
+ t,
177
+ locale
178
+ } = (0, _context.useLocaleContext)();
179
+ const [loading, setLoading] = (0, _react.useState)(false);
180
+ const [editingItem, setEditingItem] = (0, _react.useState)(null);
181
+ const [error, setError] = (0, _react.useState)('');
182
+ const [mountPointHelperText, setMountPointHelperText] = (0, _react.useState)('');
183
+ const {
184
+ api,
185
+ ws: {
186
+ useSubscription
187
+ },
188
+ inService,
189
+ info: nodeInfo
190
+ } = (0, _node.useNodeContext)();
191
+ const {
192
+ blocklet,
193
+ actions: {
194
+ refreshBlocklet: refreshApp
195
+ }
196
+ } = (0, _blocklet.useBlockletContext)();
197
+ const [purchaseData, setPurchaseData] = (0, _react.useState)(null);
198
+ const [isWaitingPurchase, setIsWaitingPurchase] = (0, _react.useState)(false);
199
+ const initParams = {
200
+ bundleDid: '',
201
+ componentDid: '',
202
+ componentName: '',
203
+ pathPrefix: '',
204
+ name: '',
205
+ title: '',
206
+ configsList: [],
207
+ configsValue: {},
208
+ hasMissRequiredConfigs: false,
209
+ hasEnvironmentsStep: false,
210
+ hasRequiredEnvironments: false,
211
+ requirePurchase: false,
212
+ didSpaceCapability: null,
213
+ installResultProps: {},
214
+ purchaseResultProps: {},
215
+ showFromUrlDialog: false
216
+ };
217
+ const [params, setParams] = (0, _react.useState)(initParams);
218
+ const [activeStep, setActiveStep] = (0, _react.useState)(0);
219
+ const component = (0, _react.useRef)({});
220
+ const stepRef = (0, _react.useRef)({});
221
+ const purchaseRef = (0, _react.useRef)({});
222
+ const isMobile = (0, _useMediaQuery.default)(theme => theme.breakpoints.down('md'));
223
+ const routerParams = (0, _reactRouterDom.useParams)();
224
+ const {
225
+ meta
226
+ } = component.current;
227
+ // eslint-disable-next-line no-unused-vars
228
+ const {
229
+ setActiveStepByIndex
230
+ } = stepRef.current || {};
231
+ const isServerlessMode = nodeInfo.mode === _constant2.NODE_MODES.SERVERLESS;
232
+ const updateParams = obj => setParams(x => _objectSpread(_objectSpread({}, x), obj));
233
+ (0, _react.useEffect)(() => {
234
+ if (params.pathPrefix) {
235
+ const {
236
+ errMsg
237
+ } = validateInput(_objectSpread(_objectSpread({}, params), {}, {
238
+ pathPrefix: params.pathPrefix,
239
+ locale
240
+ }));
241
+ setError(errMsg);
242
+ }
243
+ }, [params.pathPrefix]); // eslint-disable-line
244
+
245
+ (0, _react.useEffect)(() => {
246
+ if (activeStep === 0) {
247
+ // reset params, when step change to select component
248
+ setParams(initParams);
249
+ }
250
+ }, [activeStep]); // eslint-disable-line
251
+
252
+ const getComponentName = () => {
253
+ var _component$current;
254
+ if (component !== null && component !== void 0 && (_component$current = component.current) !== null && _component$current !== void 0 && _component$current.meta) {
255
+ return (0, _util.getDisplayName)(component.current);
256
+ }
257
+ return '';
258
+ };
259
+ const setInstallErrorResult = errorMessage => {
260
+ const update = _loading => {
261
+ updateParams({
262
+ installResultProps: {
263
+ variant: 'error',
264
+ title: getComponentName(),
265
+ subTitle: errorMessage,
266
+ footer: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
267
+ className: "bottom-button",
268
+ disabled: _loading,
269
+ "data-cy": "retry-install-component",
270
+ onClick: async () => {
271
+ // set button disabled and show spinner
272
+ update(true);
273
+ await onInstall(component.current.installInput);
274
+ },
275
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
276
+ display: "flex",
277
+ alignItems: "center",
278
+ children: [_loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
279
+ size: 16,
280
+ style: {
281
+ marginRight: 8
282
+ }
283
+ }), t('common.retry')]
284
+ })
285
+ })
286
+ }
287
+ });
288
+ };
289
+ update();
290
+ };
291
+ const createBlockletEventHandler = handler => {
292
+ return b => {
293
+ var _b$meta, _blocklet$meta;
294
+ if (((b === null || b === void 0 ? void 0 : (_b$meta = b.meta) === null || _b$meta === void 0 ? void 0 : _b$meta.did) || (b === null || b === void 0 ? void 0 : b.meta)) === (blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did)) {
295
+ handler(b);
296
+ }
297
+ };
298
+ };
299
+ useSubscription(_constant.BlockletEvents.statusChange, createBlockletEventHandler(e => {
300
+ switch (e.status) {
301
+ case _constant.BlockletStatus.upgrading:
302
+ updateParams({
303
+ installResultProps: {
304
+ variant: 'success',
305
+ title: getComponentName(),
306
+ subTitle: t('blocklet.component.installSuccessTip')
307
+ }
308
+ });
309
+ postInstalledMessage(routerParams.componentDid);
310
+ break;
311
+ default:
312
+ }
313
+ }), [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta2 = blocklet.meta) === null || _blocklet$meta2 === void 0 ? void 0 : _blocklet$meta2.did]);
314
+ useSubscription(_constant.BlockletEvents.downloadFailed, createBlockletEventHandler(() => {
315
+ setInstallErrorResult(t('blocklet.component.installComponentError'));
316
+ }), [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta3 = blocklet.meta) === null || _blocklet$meta3 === void 0 ? void 0 : _blocklet$meta3.did]);
317
+ useSubscription(_constant.BlockletEvents.installFailed, createBlockletEventHandler(() => {
318
+ setInstallErrorResult(t('blocklet.component.installComponentError'));
319
+ }), [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta4 = blocklet.meta) === null || _blocklet$meta4 === void 0 ? void 0 : _blocklet$meta4.did]);
320
+ const onOver = () => {
321
+ setLoading(false);
322
+ setParams({});
323
+ component.current = {};
324
+ onClose();
325
+ };
326
+ const onInstall = async payload => {
327
+ var _component$current2, _component$current3;
328
+ const {
329
+ pathPrefix: mountPoint,
330
+ bundleDid,
331
+ title,
332
+ componentName = '',
333
+ componentDid = ''
334
+ } = params;
335
+ // eslint-disable-next-line no-shadow
336
+ const {
337
+ configs = [],
338
+ registryUrl,
339
+ inStore,
340
+ inputUrl
341
+ } = ((_component$current2 = component.current) === null || _component$current2 === void 0 ? void 0 : _component$current2.meta) || {};
342
+ const downloadTokenList = (_component$current3 = component.current) === null || _component$current3 === void 0 ? void 0 : _component$current3.downloadTokenList;
343
+ const url = inStore ? (0, _util2.getBlockletMetaUrl)(registryUrl, bundleDid) : inputUrl;
344
+ setLoading(true);
345
+ const installInput = _objectSpread(_objectSpread(_objectSpread({
346
+ rootDid: blocklet.meta.did,
347
+ url,
348
+ mountPoint: (0, _urlPathFriendly.default)(mountPoint),
349
+ title,
350
+ name: componentName,
351
+ did: componentDid
352
+ }, params.hasEnvironmentsStep && configs.length > 0 ? {
353
+ configs: configs.map(item => {
354
+ return _objectSpread(_objectSpread({}, item), {}, {
355
+ value: params.configsValue[item.key] || ''
356
+ });
357
+ })
358
+ } : {}), downloadTokenList ? {
359
+ downloadTokenList
360
+ } : {}), payload);
361
+ try {
362
+ await api.installComponent({
363
+ input: installInput
364
+ });
365
+ if (registryUrl) {
366
+ const {
367
+ teamDid,
368
+ storeList
369
+ } = (0, _util2.getStoreList)({
370
+ fromBlocklet: inService,
371
+ nodeInfo,
372
+ blocklet
373
+ });
374
+ const {
375
+ isNew,
376
+ decoded
377
+ } = (0, _util2.isNewStoreUrl)(registryUrl, storeList);
378
+ if (isNew) {
379
+ await api.addBlockletStore({
380
+ input: {
381
+ teamDid,
382
+ url: decoded
383
+ }
384
+ });
385
+ }
386
+ }
387
+ updateParams({
388
+ installResultProps: {}
389
+ });
390
+
391
+ // let app state refresh fast before receive subscribe event
392
+ refreshApp({
393
+ showError: false,
394
+ attachRuntimeInfo: false
395
+ });
396
+ } catch (err) {
397
+ const errMsg = (0, _util2.formatError)(err);
398
+ _Toast.default.error(errMsg);
399
+ console.error('installComponent error: ', err);
400
+ setInstallErrorResult(errMsg);
401
+ } finally {
402
+ setLoading(false);
403
+ component.current.installInput = installInput;
404
+ }
405
+ };
406
+ const validateInput = input => {
407
+ // FIXME: validatePathPrefix should be updated
408
+ const errMsg = (0, _util3.validatePathPrefix)({
409
+ params: _objectSpread(_objectSpread({}, input), {}, {
410
+ did: input.bundleDid
411
+ }),
412
+ blocklets: [blocklet],
413
+ // blocklets: component.current?.blocklets?.map(x => ({ meta: x })) || [],
414
+ blocklet,
415
+ locale
416
+ });
417
+ return {
418
+ errMsg
419
+ };
420
+ };
421
+ const onNext = async payload => {
422
+ const {
423
+ errMsg
424
+ } = validateInput(_objectSpread(_objectSpread({}, params), {}, {
425
+ locale
426
+ }));
427
+ setError(errMsg);
428
+
429
+ // the step can complete, install component
430
+ if (activeStep === steps.length - 2) {
431
+ await onInstall(payload);
432
+ }
433
+ setActiveStepByIndex(x => x + 1);
434
+ };
435
+ const _onCancel = () => {
436
+ setActiveStepByIndex(x => x - 1);
437
+ };
438
+ const onGeneratePurchaseData = () => {
439
+ const {
440
+ pathPrefix: mountPoint,
441
+ bundleDid,
442
+ title,
443
+ componentName = '',
444
+ componentDid = ''
445
+ } = params;
446
+
447
+ // eslint-disable-next-line no-shadow
448
+ const {
449
+ meta = {}
450
+ } = component.current || {};
451
+ const {
452
+ registryUrl,
453
+ inStore,
454
+ inputUrl
455
+ } = meta;
456
+ const url = inStore ? (0, _util2.getBlockletMetaUrl)(registryUrl, bundleDid) : inputUrl;
457
+ setPurchaseData({
458
+ meta,
459
+ installOpts: {
460
+ type: 'component',
461
+ rootDid: blocklet.meta.did,
462
+ mountPoint,
463
+ url,
464
+ title,
465
+ name: componentName,
466
+ did: componentDid
467
+ }
468
+ });
469
+ };
470
+ const onCancelPurchase = errorMessage => {
471
+ setIsWaitingPurchase(false);
472
+ updateParams({
473
+ purchaseResultProps: {
474
+ variant: 'error',
475
+ title: getComponentName(),
476
+ subTitle: errorMessage,
477
+ style: {
478
+ paddingTop: 120
479
+ },
480
+ footer: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
481
+ className: "bottom-button",
482
+ "data-cy": "retry-purchase-component",
483
+ onClick: () => {
484
+ updateParams({
485
+ purchaseResultProps: {}
486
+ });
487
+ },
488
+ children: t('common.retry')
489
+ })
490
+ }
491
+ });
492
+ };
493
+ const onSuccessPurchase = _ref4 => {
494
+ let {
495
+ downloadTokenList
496
+ } = _ref4;
497
+ component.current.downloadTokenList = downloadTokenList;
498
+ setIsWaitingPurchase(false);
499
+ onNext();
500
+ };
501
+ const setConfigValue = _ref5 => {
502
+ var _blocklet$settings, _meta$environments;
503
+ let {
504
+ chooseParams = component.current,
505
+ componentDid: componentDidValue,
506
+ isInit = false
507
+ } = _ref5;
508
+ // eslint-disable-next-line no-shadow
509
+ const {
510
+ meta,
511
+ registryUrl,
512
+ inStore,
513
+ inputUrl
514
+ } = chooseParams;
515
+ const {
516
+ did: bundleDid,
517
+ title,
518
+ name
519
+ } = meta;
520
+
521
+ // deleted history list
522
+ const list = (((_blocklet$settings = blocklet.settings) === null || _blocklet$settings === void 0 ? void 0 : _blocklet$settings.children) || []).filter(x => x.status === 'deleted' && x.meta.bundleDid === bundleDid);
523
+ const componentDid = componentDidValue || '';
524
+ const newConfigs = (_meta$environments = meta.environments) === null || _meta$environments === void 0 ? void 0 : _meta$environments.map(item => {
525
+ const {
526
+ name: key,
527
+ validation
528
+ } = item,
529
+ rest = _objectWithoutProperties(item, _excluded);
530
+ const formatItem = {
531
+ // if the blocklet has validation, provide the validation (fix not inStore)
532
+ validation: (0, _isNil.default)(validation) ? '' : validation
533
+ };
534
+ return _objectSpread(_objectSpread({}, rest), {}, {
535
+ key
536
+ }, formatItem);
537
+ });
538
+ component.current = _objectSpread(_objectSpread({}, chooseParams), {}, {
539
+ meta: _objectSpread(_objectSpread({}, meta), {}, {
540
+ // init configs from environments
541
+ configs: newConfigs,
542
+ registryUrl,
543
+ inStore,
544
+ inputUrl
545
+ })
546
+ });
547
+ let doc = {};
548
+
549
+ // if is init, should update configs
550
+ if (isInit) {
551
+ const ancestors = [blocklet];
552
+
553
+ // component config
554
+ const componentSelfConfigs = newConfigs || [];
555
+
556
+ // TODO: meta not include children environments/configs before install, waiting for next sprint to design
557
+ const componentChildrenConfigs = [];
558
+
559
+ // eslint-disable-next-line
560
+ // chooseBlocklet?.children?.map(childBlocklet => {
561
+ // // eslint-disable-next-line no-shadow
562
+ // forEachChildSync(childBlocklet, (b, { ancestors }) => {
563
+ // const ancestorDids = ancestors.slice(1).map(x => x.meta.did);
564
+
565
+ // componentChildrenConfigs.push(
566
+ // (b.configs || []).map(x => ({ ...x, childDid: ancestorDids.concat(b.meta.did) }))
567
+ // );
568
+ // });
569
+
570
+ // return false;
571
+ // });
572
+
573
+ const componentAllConfigs = (0, _uniqBy.default)((0, _flatten.default)([...componentSelfConfigs, ...componentChildrenConfigs]), 'key').filter(x => !!x.key).sort((a, b) => {
574
+ if (a.required && !b.required) {
575
+ return -1;
576
+ }
577
+ if (b.required && !a.required) {
578
+ return 1;
579
+ }
580
+ return 0;
581
+ });
582
+ const sharedConfigObj = (0, _util.getSharedConfigObj)(ancestors[0], {
583
+ configs: componentAllConfigs
584
+ });
585
+ const configsValue = {};
586
+ const configsList = componentAllConfigs.map(item => {
587
+ const {
588
+ default: defaultValue,
589
+ key
590
+ } = item,
591
+ rest = _objectWithoutProperties(item, _excluded2);
592
+ configsValue[key] = sharedConfigObj[key] || defaultValue;
593
+ return _objectSpread(_objectSpread({}, rest), {}, {
594
+ key,
595
+ hidden: !!_constant.BLOCKLET_CONFIGURABLE_KEY[key]
596
+ });
597
+ });
598
+ doc = _objectSpread(_objectSpread({}, doc), {}, {
599
+ configsList,
600
+ configsValue,
601
+ hasMissRequiredConfigs: hasMissRequiredConfigs(configsList, configsValue)
602
+ });
603
+ }
604
+ const hasRootPath = blocklet.children.some(x => x.mountPoint === '/');
605
+
606
+ // use deleted history
607
+ const config = list.find(x => x.meta.bundleDid === bundleDid);
608
+ if (config) {
609
+ doc = _objectSpread(_objectSpread({}, doc), {}, {
610
+ pathPrefix: config.mountPoint || '',
611
+ title: title || '',
612
+ componentName: config.meta.name,
613
+ // use history's environments
614
+ hasEnvironmentsStep: false
615
+ });
616
+ } else {
617
+ var _component$current$me, _component$current$me2;
618
+ doc = _objectSpread(_objectSpread({}, doc), {}, {
619
+ pathPrefix: hasRootPath ? "/".concat((0, _urlPathFriendly.default)(title) || (0, _urlPathFriendly.default)(name)) : '/',
620
+ title: title || '',
621
+ componentName: '',
622
+ hasEnvironmentsStep: ((_component$current$me = component.current.meta) === null || _component$current$me === void 0 ? void 0 : (_component$current$me2 = _component$current$me.environments) === null || _component$current$me2 === void 0 ? void 0 : _component$current$me2.length) > 0
623
+ });
624
+ }
625
+
626
+ // eslint-disable-next-line no-shadow
627
+ const componentRequirePurchase = requirePurchase(component.current.meta);
628
+ const componentDIDSpaceCapability = getDIDSpaceCapability(component.current.meta);
629
+ const didSpaceEndpoint = getDIDSpaceEndpoint(blocklet);
630
+ updateParams(_objectSpread(_objectSpread({
631
+ bundleDid,
632
+ componentDid
633
+ }, doc), {}, {
634
+ hasRequiredEnvironments: hasRequiredEnvironments(component.current.meta),
635
+ requirePurchase: componentRequirePurchase,
636
+ didSpaceCapability: componentDIDSpaceCapability,
637
+ didSpaceEndpoint
638
+ }));
639
+ if (isInit && componentRequirePurchase) {
640
+ onGeneratePurchaseData();
641
+ }
642
+ };
643
+ const steps = [{
644
+ key: 'selectComponent',
645
+ name: t('blocklet.component.selectComponent'),
646
+ body: /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
647
+ component: "div",
648
+ children: [params.showFromUrlDialog && /*#__PURE__*/(0, _jsxRuntime.jsx)(_installFromUrl.default
649
+ // if not set defaultUrl, the dialog will always show step 1 when the dialog is opened
650
+ // defaultUrl={meta?.inputUrl}
651
+ , {
652
+ mode: "component",
653
+ onCancel: () => {
654
+ updateParams({
655
+ showFromUrlDialog: false
656
+ });
657
+ }
658
+ // eslint-disable-next-line no-shadow
659
+ ,
660
+ onSuccess: _ref6 => {
661
+ let {
662
+ meta,
663
+ inputUrl,
664
+ inStore,
665
+ registryUrl
666
+ } = _ref6;
667
+ setConfigValue({
668
+ chooseParams: {
669
+ meta,
670
+ inputUrl,
671
+ inStore,
672
+ registryUrl
673
+ },
674
+ isInit: true
675
+ });
676
+ updateParams({
677
+ showFromUrlDialog: false
678
+ });
679
+ onNext();
680
+ },
681
+ handleText: {
682
+ title: t('blocklet.component.addComponentTip.fromUrl'),
683
+ confirm: t('blocklet.component.choose')
684
+ }
685
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_selectStore.default, {
686
+ stores: stores,
687
+ extra: !isServerlessMode ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
688
+ variant: "text",
689
+ color: "primary",
690
+ "data-cy": "add-component-from-url",
691
+ onClick: () => {
692
+ updateParams({
693
+ showFromUrlDialog: true
694
+ });
695
+ },
696
+ style: {
697
+ padding: '0 2px'
698
+ },
699
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Link.default, {
700
+ style: {
701
+ fontSize: 20,
702
+ marginRight: 4
703
+ }
704
+ }), " ", t('blocklet.component.addComponentTip.fromUrl'), ' ']
705
+ }) : null,
706
+ loading: loading,
707
+ onChange: () => {
708
+ setParams({});
709
+ component.current = {};
710
+ },
711
+ storageKey: storageKey,
712
+ children: _ref7 => {
713
+ let {
714
+ currentRegistry
715
+ } = _ref7;
716
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_storeBlockletList.default, {
717
+ serverVersion: nodeInfo === null || nodeInfo === void 0 ? void 0 : nodeInfo.version,
718
+ style: isMobile ? {
719
+ // should remove other dom height/margin
720
+ height: 'calc(100vh - 56px - 80px - 32px - 40px )'
721
+ } : {
722
+ height: 'calc(100% - 40px)'
723
+ },
724
+ storeUrl: currentRegistry.url,
725
+ resourceType: resourceType,
726
+ handleButtonClick: chooseParams => {
727
+ setConfigValue({
728
+ chooseParams: _objectSpread(_objectSpread({}, chooseParams), {}, {
729
+ inStore: true // choose from store, must be inStore
730
+ }),
731
+
732
+ isInit: true
733
+ });
734
+ },
735
+ handleBlockletRender: _ref8 => {
736
+ let {
737
+ blocklet: blockletItem,
738
+ defaultRender
739
+ } = _ref8;
740
+ const isChosen = (params === null || params === void 0 ? void 0 : params.bundleDid) && (params === null || params === void 0 ? void 0 : params.bundleDid) === (blockletItem === null || blockletItem === void 0 ? void 0 : blockletItem.did);
741
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StoreBlockletItemWrapper, {
742
+ children: [isChosen && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
743
+ className: "check-container",
744
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Check.default, {
745
+ className: "check-icon"
746
+ })
747
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
748
+ className: isChosen ? 'choose-blocklet' : '',
749
+ style: {
750
+ marginLeft: 16
751
+ },
752
+ children: defaultRender
753
+ })]
754
+ });
755
+ }
756
+ });
757
+ }
758
+ })]
759
+ }),
760
+ cancel: mode === 'embed' ? undefined : t('common.cancel'),
761
+ confirm: getConfirmText({
762
+ params,
763
+ blocklet,
764
+ t
765
+ }),
766
+ onCancel: onOver,
767
+ onConfirm: () => {
768
+ onNext();
769
+ }
770
+ }, {
771
+ key: 'agreement',
772
+ name: t('launchBlocklet.introduction'),
773
+ body: /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
774
+ component: "div",
775
+ className: "agreement-wrapper",
776
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_pageHeader.default, {
777
+ title: t('launchBlocklet.introduction'),
778
+ subTitle: t('blocklet.component.addComponentTip.introduction')
779
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_agreement.default, {
780
+ meta: meta,
781
+ onClickNext: onNext,
782
+ handleDescEle: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
783
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
784
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
785
+ // eslint-disable-next-line
786
+ dangerouslySetInnerHTML: {
787
+ __html: t("blocklet.component.addComponentTip.".concat(params.requirePurchase ? 'isPurchase' : 'isFree'), {
788
+ name: getComponentName()
789
+ })
790
+ }
791
+ })
792
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
793
+ children: t('blocklet.component.addComponentTip.belowInformation')
794
+ })]
795
+ })
796
+ })]
797
+ }),
798
+ cancel: t('common.pre'),
799
+ confirm: t('launchBlocklet.next'),
800
+ onCancel: _onCancel,
801
+ onConfirm: () => {
802
+ setIsWaitingPurchase(false);
803
+ onNext();
804
+ }
805
+ }, meta && params.requirePurchase && {
806
+ key: 'purchase',
807
+ name: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
808
+ children: [t('common.verifyNFT'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_required.default, {})]
809
+ }),
810
+ body: /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
811
+ component: "div",
812
+ className: "flex-align-center",
813
+ style: {
814
+ flexDirection: 'column'
815
+ },
816
+ children: [!(((_purchaseRef$current = purchaseRef.current) === null || _purchaseRef$current === void 0 ? void 0 : (_purchaseRef$current$ = _purchaseRef$current.getCurrentStep) === null || _purchaseRef$current$ === void 0 ? void 0 : _purchaseRef$current$.call(_purchaseRef$current)) === 2 || isWaitingPurchase) && /*#__PURE__*/(0, _jsxRuntime.jsx)(PageHeaderWrapper, {
817
+ title: t('common.verifyNFT'),
818
+ subTitle: t('blocklet.component.addComponentTip.verifyNFT')
819
+ }), !(0, _isEmpty.default)(params.purchaseResultProps) ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
820
+ className: "flex-align-center flex-justify-center",
821
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_launchResultMessage.default, _objectSpread({}, params.purchaseResultProps))
822
+ }) : purchaseData && /*#__PURE__*/(0, _jsxRuntime.jsx)(_purchase.ComponentPurchaseSelect, {
823
+ ref: purchaseRef,
824
+ meta: purchaseData.meta
825
+ // if select deleted history, use verify mode
826
+ ,
827
+ mode: params.componentDid ? 'verify' : 'both',
828
+ onCancel: onCancelPurchase,
829
+ installOpts: purchaseData.installOpts,
830
+ handlePaySuccess: onSuccessPurchase
831
+ })]
832
+ }),
833
+ disabled: ((_purchaseRef$current2 = purchaseRef.current) === null || _purchaseRef$current2 === void 0 ? void 0 : (_purchaseRef$current3 = _purchaseRef$current2.getCurrentStep) === null || _purchaseRef$current3 === void 0 ? void 0 : _purchaseRef$current3.call(_purchaseRef$current2)) === 2 || isWaitingPurchase,
834
+ cancel: t('common.pre'),
835
+ confirm: t('common.next'),
836
+ onConfirm: () => {
837
+ if (typeof purchaseRef.current.onNext === 'function') {
838
+ purchaseRef.current.onNext();
839
+ setIsWaitingPurchase(true);
840
+ }
841
+ },
842
+ onCancel: () => {
843
+ _onCancel();
844
+ }
845
+ }, (0, _util.hasStartEngine)(meta) && {
846
+ key: 'config',
847
+ name: t('common.config'),
848
+ error,
849
+ body: /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
850
+ component: "div",
851
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PageHeaderWrapper, {
852
+ title: t('common.config'),
853
+ subTitle: t('blocklet.component.addComponentTip.config')
854
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
855
+ label: t('blocklet.component.mountPoint'),
856
+ autoComplete: "off",
857
+ variant: "outlined",
858
+ name: "pathPrefix",
859
+ inputProps: {
860
+ 'data-cy': 'mount-point-input'
861
+ },
862
+ fullWidth: true,
863
+ helperText: mountPointHelperText || t('blocklet.component.mountPointTip'),
864
+ style: {
865
+ marginBottom: 32
866
+ },
867
+ margin: "normal",
868
+ value: params.pathPrefix,
869
+ onChange: e => {
870
+ const pathPrefix = e.target.value;
871
+ updateParams({
872
+ pathPrefix
873
+ });
874
+ setMountPointHelperText(t('common.slugifyHint', {
875
+ value: (0, _util2.formatMountPoint)(pathPrefix)
876
+ }));
877
+ }
878
+ }), !!error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
879
+ type: "error",
880
+ style: {
881
+ width: '100%',
882
+ marginTop: 8
883
+ },
884
+ children: error
885
+ })]
886
+ }),
887
+ cancel: t('common.pre'),
888
+ confirm: t('common.next'),
889
+ onCancel: _onCancel,
890
+ onConfirm: () => {
891
+ onNext();
892
+ }
893
+ }, meta && (params === null || params === void 0 ? void 0 : params.hasEnvironmentsStep) && {
894
+ key: 'environment',
895
+ name: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
896
+ children: [t('common.environment'), " ", params.hasRequiredEnvironments && /*#__PURE__*/(0, _jsxRuntime.jsx)(_required.default, {})]
897
+ }),
898
+ disabled: !!editingItem || (params === null || params === void 0 ? void 0 : params.hasMissRequiredConfigs),
899
+ body: () => {
900
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
901
+ component: "div",
902
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PageHeaderWrapper, {
903
+ title: t('common.environment'),
904
+ subTitle: t('blocklet.component.addComponentTip.environment')
905
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_schemaForm.default, {
906
+ style: {
907
+ marginTop: -12,
908
+ width: '100%'
909
+ },
910
+ schema: params.configsList,
911
+ defaultValue: params.configsValue
912
+ // eslint-disable-next-line
913
+ ,
914
+ onChange: (changeValue, _ref9) => {
915
+ let {
916
+ action,
917
+ currentItem,
918
+ allValues
919
+ } = _ref9;
920
+ if (action === 'confirm') {
921
+ updateParams({
922
+ hasMissRequiredConfigs: hasMissRequiredConfigs(params.configsList, allValues),
923
+ configsValue: allValues
924
+ });
925
+ }
926
+ if (action === 'edit') {
927
+ setEditingItem(currentItem);
928
+ } else if (['cancel', 'confirm'].includes(action)) {
929
+ setEditingItem(null);
930
+ }
931
+ }
932
+ })]
933
+ });
934
+ },
935
+ cancel: t('common.pre'),
936
+ confirm: t('common.next'),
937
+ onCancel: _onCancel,
938
+ onConfirm: onNext
939
+ }, meta && (params === null || params === void 0 ? void 0 : params.didSpaceCapability) && {
940
+ key: 'didSpace',
941
+ name: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
942
+ children: [t('blocklet.component.didSpaceConfig'), " ", params.didSpaceCapability === 'required' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_required.default, {})]
943
+ }),
944
+ disabled: params.didSpaceCapability === 'required' && !params.didSpaceEndpoint,
945
+ body: () => {
946
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(TypographyWrapper, {
947
+ component: "div",
948
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PageHeaderWrapper, {
949
+ title: t('blocklet.component.didSpaceConfig'),
950
+ subTitle: t('blocklet.component.didSpaceConfigTip')
951
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
952
+ sx: {
953
+ mt: '36px',
954
+ '& > div': {
955
+ maxWidth: 'unset !important',
956
+ '& .MuiAutocomplete-root': {
957
+ maxWidth: 'unset !important'
958
+ }
959
+ }
960
+ },
961
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_spaceConnector.default, {
962
+ sx: {
963
+ '& .MuiFormHelperText-root': {
964
+ wordBreak: 'break-all'
965
+ }
966
+ },
967
+ helperText: params.didSpaceEndpoint && t('blocklet.component.didSpaceConnected', {
968
+ endpoint: params.didSpaceEndpoint
969
+ }),
970
+ onConnect: () => {
971
+ onNext();
972
+ }
973
+ })
974
+ })]
975
+ });
976
+ },
977
+ cancel: t('common.pre'),
978
+ confirm: t('common.next'),
979
+ onCancel: _onCancel,
980
+ onConfirm: onNext
981
+ }, {
982
+ key: 'install',
983
+ name: t('common.install'),
984
+ disabled: false,
985
+ loading: false,
986
+ body: /*#__PURE__*/(0, _jsxRuntime.jsx)(TypographyWrapper, {
987
+ component: "div",
988
+ className: "flex-justify-center flex-align-center",
989
+ style: {
990
+ flexDirection: 'column'
991
+ },
992
+ children: (0, _isEmpty.default)(params.installResultProps) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_AnimationWaiter.default, {
993
+ message: /*#__PURE__*/(0, _jsxRuntime.jsx)(MessageDiv, {
994
+ children: t('blocklet.component.installingCanCloseWindowTip')
995
+ }),
996
+ increaseSpeed: 0.3,
997
+ messageLoop: false
998
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
999
+ style: {
1000
+ marginTop: 120
1001
+ },
1002
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_launchResultMessage.default, _objectSpread({}, params.installResultProps))
1003
+ })
1004
+ }),
1005
+ confirm: t('common.complete'),
1006
+ onConfirm: () => {
1007
+ postInstalledMessage(routerParams.componentDid);
1008
+ onOver();
1009
+ // scroll to bottom
1010
+ setTimeout(() => {
1011
+ const scrollDom = document.getElementsByClassName('dashboard-main')[0];
1012
+ if (scrollDom) {
1013
+ scrollDom.scrollTop = scrollDom.scrollHeight;
1014
+ }
1015
+ }, 200);
1016
+ }
1017
+ }].filter(item => item);
1018
+ const step = steps[activeStep] || {};
1019
+ const isDisabled = () => {
1020
+ if (loading || step.error || !params.bundleDid) {
1021
+ return true;
1022
+ }
1023
+
1024
+ // after select component and confirm license
1025
+ if (activeStep > 1) {
1026
+ return !params.pathPrefix;
1027
+ }
1028
+ return false;
1029
+ };
1030
+ if (!blocklet) {
1031
+ return null;
1032
+ }
1033
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, {
1034
+ sx: isMobile ? {
1035
+ width: '100%',
1036
+ height: window.innerHeight
1037
+ } : {
1038
+ width: '100%',
1039
+ height: mode === 'embed' ? '100vh' : '72vh'
1040
+ },
1041
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_step.StepProvider, {
1042
+ steps: steps,
1043
+ mode: "memory",
1044
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StepContent, {
1045
+ ref: stepRef,
1046
+ meta: meta,
1047
+ isMobile: isMobile,
1048
+ onStepChange: newStep => {
1049
+ setActiveStep(newStep);
1050
+ }
1051
+ })
1052
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
1053
+ className: "action-bar",
1054
+ children: [step.cancel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
1055
+ onClick: e => {
1056
+ e.stopPropagation();
1057
+ step.onCancel();
1058
+ },
1059
+ disabled: activeStep === steps.length - 2 && loading,
1060
+ color: "inherit",
1061
+ children: step.cancel || t('common.cancel')
1062
+ }), step.confirm && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
1063
+ onClick: e => {
1064
+ e.stopPropagation();
1065
+ step.onConfirm();
1066
+ },
1067
+ color: "primary",
1068
+ "data-cy": "submit-confirm-next",
1069
+ disabled: loading || (typeof step.disabled === 'boolean' ? step.disabled : isDisabled()),
1070
+ variant: "contained",
1071
+ autoFocus: true,
1072
+ title: step.confirm,
1073
+ style: {
1074
+ marginLeft: 8,
1075
+ overflow: 'hidden',
1076
+ textOverflow: 'ellipsis',
1077
+ whiteSpace: 'nowrap',
1078
+ minWidth: '140px',
1079
+ maxWidth: '280px',
1080
+ textAlign: 'center'
1081
+ },
1082
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
1083
+ display: "flex",
1084
+ alignItems: "center",
1085
+ children: [(typeof step.loading === 'boolean' ? step.loading : loading) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
1086
+ style: {
1087
+ marginRight: 8
1088
+ },
1089
+ size: 16
1090
+ }), step.confirm]
1091
+ })
1092
+ })]
1093
+ })]
1094
+ });
1095
+ }
1096
+ AddComponentCore.propTypes = {
1097
+ onClose: _propTypes.default.func,
1098
+ mode: _propTypes.default.oneOf(['normal', 'embed']),
1099
+ stores: _propTypes.default.arrayOf(_propTypes.default.string),
1100
+ resourceType: _propTypes.default.string,
1101
+ storageKey: _propTypes.default.string
1102
+ };
1103
+ AddComponentCore.defaultProps = {
1104
+ onClose: () => {},
1105
+ mode: 'normal',
1106
+ stores: [],
1107
+ resourceType: '',
1108
+ storageKey: ''
1109
+ };
1110
+ const Wrapper = (0, _styled.default)(_Box.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .action-bar {\n display: flex;\n justify-content: flex-end;\n position: sticky;\n bottom: 0;\n padding-top: 16px;\n z-index: 100;\n width: 100%;\n background: #fff;\n border-top: 1px solid #eee;\n }\n"])));
1111
+ const TypographyWrapper = (0, _styled.default)(_Typography.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n"])));
1112
+ const RightContent = _styled.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: flex-start;\n\n .bottom-button {\n min-width: 200px;\n }\n\n // blocklet-select-side\n aside {\n width: 140px;\n }\n"])));
1113
+ const isMobileContent = props => {
1114
+ if (props.isMobile) {
1115
+ return "\n height: calc(100vh - 56px - 64px - 48px);\n ";
1116
+ }
1117
+ return '';
1118
+ };
1119
+ const ContentWrapper = (0, _styled.default)(_Box.default)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n\n & .flex-justify-center {\n display: flex;\n justify-content: center;\n }\n\n & .flex-align-center {\n display: flex;\n height: 100%;\n align-items: center;\n ", "\n }\n\n & .agreement-wrapper {\n ", "\n max-height: 60vh;\n .eula-trigger {\n padding-right: 0;\n }\n .next-button {\n display: none;\n }\n }\n\n & .connect {\n background: white;\n }\n"])), _ref10 => {
1120
+ let {
1121
+ className
1122
+ } = _ref10;
1123
+ // mobile extra style
1124
+ if (className === 'mobileStyle') {
1125
+ return "\n & > div{\n height: 100%;\n }\n .root-header {\n .app-name-content {\n display: none;\n }\n }\n\n\n\n // content-panel\n .root-header + div{\n padding-top: 0;\n position: relative;\n & > div {\n padding-top: 0;\n }\n }\n\n header + div {\n padding-top: 0;\n }\n\n header {\n .header-title {\n margin-left: 0;\n }\n\n .header-title-name {\n max-width: 100% !important;\n }\n }\n ";
1126
+ }
1127
+ return "\n position: relative;\n .root-header {\n z-index: auto !important;\n position: fixed !important;\n }\n & > div {\n height: 100%;\n width: 100%;\n max-width: 100%;\n & > div {\n max-height: unset !important;\n max-width: 100%;\n & > div {\n // left-panel\n &:first-child {\n padding: 0;\n width: 25%;\n min-width: 240px;\n & > div:first-child {\n display: none;\n }\n // step\n & > div:last-child {\n // margin-top: 32px;\n margin-top: 0;\n }\n }\n // right-panel\n &:last-child {\n padding-top: 0;\n padding-right: 0px;\n overflow-y: auto;\n .app-content {\n padding: 0 0 24px 0;\n }\n .button-container {\n padding-right: 0;\n }\n }\n }\n }\n }\n\n ";
1128
+ }, props => isMobileContent(props), props => isMobileContent(props));
1129
+ const PageHeaderWrapper = (0, _styled.default)(_pageHeader.default)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin-bottom: 24px;\n"])));
1130
+ const StoreBlockletItemWrapper = _styled.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n\n .choose-blocklet {\n background-color: rgb(236, 251, 253);\n border-color: rgb(236, 251, 253);\n border-radius: 8px;\n }\n\n .check-container {\n position: absolute;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: flex-end;\n align-items: flex-end;\n width: 30px;\n height: 30px;\n border-radius: 0 0 8px 0;\n color: ", ";\n overflow: hidden;\n transition: all ease 0.3s;\n &:after {\n position: absolute;\n z-index: 0;\n display: block;\n width: 0;\n height: 0;\n border-top: transparent solid 15px;\n border-left: transparent solid 15px;\n border-bottom: ", " solid 15px;\n border-right: ", " solid 15px;\n transition: all ease 0.1s;\n content: '';\n }\n\n .check-icon {\n position: relative;\n z-index: 2;\n margin: 0 1px 1px 0;\n font-size: 16px;\n transition: all ease 0.2s;\n }\n }\n"])), props => props.theme.palette.common.white, props => props.theme.palette.primary.main, props => props.theme.palette.primary.main);
1131
+ const MessageDiv = _styled.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n color: ", ";\n .msg-before {\n display: inline-block;\n color: #aaa;\n font-size: 14px;\n margin-right: 6px;\n }\n"])), props => props.theme.palette.primary.main);