@bigbinary/neeto-themes-frontend 4.0.25 → 4.0.27

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,2621 @@
1
+ 'use strict';
2
+
3
+ var shallow = require('zustand/shallow');
4
+ var react = require('react');
5
+ var neetoAtoms = require('@bigbinary/neeto-atoms');
6
+ var neetoCist = require('@bigbinary/neeto-cist');
7
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/v2/react-utils');
8
+ var reactI18next = require('react-i18next');
9
+ var useGlobalThemesApi = require('../../useGlobalThemesApi-DOH4EK5Q.js');
10
+ var useExpandedSection = require('../../useExpandedSection-GpzbAxmE.js');
11
+ var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
12
+ var _regeneratorRuntime = require('@babel/runtime/regenerator');
13
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
14
+ var classnames = require('classnames');
15
+ var utils$1 = require('@bigbinary/neeto-commons-frontend/v2/utils');
16
+ var Collapse = require('@bigbinary/neeto-icons/Collapse');
17
+ var reactRouterDom = require('react-router-dom');
18
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
19
+ var formik$1 = require('@bigbinary/neeto-atoms/formik');
20
+ var Close = require('@bigbinary/neeto-icons/Close');
21
+ var ramda = require('ramda');
22
+ var i18n = require('i18next');
23
+ var yup = require('yup');
24
+ var formik = require('formik');
25
+ var utils = require('../../index-BUeeI0XI.js');
26
+ var jsxRuntime = require('react/jsx-runtime');
27
+ var Right = require('@bigbinary/neeto-icons/Right');
28
+ var Left = require('@bigbinary/neeto-icons/Left');
29
+ var HelpPopover = require('@bigbinary/neeto-molecules/v2/HelpPopover');
30
+ var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
31
+ var reactDom = require('react-dom');
32
+ var CenterAlign = require('@bigbinary/neeto-icons/CenterAlign');
33
+ var LeftAlign = require('@bigbinary/neeto-icons/LeftAlign');
34
+ var antd = require('antd');
35
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
36
+ var ImageUploader = require('@bigbinary/neeto-image-uploader-frontend/v2/ImageUploader');
37
+ var Search = require('@bigbinary/neeto-molecules/v2/Search');
38
+ var AddImage = require('@bigbinary/neeto-icons/AddImage');
39
+ var CodeBlock = require('@bigbinary/neeto-icons/CodeBlock');
40
+ var ColorPicker = require('@bigbinary/neeto-icons/ColorPicker');
41
+ var MoreDropdown = require('@bigbinary/neeto-molecules/v2/MoreDropdown');
42
+ var LeftArrow = require('@bigbinary/neeto-icons/LeftArrow');
43
+ var RightArrow = require('@bigbinary/neeto-icons/RightArrow');
44
+ var Search$1 = require('@bigbinary/neeto-icons/Search');
45
+ require('@tanstack/react-query');
46
+ require('axios');
47
+ require('@bigbinary/neeto-commons-frontend/react-utils');
48
+ require('zustand');
49
+ require('@bigbinary/neetoui/Toastr');
50
+
51
+ function _interopNamespaceDefault(e) {
52
+ var n = Object.create(null);
53
+ if (e) {
54
+ Object.keys(e).forEach(function (k) {
55
+ if (k !== 'default') {
56
+ var d = Object.getOwnPropertyDescriptor(e, k);
57
+ Object.defineProperty(n, k, d.get ? d : {
58
+ enumerable: true,
59
+ get: function () { return e[k]; }
60
+ });
61
+ }
62
+ });
63
+ }
64
+ n.default = e;
65
+ return Object.freeze(n);
66
+ }
67
+
68
+ var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
69
+
70
+ var getImageFromUrl = function getImageFromUrl(source) {
71
+ var image = new Image();
72
+ image.crossOrigin = "anonymous";
73
+ image.src = source;
74
+ return new Promise(function (resolve) {
75
+ image.onload = function () {
76
+ resolve(image);
77
+ };
78
+ });
79
+ };
80
+ var getDominantColorFromUrl = /*#__PURE__*/function () {
81
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(imageUrl) {
82
+ var image, context, c;
83
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
84
+ while (1) switch (_context.prev = _context.next) {
85
+ case 0:
86
+ _context.prev = 0;
87
+ _context.next = 3;
88
+ return getImageFromUrl(imageUrl);
89
+ case 3:
90
+ image = _context.sent;
91
+ context = document.createElement("canvas").getContext("2d");
92
+ context === null || context === void 0 || context.drawImage(image, 0, 0, 1, 1);
93
+ c = context === null || context === void 0 ? void 0 : context.getImageData(0, 0, 1, 1).data;
94
+ if (!c) {
95
+ _context.next = 9;
96
+ break;
97
+ }
98
+ return _context.abrupt("return", "#".concat(((1 << 24) + (c[0] << 16) + (c[1] << 8) + c[2]).toString(16).slice(1)));
99
+ case 9:
100
+ return _context.abrupt("return", null);
101
+ case 12:
102
+ _context.prev = 12;
103
+ _context.t0 = _context["catch"](0);
104
+ neetoAtoms.Toastr.error(_context.t0);
105
+ return _context.abrupt("return", null);
106
+ case 16:
107
+ case "end":
108
+ return _context.stop();
109
+ }
110
+ }, _callee, null, [[0, 12]]);
111
+ }));
112
+ return function getDominantColorFromUrl(_x) {
113
+ return _ref.apply(this, arguments);
114
+ };
115
+ }();
116
+ var scrollElementIntoView = function scrollElementIntoView(elementId) {
117
+ var elementToScroll = document.getElementById(elementId);
118
+ var sidebarContainer = document.querySelector(".neeto-themes-sidebar__scroll");
119
+ if (!elementToScroll || !sidebarContainer) return;
120
+ var elementRect = elementToScroll.getBoundingClientRect();
121
+ var sidebarContainerRect = sidebarContainer.getBoundingClientRect();
122
+ var offset = elementRect.top - sidebarContainerRect.top + sidebarContainer.scrollTop;
123
+ sidebarContainer.scrollTo({
124
+ top: offset,
125
+ behavior: "smooth"
126
+ });
127
+ };
128
+ var isFunction = function isFunction(obj) {
129
+ return typeof obj === "function";
130
+ };
131
+ var isNewThemeRoute = function isNewThemeRoute() {
132
+ return location.pathname.endsWith("new");
133
+ };
134
+ var isEditThemeRoute = function isEditThemeRoute() {
135
+ return location.pathname.endsWith("edit");
136
+ };
137
+
138
+ // Keeps the spinner visible a bit longer so the apply feels deliberate,
139
+ // before the card glides into the pinned active section.
140
+ var APPLY_SPINNER_DELAY = 900;
141
+
142
+ var POSITION_OPTIONS = [{
143
+ label: "Left",
144
+ value: "left"
145
+ }, {
146
+ label: "Right",
147
+ value: "right"
148
+ }];
149
+ var FONT_OPTIONS = [{
150
+ label: "System UI",
151
+ value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
152
+ }, {
153
+ label: "Cedarville Cursive",
154
+ value: "'Cedarville Cursive', cursive"
155
+ }, {
156
+ label: "Poppins",
157
+ value: "Poppins, sans-serif"
158
+ }, {
159
+ label: "Roboto",
160
+ value: "Roboto, sans-serif"
161
+ }, {
162
+ label: "Open Sans",
163
+ value: "Open Sans, sans-serif"
164
+ }, {
165
+ label: "Montserrat",
166
+ value: "Montserrat, sans-serif"
167
+ }, {
168
+ label: "Raleway",
169
+ value: "Raleway, sans-serif"
170
+ }, {
171
+ label: "Quicksand",
172
+ value: "Quicksand, sans-serif"
173
+ }, {
174
+ label: "Inter",
175
+ value: "Inter, sans-serif"
176
+ }, {
177
+ label: "Satoshi",
178
+ value: "Satoshi, sans-serif"
179
+ }, {
180
+ label: "Chillax",
181
+ value: "Chillax, sans-serif"
182
+ }, {
183
+ label: "Clash Display",
184
+ value: "Clash Display, sans-serif"
185
+ }, {
186
+ label: "General Sans",
187
+ value: "General Sans, sans-serif"
188
+ }, {
189
+ label: "Cabinet Grotesk",
190
+ value: "Cabinet Grotesk, sans-serif"
191
+ }, {
192
+ label: "Lora",
193
+ value: "Lora, serif"
194
+ }, {
195
+ label: "Merriweather",
196
+ value: "Merriweather, serif"
197
+ }, {
198
+ label: "Boska",
199
+ value: "Boska, serif"
200
+ }, {
201
+ label: "Playfair Display",
202
+ value: "Playfair Display, serif"
203
+ }, {
204
+ label: "Roboto Slab",
205
+ value: "Roboto Slab, serif"
206
+ }, {
207
+ label: "Dancing Script",
208
+ value: "Dancing Script, cursive"
209
+ }, {
210
+ label: "Tw Cent",
211
+ value: "Tw Cen MT, Tahoma, sans-serif"
212
+ }, {
213
+ label: "Comic Sans",
214
+ value: "Comic Sans MS, cursive"
215
+ }];
216
+ var THEME_VALIDATION_SCHEMA = yup__namespace.object().shape({
217
+ name: yup__namespace.string().required(function () {
218
+ return i18n.t("neetoThemes.validations.nameRequired");
219
+ }),
220
+ properties: yup__namespace.array().of(yup__namespace.object().shape({
221
+ key: yup__namespace.string(),
222
+ value: yup__namespace.string().when("key", {
223
+ is: function is(key) {
224
+ return key === null || key === void 0 ? void 0 : key.endsWith("_url");
225
+ },
226
+ then: function then(schema) {
227
+ return schema.url(function () {
228
+ return i18n.t("neetoThemes.validations.invalidUrl");
229
+ });
230
+ }
231
+ })
232
+ }))
233
+ });
234
+ var OVERLAY_OPACITY_SLIDER_MARKS = {
235
+ 0: " "
236
+ };
237
+ var HUNDRED = 100;
238
+
239
+ var DESIGN_SCREENS = {
240
+ THEMES: "Themes",
241
+ Customize: "Customize",
242
+ CustomCSS: "CustomCSS"
243
+ };
244
+ var ONE_MEGABYTE = 1;
245
+
246
+ var MonacoEditor = /*#__PURE__*/react.lazy(function () {
247
+ return import('@monaco-editor/react');
248
+ });
249
+ var Editor = function Editor(_ref) {
250
+ var value = _ref.value,
251
+ isCustomCssScreen = _ref.isCustomCssScreen,
252
+ onChange = _ref.onChange;
253
+ return /*#__PURE__*/jsxRuntime.jsx(react.Suspense, {
254
+ fallback: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Spinner, {}),
255
+ children: /*#__PURE__*/jsxRuntime.jsx(MonacoEditor, {
256
+ onChange: onChange,
257
+ value: value,
258
+ language: "css",
259
+ theme: "vs-dark",
260
+ className: classnames({
261
+ rounded: true,
262
+ "css-editor-height__expanded": isCustomCssScreen,
263
+ "css-editor-height__regular": !isCustomCssScreen
264
+ }),
265
+ options: {
266
+ scrollBeyondLastLine: false,
267
+ minimap: {
268
+ enabled: false
269
+ }
270
+ }
271
+ })
272
+ });
273
+ };
274
+
275
+ function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
276
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
277
+ var Card$2 = function Card(_ref) {
278
+ var _ref$title = _ref.title,
279
+ title = _ref$title === void 0 ? "" : _ref$title,
280
+ children = _ref.children,
281
+ name = _ref.name,
282
+ className = _ref.className,
283
+ helpPopoverProps = _ref.helpPopoverProps,
284
+ required = _ref.required;
285
+ var _useExpandedSection = useExpandedSection.useExpandedSection(),
286
+ expandedSection = _useExpandedSection.expandedSection,
287
+ setExpandedSection = _useExpandedSection.setExpandedSection;
288
+ var isOpen = expandedSection === name;
289
+ var isRTL = i18n.dir() === "rtl";
290
+ var ToggleIcon = isRTL ? Left : Right;
291
+ var handleToggle = function handleToggle() {
292
+ return setExpandedSection(isOpen ? "" : name);
293
+ };
294
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
295
+ "data-testid": "theme-".concat(neetoCist.hyphenate(title), "-properties"),
296
+ className: classnames("neeto-themes-nano-section border-border border-b pt-2 transition-all duration-300 last:border-none", className, {
297
+ "pb-2": !isOpen,
298
+ "pb-3": isOpen
299
+ }),
300
+ children: [title && /*#__PURE__*/jsxRuntime.jsxs("button", {
301
+ className: "neeto-themes-nano-section__title flex w-full cursor-pointer items-center justify-between px-1 py-2 focus:outline-none",
302
+ type: "button",
303
+ onClick: handleToggle,
304
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
305
+ asChild: true,
306
+ className: "flex min-w-0 grow items-center gap-2 text-start",
307
+ "data-testid": "theme-properties",
308
+ variant: "h4",
309
+ weight: "semibold",
310
+ children: /*#__PURE__*/jsxRuntime.jsxs("span", {
311
+ children: [title, required && /*#__PURE__*/jsxRuntime.jsx("span", {
312
+ "aria-hidden": true,
313
+ className: "-ms-1",
314
+ children: "*"
315
+ }), neetoCist.isPresent(helpPopoverProps) && /*#__PURE__*/jsxRuntime.jsx(HelpPopover, _objectSpread$4({}, helpPopoverProps))]
316
+ })
317
+ }), /*#__PURE__*/jsxRuntime.jsx(ToggleIcon, {
318
+ size: 20,
319
+ className: classnames("transition-all duration-300", {
320
+ "rotate-90 rtl:-rotate-90": isOpen
321
+ })
322
+ })]
323
+ }), children && /*#__PURE__*/jsxRuntime.jsx("div", {
324
+ className: classnames("neeto-themes-nano-section__content w-full space-y-3 overflow-hidden px-1 transition-all duration-300", {
325
+ "neeto-themes-nano-section__content--closed": !isOpen,
326
+ "neeto-themes-nano-section__content--open pb-1": isOpen
327
+ }),
328
+ children: children
329
+ })]
330
+ });
331
+ };
332
+
333
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
334
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); 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; } }
335
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
336
+ var isScreenCustomCSS = function isScreenCustomCSS(screen) {
337
+ return screen === DESIGN_SCREENS.CustomCSS;
338
+ };
339
+ var buildPathname = function buildPathname(route) {
340
+ var pathname = "";
341
+ var _iterator = _createForOfIteratorHelper(location.pathname.split("/")),
342
+ _step;
343
+ try {
344
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
345
+ var segment = _step.value;
346
+ if (ramda.isEmpty(segment)) {
347
+ continue;
348
+ }
349
+ if (segment === "themes") {
350
+ break;
351
+ }
352
+ pathname += "/".concat(segment);
353
+ }
354
+ } catch (err) {
355
+ _iterator.e(err);
356
+ } finally {
357
+ _iterator.f();
358
+ }
359
+ return "".concat(pathname).concat(route);
360
+ };
361
+
362
+ // FLIP: measure each theme card's position, apply the React update, then
363
+ // transform every card back to its old spot and let a CSS transition glide
364
+ // it to the new one. The animation itself is CSS (.neeto-themes-flip-animating).
365
+ var animateThemeReorder = function animateThemeReorder(updateFn) {
366
+ var prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
367
+ var cards = _toConsumableArray(document.querySelectorAll("[data-flip-id]"));
368
+ var scrollContainer = document.querySelector(".neeto-themes-sidebar__scroll");
369
+ if (prefersReducedMotion || cards.length === 0) {
370
+ updateFn();
371
+ if (scrollContainer) scrollContainer.scrollTop = 0;
372
+ return;
373
+ }
374
+ var oldRects = new Map(cards.map(function (card) {
375
+ return [card.dataset.flipId, card.getBoundingClientRect()];
376
+ }));
377
+ reactDom.flushSync(updateFn);
378
+
379
+ // Move the viewport to the top — the applied theme is now the first card.
380
+ // The FLIP deltas below are measured after this, so the scroll is folded
381
+ // into the glide instead of showing as an instant jump.
382
+ if (scrollContainer) scrollContainer.scrollTop = 0;
383
+ var flips = _toConsumableArray(document.querySelectorAll("[data-flip-id]")).map(function (card) {
384
+ var oldRect = oldRects.get(card.dataset.flipId);
385
+ if (!oldRect) return null;
386
+ var newRect = card.getBoundingClientRect();
387
+ var dx = oldRect.left - newRect.left;
388
+ var dy = oldRect.top - newRect.top;
389
+ return dx || dy ? {
390
+ card: card,
391
+ dx: dx,
392
+ dy: dy
393
+ } : null;
394
+ }).filter(Boolean);
395
+ if (flips.length === 0) return;
396
+ flips.forEach(function (_ref) {
397
+ var card = _ref.card,
398
+ dx = _ref.dx,
399
+ dy = _ref.dy;
400
+ card.style.transform = "translate(".concat(dx, "px, ").concat(dy, "px)");
401
+ });
402
+
403
+ // Force a reflow so the starting transform is committed before animating.
404
+ document.body.offsetHeight;
405
+ flips.forEach(function (_ref2) {
406
+ var card = _ref2.card;
407
+ card.classList.add("neeto-themes-flip-animating");
408
+ card.style.transform = "";
409
+ card.addEventListener("transitionend", function () {
410
+ card.classList.remove("neeto-themes-flip-animating");
411
+ }, {
412
+ once: true
413
+ });
414
+ });
415
+ };
416
+
417
+ var CustomCSS = function CustomCSS(_ref) {
418
+ var onEditCSSClick = _ref.onEditCSSClick,
419
+ currentScreen = _ref.currentScreen,
420
+ isEnabled = _ref.isEnabled,
421
+ isProFeature = _ref.isProFeature;
422
+ var _useTranslation = reactI18next.useTranslation(),
423
+ t = _useTranslation.t;
424
+ var _useFormikContext = formik.useFormikContext(),
425
+ values = _useFormikContext.values,
426
+ setFieldValue = _useFormikContext.setFieldValue;
427
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
428
+ return {
429
+ themePropertiesSchema: store["themePropertiesSchema"],
430
+ helpPopoverProps: store["helpPopoverProps"]
431
+ };
432
+ }, shallow.shallow),
433
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema,
434
+ helpPopoverProps = _useConfigStore.helpPopoverProps;
435
+ var _helpPopoverProps$cus = helpPopoverProps.customCss,
436
+ customCssHelpPopoverProps = _helpPopoverProps$cus === void 0 ? {} : _helpPopoverProps$cus;
437
+ var _useExpandedSection = useExpandedSection.useExpandedSection(),
438
+ expandedSection = _useExpandedSection.expandedSection;
439
+ var isExpanded = expandedSection === "customcss";
440
+ var customCSS = neetoCist.findBy({
441
+ kind: "custom_css"
442
+ }, values.properties);
443
+ if (!customCSS || !isEnabled && !isProFeature) return null;
444
+ var parentElementClass = neetoCist.findBy({
445
+ kind: "custom_css"
446
+ }, themePropertiesSchema).parentClass;
447
+ var isCustomCssScreen = isScreenCustomCSS(currentScreen);
448
+ var handleEditorToggle = function handleEditorToggle() {
449
+ if (!isCustomCssScreen) return onEditCSSClick(DESIGN_SCREENS.CustomCSS);
450
+ onEditCSSClick(DESIGN_SCREENS.Customize);
451
+ return setTimeout(function () {
452
+ scrollElementIntoView("css-editor");
453
+ }, 400);
454
+ };
455
+ var handleChange = function handleChange(value) {
456
+ var index = neetoCist.findIndexBy({
457
+ key: customCSS.key
458
+ }, values.properties);
459
+ if (index !== -1 && values.properties[index].value !== value) {
460
+ setFieldValue("properties[".concat(index, "].value"), value);
461
+ utils.setCustomCSS({
462
+ css: value,
463
+ elementId: customCSS.key,
464
+ parentElementClass: parentElementClass
465
+ });
466
+ }
467
+ };
468
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
469
+ className: "neeto-themes-sidebar__custom-css-wrapper",
470
+ id: "css-editor",
471
+ children: /*#__PURE__*/jsxRuntime.jsx(Card$2, {
472
+ name: "customcss",
473
+ helpPopoverProps: isEnabled ? customCssHelpPopoverProps : {
474
+ title: t("neetoThemes.common.proFeature.customCSS.title"),
475
+ description: t("neetoThemes.common.proFeature.customCSS.description")
476
+ },
477
+ title: isCustomCssScreen ? "" : t("neetoThemes.build.leftSideBar.themes.customCSS"),
478
+ children: isEnabled ? /*#__PURE__*/jsxRuntime.jsxs("div", {
479
+ className: "w-full",
480
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
481
+ className: "neeto-themes-sidebar__custom-css-editor-header w-full justify-end gap-1 rounded-b-none p-2",
482
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
483
+ size: "sm",
484
+ variant: "outline",
485
+ label: isCustomCssScreen ? t("neetoThemes.buttons.minimizeEditor") : t("neetoThemes.buttons.expandEditor"),
486
+ onClick: handleEditorToggle
487
+ })
488
+ }), isExpanded && /*#__PURE__*/jsxRuntime.jsx(Editor, {
489
+ isCustomCssScreen: isCustomCssScreen,
490
+ value: customCSS.value,
491
+ onChange: handleChange
492
+ })]
493
+ }) : /*#__PURE__*/jsxRuntime.jsx("div", {
494
+ className: "px-1 py-2",
495
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
496
+ variant: "body2",
497
+ children: t("neetoThemes.common.proFeature.customCSS.description")
498
+ })
499
+ })
500
+ })
501
+ });
502
+ };
503
+
504
+ var LogoPosition = function LogoPosition() {
505
+ var _useTranslation = reactI18next.useTranslation(),
506
+ t = _useTranslation.t;
507
+ var _useFormikContext = formik.useFormikContext(),
508
+ values = _useFormikContext.values;
509
+ var index = neetoCist.findIndexBy({
510
+ key: "logo_position"
511
+ }, values.properties);
512
+ // Do not show this field if the logo_position property is not present.
513
+ if (index === -1) return null;
514
+ return /*#__PURE__*/jsxRuntime.jsxs(formik$1.RadioGroup, {
515
+ name: "properties[".concat(index, "].value"),
516
+ orientation: "vertical",
517
+ label: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
518
+ asChild: true,
519
+ className: "my-3",
520
+ variant: "body2",
521
+ weight: "semibold",
522
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
523
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.title")
524
+ })
525
+ }),
526
+ children: [/*#__PURE__*/jsxRuntime.jsx(formik$1.RadioGroup.Item, {
527
+ value: "over_left",
528
+ label: /*#__PURE__*/jsxRuntime.jsxs("span", {
529
+ className: "flex flex-col gap-1",
530
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
531
+ asChild: true,
532
+ variant: "body2",
533
+ weight: "semibold",
534
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
535
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.overLeft")
536
+ })
537
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
538
+ asChild: true,
539
+ variant: "body3",
540
+ weight: "normal",
541
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
542
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.overLeftDescription")
543
+ })
544
+ })]
545
+ })
546
+ }), /*#__PURE__*/jsxRuntime.jsx(formik$1.RadioGroup.Item, {
547
+ value: "below_left",
548
+ label: /*#__PURE__*/jsxRuntime.jsxs("span", {
549
+ className: "flex flex-col gap-1",
550
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
551
+ asChild: true,
552
+ variant: "body2",
553
+ weight: "semibold",
554
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
555
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.belowLeft")
556
+ })
557
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
558
+ asChild: true,
559
+ variant: "body3",
560
+ weight: "normal",
561
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
562
+ children: t("neetoThemes.build.leftSideBar.themes.logoPosition.belowLeftDescription")
563
+ })
564
+ })]
565
+ })
566
+ })]
567
+ });
568
+ };
569
+
570
+ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
571
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
572
+
573
+ // Capitalizes the first letter of the displayed label while keeping the
574
+ // underlying value untouched (position values like "top left" are used
575
+ // verbatim as CSS background-position, so they must stay lowercase).
576
+ var toCapitalizedOption = function toCapitalizedOption(value) {
577
+ var _toLabelAndValue = neetoCist.toLabelAndValue(value),
578
+ label = _toLabelAndValue.label,
579
+ optionValue = _toLabelAndValue.value;
580
+ return {
581
+ label: label ? neetoCist.capitalize(label) : label,
582
+ value: optionValue
583
+ };
584
+ };
585
+ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchema) {
586
+ if (neetoCist.isPresent(theme)) return theme;
587
+ return {
588
+ name: i18n.t("neetoThemes.build.leftSideBar.themes.createTheme.newThemeName"),
589
+ properties: themePropertiesSchema.map(function (_ref) {
590
+ var key = _ref.key,
591
+ kind = _ref.kind,
592
+ defaultValue = _ref.defaultValue,
593
+ _ref$order = _ref.order,
594
+ order = _ref$order === void 0 ? null : _ref$order,
595
+ dependsOn = _ref.dependsOn;
596
+ switch (kind) {
597
+ case "text_input":
598
+ return _objectSpread$3({
599
+ value: defaultValue || "",
600
+ kind: "text_input",
601
+ key: key,
602
+ dependsOn: dependsOn
603
+ }, order !== null && {
604
+ order: order
605
+ });
606
+ case "color":
607
+ return _objectSpread$3({
608
+ value: defaultValue,
609
+ kind: "color",
610
+ key: key,
611
+ dependsOn: dependsOn
612
+ }, order !== null && {
613
+ order: order
614
+ });
615
+ case "font_family":
616
+ return _objectSpread$3({
617
+ value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
618
+ kind: "font_family",
619
+ key: key,
620
+ dependsOn: dependsOn
621
+ }, order !== null && {
622
+ order: order
623
+ });
624
+ case "overlay_opacity":
625
+ return _objectSpread$3({
626
+ value: 0,
627
+ kind: "overlay_opacity",
628
+ key: key,
629
+ dependsOn: dependsOn
630
+ }, order !== null && {
631
+ order: order
632
+ });
633
+ case "slider":
634
+ return _objectSpread$3({
635
+ value: 0,
636
+ kind: "slider",
637
+ key: key,
638
+ dependsOn: dependsOn
639
+ }, order !== null && {
640
+ order: order
641
+ });
642
+ case "radius":
643
+ return _objectSpread$3({
644
+ value: defaultValue,
645
+ kind: "radius",
646
+ key: key,
647
+ dependsOn: dependsOn
648
+ }, order !== null && {
649
+ order: order
650
+ });
651
+ case "boolean":
652
+ return _objectSpread$3({
653
+ value: String(defaultValue),
654
+ kind: "boolean",
655
+ key: key,
656
+ dependsOn: dependsOn
657
+ }, order !== null && {
658
+ order: order
659
+ });
660
+ case "order_selector":
661
+ return _objectSpread$3({
662
+ value: defaultValue,
663
+ kind: "order_selector",
664
+ key: key,
665
+ dependsOn: dependsOn
666
+ }, order !== null && {
667
+ order: order
668
+ });
669
+ case "alignment_block":
670
+ return _objectSpread$3({
671
+ value: defaultValue,
672
+ kind: "alignment_block",
673
+ key: key,
674
+ dependsOn: dependsOn
675
+ }, order !== null && {
676
+ order: order
677
+ });
678
+ case "custom_css":
679
+ return _objectSpread$3({
680
+ value: defaultValue,
681
+ kind: "custom_css",
682
+ key: key,
683
+ dependsOn: dependsOn
684
+ }, order !== null && {
685
+ order: order
686
+ });
687
+ case "logo_position":
688
+ return _objectSpread$3({
689
+ value: defaultValue,
690
+ kind: "logo_position",
691
+ key: key,
692
+ dependsOn: dependsOn
693
+ }, order !== null && {
694
+ order: order
695
+ });
696
+ default:
697
+ return null;
698
+ }
699
+ }).filter(neetoCist.isNot(null))
700
+ };
701
+ };
702
+ var buildImageData = function buildImageData(values, themePropertiesSchema) {
703
+ return neetoCist.filterBy({
704
+ kind: "image"
705
+ }, themePropertiesSchema).reduce(function (acc, item) {
706
+ var _values$snakeToCamelC;
707
+ var signedId = (_values$snakeToCamelC = values[neetoCist.snakeToCamelCase(item.key)]) === null || _values$snakeToCamelC === void 0 ? void 0 : _values$snakeToCamelC.signedId;
708
+ acc[item.key] = signedId;
709
+ return acc;
710
+ }, {});
711
+ };
712
+ var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
713
+ var property = neetoCist.findBy({
714
+ key: key
715
+ }, themePropertiesSchema);
716
+ if (neetoCist.isNotPresent(property)) return false;
717
+ if (property !== null && property !== void 0 && property.hidden) return false;
718
+ var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
719
+ if (neetoCist.isNotPresent(conditionalKey)) return true;
720
+ var dependentPropertySchema = neetoCist.findBy({
721
+ key: conditionalKey
722
+ }, themePropertiesSchema);
723
+ var dependentProperty = neetoCist.findBy({
724
+ key: conditionalKey
725
+ }, formikValues.properties);
726
+ if (dependentPropertySchema.kind === "image") {
727
+ var _formikValues$snakeTo;
728
+ return neetoCist.isPresent((_formikValues$snakeTo = formikValues[neetoCist.snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
729
+ } else if (dependentPropertySchema.kind === "boolean") {
730
+ return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
731
+ }
732
+ return neetoCist.isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
733
+ };
734
+ var buildLabel = function buildLabel(key, kind) {
735
+ return i18n.t("neetoThemes.properties.".concat(neetoCist.snakeToCamelCase(kind), ".").concat(neetoCist.snakeToCamelCase(key)));
736
+ };
737
+ var buildProperties = function buildProperties(values, condition, themePropertiesSchema) {
738
+ values.forEach(function (value) {
739
+ themePropertiesSchema.forEach(function (theme) {
740
+ if (!(value.key === theme.key)) return;
741
+ value.dependsOn = theme.dependsOn;
742
+ });
743
+ });
744
+ if (condition) {
745
+ return neetoCist.filterBy({
746
+ dependsOn: condition
747
+ }, values);
748
+ }
749
+ var imageKeys = new Set();
750
+ neetoCist.filterBy({
751
+ kind: "image"
752
+ }, themePropertiesSchema).forEach(function (ele) {
753
+ return imageKeys.add(ele.key);
754
+ });
755
+ return values === null || values === void 0 ? void 0 : values.filter(function (_ref2) {
756
+ var dependsOn = _ref2.dependsOn;
757
+ return !imageKeys.has(dependsOn);
758
+ });
759
+ };
760
+
761
+ var AlignmentBlock = function AlignmentBlock(_ref) {
762
+ var label = _ref.label,
763
+ name = _ref.name;
764
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
765
+ className: "flex items-center justify-between gap-2",
766
+ "data-testid": utils$1.joinHyphenCase(label),
767
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
768
+ "data-testid": "style-fields-labels",
769
+ variant: "body2",
770
+ children: label
771
+ }), /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
772
+ name: name,
773
+ children: function children(_ref2) {
774
+ var value = _ref2.field.value,
775
+ setFieldValue = _ref2.form.setFieldValue;
776
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
777
+ className: "border-input neeto-themes-nano-alignment-block flex items-center border",
778
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
779
+ className: "neeto-themes-nano-alignment-button neeto-themes-nano-alignment-button__alignment-left",
780
+ "data-testid": "alignment-left",
781
+ variant: value === "left" ? "default" : "ghost",
782
+ icon: function icon() {
783
+ return /*#__PURE__*/jsxRuntime.jsx(LeftAlign, {
784
+ size: 20,
785
+ className: classnames({
786
+ rounded: true,
787
+ "text-primary": value === "left",
788
+ "text-muted-foreground": value !== "left"
789
+ })
790
+ });
791
+ },
792
+ tooltipProps: {
793
+ content: "Left align",
794
+ position: "bottom"
795
+ },
796
+ onClick: function onClick() {
797
+ return setFieldValue(name, "left");
798
+ }
799
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
800
+ className: "neeto-themes-nano-alignment-divider"
801
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
802
+ className: "neeto-themes-nano-alignment-button neeto-themes-nano-alignment-button__alignment-center",
803
+ "data-testid": "alignment-center",
804
+ variant: value === "center" ? "default" : "ghost",
805
+ icon: function icon() {
806
+ return /*#__PURE__*/jsxRuntime.jsx(CenterAlign, {
807
+ size: 20,
808
+ className: classnames({
809
+ rounded: true,
810
+ "text-primary": value === "center",
811
+ "text-muted-foreground": value !== "center"
812
+ })
813
+ });
814
+ },
815
+ tooltipProps: {
816
+ content: "Center align",
817
+ position: "bottom"
818
+ },
819
+ onClick: function onClick() {
820
+ return setFieldValue(name, "center");
821
+ }
822
+ })]
823
+ });
824
+ }
825
+ })]
826
+ });
827
+ };
828
+
829
+ var ColorBlock = function ColorBlock(_ref) {
830
+ var label = _ref.label,
831
+ _ref$color = _ref.color,
832
+ color = _ref$color === void 0 ? "#FFFFFF" : _ref$color,
833
+ onChange = _ref.onChange,
834
+ showTransparencyControl = _ref.showTransparencyControl;
835
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
836
+ className: "flex items-center justify-between",
837
+ "data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
838
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
839
+ "data-testid": "style-fields-labels",
840
+ variant: "body2",
841
+ children: label
842
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.ColorPicker, {
843
+ color: color,
844
+ onChange: onChange,
845
+ showTransparencyControl: showTransparencyControl,
846
+ showEyeDropper: true,
847
+ size: "medium"
848
+ })]
849
+ });
850
+ };
851
+
852
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
853
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
854
+ var FontPickerBlock = function FontPickerBlock(_ref) {
855
+ var label = _ref.label,
856
+ _ref$placeholder = _ref.placeholder,
857
+ placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
858
+ value = _ref.value,
859
+ options = _ref.options,
860
+ onChange = _ref.onChange;
861
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
862
+ className: "flex items-center justify-between",
863
+ "data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
864
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
865
+ "data-testid": "style-fields-labels",
866
+ variant: "body2",
867
+ children: label
868
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
869
+ className: "w-40",
870
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Select, {
871
+ onChange: onChange,
872
+ options: options,
873
+ placeholder: placeholder,
874
+ value: value,
875
+ menuPosition: "fixed",
876
+ styles: {
877
+ option: function option(styles, _ref2) {
878
+ var data = _ref2.data;
879
+ return _objectSpread$2(_objectSpread$2({}, styles), {}, {
880
+ fontFamily: data.value
881
+ });
882
+ }
883
+ }
884
+ })
885
+ })]
886
+ });
887
+ };
888
+
889
+ var SelectBlock = function SelectBlock(_ref) {
890
+ var label = _ref.label,
891
+ _ref$placeholder = _ref.placeholder,
892
+ placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
893
+ value = _ref.value,
894
+ options = _ref.options,
895
+ onChange = _ref.onChange;
896
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
897
+ className: "border-border flex flex-col gap-2 border-t pt-3",
898
+ "data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
899
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
900
+ "data-testid": "logo-field-labels",
901
+ variant: "body2",
902
+ children: label
903
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Select, {
904
+ onChange: onChange,
905
+ options: options,
906
+ placeholder: placeholder,
907
+ value: value
908
+ })]
909
+ });
910
+ };
911
+
912
+ var SliderBlock = function SliderBlock(_ref) {
913
+ var label = _ref.label,
914
+ onChange = _ref.onChange,
915
+ value = _ref.value,
916
+ min = _ref.min,
917
+ max = _ref.max,
918
+ marks = _ref.marks;
919
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
920
+ className: "flex items-center justify-between gap-3",
921
+ "data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
922
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
923
+ "data-testid": "style-fields-labels",
924
+ variant: "body2",
925
+ children: label
926
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Slider, {
927
+ marks: marks,
928
+ max: max,
929
+ min: min,
930
+ onChange: onChange,
931
+ value: value,
932
+ className: "my-2 w-20",
933
+ tooltip: {
934
+ formatter: null
935
+ }
936
+ })]
937
+ });
938
+ };
939
+
940
+ var _excluded = ["label", "name", "asCheckbox"];
941
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
942
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
943
+ var SwitchBlock = function SwitchBlock(_ref) {
944
+ var label = _ref.label,
945
+ name = _ref.name,
946
+ _ref$asCheckbox = _ref.asCheckbox,
947
+ asCheckbox = _ref$asCheckbox === void 0 ? false : _ref$asCheckbox,
948
+ inputProps = _objectWithoutProperties(_ref, _excluded);
949
+ var _useTranslation = reactI18next.useTranslation(),
950
+ t = _useTranslation.t,
951
+ i18n = _useTranslation.i18n;
952
+ var translationKey = "neetoThemes.properties.boolean.".concat(name, "HelpText");
953
+ var doesHelpTextExist = i18n.exists(translationKey);
954
+ if (asCheckbox) {
955
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
956
+ className: "flex items-center gap-2",
957
+ "data-testid": "theme-style-content-background",
958
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Checkbox, _objectSpread$1(_objectSpread$1({}, _objectSpread$1({
959
+ label: label,
960
+ name: name
961
+ }, inputProps)), {}, {
962
+ "data-testid": "enable-background-color-toggle"
963
+ })), doesHelpTextExist && /*#__PURE__*/jsxRuntime.jsx(HelpPopover, {
964
+ className: "shrink-0",
965
+ description: t(translationKey)
966
+ })]
967
+ });
968
+ }
969
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
970
+ className: "flex items-center justify-between",
971
+ "data-testid": "theme-style-content-background",
972
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
973
+ className: "inline-flex items-center gap-4",
974
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
975
+ "data-testid": "style-fields-labels",
976
+ variant: "body2",
977
+ className: classnames({
978
+ "w-32": doesHelpTextExist,
979
+ "w-auto": !doesHelpTextExist
980
+ }),
981
+ children: label
982
+ }), doesHelpTextExist && /*#__PURE__*/jsxRuntime.jsx(HelpPopover, {
983
+ className: "shrink-0",
984
+ description: t(translationKey)
985
+ })]
986
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Switch, _objectSpread$1(_objectSpread$1({}, _objectSpread$1({
987
+ name: name
988
+ }, inputProps)), {}, {
989
+ "data-testid": "enable-background-color-toggle"
990
+ }))]
991
+ });
992
+ };
993
+
994
+ var TextBlock = function TextBlock(_ref) {
995
+ var label = _ref.label,
996
+ name = _ref.name,
997
+ _ref$type = _ref.type,
998
+ type = _ref$type === void 0 ? "text" : _ref$type,
999
+ value = _ref.value,
1000
+ onChange = _ref.onChange,
1001
+ placeholder = _ref.placeholder,
1002
+ error = _ref.error;
1003
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
1004
+ className: "flex items-center justify-between",
1005
+ "data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
1006
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1007
+ "data-testid": "style-fields-labels",
1008
+ variant: "body2",
1009
+ children: label
1010
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
1011
+ className: "w-40",
1012
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
1013
+ error: error,
1014
+ name: name,
1015
+ onChange: onChange,
1016
+ placeholder: placeholder,
1017
+ type: type,
1018
+ value: value
1019
+ })
1020
+ })]
1021
+ });
1022
+ };
1023
+
1024
+ var Properties = function Properties(_ref) {
1025
+ var onPropertiesChange = _ref.onPropertiesChange,
1026
+ condition = _ref.condition,
1027
+ themeId = _ref.themeId;
1028
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
1029
+ return {
1030
+ themePropertiesSchema: store["themePropertiesSchema"]
1031
+ };
1032
+ }, shallow.shallow),
1033
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema;
1034
+ var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
1035
+ return {
1036
+ setThemeState: store["setThemeState"]
1037
+ };
1038
+ }, shallow.shallow),
1039
+ setThemeState = _useThemeStore.setThemeState;
1040
+ var _useFormikContext = formik.useFormikContext(),
1041
+ setFieldValue = _useFormikContext.setFieldValue,
1042
+ values = _useFormikContext.values,
1043
+ errors = _useFormikContext.errors;
1044
+ var _useThemeUtils = useExpandedSection.useThemeUtils(),
1045
+ setVariable = _useThemeUtils.setVariable,
1046
+ setTheme = _useThemeUtils.setTheme;
1047
+ var handleColorChange = function handleColorChange(name) {
1048
+ return function (_ref2) {
1049
+ var hex = _ref2.hex,
1050
+ rgb = _ref2.rgb;
1051
+ if (name === "background_color") {
1052
+ var _findBy, _values$backgroundIma;
1053
+ var isDominantBackgroundColorEnabled = ((_findBy = neetoCist.findBy({
1054
+ key: "is_dominant_background_color_enabled"
1055
+ }, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) === "true";
1056
+ var hasImageWithDominantColor = values === null || values === void 0 || (_values$backgroundIma = values.backgroundImage) === null || _values$backgroundIma === void 0 ? void 0 : _values$backgroundIma.dominantColor;
1057
+ if (isDominantBackgroundColorEnabled && hasImageWithDominantColor) {
1058
+ return;
1059
+ }
1060
+ }
1061
+ handleChange(name, hex, "".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(rgb.a));
1062
+ };
1063
+ };
1064
+ var handleChange = function handleChange(name, value, variableValue) {
1065
+ var index = neetoCist.findIndexBy({
1066
+ key: name
1067
+ }, values.properties);
1068
+ if (index !== -1 && values.properties[index].value !== value) {
1069
+ setFieldValue("properties[".concat(index, "].value"), value);
1070
+ }
1071
+ setVariable(neetoCist.snakeToCamelCase(name), variableValue !== null && variableValue !== void 0 ? variableValue : value);
1072
+ };
1073
+ var handleOverlayChange = function handleOverlayChange(key, value) {
1074
+ var index = neetoCist.findIndexBy({
1075
+ key: key
1076
+ }, values.properties);
1077
+ var overlayColorVariable = "".concat(key, "_overlay_color");
1078
+ setFieldValue("properties[".concat(index, "].value"), value);
1079
+ setVariable("".concat(key, "_overlay_opacity"), Math.abs(value / 100));
1080
+ if (value < 0) {
1081
+ handleChange(overlayColorVariable, "#000000", "0, 0, 0");
1082
+ } else {
1083
+ handleChange(overlayColorVariable, "#ffffff", "255, 255, 255");
1084
+ }
1085
+ };
1086
+ react.useEffect(function () {
1087
+ if (!((values === null || values === void 0 ? void 0 : values.id) === themeId)) return;
1088
+ onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values, handleChange, handleColorChange);
1089
+ setTheme(values);
1090
+ setThemeState({
1091
+ previewingTheme: values
1092
+ });
1093
+ }, [values]);
1094
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
1095
+ children: buildProperties(values === null || values === void 0 ? void 0 : values.properties, condition, themePropertiesSchema).sort(function (a, b) {
1096
+ var order = function order(key) {
1097
+ var _findBy2;
1098
+ return ((_findBy2 = neetoCist.findBy({
1099
+ key: key
1100
+ }, themePropertiesSchema)) === null || _findBy2 === void 0 ? void 0 : _findBy2.order) || Infinity;
1101
+ };
1102
+ return order(a.key) - order(b.key);
1103
+ }).map(function (_ref3) {
1104
+ var _findBy3;
1105
+ var key = _ref3.key,
1106
+ value = _ref3.value,
1107
+ kind = _ref3.kind;
1108
+ var isCurrentPropertyVisible = isPropertyVisible(key, values, themePropertiesSchema);
1109
+ if (!isCurrentPropertyVisible) return null;
1110
+ switch (kind) {
1111
+ case "text_input":
1112
+ {
1113
+ var _errors$properties;
1114
+ var index = neetoCist.findIndexBy({
1115
+ key: key
1116
+ }, values.properties);
1117
+ var error = errors === null || errors === void 0 || (_errors$properties = errors.properties) === null || _errors$properties === void 0 || (_errors$properties = _errors$properties[index]) === null || _errors$properties === void 0 ? void 0 : _errors$properties.value;
1118
+ return /*#__PURE__*/react.createElement(TextBlock, {
1119
+ error: error,
1120
+ key: key,
1121
+ label: buildLabel(key, kind),
1122
+ name: "properties[".concat(index, "].value"),
1123
+ value: value || "",
1124
+ onChange: function onChange(e) {
1125
+ return setFieldValue("properties[".concat(index, "].value"), e.target.value);
1126
+ }
1127
+ });
1128
+ }
1129
+ case "font_family":
1130
+ return /*#__PURE__*/jsxRuntime.jsx(FontPickerBlock, {
1131
+ label: buildLabel(key, kind),
1132
+ options: FONT_OPTIONS,
1133
+ value: neetoCist.findBy({
1134
+ value: value || null
1135
+ }, FONT_OPTIONS),
1136
+ onChange: function onChange(_ref4) {
1137
+ var value = _ref4.value;
1138
+ return handleChange(key, value);
1139
+ }
1140
+ }, key);
1141
+ case "color":
1142
+ return /*#__PURE__*/jsxRuntime.jsx(ColorBlock, {
1143
+ color: value,
1144
+ label: buildLabel(key, kind),
1145
+ showTransparencyControl: ((_findBy3 = neetoCist.findBy({
1146
+ key: key
1147
+ }, themePropertiesSchema)) === null || _findBy3 === void 0 ? void 0 : _findBy3.showTransparencyControl) || false,
1148
+ onChange: handleColorChange(key)
1149
+ }, key);
1150
+ case "radius":
1151
+ return /*#__PURE__*/jsxRuntime.jsx(SliderBlock, {
1152
+ label: buildLabel(key, kind),
1153
+ max: 50,
1154
+ min: 0,
1155
+ value: Number(value) || 0,
1156
+ onChange: function onChange(radius) {
1157
+ return handleChange(key, radius, "".concat(radius, "px"));
1158
+ }
1159
+ }, key);
1160
+ case "overlay_opacity":
1161
+ return /*#__PURE__*/jsxRuntime.jsx(SliderBlock, {
1162
+ label: buildLabel(key, kind),
1163
+ marks: OVERLAY_OPACITY_SLIDER_MARKS,
1164
+ max: HUNDRED,
1165
+ min: ramda.negate(HUNDRED),
1166
+ value: Number(value) || 0,
1167
+ onChange: function onChange(opacity) {
1168
+ return handleOverlayChange(key, opacity);
1169
+ }
1170
+ }, key);
1171
+ case "position_selector":
1172
+ {
1173
+ var _findBy4;
1174
+ var _index = neetoCist.findIndexBy({
1175
+ key: key
1176
+ }, values.properties);
1177
+ var options = (_findBy4 = neetoCist.findBy({
1178
+ key: key
1179
+ }, themePropertiesSchema)) === null || _findBy4 === void 0 || (_findBy4 = _findBy4.options) === null || _findBy4 === void 0 ? void 0 : _findBy4.map(toCapitalizedOption);
1180
+ return /*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
1181
+ label: buildLabel(key, kind),
1182
+ options: options || POSITION_OPTIONS,
1183
+ placeholder: "left",
1184
+ value: toCapitalizedOption(value),
1185
+ onChange: function onChange(option) {
1186
+ return setFieldValue("properties[".concat(_index, "].value"), option.value);
1187
+ }
1188
+ }, key);
1189
+ }
1190
+ case "boolean":
1191
+ {
1192
+ var _findBy5;
1193
+ var _index2 = neetoCist.findIndexBy({
1194
+ key: key
1195
+ }, values.properties);
1196
+ var renderAsCheckbox = ((_findBy5 = neetoCist.findBy({
1197
+ key: key
1198
+ }, themePropertiesSchema)) === null || _findBy5 === void 0 ? void 0 : _findBy5.renderAsCheckbox) || false;
1199
+ return /*#__PURE__*/jsxRuntime.jsx(SwitchBlock, {
1200
+ asCheckbox: renderAsCheckbox,
1201
+ checked: value !== "false",
1202
+ label: buildLabel(key, kind),
1203
+ name: neetoCist.snakeToCamelCase(key),
1204
+ onCheckedChange: function onCheckedChange(checked) {
1205
+ return setFieldValue("properties[".concat(_index2, "].value"), String(checked));
1206
+ }
1207
+ }, key);
1208
+ }
1209
+ case "alignment_block":
1210
+ {
1211
+ var _index3 = neetoCist.findIndexBy({
1212
+ key: key
1213
+ }, values.properties);
1214
+ return /*#__PURE__*/jsxRuntime.jsx(AlignmentBlock, {
1215
+ label: buildLabel(key, kind),
1216
+ name: "properties[".concat(_index3, "].value")
1217
+ });
1218
+ }
1219
+ default:
1220
+ return null;
1221
+ }
1222
+ })
1223
+ });
1224
+ };
1225
+
1226
+ var ImageBlock = function ImageBlock(_ref) {
1227
+ var _findBy;
1228
+ var label = _ref.label,
1229
+ name = _ref.name,
1230
+ _ref$imageData = _ref.imageData,
1231
+ imageData = _ref$imageData === void 0 ? {} : _ref$imageData,
1232
+ _ref$uploadConfig = _ref.uploadConfig,
1233
+ uploadConfig = _ref$uploadConfig === void 0 ? {
1234
+ maxImageSize: ONE_MEGABYTE
1235
+ } : _ref$uploadConfig,
1236
+ attribute = _ref.attribute,
1237
+ defaultImageSize = _ref.defaultImageSize,
1238
+ useDefaultImageSize = _ref.useDefaultImageSize,
1239
+ fixedAspectRatio = _ref.fixedAspectRatio;
1240
+ var _useTranslation = reactI18next.useTranslation(),
1241
+ t = _useTranslation.t;
1242
+ var _useFormikContext = formik.useFormikContext(),
1243
+ setFieldValue = _useFormikContext.setFieldValue,
1244
+ values = _useFormikContext.values;
1245
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
1246
+ return {
1247
+ themePropertiesSchema: store["themePropertiesSchema"]
1248
+ };
1249
+ }, shallow.shallow),
1250
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema;
1251
+ var propertySchema = neetoCist.findBy({
1252
+ key: attribute
1253
+ }, themePropertiesSchema);
1254
+ var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
1255
+ var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
1256
+ var positionKeyInSchema = neetoCist.findBy({
1257
+ key: "".concat(name, "_position")
1258
+ }, themePropertiesSchema);
1259
+ var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && neetoCist.isPresent(positionKeyInSchema);
1260
+ var positionKeyIndex = neetoCist.findIndexBy({
1261
+ key: "".concat(name, "_position")
1262
+ }, values.properties);
1263
+ var handleImageChange = /*#__PURE__*/function () {
1264
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
1265
+ var dominantColor;
1266
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1267
+ while (1) switch (_context.prev = _context.next) {
1268
+ case 0:
1269
+ _context.prev = 0;
1270
+ if (!(ramda.isEmpty(image.signedId) || ramda.isEmpty(image.url))) {
1271
+ _context.next = 4;
1272
+ break;
1273
+ }
1274
+ setFieldValue(name, {
1275
+ signedId: null,
1276
+ url: image.url
1277
+ });
1278
+ return _context.abrupt("return");
1279
+ case 4:
1280
+ _context.next = 6;
1281
+ return getDominantColorFromUrl(image.url);
1282
+ case 6:
1283
+ dominantColor = _context.sent;
1284
+ setFieldValue(name, {
1285
+ signedId: image.signedId,
1286
+ url: image.url,
1287
+ dominantColor: dominantColor
1288
+ });
1289
+ _context.next = 13;
1290
+ break;
1291
+ case 10:
1292
+ _context.prev = 10;
1293
+ _context.t0 = _context["catch"](0);
1294
+ neetoAtoms.Toastr.error(_context.t0);
1295
+ case 13:
1296
+ case "end":
1297
+ return _context.stop();
1298
+ }
1299
+ }, _callee, null, [[0, 10]]);
1300
+ }));
1301
+ return function handleImageChange(_x) {
1302
+ return _ref2.apply(this, arguments);
1303
+ };
1304
+ }();
1305
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
1306
+ className: "space-y-3",
1307
+ "data-testid": "theme-style-".concat(label ? utils$1.joinHyphenCase(label) : "image-block"),
1308
+ children: [label && /*#__PURE__*/jsxRuntime.jsx("div", {
1309
+ className: "flex items-center justify-between",
1310
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1311
+ "data-testid": "style-fields-labels",
1312
+ variant: "body2",
1313
+ children: label
1314
+ })
1315
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1316
+ className: "space-y-3",
1317
+ children: [/*#__PURE__*/react.createElement(ImageUploader, {
1318
+ fixedAspectRatio: fixedAspectRatio,
1319
+ uploadConfig: uploadConfig,
1320
+ className: "h-40 w-full",
1321
+ defaultImageSize: useDefaultImageSize ? defaultImageSize : {},
1322
+ key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
1323
+ src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
1324
+ onUploadComplete: handleImageChange
1325
+ }), isPositionChangerVisible && /*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
1326
+ label: buildLabel("".concat(name, "Position"), "image"),
1327
+ options: (options === null || options === void 0 ? void 0 : options.map(toCapitalizedOption)) || POSITION_OPTIONS,
1328
+ placeholder: t("neetoThemes.common.left"),
1329
+ value: toCapitalizedOption(((_findBy = neetoCist.findBy({
1330
+ key: "".concat(name, "_position")
1331
+ }, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) || (positionKeyInSchema === null || positionKeyInSchema === void 0 ? void 0 : positionKeyInSchema.defaultValue)),
1332
+ onChange: function onChange(option) {
1333
+ return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
1334
+ }
1335
+ })]
1336
+ })]
1337
+ });
1338
+ };
1339
+
1340
+ var Images = function Images(_ref) {
1341
+ var _values$coverImage;
1342
+ var attribute = _ref.attribute,
1343
+ className = _ref.className,
1344
+ onPropertiesChange = _ref.onPropertiesChange,
1345
+ defaultImageSize = _ref.defaultImageSize,
1346
+ useDefaultImageSize = _ref.useDefaultImageSize,
1347
+ fixedAspectRatio = _ref.fixedAspectRatio;
1348
+ var _useFormikContext = formik.useFormikContext(),
1349
+ values = _useFormikContext.values;
1350
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
1351
+ return {
1352
+ helpPopoverProps: store["helpPopoverProps"]
1353
+ };
1354
+ }, shallow.shallow),
1355
+ helpPopoverProps = _useConfigStore.helpPopoverProps;
1356
+ var key = neetoCist.snakeToCamelCase(attribute);
1357
+ var title = buildLabel(key, "image");
1358
+ var imageData = values[key];
1359
+ return /*#__PURE__*/jsxRuntime.jsxs(Card$2, {
1360
+ className: className,
1361
+ title: title,
1362
+ helpPopoverProps: helpPopoverProps[key],
1363
+ name: key,
1364
+ children: [/*#__PURE__*/jsxRuntime.jsx(ImageBlock, {
1365
+ attribute: attribute,
1366
+ defaultImageSize: defaultImageSize,
1367
+ fixedAspectRatio: fixedAspectRatio,
1368
+ imageData: imageData,
1369
+ useDefaultImageSize: useDefaultImageSize,
1370
+ name: key
1371
+ }), /*#__PURE__*/jsxRuntime.jsx(Properties, {
1372
+ onPropertiesChange: onPropertiesChange,
1373
+ condition: attribute
1374
+ }), key === "logo" && ((_values$coverImage = values.coverImage) === null || _values$coverImage === void 0 ? void 0 : _values$coverImage.url) && /*#__PURE__*/jsxRuntime.jsx(LogoPosition, {})]
1375
+ });
1376
+ };
1377
+
1378
+ var ThemeMeta = function ThemeMeta(_ref) {
1379
+ var className = _ref.className;
1380
+ var _useTranslation = reactI18next.useTranslation(),
1381
+ t = _useTranslation.t;
1382
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
1383
+ return {
1384
+ helpPopoverProps: store["helpPopoverProps"]
1385
+ };
1386
+ }, shallow.shallow),
1387
+ helpPopoverProps = _useConfigStore.helpPopoverProps;
1388
+ var _helpPopoverProps$nam = helpPopoverProps.name,
1389
+ nameHelpPopoverProps = _helpPopoverProps$nam === void 0 ? {} : _helpPopoverProps$nam;
1390
+ return /*#__PURE__*/jsxRuntime.jsx(Card$2, {
1391
+ className: className,
1392
+ required: true,
1393
+ helpPopoverProps: nameHelpPopoverProps,
1394
+ name: "name",
1395
+ title: t("neetoThemes.common.name"),
1396
+ children: /*#__PURE__*/jsxRuntime.jsx(formik$1.Input, {
1397
+ autoFocus: true,
1398
+ "data-testid": "theme-name-property",
1399
+ name: "name"
1400
+ })
1401
+ });
1402
+ };
1403
+
1404
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1405
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1406
+ var Customize = function Customize(_ref) {
1407
+ var theme = _ref.theme,
1408
+ onCreateTheme = _ref.onCreateTheme,
1409
+ onApplyTheme = _ref.onApplyTheme,
1410
+ onUpdateTheme = _ref.onUpdateTheme,
1411
+ isApplyingTheme = _ref.isApplyingTheme,
1412
+ onPropertiesChange = _ref.onPropertiesChange,
1413
+ defaultImageSize = _ref.defaultImageSize,
1414
+ fixedAspectRatio = _ref.fixedAspectRatio,
1415
+ onEditCSSClick = _ref.onEditCSSClick,
1416
+ currentScreen = _ref.currentScreen;
1417
+ var _useTranslation = reactI18next.useTranslation(),
1418
+ t = _useTranslation.t;
1419
+ useExpandedSection.useSyncExpandedSectionFromUrl();
1420
+ var history = reactRouterDom.useHistory();
1421
+ var _useState = react.useState(false),
1422
+ _useState2 = _slicedToArray(_useState, 2),
1423
+ isNotAppliedPopoverOpen = _useState2[0],
1424
+ setIsNotAppliedPopoverOpen = _useState2[1];
1425
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
1426
+ return {
1427
+ themePropertiesSchema: store["themePropertiesSchema"],
1428
+ entityType: store["entityType"],
1429
+ isFetchingSchema: store["isFetchingSchema"],
1430
+ helpPopoverProps: store["helpPopoverProps"],
1431
+ enabledFeatures: store["enabledFeatures"],
1432
+ proFeatures: store["proFeatures"]
1433
+ };
1434
+ }, shallow.shallow),
1435
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema,
1436
+ entityType = _useConfigStore.entityType,
1437
+ isFetchingSchema = _useConfigStore.isFetchingSchema,
1438
+ helpPopoverProps = _useConfigStore.helpPopoverProps,
1439
+ enabledFeatures = _useConfigStore.enabledFeatures,
1440
+ proFeatures = _useConfigStore.proFeatures;
1441
+ var _useParams = reactRouterDom.useParams(),
1442
+ themeId = _useParams.themeId;
1443
+ var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
1444
+ return {
1445
+ currentTheme: store["currentTheme"],
1446
+ setThemeState: store["setThemeState"]
1447
+ };
1448
+ }, shallow.shallow),
1449
+ currentTheme = _useThemeStore.currentTheme,
1450
+ setThemeState = _useThemeStore.setThemeState;
1451
+ var _useShowGlobalTheme = useGlobalThemesApi.useShowGlobalTheme(entityType),
1452
+ _useShowGlobalTheme$d = _useShowGlobalTheme.data,
1453
+ _useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
1454
+ _useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
1455
+ globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3;
1456
+ var _useFetchTheme = useGlobalThemesApi.useFetchTheme(themeId, {
1457
+ enabled: isEditThemeRoute() && ramda.isNotNil(themeId),
1458
+ initialData: theme !== null && theme !== void 0 ? theme : undefined
1459
+ }),
1460
+ _useFetchTheme$data = _useFetchTheme.data,
1461
+ themeData = _useFetchTheme$data === void 0 ? {} : _useFetchTheme$data,
1462
+ isLoadingTheme = _useFetchTheme.isLoadingTheme;
1463
+ var isLoading = isFetchingSchema || isLoadingTheme;
1464
+ var isThemeGlobalTheme = themeId && (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
1465
+ var isCurrentThemeAndGlobalThemeSame = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id);
1466
+ var _helpPopoverProps$sty = helpPopoverProps.style,
1467
+ styleHelpPopoverProps = _helpPopoverProps$sty === void 0 ? {} : _helpPopoverProps$sty;
1468
+ var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1469
+ var _useCreateTheme = useGlobalThemesApi.useCreateTheme(),
1470
+ createTheme = _useCreateTheme.mutate,
1471
+ isCreating = _useCreateTheme.isPending;
1472
+ var _useUpdateTheme = useGlobalThemesApi.useUpdateTheme(themeId),
1473
+ updateTheme = _useUpdateTheme.mutate,
1474
+ isUpdating = _useUpdateTheme.isPending;
1475
+ var isSubmitting = isCreating || isUpdating;
1476
+ var isCustomCssScreen = isScreenCustomCSS(currentScreen);
1477
+ var onSubmit = function onSubmit(values, _ref2) {
1478
+ var resetForm = _ref2.resetForm;
1479
+ var imageData = buildImageData(values, themePropertiesSchema);
1480
+ var themeToSave = _objectSpread({
1481
+ propertiesAttributes: values.properties,
1482
+ name: values.name,
1483
+ shouldSetAsGlobalTheme: values.shouldSetAsGlobalTheme,
1484
+ entityType: values.entityType
1485
+ }, imageData);
1486
+ if (!themeId) {
1487
+ return createTheme(themeToSave, {
1488
+ onSuccess: function onSuccess(_ref3) {
1489
+ var theme = _ref3.theme;
1490
+ resetForm({
1491
+ values: theme
1492
+ });
1493
+ onCreateTheme(theme);
1494
+ history.replace(utils$1.buildUrl(buildPathname(useGlobalThemesApi.routes.themes.edit), {
1495
+ themeId: theme.id
1496
+ }));
1497
+ }
1498
+ });
1499
+ }
1500
+ return updateTheme(themeToSave, {
1501
+ onSuccess: function onSuccess(_ref4) {
1502
+ var theme = _ref4.theme;
1503
+ onUpdateTheme(theme);
1504
+ resetForm({
1505
+ values: theme
1506
+ });
1507
+ }
1508
+ });
1509
+ };
1510
+ react.useEffect(function () {
1511
+ if (ramda.isNotNil(themeId) && !isLoadingTheme) {
1512
+ setThemeState({
1513
+ previewingTheme: themeData
1514
+ });
1515
+ }
1516
+ }, [isLoadingTheme]);
1517
+ if (isLoading) {
1518
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
1519
+ className: "flex h-full w-full items-center justify-center",
1520
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Spinner, {})
1521
+ });
1522
+ }
1523
+ return /*#__PURE__*/jsxRuntime.jsx(formik$1.Form, {
1524
+ formikProps: {
1525
+ initialValues: _objectSpread(_objectSpread({}, buildInitialValues(themeData, themePropertiesSchema)), {}, {
1526
+ shouldSetAsGlobalTheme: isThemeGlobalTheme,
1527
+ entityType: entityType
1528
+ }),
1529
+ validationSchema: THEME_VALIDATION_SCHEMA,
1530
+ enableReinitialize: true,
1531
+ onSubmit: onSubmit
1532
+ },
1533
+ children: function children(_ref5) {
1534
+ var dirty = _ref5.dirty,
1535
+ isValid = _ref5.isValid,
1536
+ values = _ref5.values,
1537
+ setFieldValue = _ref5.setFieldValue;
1538
+ var isNotAppliedCondition = !isEditingCurrentlyAppliedTheme && !(isCurrentThemeAndGlobalThemeSame && values.shouldSetAsGlobalTheme);
1539
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
1540
+ className: "neeto-themes-sidebar__scroll",
1541
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1542
+ className: "neeto-themes-sidebar__scroll-content flex grow flex-col px-4 pb-4 lg:px-5",
1543
+ children: [!isSubmitting && /*#__PURE__*/jsxRuntime.jsx(formik$1.BlockNavigation, {}), /*#__PURE__*/jsxRuntime.jsx(ThemeMeta, {
1544
+ className: classnames({
1545
+ hidden: isCustomCssScreen
1546
+ })
1547
+ }), /*#__PURE__*/jsxRuntime.jsx(Card$2, {
1548
+ className: classnames({
1549
+ hidden: isCustomCssScreen
1550
+ }),
1551
+ helpPopoverProps: styleHelpPopoverProps,
1552
+ name: "style",
1553
+ title: t("neetoThemes.common.style"),
1554
+ children: /*#__PURE__*/jsxRuntime.jsx(Properties, {
1555
+ onPropertiesChange: onPropertiesChange,
1556
+ themeId: themeId
1557
+ })
1558
+ }), neetoCist.filterBy({
1559
+ kind: "image"
1560
+ }, themePropertiesSchema).map(function (_ref6) {
1561
+ var key = _ref6.key,
1562
+ useDefaultImageSize = _ref6.useDefaultImageSize,
1563
+ propertyDefaultSize = _ref6.defaultImageSize,
1564
+ propertyFixedAspectRatio = _ref6.fixedAspectRatio;
1565
+ return /*#__PURE__*/react.createElement(Images, _defineProperty({
1566
+ fixedAspectRatio: fixedAspectRatio,
1567
+ onPropertiesChange: onPropertiesChange,
1568
+ useDefaultImageSize: useDefaultImageSize,
1569
+ attribute: key,
1570
+ className: classnames({
1571
+ hidden: isCustomCssScreen
1572
+ }),
1573
+ defaultImageSize: propertyDefaultSize || defaultImageSize,
1574
+ key: key
1575
+ }, "fixedAspectRatio", propertyFixedAspectRatio || fixedAspectRatio));
1576
+ }), /*#__PURE__*/jsxRuntime.jsx(CustomCSS, {
1577
+ currentScreen: currentScreen,
1578
+ onEditCSSClick: onEditCSSClick,
1579
+ isEnabled: enabledFeatures.customCSS,
1580
+ isProFeature: proFeatures.customCSS
1581
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1582
+ className: "bg-muted/50 border-border mt-2 flex flex-col space-y-2 border p-2",
1583
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tooltip, {
1584
+ disabled: !isThemeGlobalTheme,
1585
+ content: t("neetoThemes.build.leftSideBar.themes.themeOptions.setAsGlobalTheme.tooltipContent"),
1586
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Switch, {
1587
+ checked: values.shouldSetAsGlobalTheme,
1588
+ disabled: isThemeGlobalTheme,
1589
+ name: "shouldSetAsGlobalTheme",
1590
+ label: t("neetoThemes.build.leftSideBar.themes.themeOptions.setAsGlobalTheme.label"),
1591
+ onCheckedChange: function onCheckedChange(checked) {
1592
+ return setFieldValue("shouldSetAsGlobalTheme", checked);
1593
+ }
1594
+ })
1595
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1596
+ className: "text-sm",
1597
+ variant: "body2",
1598
+ children: t("neetoThemes.build.leftSideBar.themes.themeOptions.setAsGlobalTheme.helpText", {
1599
+ entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()), {
1600
+ count: 2
1601
+ })
1602
+ })
1603
+ })]
1604
+ })]
1605
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1606
+ className: "bg-background shadow-sm sticky bottom-0 start-0 end-0 flex justify-end gap-x-2 px-4 py-6 lg:px-5 xl:px-6",
1607
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1608
+ "data-testid": "reset-button",
1609
+ disabled: !dirty || isSubmitting,
1610
+ label: t("neetoThemes.buttons.reset"),
1611
+ type: "reset",
1612
+ variant: "ghost"
1613
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Popover, {
1614
+ open: isNotAppliedPopoverOpen,
1615
+ position: "top",
1616
+ trigger: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1617
+ "data-testid": "save-changes-button",
1618
+ label: t("neetoThemes.buttons.save"),
1619
+ loading: isSubmitting,
1620
+ type: "submit",
1621
+ disabled: !dirty && (themeData === null || themeData === void 0 ? void 0 : themeData.id) || isSubmitting || !isValid,
1622
+ onClick: function onClick() {
1623
+ if (isNotAppliedCondition) {
1624
+ setIsNotAppliedPopoverOpen(true);
1625
+ }
1626
+ }
1627
+ }),
1628
+ onOpenChange: setIsNotAppliedPopoverOpen,
1629
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1630
+ className: "flex flex-col items-start gap-2",
1631
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1632
+ className: "absolute end-1 top-1 z-0",
1633
+ icon: Close,
1634
+ size: "sm",
1635
+ variant: "ghost",
1636
+ onClick: function onClick() {
1637
+ return setIsNotAppliedPopoverOpen(false);
1638
+ }
1639
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1640
+ className: "w-72 pe-5",
1641
+ variant: "body2",
1642
+ weight: "normal",
1643
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1644
+ components: {
1645
+ bold: /*#__PURE__*/jsxRuntime.jsx("strong", {})
1646
+ },
1647
+ i18nKey: "neetoThemes.build.leftSideBar.themes.notAppliedYet",
1648
+ values: {
1649
+ entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()))
1650
+ }
1651
+ })
1652
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1653
+ disabled: isApplyingTheme,
1654
+ label: t("neetoThemes.buttons.applyThisTheme"),
1655
+ loading: isApplyingTheme,
1656
+ onClick: function onClick() {
1657
+ return onApplyTheme(themeData);
1658
+ }
1659
+ })]
1660
+ })
1661
+ })]
1662
+ })]
1663
+ });
1664
+ }
1665
+ });
1666
+ };
1667
+
1668
+ var QuickActionRow = function QuickActionRow(_ref) {
1669
+ var Icon = _ref.icon,
1670
+ label = _ref.label,
1671
+ onClick = _ref.onClick,
1672
+ testId = _ref.testId;
1673
+ return /*#__PURE__*/jsxRuntime.jsxs("button", {
1674
+ onClick: onClick,
1675
+ className: "border-border hover:bg-muted flex w-full cursor-pointer items-center gap-3 border-t px-3 py-2 text-start transition-colors",
1676
+ "data-testid": testId,
1677
+ type: "button",
1678
+ children: [/*#__PURE__*/jsxRuntime.jsx(Icon, {
1679
+ size: 16
1680
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1681
+ variant: "body2",
1682
+ children: label
1683
+ })]
1684
+ });
1685
+ };
1686
+
1687
+ var Thumbnail = function Thumbnail(_ref) {
1688
+ var _theme$snakeToCamelCa, _findBy, _findBy2;
1689
+ var active = _ref.active,
1690
+ isPreviewing = _ref.isPreviewing,
1691
+ isHighLightedTheme = _ref.isHighLightedTheme,
1692
+ theme = _ref.theme;
1693
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
1694
+ return {
1695
+ themePropertiesSchema: store["themePropertiesSchema"]
1696
+ };
1697
+ }, shallow.shallow),
1698
+ _useConfigStore$theme = _useConfigStore.themePropertiesSchema,
1699
+ themePropertiesSchema = _useConfigStore$theme === void 0 ? [] : _useConfigStore$theme;
1700
+ var _themePropertiesSchem = _slicedToArray(themePropertiesSchema, 2),
1701
+ colorObject1 = _themePropertiesSchem[0],
1702
+ colorObject2 = _themePropertiesSchem[1];
1703
+ var primaryLabel = neetoCist.humanize(colorObject1 === null || colorObject1 === void 0 ? void 0 : colorObject1.key);
1704
+ var secondaryLabel = neetoCist.humanize(colorObject2 === null || colorObject2 === void 0 ? void 0 : colorObject2.key);
1705
+ var primaryColor = neetoCist.findBy({
1706
+ key: colorObject1.key
1707
+ }, theme.properties).value;
1708
+ var secondaryColor = neetoCist.findBy({
1709
+ key: colorObject2.key
1710
+ }, theme.properties).value;
1711
+ var backgroundImageUrl = (_theme$snakeToCamelCa = theme[neetoCist.snakeToCamelCase(neetoCist.findBy({
1712
+ useAsCardBackground: true
1713
+ }, themePropertiesSchema).key)]) === null || _theme$snakeToCamelCa === void 0 ? void 0 : _theme$snakeToCamelCa.url;
1714
+ var buttonBackgroundColor = (_findBy = neetoCist.findBy({
1715
+ key: (_findBy2 = neetoCist.findBy({
1716
+ useAsCardButtonBackground: true
1717
+ }, themePropertiesSchema)) === null || _findBy2 === void 0 ? void 0 : _findBy2.key
1718
+ }, theme.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value;
1719
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
1720
+ className: classnames("neeto-themes-theme-thumbnail rounded-lg border transition-all duration-300 ease-in-out", {
1721
+ "border-gray-400": !active,
1722
+ "border-gray-800 neeto-themes-theme-thumbnail--active": active,
1723
+ "neeto-themes-theme-thumbnail--preview-active": isPreviewing,
1724
+ "neeto-themes-theme-thumbnail--highlight-active": isHighLightedTheme
1725
+ }),
1726
+ style: {
1727
+ backgroundImage: backgroundImageUrl ? "url(".concat(backgroundImageUrl, ")") : "initial",
1728
+ backgroundSize: "cover"
1729
+ },
1730
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
1731
+ className: "rounded-lg cursor-pointer p-3 transition-all duration-300 ease-in-out group-hover:opacity-85",
1732
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1733
+ className: "rounded-lg p-3",
1734
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1735
+ className: "mb-3",
1736
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1737
+ variant: "h3",
1738
+ weight: "semibold",
1739
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
1740
+ style: {
1741
+ color: primaryColor
1742
+ },
1743
+ children: primaryLabel
1744
+ })
1745
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1746
+ className: "text-muted-foreground",
1747
+ variant: "body2",
1748
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
1749
+ style: {
1750
+ color: secondaryColor
1751
+ },
1752
+ children: secondaryLabel
1753
+ })
1754
+ })]
1755
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
1756
+ className: "rounded-lg h-5 w-12",
1757
+ style: {
1758
+ backgroundColor: buttonBackgroundColor
1759
+ }
1760
+ })]
1761
+ })
1762
+ })
1763
+ });
1764
+ };
1765
+
1766
+ var Card = function Card(_ref) {
1767
+ var _ref$active = _ref.active,
1768
+ active = _ref$active === void 0 ? false : _ref$active,
1769
+ isPreviewing = _ref.isPreviewing,
1770
+ onSetPreviewTheme = _ref.onSetPreviewTheme,
1771
+ onDeleteTheme = _ref.onDeleteTheme,
1772
+ onEditTheme = _ref.onEditTheme,
1773
+ theme = _ref.theme,
1774
+ isApplyingTheme = _ref.isApplyingTheme,
1775
+ onCloneTheme = _ref.onCloneTheme,
1776
+ isHighLightedTheme = _ref.isHighLightedTheme,
1777
+ isGlobalTheme = _ref.isGlobalTheme,
1778
+ onApplyTheme = _ref.onApplyTheme,
1779
+ Thumbnail$1 = _ref.thumbnail;
1780
+ var _useTranslation = reactI18next.useTranslation(),
1781
+ t = _useTranslation.t;
1782
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
1783
+ return {
1784
+ themePropertiesSchema: store["themePropertiesSchema"]
1785
+ };
1786
+ }, shallow.shallow),
1787
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema;
1788
+ var id = theme.id,
1789
+ name = theme.name;
1790
+ var imageProperties = neetoCist.filterBy({
1791
+ kind: "image"
1792
+ }, themePropertiesSchema);
1793
+ var handleDeleteTheme = function handleDeleteTheme() {
1794
+ return onDeleteTheme(id, name);
1795
+ };
1796
+ var handleQuickEdit = function handleQuickEdit(section) {
1797
+ return function (e) {
1798
+ e.stopPropagation();
1799
+ if (neetoCist.isPresent(onEditTheme)) onEditTheme(theme, section);else onCloneTheme(theme, section);
1800
+ };
1801
+ };
1802
+ var showMoreDropdown = isFunction(onDeleteTheme);
1803
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
1804
+ className: "group space-y-2 pt-0.5",
1805
+ "data-flip-id": theme.id,
1806
+ "data-testid": active ? "active-theme-card" : "theme-card",
1807
+ id: theme.id,
1808
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1809
+ className: classnames("neeto-themes-theme-thumbnail rounded-lg relative cursor-pointer border-2 transition-all duration-300 ease-in-out", {
1810
+ "border-gray-400": !active,
1811
+ "neeto-themes-theme-thumbnail--active": active,
1812
+ "neeto-themes-theme-thumbnail--preview-active": isPreviewing,
1813
+ "neeto-themes-theme-thumbnail--highlight-active": isHighLightedTheme
1814
+ }),
1815
+ onClick: function onClick() {
1816
+ return onSetPreviewTheme(theme);
1817
+ },
1818
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1819
+ className: "rounded-lg relative overflow-hidden rounded-bl-none rounded-br-none transition-all duration-300 ease-in-out",
1820
+ children: [active ? /*#__PURE__*/jsxRuntime.jsx("div", {
1821
+ className: "neeto-themes-theme-thumbnail__active-banner absolute start-0 top-0 z-10 w-full py-1 text-center text-xs font-semibold uppercase tracking-wide",
1822
+ "data-testid": "active-theme-label",
1823
+ children: t("neetoThemes.common.activeTheme")
1824
+ }) : /*#__PURE__*/jsxRuntime.jsx("div", {
1825
+ className: "absolute start-0 top-0 z-10 flex h-full w-full items-center justify-center px-3 pb-3 pt-3",
1826
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1827
+ className: classnames("-translate-y-9 flex w-full items-center justify-between gap-2", {
1828
+ hidden: !isPreviewing,
1829
+ "group-hover:flex": true
1830
+ }),
1831
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1832
+ "data-testid": "preview-theme-button",
1833
+ disabled: isPreviewing,
1834
+ label: t("neetoThemes.common.previewTheme"),
1835
+ variant: "secondary",
1836
+ className: classnames({
1837
+ "neeto-themes-theme-thumbnail__preview-btn--disabled opacity-100": isPreviewing,
1838
+ "neeto-themes-theme-thumbnail__preview-btn shrink-0 justify-center": true
1839
+ }),
1840
+ onClick: function onClick() {
1841
+ return onSetPreviewTheme(theme);
1842
+ }
1843
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
1844
+ className: "neeto-themes-theme-thumbnail__apply-btn shrink-0 justify-center",
1845
+ "data-testid": "apply-theme-button",
1846
+ disabled: isApplyingTheme,
1847
+ label: t("neetoThemes.common.useTheme"),
1848
+ loading: isApplyingTheme,
1849
+ variant: "default",
1850
+ onClick: function onClick() {
1851
+ return onApplyTheme(theme);
1852
+ }
1853
+ })]
1854
+ })
1855
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
1856
+ className: "neeto-themes-theme-thumbnail__overlay w-full transition-all duration-300 ease-in-out",
1857
+ children: Thumbnail$1 ? /*#__PURE__*/jsxRuntime.jsx(Thumbnail$1, {
1858
+ active: active,
1859
+ isHighLightedTheme: isHighLightedTheme,
1860
+ isPreviewing: isPreviewing,
1861
+ theme: theme
1862
+ }) : /*#__PURE__*/jsxRuntime.jsx(Thumbnail, {
1863
+ active: active,
1864
+ isHighLightedTheme: isHighLightedTheme,
1865
+ isPreviewing: isPreviewing,
1866
+ theme: theme
1867
+ })
1868
+ })]
1869
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1870
+ className: "border-border flex items-start justify-between gap-1 border-t p-2",
1871
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1872
+ className: "flex items-center space-x-2",
1873
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1874
+ className: "text-muted-foreground line-clamp-2 min-w-0 grow wrap-anywhere pt-1 italic",
1875
+ "data-testid": "theme-name",
1876
+ variant: "body2",
1877
+ children: name
1878
+ }), isGlobalTheme && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
1879
+ className: "text-muted-foreground shrink-0 pt-1 italic",
1880
+ "data-testid": "default-theme-label",
1881
+ variant: "body2",
1882
+ children: t("neetoThemes.common.defaultTheme")
1883
+ })]
1884
+ }), showMoreDropdown && /*#__PURE__*/jsxRuntime.jsx(MoreDropdown, {
1885
+ dropdownButtonProps: {
1886
+ size: "sm"
1887
+ },
1888
+ dropdownProps: {
1889
+ strategy: "fixed",
1890
+ onClick: function onClick(e) {
1891
+ return e.stopPropagation();
1892
+ }
1893
+ },
1894
+ menuItems: [{
1895
+ key: "delete",
1896
+ "data-testid": "delete-theme-menu-item",
1897
+ label: t("neetoThemes.build.leftSideBar.themes.themeOptions.delete"),
1898
+ isDisabled: isApplyingTheme,
1899
+ onClick: function onClick(e) {
1900
+ e.stopPropagation();
1901
+ handleDeleteTheme();
1902
+ }
1903
+ }]
1904
+ })]
1905
+ }), active && /*#__PURE__*/jsxRuntime.jsxs("div", {
1906
+ className: "flex flex-col",
1907
+ children: [/*#__PURE__*/jsxRuntime.jsx(QuickActionRow, {
1908
+ icon: ColorPicker,
1909
+ label: t("neetoThemes.common.customizeStyle"),
1910
+ testId: "quick-customize-style",
1911
+ onClick: handleQuickEdit("style")
1912
+ }), imageProperties.map(function (_ref2) {
1913
+ var _theme$camelKey;
1914
+ var key = _ref2.key;
1915
+ var camelKey = neetoCist.snakeToCamelCase(key);
1916
+ var hasImage = neetoCist.isPresent((_theme$camelKey = theme[camelKey]) === null || _theme$camelKey === void 0 ? void 0 : _theme$camelKey.url);
1917
+ var action = hasImage ? "change" : "add";
1918
+ var specificKey = "neetoThemes.common.".concat(action).concat(neetoCist.capitalize(camelKey));
1919
+ return /*#__PURE__*/jsxRuntime.jsx(QuickActionRow, {
1920
+ icon: AddImage,
1921
+ label: t([specificKey, "neetoThemes.common.addImage"]),
1922
+ testId: "quick-add-".concat(neetoCist.hyphenate(key)),
1923
+ onClick: handleQuickEdit(camelKey)
1924
+ }, key);
1925
+ }), /*#__PURE__*/jsxRuntime.jsx(QuickActionRow, {
1926
+ icon: CodeBlock,
1927
+ label: t("neetoThemes.build.leftSideBar.themes.customCSS"),
1928
+ testId: "quick-custom-css",
1929
+ onClick: handleQuickEdit("customcss")
1930
+ })]
1931
+ })]
1932
+ })
1933
+ });
1934
+ };
1935
+ var Card$1 = /*#__PURE__*/react.memo(Card);
1936
+
1937
+ var Themes = function Themes(_ref) {
1938
+ var onEditTheme = _ref.onEditTheme,
1939
+ _ref$themes = _ref.themes,
1940
+ themes = _ref$themes === void 0 ? [] : _ref$themes,
1941
+ _ref$defaultThemes = _ref.defaultThemes,
1942
+ defaultThemes = _ref$defaultThemes === void 0 ? [] : _ref$defaultThemes,
1943
+ onDeleteTheme = _ref.onDeleteTheme,
1944
+ themeToHighlight = _ref.themeToHighlight,
1945
+ didScrollActiveThemeIntoView = _ref.didScrollActiveThemeIntoView,
1946
+ isLoading = _ref.isLoading,
1947
+ currentTheme = _ref.currentTheme,
1948
+ isCurrentThemeLoading = _ref.isCurrentThemeLoading,
1949
+ thumbnail = _ref.thumbnail,
1950
+ themeBeingApplied = _ref.themeBeingApplied,
1951
+ onApplyTheme = _ref.onApplyTheme,
1952
+ onApplyThemeSuccess = _ref.onApplyThemeSuccess,
1953
+ _ref$isSearchVisible = _ref.isSearchVisible,
1954
+ isSearchVisible = _ref$isSearchVisible === void 0 ? false : _ref$isSearchVisible;
1955
+ var _useTranslation = reactI18next.useTranslation(),
1956
+ t = _useTranslation.t;
1957
+ var _useThemeUtils = useExpandedSection.useThemeUtils(),
1958
+ setTheme = _useThemeUtils.setTheme;
1959
+ var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
1960
+ return {
1961
+ setThemeState: store["setThemeState"],
1962
+ previewingTheme: store["previewingTheme"]
1963
+ };
1964
+ }, shallow.shallow),
1965
+ setThemeState = _useThemeStore.setThemeState,
1966
+ previewingTheme = _useThemeStore.previewingTheme;
1967
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
1968
+ return {
1969
+ entityType: store["entityType"],
1970
+ entityId: store["entityId"]
1971
+ };
1972
+ }, shallow.shallow),
1973
+ entityType = _useConfigStore.entityType,
1974
+ entityId = _useConfigStore.entityId;
1975
+ var _useQueryParams = reactUtils.useQueryParams(),
1976
+ _useQueryParams$searc = _useQueryParams.searchTerm,
1977
+ searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
1978
+ var _useCloneTheme = useGlobalThemesApi.useCloneTheme(),
1979
+ cloneTheme = _useCloneTheme.mutate;
1980
+ var _useApplyTheme = useGlobalThemesApi.useApplyTheme({}),
1981
+ applyClonedTheme = _useApplyTheme.mutate;
1982
+ var _useShowGlobalTheme = useGlobalThemesApi.useShowGlobalTheme(entityType),
1983
+ _useShowGlobalTheme$d = _useShowGlobalTheme.data,
1984
+ _useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
1985
+ _useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
1986
+ globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3,
1987
+ isLoadingGlobalTheme = _useShowGlobalTheme.isLoading;
1988
+ react.useEffect(function () {
1989
+ if (didScrollActiveThemeIntoView.current || !(currentTheme !== null && currentTheme !== void 0 && currentTheme.id)) return;
1990
+ didScrollActiveThemeIntoView.current = true;
1991
+ setTimeout(function () {
1992
+ scrollElementIntoView(currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1993
+ }, 100);
1994
+ }, [didScrollActiveThemeIntoView, currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id]);
1995
+ var setPreviewTheme = function setPreviewTheme(theme) {
1996
+ setThemeState({
1997
+ previewingTheme: theme
1998
+ });
1999
+ setTheme(theme);
2000
+ };
2001
+ var activeThemeId = currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id;
2002
+ var lowerSearchTerm = searchTerm.toLowerCase();
2003
+ var matchesSearch = function matchesSearch(theme) {
2004
+ return theme.name.toLowerCase().includes(lowerSearchTerm);
2005
+ };
2006
+ var activeTheme = activeThemeId ? [].concat(_toConsumableArray(defaultThemes), _toConsumableArray(themes)).find(function (theme) {
2007
+ return theme.id === activeThemeId;
2008
+ }) : null;
2009
+ var isActiveThemeCustom = themes.some(function (theme) {
2010
+ return theme.id === activeThemeId;
2011
+ });
2012
+ var filteredDefaultThemes = defaultThemes.filter(function (theme) {
2013
+ return theme.id !== activeThemeId && matchesSearch(theme);
2014
+ });
2015
+ var filteredThemes = themes.filter(function (theme) {
2016
+ return theme.id !== activeThemeId && matchesSearch(theme);
2017
+ });
2018
+ var showActiveThemeSection = activeTheme && matchesSearch(activeTheme);
2019
+ var handleCloneTheme = function handleCloneTheme(data, section) {
2020
+ cloneTheme(data.id, {
2021
+ onSuccess: function onSuccess(_ref2) {
2022
+ var clonedTheme = _ref2.theme;
2023
+ applyClonedTheme({
2024
+ themeId: clonedTheme.id,
2025
+ entityId: entityId,
2026
+ entityType: entityType
2027
+ }, {
2028
+ onSuccess: function onSuccess() {
2029
+ onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(clonedTheme);
2030
+ onEditTheme(clonedTheme, section);
2031
+ }
2032
+ });
2033
+ }
2034
+ });
2035
+ };
2036
+ if (isLoading || isCurrentThemeLoading || isLoadingGlobalTheme) {
2037
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
2038
+ className: "flex h-full w-full items-center justify-center",
2039
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Spinner, {})
2040
+ });
2041
+ }
2042
+ var activeThemeSection = showActiveThemeSection && /*#__PURE__*/jsxRuntime.jsx("div", {
2043
+ className: "border-border mb-6 border-b px-6 pb-6 lg:px-5 xl:px-6",
2044
+ children: /*#__PURE__*/jsxRuntime.jsx(Card$1, {
2045
+ onApplyTheme: onApplyTheme,
2046
+ thumbnail: thumbnail,
2047
+ active: true,
2048
+ isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === activeTheme.id,
2049
+ isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === activeTheme.id,
2050
+ isHighLightedTheme: activeTheme.id === themeToHighlight,
2051
+ isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === activeTheme.id,
2052
+ theme: activeTheme,
2053
+ onCloneTheme: handleCloneTheme,
2054
+ onEditTheme: isActiveThemeCustom ? onEditTheme : undefined,
2055
+ onSetPreviewTheme: setPreviewTheme
2056
+ })
2057
+ });
2058
+ var systemThemesSection = neetoCist.isNotEmpty(filteredDefaultThemes) && /*#__PURE__*/jsxRuntime.jsx("div", {
2059
+ className: "mb-6 space-y-3",
2060
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
2061
+ className: "flex flex-col gap-4 px-6 pb-10 lg:px-5 xl:px-6",
2062
+ "data-testid": "system-themes",
2063
+ children: filteredDefaultThemes.map(function (theme) {
2064
+ return /*#__PURE__*/react.createElement(Card$1, {
2065
+ onApplyTheme: onApplyTheme,
2066
+ theme: theme,
2067
+ thumbnail: thumbnail,
2068
+ active: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id,
2069
+ isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
2070
+ isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === theme.id,
2071
+ isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
2072
+ key: theme.id,
2073
+ onCloneTheme: handleCloneTheme,
2074
+ onSetPreviewTheme: setPreviewTheme
2075
+ });
2076
+ })
2077
+ })
2078
+ });
2079
+ var customThemesSection = neetoCist.isNotEmpty(filteredThemes) && /*#__PURE__*/jsxRuntime.jsx("div", {
2080
+ className: "mb-6 space-y-3",
2081
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
2082
+ className: "flex flex-col gap-4 px-6",
2083
+ "data-testid": "custom-themes",
2084
+ children: filteredThemes.map(function (theme) {
2085
+ var isActive = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id;
2086
+ var isPreviewing = (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id;
2087
+ return /*#__PURE__*/react.createElement(Card$1, {
2088
+ isPreviewing: isPreviewing,
2089
+ onApplyTheme: onApplyTheme,
2090
+ onEditTheme: onEditTheme,
2091
+ theme: theme,
2092
+ thumbnail: thumbnail,
2093
+ active: isActive,
2094
+ isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
2095
+ isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === theme.id,
2096
+ isHighLightedTheme: theme.id === themeToHighlight,
2097
+ key: theme.id,
2098
+ onCloneTheme: handleCloneTheme,
2099
+ onDeleteTheme: !isActive && onDeleteTheme,
2100
+ onSetPreviewTheme: setPreviewTheme
2101
+ });
2102
+ })
2103
+ })
2104
+ });
2105
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
2106
+ className: "neeto-themes-sidebar__scroll",
2107
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
2108
+ className: "mb-6 space-y-3",
2109
+ children: [isSearchVisible && /*#__PURE__*/jsxRuntime.jsx(Search, {
2110
+ autoFocus: true,
2111
+ enableUrlSync: true,
2112
+ autoComplete: "off",
2113
+ className: "mb-4 mt-1 px-6",
2114
+ placeholder: t("neetoThemes.common.searchThemes")
2115
+ }), ramda.isEmpty(filteredThemes) && ramda.isEmpty(filteredDefaultThemes) && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
2116
+ className: "text-center",
2117
+ "data-testid": "no-data-title",
2118
+ variant: "body2",
2119
+ children: t("neetoThemes.common.noResultsFound")
2120
+ })]
2121
+ }), activeThemeSection, systemThemesSection, customThemesSection]
2122
+ });
2123
+ };
2124
+
2125
+ var TitleBar = function TitleBar(_ref) {
2126
+ var currentScreen = _ref.currentScreen,
2127
+ handleBackPress = _ref.handleBackPress,
2128
+ handleToggleSearch = _ref.handleToggleSearch;
2129
+ var _useTranslation = reactI18next.useTranslation(),
2130
+ t = _useTranslation.t;
2131
+ var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
2132
+ return {
2133
+ previewingTheme: store["previewingTheme"]
2134
+ };
2135
+ }, shallow.shallow),
2136
+ previewingTheme = _useThemeStore.previewingTheme;
2137
+ var themeId = previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id;
2138
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
2139
+ return {
2140
+ entityType: store["entityType"],
2141
+ helpDocUrl: store["helpDocUrl"]
2142
+ };
2143
+ }, shallow.shallow),
2144
+ entityType = _useConfigStore.entityType,
2145
+ helpDocUrl = _useConfigStore.helpDocUrl;
2146
+ var isCustomizeScreen = isEditThemeRoute() || isNewThemeRoute();
2147
+ var isCustomCssScreen = isScreenCustomCSS(currentScreen);
2148
+ var isRTL = i18n.dir() === "rtl";
2149
+ var BackButtonIcon = isRTL ? RightArrow : LeftArrow;
2150
+ if (isCustomizeScreen) {
2151
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
2152
+ className: "neeto-themes-sidebar__header px-4",
2153
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
2154
+ className: "flex items-center justify-start space-x-2",
2155
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
2156
+ "data-testid": "customize-themes-back-button",
2157
+ icon: BackButtonIcon,
2158
+ iconPosition: "left",
2159
+ variant: "ghost",
2160
+ tooltipProps: {
2161
+ content: isCustomCssScreen ? t("neetoThemes.buttons.backToEdit") : t("neetoThemes.buttons.backToThemes"),
2162
+ position: "top"
2163
+ },
2164
+ onClick: function onClick() {
2165
+ return handleBackPress(themeId);
2166
+ }
2167
+ }), /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Typography, {
2168
+ "data-testid": "themes-header",
2169
+ variant: "h3",
2170
+ weight: "semibold",
2171
+ children: [isCustomizeScreen && !isCustomCssScreen && (isNewThemeRoute() ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
2172
+ })]
2173
+ })
2174
+ });
2175
+ }
2176
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
2177
+ className: "neeto-themes-sidebar__header px-6 lg:px-5 xl:px-6",
2178
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
2179
+ className: "flex items-center justify-between space-x-2",
2180
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
2181
+ className: "flex space-x-2",
2182
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
2183
+ "data-testid": "themes-header",
2184
+ variant: "h3",
2185
+ weight: "semibold",
2186
+ children: t("neetoThemes.build.leftSideBar.headerTabs.themes")
2187
+ }), /*#__PURE__*/jsxRuntime.jsx(HelpPopover, {
2188
+ helpLinkProps: helpDocUrl && {
2189
+ href: helpDocUrl
2190
+ },
2191
+ title: t("neetoThemes.build.leftSideBar.helpPopover.title"),
2192
+ description: t("neetoThemes.build.leftSideBar.helpPopover.description", {
2193
+ entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()))
2194
+ })
2195
+ })]
2196
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
2197
+ className: "self-end",
2198
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
2199
+ "data-testid": "themes-search-toggle-button",
2200
+ icon: Search$1,
2201
+ iconPosition: "left",
2202
+ variant: "ghost",
2203
+ tooltipProps: {
2204
+ content: t("neetoThemes.common.searchThemes"),
2205
+ position: "top"
2206
+ },
2207
+ onClick: handleToggleSearch
2208
+ })
2209
+ })]
2210
+ })
2211
+ });
2212
+ };
2213
+
2214
+ var MemoizedAlert = /*#__PURE__*/react.memo(neetoAtoms.Alert);
2215
+ var Sidebar = function Sidebar(_ref) {
2216
+ var _themeToDelete$curren2;
2217
+ var thumbnail = _ref.thumbnail,
2218
+ onPropertiesChange = _ref.onPropertiesChange,
2219
+ defaultImageSize = _ref.defaultImageSize,
2220
+ fixedAspectRatio = _ref.fixedAspectRatio,
2221
+ onApplyThemeSuccess = _ref.onApplyThemeSuccess,
2222
+ onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
2223
+ var _useState = react.useState(DESIGN_SCREENS.THEMES),
2224
+ _useState2 = _slicedToArray(_useState, 2),
2225
+ currentScreen = _useState2[0],
2226
+ setCurrentScreen = _useState2[1];
2227
+ var _useState3 = react.useState(false),
2228
+ _useState4 = _slicedToArray(_useState3, 2),
2229
+ isDeleteAlertOpen = _useState4[0],
2230
+ setIsDeleteAlertOpen = _useState4[1];
2231
+ var _useState5 = react.useState(null),
2232
+ _useState6 = _slicedToArray(_useState5, 2),
2233
+ themeToHighlight = _useState6[0],
2234
+ setThemeToHighlight = _useState6[1];
2235
+ var _useState7 = react.useState({}),
2236
+ _useState8 = _slicedToArray(_useState7, 2),
2237
+ themeBeingApplied = _useState8[0],
2238
+ setThemeBeingApplied = _useState8[1];
2239
+ var _useBreakpoints = reactUtils.useBreakpoints(),
2240
+ isSize = _useBreakpoints.isSize;
2241
+ var isLargerScreen = !isSize("mobile");
2242
+ var _useState9 = react.useState(!isLargerScreen),
2243
+ _useState10 = _slicedToArray(_useState9, 2),
2244
+ isThemesSidebarCollapsed = _useState10[0],
2245
+ setIsThemesSidebarCollapsed = _useState10[1];
2246
+ var history = reactRouterDom.useHistory();
2247
+ react.useEffect(function () {
2248
+ setIsThemesSidebarCollapsed(!isLargerScreen);
2249
+ }, [isLargerScreen]);
2250
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
2251
+ return {
2252
+ entityType: store["entityType"],
2253
+ entityId: store["entityId"],
2254
+ isFetchingSchema: store["isFetchingSchema"],
2255
+ defaultThemeName: store["defaultThemeName"]
2256
+ };
2257
+ }, shallow.shallow),
2258
+ entityType = _useConfigStore.entityType,
2259
+ entityId = _useConfigStore.entityId,
2260
+ isFetchingSchema = _useConfigStore.isFetchingSchema,
2261
+ defaultThemeName = _useConfigStore.defaultThemeName;
2262
+ var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
2263
+ return {
2264
+ setThemeState: store["setThemeState"]
2265
+ };
2266
+ }, shallow.shallow),
2267
+ setThemeState = _useThemeStore.setThemeState;
2268
+ var didScrollActiveThemeIntoView = react.useRef(null);
2269
+ var _useTranslation = reactI18next.useTranslation(),
2270
+ t = _useTranslation.t;
2271
+ var _useThemeUtils = useExpandedSection.useThemeUtils(),
2272
+ setTheme = _useThemeUtils.setTheme;
2273
+ var _useListThemes = useGlobalThemesApi.useListThemes(entityId),
2274
+ _useListThemes$data = _useListThemes.data,
2275
+ _useListThemes$data2 = _useListThemes$data === void 0 ? {} : _useListThemes$data,
2276
+ _useListThemes$data2$ = _useListThemes$data2.themes,
2277
+ themes = _useListThemes$data2$ === void 0 ? [] : _useListThemes$data2$,
2278
+ _useListThemes$data2$2 = _useListThemes$data2.defaultThemes,
2279
+ defaultThemes = _useListThemes$data2$2 === void 0 ? [] : _useListThemes$data2$2,
2280
+ isLoading = _useListThemes.isLoading;
2281
+ var _useShowThemeEntity = useGlobalThemesApi.useShowThemeEntity(entityId),
2282
+ _useShowThemeEntity$d = _useShowThemeEntity.data,
2283
+ _useShowThemeEntity$d2 = _useShowThemeEntity$d === void 0 ? {} : _useShowThemeEntity$d,
2284
+ _useShowThemeEntity$d3 = _useShowThemeEntity$d2.theme,
2285
+ currentTheme = _useShowThemeEntity$d3 === void 0 ? {} : _useShowThemeEntity$d3,
2286
+ isCurrentThemeLoading = _useShowThemeEntity.isLoading;
2287
+ var _useDeleteTheme = useGlobalThemesApi.useDeleteTheme(),
2288
+ deleteTheme = _useDeleteTheme.mutate,
2289
+ isDeleting = _useDeleteTheme.isPending;
2290
+ var _useApplyTheme = useGlobalThemesApi.useApplyTheme({
2291
+ onSuccess: function onSuccess(_ref2) {
2292
+ var theme = _ref2.theme;
2293
+ var applyUpdates = function applyUpdates() {
2294
+ setTheme(theme);
2295
+ highlightTheme(theme);
2296
+ setThemeState({
2297
+ previewingTheme: theme
2298
+ });
2299
+ setThemeBeingApplied({});
2300
+ setCurrentScreen(DESIGN_SCREENS.THEMES);
2301
+ onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(theme);
2302
+ };
2303
+
2304
+ // Keep the spinner visible a bit longer so the apply feels deliberate,
2305
+ // then glide the card into the pinned active section.
2306
+ setTimeout(function () {
2307
+ return animateThemeReorder(applyUpdates);
2308
+ }, APPLY_SPINNER_DELAY);
2309
+ }
2310
+ }),
2311
+ applyTheme = _useApplyTheme.mutate,
2312
+ isApplyingTheme = _useApplyTheme.isPending;
2313
+ var themeToDelete = react.useRef(null);
2314
+ var themeToEdit = react.useRef(null);
2315
+ var isCustomCssScreen = isScreenCustomCSS(currentScreen);
2316
+ var _useState11 = react.useState(false),
2317
+ _useState12 = _slicedToArray(_useState11, 2),
2318
+ isSearchVisible = _useState12[0],
2319
+ setIsSearchVisible = _useState12[1];
2320
+ var handleToggleSearch = function handleToggleSearch() {
2321
+ setIsSearchVisible(function (prev) {
2322
+ var next = !prev;
2323
+ if (!next) {
2324
+ var params = new URLSearchParams(history.location.search);
2325
+ params["delete"]("searchTerm");
2326
+ history.replace({
2327
+ search: params.toString()
2328
+ });
2329
+ }
2330
+ return next;
2331
+ });
2332
+ };
2333
+ var handleEditTheme = function handleEditTheme(theme, section) {
2334
+ themeToEdit.current = theme;
2335
+ var pathname = utils$1.buildUrl(buildPathname(useGlobalThemesApi.routes.themes.edit), {
2336
+ themeId: theme.id
2337
+ });
2338
+ history.push({
2339
+ pathname: pathname,
2340
+ search: section ? "?section=".concat(section) : ""
2341
+ });
2342
+ };
2343
+ var onApplyTheme = function onApplyTheme(theme) {
2344
+ if (themeBeingApplied !== null && themeBeingApplied !== void 0 && themeBeingApplied.id) return;
2345
+ setThemeBeingApplied(theme);
2346
+ applyTheme({
2347
+ themeId: theme.id,
2348
+ entityId: entityId,
2349
+ entityType: entityType
2350
+ }, {
2351
+ onError: function onError() {
2352
+ return setThemeBeingApplied({});
2353
+ }
2354
+ });
2355
+ };
2356
+ var navigateToThemesScreen = function navigateToThemesScreen(themeId) {
2357
+ highlightTheme(neetoCist.isPresent(themeId) ? themeId : currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
2358
+ history.push(buildPathname(useGlobalThemesApi.routes.themes.index));
2359
+ themeToEdit.current = null;
2360
+ };
2361
+ var handleBackPress = function handleBackPress(themeId) {
2362
+ if (isCustomCssScreen) {
2363
+ setCurrentScreen(DESIGN_SCREENS.Customize);
2364
+ return;
2365
+ }
2366
+ navigateToThemesScreen(themeId);
2367
+ };
2368
+ var highlightTheme = function highlightTheme(themeIdToHighlight) {
2369
+ setTimeout(function () {
2370
+ scrollElementIntoView(themeIdToHighlight);
2371
+ }, 1500);
2372
+ setTimeout(function () {
2373
+ setThemeToHighlight(null);
2374
+ }, 4000);
2375
+ setThemeToHighlight(themeIdToHighlight);
2376
+ };
2377
+ var onCreateTheme = function onCreateTheme(createdTheme) {
2378
+ themeToEdit.current = createdTheme;
2379
+ setTheme(createdTheme);
2380
+ setThemeState({
2381
+ previewingTheme: createdTheme
2382
+ });
2383
+ };
2384
+ var onUpdateTheme = function onUpdateTheme(updatedTheme) {
2385
+ themeToEdit.current = updatedTheme;
2386
+ onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 || onUpdateThemeSuccess(updatedTheme);
2387
+ };
2388
+ var handleDelete = function handleDelete(themeId, name) {
2389
+ setIsDeleteAlertOpen(true);
2390
+ themeToDelete.current = {
2391
+ id: themeId,
2392
+ name: name
2393
+ };
2394
+ };
2395
+ var handleCloseDeleteAlert = react.useCallback(function () {
2396
+ setIsDeleteAlertOpen(false);
2397
+ themeToDelete.current = null;
2398
+ }, [themeToDelete]);
2399
+ var handleDeleteTheme = react.useCallback(function () {
2400
+ var _themeToDelete$curren;
2401
+ deleteTheme((_themeToDelete$curren = themeToDelete.current) === null || _themeToDelete$curren === void 0 ? void 0 : _themeToDelete$curren.id, {
2402
+ onSuccess: function onSuccess() {
2403
+ setIsDeleteAlertOpen(false);
2404
+ themeToDelete.current = null;
2405
+ }
2406
+ });
2407
+ }, [deleteTheme, themeToDelete]);
2408
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2409
+ children: [!isThemesSidebarCollapsed && /*#__PURE__*/jsxRuntime.jsx("div", {
2410
+ className: "neeto-themes-sidebar__backdrop",
2411
+ onClick: function onClick() {
2412
+ setIsThemesSidebarCollapsed(!isThemesSidebarCollapsed);
2413
+ }
2414
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
2415
+ className: classnames("neeto-themes-sidebar border-border shrink-0 border-e transition-all duration-300", {
2416
+ "neeto-themes-sidebar--expanded": isCustomCssScreen
2417
+ }, {
2418
+ "neeto-themes-sidebar--collapsed": isThemesSidebarCollapsed
2419
+ }),
2420
+ children: [/*#__PURE__*/jsxRuntime.jsx(TitleBar, {
2421
+ currentScreen: currentScreen,
2422
+ handleBackPress: handleBackPress,
2423
+ handleToggleSearch: handleToggleSearch
2424
+ }), /*#__PURE__*/jsxRuntime.jsxs(reactRouterDom.Switch, {
2425
+ children: [/*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, {
2426
+ exact: true,
2427
+ path: buildPathname(useGlobalThemesApi.routes.themes.index),
2428
+ render: function render() {
2429
+ return /*#__PURE__*/jsxRuntime.jsx(Themes, {
2430
+ currentTheme: currentTheme,
2431
+ defaultThemes: defaultThemes,
2432
+ didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
2433
+ highlightTheme: highlightTheme,
2434
+ isCurrentThemeLoading: isCurrentThemeLoading,
2435
+ isSearchVisible: isSearchVisible,
2436
+ onApplyTheme: onApplyTheme,
2437
+ onApplyThemeSuccess: onApplyThemeSuccess,
2438
+ themeBeingApplied: themeBeingApplied,
2439
+ themeToHighlight: themeToHighlight,
2440
+ themes: themes,
2441
+ thumbnail: thumbnail,
2442
+ isLoading: isLoading || isFetchingSchema,
2443
+ onDeleteTheme: handleDelete,
2444
+ onEditTheme: handleEditTheme
2445
+ });
2446
+ }
2447
+ }), /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, {
2448
+ path: buildPathname(useGlobalThemesApi.routes.themes["new"]),
2449
+ render: function render() {
2450
+ return /*#__PURE__*/jsxRuntime.jsx(Customize, {
2451
+ currentScreen: currentScreen,
2452
+ defaultImageSize: defaultImageSize,
2453
+ fixedAspectRatio: fixedAspectRatio,
2454
+ isApplyingTheme: isApplyingTheme,
2455
+ onApplyTheme: onApplyTheme,
2456
+ onCreateTheme: onCreateTheme,
2457
+ onPropertiesChange: onPropertiesChange,
2458
+ onUpdateTheme: onUpdateTheme,
2459
+ theme: themeToEdit.current,
2460
+ onEditCSSClick: setCurrentScreen
2461
+ });
2462
+ }
2463
+ }), /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, {
2464
+ path: buildPathname(useGlobalThemesApi.routes.themes.edit),
2465
+ render: function render() {
2466
+ return /*#__PURE__*/jsxRuntime.jsx(Customize, {
2467
+ currentScreen: currentScreen,
2468
+ defaultImageSize: defaultImageSize,
2469
+ fixedAspectRatio: fixedAspectRatio,
2470
+ isApplyingTheme: isApplyingTheme,
2471
+ onApplyTheme: onApplyTheme,
2472
+ onCreateTheme: onCreateTheme,
2473
+ onPropertiesChange: onPropertiesChange,
2474
+ onUpdateTheme: onUpdateTheme,
2475
+ theme: themeToEdit.current,
2476
+ onEditCSSClick: setCurrentScreen
2477
+ });
2478
+ }
2479
+ })]
2480
+ }), /*#__PURE__*/jsxRuntime.jsx(MemoizedAlert, {
2481
+ isOpen: isDeleteAlertOpen,
2482
+ isSubmitting: isDeleting,
2483
+ title: t("neetoThemes.alerts.title.deleteTheme"),
2484
+ message: t("neetoThemes.alerts.message.deleteTheme", {
2485
+ name: (_themeToDelete$curren2 = themeToDelete.current) === null || _themeToDelete$curren2 === void 0 ? void 0 : _themeToDelete$curren2.name,
2486
+ defaultThemeName: defaultThemeName,
2487
+ entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()))
2488
+ }),
2489
+ onClose: handleCloseDeleteAlert,
2490
+ onSubmit: handleDeleteTheme
2491
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
2492
+ className: "neeto-themes-sidebar__toggler",
2493
+ icon: Collapse,
2494
+ variant: "outline",
2495
+ onClick: function onClick() {
2496
+ setIsThemesSidebarCollapsed(!isThemesSidebarCollapsed);
2497
+ }
2498
+ })]
2499
+ })]
2500
+ });
2501
+ };
2502
+
2503
+ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2504
+ var children = _ref.children,
2505
+ entityType = _ref.entityType,
2506
+ entityId = _ref.entityId,
2507
+ thumbnail = _ref.thumbnail,
2508
+ onPropertiesChange = _ref.onPropertiesChange,
2509
+ _ref$defaultImageSize = _ref.defaultImageSize,
2510
+ defaultImageSize = _ref$defaultImageSize === void 0 ? {} : _ref$defaultImageSize,
2511
+ _ref$fixedAspectRatio = _ref.fixedAspectRatio,
2512
+ fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio,
2513
+ _ref$helpDocUrl = _ref.helpDocUrl,
2514
+ helpDocUrl = _ref$helpDocUrl === void 0 ? null : _ref$helpDocUrl,
2515
+ _ref$isTemplateThemes = _ref.isTemplateThemesEnabled,
2516
+ isTemplateThemesEnabled = _ref$isTemplateThemes === void 0 ? false : _ref$isTemplateThemes,
2517
+ _ref$pageTitle = _ref.pageTitle,
2518
+ pageTitle = _ref$pageTitle === void 0 ? null : _ref$pageTitle,
2519
+ _ref$onApplyThemeSucc = _ref.onApplyThemeSuccess,
2520
+ onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? neetoCist.noop : _ref$onApplyThemeSucc,
2521
+ _ref$onUpdateThemeSuc = _ref.onUpdateThemeSuccess,
2522
+ onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? neetoCist.noop : _ref$onUpdateThemeSuc,
2523
+ _ref$helpPopoverProps = _ref.helpPopoverProps,
2524
+ helpPopoverProps = _ref$helpPopoverProps === void 0 ? {} : _ref$helpPopoverProps,
2525
+ _ref$enabledFeatures = _ref.enabledFeatures,
2526
+ enabledFeatures = _ref$enabledFeatures === void 0 ? {
2527
+ customCSS: true
2528
+ } : _ref$enabledFeatures,
2529
+ _ref$proFeatures = _ref.proFeatures,
2530
+ proFeatures = _ref$proFeatures === void 0 ? {} : _ref$proFeatures;
2531
+ react.useMemo(useGlobalThemesApi.registerNeetoThemesTranslations, []);
2532
+ var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
2533
+ return {
2534
+ setThemeState: store["setThemeState"]
2535
+ };
2536
+ }, shallow.shallow),
2537
+ setThemeState = _useThemeStore.setThemeState;
2538
+ var _useThemeUtils = useExpandedSection.useThemeUtils(),
2539
+ setTheme = _useThemeUtils.setTheme;
2540
+ var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
2541
+ return {
2542
+ setConfigState: store["setConfigState"]
2543
+ };
2544
+ }, shallow.shallow),
2545
+ setConfigState = _useConfigStore.setConfigState;
2546
+ var _useTranslation = reactI18next.useTranslation(),
2547
+ t = _useTranslation.t;
2548
+ var _useShowThemeEntity = useGlobalThemesApi.useShowThemeEntity(entityId),
2549
+ _useShowThemeEntity$d = _useShowThemeEntity.data,
2550
+ _useShowThemeEntity$d2 = _useShowThemeEntity$d === void 0 ? {} : _useShowThemeEntity$d,
2551
+ _useShowThemeEntity$d3 = _useShowThemeEntity$d2.theme,
2552
+ currentTheme = _useShowThemeEntity$d3 === void 0 ? {} : _useShowThemeEntity$d3,
2553
+ isLoading = _useShowThemeEntity.isLoading,
2554
+ isFetchingCurrentTheme = _useShowThemeEntity.isFetching;
2555
+ var isCurrentThemeLoading = isLoading || isFetchingCurrentTheme;
2556
+ react.useEffect(function () {
2557
+ setConfigState({
2558
+ entityType: entityType,
2559
+ entityId: entityId,
2560
+ isTemplateThemesEnabled: isTemplateThemesEnabled,
2561
+ helpDocUrl: helpDocUrl,
2562
+ helpPopoverProps: helpPopoverProps,
2563
+ enabledFeatures: enabledFeatures,
2564
+ proFeatures: proFeatures
2565
+ });
2566
+ }, []);
2567
+ react.useEffect(function () {
2568
+ if (neetoCist.isNotPresent(currentTheme) || isEditThemeRoute()) {
2569
+ return;
2570
+ }
2571
+ setThemeState({
2572
+ previewingTheme: currentTheme
2573
+ });
2574
+ setTheme(currentTheme);
2575
+ }, [isLoading, entityId, currentTheme]);
2576
+ react.useEffect(function () {
2577
+ if (neetoCist.isNotPresent(currentTheme)) return;
2578
+ setThemeState({
2579
+ currentTheme: currentTheme,
2580
+ isCurrentThemeLoading: isCurrentThemeLoading
2581
+ });
2582
+ }, [currentTheme, isCurrentThemeLoading]);
2583
+ react.useEffect(function () {
2584
+ var setViewportHeight = function setViewportHeight() {
2585
+ document.documentElement.style.setProperty("--viewport-height", "".concat(window.innerHeight, "px"));
2586
+ };
2587
+ setViewportHeight();
2588
+ window.addEventListener("load", setViewportHeight);
2589
+ window.addEventListener("resize", setViewportHeight);
2590
+ window.addEventListener("orientationchange", setViewportHeight);
2591
+ window.addEventListener("scroll", setViewportHeight);
2592
+ return function () {
2593
+ window.removeEventListener("load", setViewportHeight);
2594
+ window.removeEventListener("resize", setViewportHeight);
2595
+ window.removeEventListener("orientationchange", setViewportHeight);
2596
+ window.removeEventListener("scroll", setViewportHeight);
2597
+ };
2598
+ }, []);
2599
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
2600
+ className: "neeto-themes__wrapper",
2601
+ children: [/*#__PURE__*/jsxRuntime.jsx(reactUtils.PageTitle, {
2602
+ title: pageTitle || t("neetoThemes.common.theme")
2603
+ }), /*#__PURE__*/jsxRuntime.jsx(Sidebar, {
2604
+ defaultImageSize: defaultImageSize,
2605
+ fixedAspectRatio: fixedAspectRatio,
2606
+ onApplyThemeSuccess: onApplyThemeSuccess,
2607
+ onPropertiesChange: onPropertiesChange,
2608
+ onUpdateThemeSuccess: onUpdateThemeSuccess,
2609
+ thumbnail: thumbnail
2610
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
2611
+ className: "neeto-themes-preview__wrapper",
2612
+ children: isCurrentThemeLoading ? /*#__PURE__*/jsxRuntime.jsx("div", {
2613
+ className: "m-auto flex h-full w-full items-center justify-center",
2614
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Spinner, {})
2615
+ }) : children
2616
+ })]
2617
+ });
2618
+ };
2619
+
2620
+ module.exports = NeetoThemesBuilder;
2621
+ //# sourceMappingURL=NeetoThemesBuilder.js.map