@elementor/editor-controls 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/index.d.mts +37 -25
  3. package/dist/index.d.ts +37 -25
  4. package/dist/index.js +558 -274
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +529 -239
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +11 -6
  9. package/src/bound-prop-context/prop-key-context.tsx +1 -1
  10. package/src/components/repeater.tsx +10 -4
  11. package/src/components/text-field-inner-selection.tsx +2 -2
  12. package/src/control-actions/control-actions-context.tsx +1 -1
  13. package/src/control-actions/control-actions.tsx +1 -1
  14. package/src/controls/autocomplete-control.tsx +99 -80
  15. package/src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-attachment.tsx +3 -3
  16. package/src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-position.tsx +72 -8
  17. package/src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-repeat.tsx +1 -1
  18. package/src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-size.tsx +71 -11
  19. package/src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx +107 -33
  20. package/src/controls/box-shadow-repeater-control.tsx +1 -1
  21. package/src/controls/image-control.tsx +26 -22
  22. package/src/controls/image-media-control.tsx +1 -1
  23. package/src/controls/link-control.tsx +134 -17
  24. package/src/controls/size-control.tsx +1 -1
  25. package/src/controls/stroke-control.tsx +1 -1
  26. package/src/controls/svg-media-control.tsx +107 -0
  27. package/src/create-control-replacement.tsx +2 -2
  28. package/src/env.ts +5 -0
  29. package/src/index.ts +2 -1
  30. package/src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-resolution.tsx +0 -27
package/dist/index.js CHANGED
@@ -50,6 +50,7 @@ __export(index_exports, {
50
50
  SelectControl: () => SelectControl,
51
51
  SizeControl: () => SizeControl,
52
52
  StrokeControl: () => StrokeControl,
53
+ SvgMediaControl: () => SvgMediaControl,
53
54
  TextAreaControl: () => TextAreaControl,
54
55
  TextControl: () => TextControl,
55
56
  ToggleControl: () => ToggleControl,
@@ -61,11 +62,10 @@ __export(index_exports, {
61
62
  });
62
63
  module.exports = __toCommonJS(index_exports);
63
64
 
64
- // src/controls/image-control.tsx
65
- var React10 = __toESM(require("react"));
66
- var import_editor_props3 = require("@elementor/editor-props");
67
- var import_ui6 = require("@elementor/ui");
68
- var import_i18n2 = require("@wordpress/i18n");
65
+ // src/controls/autocomplete-control.tsx
66
+ var React5 = __toESM(require("react"));
67
+ var import_icons = require("@elementor/icons");
68
+ var import_ui2 = require("@elementor/ui");
69
69
 
70
70
  // src/bound-prop-context/prop-context.tsx
71
71
  var React = __toESM(require("react"));
@@ -216,19 +216,12 @@ var resolveUnionPropType = (propType, key) => {
216
216
  return resolvedPropType;
217
217
  };
218
218
 
219
- // src/components/control-label.tsx
220
- var React3 = __toESM(require("react"));
221
- var import_ui = require("@elementor/ui");
222
- var ControlLabel = ({ children }) => {
223
- return /* @__PURE__ */ React3.createElement(import_ui.Typography, { component: "label", variant: "caption", color: "text.secondary" }, children);
224
- };
225
-
226
219
  // src/create-control.tsx
227
- var React5 = __toESM(require("react"));
228
- var import_ui2 = require("@elementor/ui");
220
+ var React4 = __toESM(require("react"));
221
+ var import_ui = require("@elementor/ui");
229
222
 
230
223
  // src/create-control-replacement.tsx
231
- var React4 = __toESM(require("react"));
224
+ var React3 = __toESM(require("react"));
232
225
  var import_react3 = require("react");
233
226
  var ControlReplacementContext = (0, import_react3.createContext)(void 0);
234
227
  var ControlReplacementProvider = ({
@@ -236,7 +229,7 @@ var ControlReplacementProvider = ({
236
229
  condition,
237
230
  children
238
231
  }) => {
239
- return /* @__PURE__ */ React4.createElement(ControlReplacementContext.Provider, { value: { component, condition } }, children);
232
+ return /* @__PURE__ */ React3.createElement(ControlReplacementContext.Provider, { value: { component, condition } }, children);
240
233
  };
241
234
  var useControlReplacement = () => {
242
235
  const { value } = useBoundProp();
@@ -265,29 +258,156 @@ function createControl(Component, { supportsReplacements = true } = {}) {
265
258
  return (props) => {
266
259
  const ControlReplacement = useControlReplacement();
267
260
  if (ControlReplacement && supportsReplacements) {
268
- return /* @__PURE__ */ React5.createElement(import_ui2.ErrorBoundary, { fallback: null }, /* @__PURE__ */ React5.createElement(ControlReplacement, { ...props }));
261
+ return /* @__PURE__ */ React4.createElement(import_ui.ErrorBoundary, { fallback: null }, /* @__PURE__ */ React4.createElement(ControlReplacement, { ...props }));
269
262
  }
270
- return /* @__PURE__ */ React5.createElement(import_ui2.ErrorBoundary, { fallback: null }, /* @__PURE__ */ React5.createElement(Component, { ...props }));
263
+ return /* @__PURE__ */ React4.createElement(import_ui.ErrorBoundary, { fallback: null }, /* @__PURE__ */ React4.createElement(Component, { ...props }));
264
+ };
265
+ }
266
+
267
+ // src/controls/autocomplete-control.tsx
268
+ var AutocompleteControl = createControl(
269
+ (props) => {
270
+ const {
271
+ options,
272
+ optionRestrictedPropTypeUtil,
273
+ onOptionChangeCallback,
274
+ onTextChangeCallback,
275
+ allowCustomValues = false,
276
+ placeholder = "",
277
+ minInputLength = 2,
278
+ customValue
279
+ } = props;
280
+ const { value: selectableValue, setValue: setSelectableValue } = useBoundProp(optionRestrictedPropTypeUtil);
281
+ const value = selectableValue || customValue || "";
282
+ const optionKeys = _factoryFilter(selectableValue || customValue || null, options, minInputLength).map(
283
+ ({ id }) => id
284
+ );
285
+ const allowClear = !!value;
286
+ const muiWarningPreventer = allowCustomValues || !!value?.toString()?.length;
287
+ const isOptionEqualToValue = () => {
288
+ return muiWarningPreventer ? void 0 : () => true;
289
+ };
290
+ const hasSelectedValue = !!findMatchingOption(options, selectableValue?.toString());
291
+ const onOptionChange = (newValue) => {
292
+ setSelectableValue(newValue);
293
+ onOptionChangeCallback?.(newValue);
294
+ };
295
+ const onTextChange = (newValue) => {
296
+ onTextChangeCallback?.(newValue);
297
+ };
298
+ return /* @__PURE__ */ React5.createElement(
299
+ import_ui2.Autocomplete,
300
+ {
301
+ forcePopupIcon: false,
302
+ disableClearable: true,
303
+ freeSolo: allowCustomValues,
304
+ value: value?.toString() || "",
305
+ size: "tiny",
306
+ onChange: (_, newValue) => onOptionChange(Number(newValue)),
307
+ readOnly: hasSelectedValue,
308
+ options: optionKeys,
309
+ getOptionKey: (optionId) => findMatchingOption(options, optionId)?.id || optionId,
310
+ getOptionLabel: (optionId) => findMatchingOption(options, optionId)?.label || optionId.toString(),
311
+ groupBy: isCategorizedOptionPool(options) ? (optionId) => findMatchingOption(options, optionId)?.groupLabel || optionId : void 0,
312
+ isOptionEqualToValue: isOptionEqualToValue(),
313
+ filterOptions: () => optionKeys,
314
+ renderOption: (optionProps, optionId) => /* @__PURE__ */ React5.createElement(import_ui2.Box, { component: "li", ...optionProps, key: optionProps.id }, findMatchingOption(options, optionId)?.label ?? optionId),
315
+ renderInput: (params) => /* @__PURE__ */ React5.createElement(
316
+ TextInput,
317
+ {
318
+ params,
319
+ handleChange: onTextChange,
320
+ allowClear,
321
+ placeholder,
322
+ hasSelectedValue
323
+ }
324
+ )
325
+ }
326
+ );
327
+ }
328
+ );
329
+ var TextInput = ({
330
+ params,
331
+ allowClear,
332
+ placeholder,
333
+ handleChange,
334
+ hasSelectedValue
335
+ }) => {
336
+ const onChange = (event) => {
337
+ handleChange(event.target.value);
271
338
  };
339
+ return /* @__PURE__ */ React5.createElement(
340
+ import_ui2.TextField,
341
+ {
342
+ ...params,
343
+ placeholder,
344
+ onChange,
345
+ sx: {
346
+ "& .MuiInputBase-input": {
347
+ cursor: hasSelectedValue ? "default" : void 0
348
+ }
349
+ },
350
+ InputProps: {
351
+ ...params.InputProps,
352
+ endAdornment: /* @__PURE__ */ React5.createElement(ClearButton, { params, allowClear, handleChange })
353
+ }
354
+ }
355
+ );
356
+ };
357
+ var ClearButton = ({
358
+ allowClear,
359
+ handleChange,
360
+ params
361
+ }) => /* @__PURE__ */ React5.createElement(import_ui2.InputAdornment, { position: "end" }, allowClear && /* @__PURE__ */ React5.createElement(import_ui2.IconButton, { size: params.size, onClick: () => handleChange(null), sx: { cursor: "pointer" } }, /* @__PURE__ */ React5.createElement(import_icons.XIcon, { fontSize: params.size })));
362
+ function findMatchingOption(options, optionId = null) {
363
+ return options.find(({ id }) => optionId?.toString() === id.toString());
364
+ }
365
+ function isCategorizedOptionPool(options) {
366
+ return options.every((option) => "groupLabel" in option);
367
+ }
368
+ function _factoryFilter(newValue, options, minInputLength) {
369
+ if (null === newValue) {
370
+ return options;
371
+ }
372
+ const formattedValue = String(newValue || "")?.toLowerCase();
373
+ if (formattedValue.length < minInputLength) {
374
+ return new Array(0);
375
+ }
376
+ return options.filter(
377
+ (option) => String(option.id).toLowerCase().includes(formattedValue) || option.label.toLowerCase().includes(formattedValue)
378
+ );
272
379
  }
273
380
 
381
+ // src/controls/image-control.tsx
382
+ var React11 = __toESM(require("react"));
383
+ var import_editor_props3 = require("@elementor/editor-props");
384
+ var import_ui7 = require("@elementor/ui");
385
+ var import_i18n2 = require("@wordpress/i18n");
386
+
387
+ // src/components/control-label.tsx
388
+ var React6 = __toESM(require("react"));
389
+ var import_ui3 = require("@elementor/ui");
390
+ var ControlLabel = ({ children }) => {
391
+ return /* @__PURE__ */ React6.createElement(import_ui3.Typography, { component: "label", variant: "caption", color: "text.secondary" }, children);
392
+ };
393
+
274
394
  // src/controls/image-media-control.tsx
275
- var React8 = __toESM(require("react"));
395
+ var React9 = __toESM(require("react"));
276
396
  var import_editor_props = require("@elementor/editor-props");
277
- var import_icons = require("@elementor/icons");
278
- var import_ui4 = require("@elementor/ui");
397
+ var import_icons2 = require("@elementor/icons");
398
+ var import_ui5 = require("@elementor/ui");
279
399
  var import_wp_media = require("@elementor/wp-media");
280
400
  var import_i18n = require("@wordpress/i18n");
281
401
 
282
402
  // src/control-actions/control-actions.tsx
283
- var React7 = __toESM(require("react"));
284
- var import_ui3 = require("@elementor/ui");
403
+ var React8 = __toESM(require("react"));
404
+ var import_ui4 = require("@elementor/ui");
285
405
 
286
406
  // src/control-actions/control-actions-context.tsx
287
- var React6 = __toESM(require("react"));
407
+ var React7 = __toESM(require("react"));
288
408
  var import_react4 = require("react");
289
409
  var Context = (0, import_react4.createContext)(null);
290
- var ControlActionsProvider = ({ children, items }) => /* @__PURE__ */ React6.createElement(Context.Provider, { value: { items } }, children);
410
+ var ControlActionsProvider = ({ children, items }) => /* @__PURE__ */ React7.createElement(Context.Provider, { value: { items } }, children);
291
411
  var useControlActions = () => {
292
412
  const context = (0, import_react4.useContext)(Context);
293
413
  if (!context) {
@@ -297,7 +417,7 @@ var useControlActions = () => {
297
417
  };
298
418
 
299
419
  // src/control-actions/control-actions.tsx
300
- var FloatingBarContainer = (0, import_ui3.styled)("span")`
420
+ var FloatingBarContainer = (0, import_ui4.styled)("span")`
301
421
  display: contents;
302
422
 
303
423
  .MuiFloatingActionBar-popper:has( .MuiFloatingActionBar-actions:empty ) {
@@ -309,8 +429,8 @@ function ControlActions({ children }) {
309
429
  if (items.length === 0) {
310
430
  return children;
311
431
  }
312
- const menuItems = items.map(({ MenuItem: MenuItem4, id }) => /* @__PURE__ */ React7.createElement(MenuItem4, { key: id }));
313
- return /* @__PURE__ */ React7.createElement(FloatingBarContainer, null, /* @__PURE__ */ React7.createElement(import_ui3.UnstableFloatingActionBar, { actions: menuItems }, children));
432
+ const menuItems = items.map(({ MenuItem: MenuItem5, id }) => /* @__PURE__ */ React8.createElement(MenuItem5, { key: id }));
433
+ return /* @__PURE__ */ React8.createElement(FloatingBarContainer, null, /* @__PURE__ */ React8.createElement(import_ui4.UnstableFloatingActionBar, { actions: menuItems }, children));
314
434
  }
315
435
 
316
436
  // src/controls/image-media-control.tsx
@@ -334,8 +454,8 @@ var ImageMediaControl = createControl((props) => {
334
454
  });
335
455
  }
336
456
  });
337
- return /* @__PURE__ */ React8.createElement(ControlActions, null, /* @__PURE__ */ React8.createElement(import_ui4.Card, { variant: "outlined" }, /* @__PURE__ */ React8.createElement(import_ui4.CardMedia, { image: src, sx: { height: 150 } }, isFetching ? /* @__PURE__ */ React8.createElement(import_ui4.Stack, { justifyContent: "center", alignItems: "center", width: "100%", height: "100%" }, /* @__PURE__ */ React8.createElement(import_ui4.CircularProgress, null)) : /* @__PURE__ */ React8.createElement(React8.Fragment, null)), /* @__PURE__ */ React8.createElement(import_ui4.CardOverlay, null, /* @__PURE__ */ React8.createElement(import_ui4.Stack, { gap: 1 }, /* @__PURE__ */ React8.createElement(
338
- import_ui4.Button,
457
+ return /* @__PURE__ */ React9.createElement(ControlActions, null, /* @__PURE__ */ React9.createElement(import_ui5.Card, { variant: "outlined" }, /* @__PURE__ */ React9.createElement(import_ui5.CardMedia, { image: src, sx: { height: 150 } }, isFetching ? /* @__PURE__ */ React9.createElement(import_ui5.Stack, { justifyContent: "center", alignItems: "center", width: "100%", height: "100%" }, /* @__PURE__ */ React9.createElement(import_ui5.CircularProgress, null)) : /* @__PURE__ */ React9.createElement(React9.Fragment, null)), /* @__PURE__ */ React9.createElement(import_ui5.CardOverlay, null, /* @__PURE__ */ React9.createElement(import_ui5.Stack, { gap: 1 }, /* @__PURE__ */ React9.createElement(
458
+ import_ui5.Button,
339
459
  {
340
460
  size: "tiny",
341
461
  color: "inherit",
@@ -343,13 +463,13 @@ var ImageMediaControl = createControl((props) => {
343
463
  onClick: () => open({ mode: "browse" })
344
464
  },
345
465
  (0, import_i18n.__)("Select Image", "elementor")
346
- ), /* @__PURE__ */ React8.createElement(
347
- import_ui4.Button,
466
+ ), /* @__PURE__ */ React9.createElement(
467
+ import_ui5.Button,
348
468
  {
349
469
  size: "tiny",
350
470
  variant: "text",
351
471
  color: "inherit",
352
- startIcon: /* @__PURE__ */ React8.createElement(import_icons.UploadIcon, null),
472
+ startIcon: /* @__PURE__ */ React9.createElement(import_icons2.UploadIcon, null),
353
473
  onClick: () => open({ mode: "upload" })
354
474
  },
355
475
  (0, import_i18n.__)("Upload Image", "elementor")
@@ -357,9 +477,9 @@ var ImageMediaControl = createControl((props) => {
357
477
  });
358
478
 
359
479
  // src/controls/select-control.tsx
360
- var React9 = __toESM(require("react"));
480
+ var React10 = __toESM(require("react"));
361
481
  var import_editor_props2 = require("@elementor/editor-props");
362
- var import_ui5 = require("@elementor/ui");
482
+ var import_ui6 = require("@elementor/ui");
363
483
  var SelectControl = createControl(({ options, onChange }) => {
364
484
  const { value, setValue } = useBoundProp(import_editor_props2.stringPropTypeUtil);
365
485
  const handleChange = (event) => {
@@ -367,125 +487,23 @@ var SelectControl = createControl(({ options, onChange }) => {
367
487
  onChange?.(newValue, value);
368
488
  setValue(newValue);
369
489
  };
370
- return /* @__PURE__ */ React9.createElement(ControlActions, null, /* @__PURE__ */ React9.createElement(import_ui5.Select, { displayEmpty: true, size: "tiny", value: value ?? "", onChange: handleChange, fullWidth: true }, options.map(({ label, ...props }) => /* @__PURE__ */ React9.createElement(import_ui5.MenuItem, { key: props.value, ...props, value: props.value ?? "" }, label))));
490
+ return /* @__PURE__ */ React10.createElement(ControlActions, null, /* @__PURE__ */ React10.createElement(import_ui6.Select, { displayEmpty: true, size: "tiny", value: value ?? "", onChange: handleChange, fullWidth: true }, options.map(({ label, ...props }) => /* @__PURE__ */ React10.createElement(import_ui6.MenuItem, { key: props.value, ...props, value: props.value ?? "" }, label))));
371
491
  });
372
492
 
373
493
  // src/controls/image-control.tsx
374
- var ImageControl = createControl((props) => {
375
- const propContext = useBoundProp(import_editor_props3.imagePropTypeUtil);
376
- return /* @__PURE__ */ React10.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React10.createElement(import_ui6.Stack, { gap: 1.5 }, /* @__PURE__ */ React10.createElement(PropKeyProvider, { bind: "src" }, /* @__PURE__ */ React10.createElement(ImageMediaControl, null)), /* @__PURE__ */ React10.createElement(PropKeyProvider, { bind: "size" }, /* @__PURE__ */ React10.createElement(import_ui6.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React10.createElement(import_ui6.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React10.createElement(ControlLabel, null, " ", (0, import_i18n2.__)("Image Resolution", "elementor"))), /* @__PURE__ */ React10.createElement(import_ui6.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React10.createElement(SelectControl, { options: props.sizes }))))));
377
- });
378
-
379
- // src/controls/autocomplete-control.tsx
380
- var React11 = __toESM(require("react"));
381
- var import_editor_props4 = require("@elementor/editor-props");
382
- var import_icons2 = require("@elementor/icons");
383
- var import_ui7 = require("@elementor/ui");
384
- var AutocompleteControl = createControl(
385
- ({
386
- options,
387
- placeholder = "",
388
- allowCustomValues = false,
389
- propType = import_editor_props4.stringPropTypeUtil,
390
- minInputLength = 2
391
- }) => {
392
- const { value = "", setValue } = useBoundProp(propType);
393
- const hasSelectedValue = !!(value && (options[value] || Object.values(options).find(({ label }) => label === value)));
394
- const allowClear = !!value;
395
- const formattedOptions = Object.keys(options);
396
- const onOptionSelect = (_, newValue) => {
397
- setValue(newValue);
398
- };
399
- const handleChange = (newValue) => {
400
- setValue(newValue);
401
- };
402
- const filterOptions = (_, { inputValue }) => {
403
- const formattedValue = inputValue?.toLowerCase() || "";
404
- if (formattedValue.length < minInputLength) {
405
- return [];
406
- }
407
- return formattedOptions.filter(
408
- (optionValue) => optionValue.toLowerCase().indexOf(formattedValue) !== -1 || options[optionValue].label.toLowerCase().indexOf(formattedValue) !== -1
409
- );
410
- };
411
- const isOptionEqualToValue = () => {
412
- return muiWarningPreventer() ? void 0 : () => true;
413
- };
414
- const muiWarningPreventer = () => allowCustomValues || !!filterOptions([], { inputValue: value }).length;
415
- return /* @__PURE__ */ React11.createElement(ControlActions, null, /* @__PURE__ */ React11.createElement(
416
- import_ui7.Autocomplete,
417
- {
418
- forcePopupIcon: false,
419
- disableClearable: true,
420
- freeSolo: muiWarningPreventer(),
421
- value: value || "",
422
- size: "tiny",
423
- onChange: onOptionSelect,
424
- readOnly: hasSelectedValue,
425
- options: formattedOptions,
426
- getOptionKey: (option) => option,
427
- getOptionLabel: (option) => options[option]?.label ?? option,
428
- groupBy: shouldGroupOptions(options) ? (option) => options[option]?.groupLabel : void 0,
429
- isOptionEqualToValue: isOptionEqualToValue(),
430
- filterOptions,
431
- renderOption: (optionProps, option) => /* @__PURE__ */ React11.createElement(import_ui7.Box, { component: "li", ...optionProps, key: optionProps.id }, options[option]?.label ?? option),
432
- renderInput: (params) => /* @__PURE__ */ React11.createElement(
433
- TextInput,
434
- {
435
- params,
436
- handleChange,
437
- allowClear,
438
- placeholder,
439
- hasSelectedValue
440
- }
441
- )
442
- }
443
- ));
494
+ var ImageControl = createControl(
495
+ ({ sizes, resolutionLabel = (0, import_i18n2.__)("Image resolution", "elementor") }) => {
496
+ const propContext = useBoundProp(import_editor_props3.imagePropTypeUtil);
497
+ return /* @__PURE__ */ React11.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React11.createElement(import_ui7.Stack, { gap: 1.5 }, /* @__PURE__ */ React11.createElement(PropKeyProvider, { bind: "src" }, /* @__PURE__ */ React11.createElement(ControlLabel, null, " ", (0, import_i18n2.__)("Choose image", "elementor"), " "), /* @__PURE__ */ React11.createElement(ImageMediaControl, null)), /* @__PURE__ */ React11.createElement(PropKeyProvider, { bind: "size" }, /* @__PURE__ */ React11.createElement(import_ui7.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React11.createElement(import_ui7.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React11.createElement(ControlLabel, null, " ", resolutionLabel, " ")), /* @__PURE__ */ React11.createElement(import_ui7.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React11.createElement(SelectControl, { options: sizes }))))));
444
498
  }
445
499
  );
446
- var TextInput = ({
447
- params,
448
- allowClear,
449
- placeholder,
450
- handleChange,
451
- hasSelectedValue
452
- }) => {
453
- const onChange = (event) => {
454
- handleChange(event.target.value);
455
- };
456
- return /* @__PURE__ */ React11.createElement(
457
- import_ui7.TextField,
458
- {
459
- ...params,
460
- placeholder,
461
- onChange,
462
- sx: {
463
- "& .MuiInputBase-input": {
464
- cursor: hasSelectedValue ? "default" : void 0
465
- }
466
- },
467
- InputProps: {
468
- ...params.InputProps,
469
- endAdornment: /* @__PURE__ */ React11.createElement(ClearButton, { params, allowClear, handleChange })
470
- }
471
- }
472
- );
473
- };
474
- var ClearButton = ({
475
- allowClear,
476
- handleChange,
477
- params
478
- }) => /* @__PURE__ */ React11.createElement(import_ui7.InputAdornment, { position: "end" }, allowClear && /* @__PURE__ */ React11.createElement(import_ui7.IconButton, { size: params.size, onClick: () => handleChange(null), sx: { cursor: "pointer" } }, /* @__PURE__ */ React11.createElement(import_icons2.XIcon, { fontSize: params.size })));
479
- function shouldGroupOptions(options) {
480
- return Object.values(options).every((option) => "groupLabel" in option);
481
- }
482
500
 
483
501
  // src/controls/text-control.tsx
484
502
  var React12 = __toESM(require("react"));
485
- var import_editor_props5 = require("@elementor/editor-props");
503
+ var import_editor_props4 = require("@elementor/editor-props");
486
504
  var import_ui8 = require("@elementor/ui");
487
505
  var TextControl = createControl(({ placeholder }) => {
488
- const { value, setValue } = useBoundProp(import_editor_props5.stringPropTypeUtil);
506
+ const { value, setValue } = useBoundProp(import_editor_props4.stringPropTypeUtil);
489
507
  const handleChange = (event) => setValue(event.target.value);
490
508
  return /* @__PURE__ */ React12.createElement(ControlActions, null, /* @__PURE__ */ React12.createElement(
491
509
  import_ui8.TextField,
@@ -501,10 +519,10 @@ var TextControl = createControl(({ placeholder }) => {
501
519
 
502
520
  // src/controls/text-area-control.tsx
503
521
  var React13 = __toESM(require("react"));
504
- var import_editor_props6 = require("@elementor/editor-props");
522
+ var import_editor_props5 = require("@elementor/editor-props");
505
523
  var import_ui9 = require("@elementor/ui");
506
524
  var TextAreaControl = createControl(({ placeholder }) => {
507
- const { value, setValue } = useBoundProp(import_editor_props6.stringPropTypeUtil);
525
+ const { value, setValue } = useBoundProp(import_editor_props5.stringPropTypeUtil);
508
526
  const handleChange = (event) => {
509
527
  setValue(event.target.value);
510
528
  };
@@ -524,7 +542,7 @@ var TextAreaControl = createControl(({ placeholder }) => {
524
542
 
525
543
  // src/controls/size-control.tsx
526
544
  var React15 = __toESM(require("react"));
527
- var import_editor_props7 = require("@elementor/editor-props");
545
+ var import_editor_props6 = require("@elementor/editor-props");
528
546
  var import_ui11 = require("@elementor/ui");
529
547
 
530
548
  // src/components/text-field-inner-selection.tsx
@@ -614,7 +632,7 @@ var defaultUnits = ["px", "%", "em", "rem", "vw", "vh"];
614
632
  var defaultUnit = "px";
615
633
  var defaultSize = NaN;
616
634
  var SizeControl = createControl(({ units: units2 = defaultUnits, placeholder, startIcon }) => {
617
- const { value, setValue } = useBoundProp(import_editor_props7.sizePropTypeUtil);
635
+ const { value, setValue } = useBoundProp(import_editor_props6.sizePropTypeUtil);
618
636
  const [state, setState] = useSyncExternalState({
619
637
  external: value,
620
638
  setExternal: setValue,
@@ -656,15 +674,15 @@ var SizeControl = createControl(({ units: units2 = defaultUnits, placeholder, st
656
674
 
657
675
  // src/controls/stroke-control.tsx
658
676
  var React17 = __toESM(require("react"));
659
- var import_editor_props9 = require("@elementor/editor-props");
677
+ var import_editor_props8 = require("@elementor/editor-props");
660
678
  var import_ui13 = require("@elementor/ui");
661
679
  var import_i18n3 = require("@wordpress/i18n");
662
680
 
663
681
  // src/controls/color-control.tsx
664
682
  var React16 = __toESM(require("react"));
665
- var import_editor_props8 = require("@elementor/editor-props");
683
+ var import_editor_props7 = require("@elementor/editor-props");
666
684
  var import_ui12 = require("@elementor/ui");
667
- var ColorControl = createControl(({ propTypeUtil = import_editor_props8.colorPropTypeUtil, ...props }) => {
685
+ var ColorControl = createControl(({ propTypeUtil = import_editor_props7.colorPropTypeUtil, ...props }) => {
668
686
  const { value, setValue } = useBoundProp(propTypeUtil);
669
687
  const handleChange = (selectedColor) => {
670
688
  setValue(selectedColor);
@@ -675,14 +693,14 @@ var ColorControl = createControl(({ propTypeUtil = import_editor_props8.colorPro
675
693
  // src/controls/stroke-control.tsx
676
694
  var units = ["px", "em", "rem"];
677
695
  var StrokeControl = createControl(() => {
678
- const propContext = useBoundProp(import_editor_props9.strokePropTypeUtil);
696
+ const propContext = useBoundProp(import_editor_props8.strokePropTypeUtil);
679
697
  return /* @__PURE__ */ React17.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React17.createElement(import_ui13.Stack, { gap: 1.5 }, /* @__PURE__ */ React17.createElement(Control, { bind: "width", label: (0, import_i18n3.__)("Stroke Width", "elementor") }, /* @__PURE__ */ React17.createElement(SizeControl, { units })), /* @__PURE__ */ React17.createElement(Control, { bind: "color", label: (0, import_i18n3.__)("Stroke Color", "elementor") }, /* @__PURE__ */ React17.createElement(ColorControl, null))));
680
698
  });
681
699
  var Control = ({ bind, label, children }) => /* @__PURE__ */ React17.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React17.createElement(import_ui13.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React17.createElement(import_ui13.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React17.createElement(ControlLabel, null, label)), /* @__PURE__ */ React17.createElement(import_ui13.Grid, { item: true, xs: 6 }, children)));
682
700
 
683
701
  // src/controls/box-shadow-repeater-control.tsx
684
702
  var React19 = __toESM(require("react"));
685
- var import_editor_props10 = require("@elementor/editor-props");
703
+ var import_editor_props9 = require("@elementor/editor-props");
686
704
  var import_ui15 = require("@elementor/ui");
687
705
  var import_i18n5 = require("@wordpress/i18n");
688
706
 
@@ -696,12 +714,16 @@ var SIZE = "tiny";
696
714
  var Repeater = ({
697
715
  label,
698
716
  itemSettings,
717
+ addToBottom = false,
699
718
  values: repeaterValues = [],
700
719
  setValues: setRepeaterValues
701
720
  }) => {
702
721
  const addRepeaterItem = () => {
703
722
  const newItem = structuredClone(itemSettings.initialValues);
704
- setRepeaterValues([...repeaterValues, newItem]);
723
+ if (addToBottom) {
724
+ return setRepeaterValues([...repeaterValues, newItem]);
725
+ }
726
+ setRepeaterValues([newItem, ...repeaterValues]);
705
727
  };
706
728
  const duplicateRepeaterItem = (index) => {
707
729
  setRepeaterValues([
@@ -797,19 +819,19 @@ var RepeaterItem = ({
797
819
  slotProps: {
798
820
  paper: {
799
821
  ref: setAnchorEl,
800
- sx: { mt: 0.5, p: 1, pt: 1, width: controlRef.current?.getBoundingClientRect().width }
822
+ sx: { mt: 0.5, width: controlRef.current?.getBoundingClientRect().width }
801
823
  }
802
824
  },
803
825
  anchorOrigin: { vertical: "bottom", horizontal: "left" },
804
826
  ...popoverProps
805
827
  },
806
- /* @__PURE__ */ React18.createElement(import_ui14.Box, { p: 0.5 }, children({ anchorEl }))
828
+ /* @__PURE__ */ React18.createElement(import_ui14.Box, null, children({ anchorEl }))
807
829
  ));
808
830
  };
809
831
 
810
832
  // src/controls/box-shadow-repeater-control.tsx
811
833
  var BoxShadowRepeaterControl = createControl(() => {
812
- const { propType, value, setValue } = useBoundProp(import_editor_props10.boxShadowPropTypeUtil);
834
+ const { propType, value, setValue } = useBoundProp(import_editor_props9.boxShadowPropTypeUtil);
813
835
  return /* @__PURE__ */ React19.createElement(PropProvider, { propType, value, setValue }, /* @__PURE__ */ React19.createElement(
814
836
  Repeater,
815
837
  {
@@ -830,8 +852,8 @@ var ItemContent = ({ anchorEl, bind }) => {
830
852
  return /* @__PURE__ */ React19.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React19.createElement(Content, { anchorEl }));
831
853
  };
832
854
  var Content = ({ anchorEl }) => {
833
- const { propType, value, setValue } = useBoundProp(import_editor_props10.shadowPropTypeUtil);
834
- return /* @__PURE__ */ React19.createElement(PropProvider, { propType, value, setValue }, /* @__PURE__ */ React19.createElement(import_ui15.Stack, { gap: 1.5 }, /* @__PURE__ */ React19.createElement(import_ui15.Grid, { container: true, gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React19.createElement(Control2, { bind: "color", label: (0, import_i18n5.__)("Color", "elementor") }, /* @__PURE__ */ React19.createElement(
855
+ const { propType, value, setValue } = useBoundProp(import_editor_props9.shadowPropTypeUtil);
856
+ return /* @__PURE__ */ React19.createElement(PropProvider, { propType, value, setValue }, /* @__PURE__ */ React19.createElement(import_ui15.Stack, { gap: 1.5, sx: { p: 1.5 } }, /* @__PURE__ */ React19.createElement(import_ui15.Grid, { container: true, gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React19.createElement(Control2, { bind: "color", label: (0, import_i18n5.__)("Color", "elementor") }, /* @__PURE__ */ React19.createElement(
835
857
  ColorControl,
836
858
  {
837
859
  slotProps: {
@@ -903,7 +925,7 @@ var initialShadow = {
903
925
 
904
926
  // src/controls/toggle-control.tsx
905
927
  var React21 = __toESM(require("react"));
906
- var import_editor_props11 = require("@elementor/editor-props");
928
+ var import_editor_props10 = require("@elementor/editor-props");
907
929
 
908
930
  // src/components/control-toggle-button-group.tsx
909
931
  var React20 = __toESM(require("react"));
@@ -954,7 +976,7 @@ var ControlToggleButtonGroup = ({
954
976
  // src/controls/toggle-control.tsx
955
977
  var ToggleControl = createControl(
956
978
  ({ options, fullWidth = false, size = "tiny" }) => {
957
- const { value, setValue } = useBoundProp(import_editor_props11.stringPropTypeUtil);
979
+ const { value, setValue } = useBoundProp(import_editor_props10.stringPropTypeUtil);
958
980
  const handleToggle = (option) => {
959
981
  setValue(option);
960
982
  };
@@ -974,7 +996,7 @@ var ToggleControl = createControl(
974
996
 
975
997
  // src/controls/number-control.tsx
976
998
  var React22 = __toESM(require("react"));
977
- var import_editor_props12 = require("@elementor/editor-props");
999
+ var import_editor_props11 = require("@elementor/editor-props");
978
1000
  var import_ui17 = require("@elementor/ui");
979
1001
  var isEmptyOrNaN = (value) => value === null || value === void 0 || value === "" || Number.isNaN(Number(value));
980
1002
  var NumberControl = createControl(
@@ -985,7 +1007,7 @@ var NumberControl = createControl(
985
1007
  step = 1,
986
1008
  shouldForceInt = false
987
1009
  }) => {
988
- const { value, setValue } = useBoundProp(import_editor_props12.numberPropTypeUtil);
1010
+ const { value, setValue } = useBoundProp(import_editor_props11.numberPropTypeUtil);
989
1011
  const handleChange = (event) => {
990
1012
  const eventValue = event.target.value;
991
1013
  if (isEmptyOrNaN(eventValue)) {
@@ -1013,7 +1035,7 @@ var NumberControl = createControl(
1013
1035
  // src/controls/equal-unequal-sizes-control.tsx
1014
1036
  var React23 = __toESM(require("react"));
1015
1037
  var import_react8 = require("react");
1016
- var import_editor_props13 = require("@elementor/editor-props");
1038
+ var import_editor_props12 = require("@elementor/editor-props");
1017
1039
  var import_ui18 = require("@elementor/ui");
1018
1040
  var import_i18n6 = require("@wordpress/i18n");
1019
1041
  var isEqualSizes = (propValue, items) => {
@@ -1040,13 +1062,13 @@ function EqualUnequalSizesControl({
1040
1062
  value: multiSizeValue,
1041
1063
  setValue: setMultiSizeValue
1042
1064
  } = useBoundProp(multiSizePropTypeUtil);
1043
- const { value: sizeValue, setValue: setSizeValue } = useBoundProp(import_editor_props13.sizePropTypeUtil);
1065
+ const { value: sizeValue, setValue: setSizeValue } = useBoundProp(import_editor_props12.sizePropTypeUtil);
1044
1066
  const splitEqualValue = () => {
1045
1067
  if (!sizeValue) {
1046
1068
  return null;
1047
1069
  }
1048
1070
  return items.reduce(
1049
- (acc, { bind }) => ({ ...acc, [bind]: import_editor_props13.sizePropTypeUtil.create(sizeValue) }),
1071
+ (acc, { bind }) => ({ ...acc, [bind]: import_editor_props12.sizePropTypeUtil.create(sizeValue) }),
1050
1072
  {}
1051
1073
  );
1052
1074
  };
@@ -1103,20 +1125,20 @@ var MultiSizeValueControl = ({ item }) => /* @__PURE__ */ React23.createElement(
1103
1125
 
1104
1126
  // src/controls/linked-dimensions-control.tsx
1105
1127
  var React24 = __toESM(require("react"));
1106
- var import_editor_props14 = require("@elementor/editor-props");
1128
+ var import_editor_props13 = require("@elementor/editor-props");
1107
1129
  var import_icons4 = require("@elementor/icons");
1108
1130
  var import_ui19 = require("@elementor/ui");
1109
1131
  var import_i18n7 = require("@wordpress/i18n");
1110
1132
  var LinkedDimensionsControl = createControl(({ label }) => {
1111
- const { value: dimensionsValue, setValue: setDimensionsValue, propType } = useBoundProp(import_editor_props14.dimensionsPropTypeUtil);
1112
- const { value: sizeValue, setValue: setSizeValue } = useBoundProp(import_editor_props14.sizePropTypeUtil);
1133
+ const { value: dimensionsValue, setValue: setDimensionsValue, propType } = useBoundProp(import_editor_props13.dimensionsPropTypeUtil);
1134
+ const { value: sizeValue, setValue: setSizeValue } = useBoundProp(import_editor_props13.sizePropTypeUtil);
1113
1135
  const isLinked = !dimensionsValue && !sizeValue ? true : !!sizeValue;
1114
1136
  const onLinkToggle = () => {
1115
1137
  if (!isLinked) {
1116
1138
  setSizeValue(dimensionsValue?.top?.value);
1117
1139
  return;
1118
1140
  }
1119
- const value = sizeValue ? import_editor_props14.sizePropTypeUtil.create(sizeValue) : null;
1141
+ const value = sizeValue ? import_editor_props13.sizePropTypeUtil.create(sizeValue) : null;
1120
1142
  setDimensionsValue({
1121
1143
  top: value,
1122
1144
  right: value,
@@ -1176,7 +1198,7 @@ var Control3 = ({ bind, startIcon, isLinked }) => {
1176
1198
  // src/controls/font-family-control.tsx
1177
1199
  var import_react9 = require("react");
1178
1200
  var React25 = __toESM(require("react"));
1179
- var import_editor_props15 = require("@elementor/editor-props");
1201
+ var import_editor_props14 = require("@elementor/editor-props");
1180
1202
  var import_icons5 = require("@elementor/icons");
1181
1203
  var import_ui20 = require("@elementor/ui");
1182
1204
  var import_i18n9 = require("@wordpress/i18n");
@@ -1215,7 +1237,7 @@ var useFilteredFontFamilies = (fontFamilies, searchValue) => {
1215
1237
  var SIZE2 = "tiny";
1216
1238
  var FontFamilyControl = createControl(({ fontFamilies }) => {
1217
1239
  const [searchValue, setSearchValue] = (0, import_react9.useState)("");
1218
- const { value: fontFamily, setValue: setFontFamily } = useBoundProp(import_editor_props15.stringPropTypeUtil);
1240
+ const { value: fontFamily, setValue: setFontFamily } = useBoundProp(import_editor_props14.stringPropTypeUtil);
1219
1241
  const popupId = (0, import_react9.useId)();
1220
1242
  const popoverState = (0, import_ui20.usePopupState)({ variant: "popover", popupId });
1221
1243
  const filteredFontFamilies = useFilteredFontFamilies(fontFamilies, searchValue);
@@ -1291,10 +1313,10 @@ var FontFamilyControl = createControl(({ fontFamilies }) => {
1291
1313
 
1292
1314
  // src/controls/url-control.tsx
1293
1315
  var React26 = __toESM(require("react"));
1294
- var import_editor_props16 = require("@elementor/editor-props");
1316
+ var import_editor_props15 = require("@elementor/editor-props");
1295
1317
  var import_ui21 = require("@elementor/ui");
1296
1318
  var UrlControl = createControl(({ placeholder }) => {
1297
- const { value, setValue } = useBoundProp(import_editor_props16.urlPropTypeUtil);
1319
+ const { value, setValue } = useBoundProp(import_editor_props15.urlPropTypeUtil);
1298
1320
  const handleChange = (event) => setValue(event.target.value);
1299
1321
  return /* @__PURE__ */ React26.createElement(ControlActions, null, /* @__PURE__ */ React26.createElement(
1300
1322
  import_ui21.TextField,
@@ -1310,26 +1332,69 @@ var UrlControl = createControl(({ placeholder }) => {
1310
1332
 
1311
1333
  // src/controls/link-control.tsx
1312
1334
  var React27 = __toESM(require("react"));
1313
- var import_editor_props17 = require("@elementor/editor-props");
1335
+ var import_react10 = require("react");
1336
+ var import_editor_props16 = require("@elementor/editor-props");
1337
+ var import_http = require("@elementor/http");
1314
1338
  var import_icons6 = require("@elementor/icons");
1315
1339
  var import_session = require("@elementor/session");
1316
1340
  var import_ui22 = require("@elementor/ui");
1317
1341
  var import_i18n10 = require("@wordpress/i18n");
1318
1342
  var SIZE3 = "tiny";
1319
1343
  var LinkControl = createControl((props) => {
1320
- const { value, path, setValue, ...propContext } = useBoundProp(import_editor_props17.linkPropTypeUtil);
1344
+ const { value, path, setValue, ...propContext } = useBoundProp(import_editor_props16.linkPropTypeUtil);
1321
1345
  const [linkSessionValue, setLinkSessionValue] = (0, import_session.useSessionStorage)(path.join("/"));
1322
- const { allowCustomValues = false, options = {}, placeholder } = props || {};
1346
+ const {
1347
+ allowCustomValues,
1348
+ queryOptions: { endpoint = "", requestParams = {} },
1349
+ placeholder,
1350
+ minInputLength = 2
1351
+ } = props || {};
1352
+ const [options, setOptions] = (0, import_react10.useState)(
1353
+ generateFirstLoadedOption(value)
1354
+ );
1323
1355
  const onEnabledChange = () => {
1324
1356
  const { meta } = linkSessionValue ?? {};
1325
1357
  const { isEnabled } = meta ?? {};
1326
- if (isEnabled && value) {
1327
- setValue(null);
1328
- } else if (linkSessionValue?.value) {
1329
- setValue(linkSessionValue?.value ?? null);
1330
- }
1358
+ setValue(isEnabled ? null : linkSessionValue?.value ?? { destination: null });
1331
1359
  setLinkSessionValue({ value, meta: { isEnabled: !isEnabled } });
1332
1360
  };
1361
+ const onOptionChange = (newValue) => {
1362
+ const valueToSave = {
1363
+ ...value,
1364
+ destination: { $$type: "number", value: newValue },
1365
+ label: {
1366
+ $$type: "string",
1367
+ value: findMatchingOption(options, newValue?.toString())?.label || ""
1368
+ }
1369
+ };
1370
+ onSaveNewValue(valueToSave);
1371
+ };
1372
+ const onTextChange = (newValue) => {
1373
+ const valueToSave = {
1374
+ ...value,
1375
+ destination: { $$type: "url", value: newValue },
1376
+ label: null
1377
+ };
1378
+ onSaveNewValue(valueToSave);
1379
+ updateOptions(newValue);
1380
+ };
1381
+ const onSaveNewValue = (newValue) => {
1382
+ setValue(newValue);
1383
+ setLinkSessionValue({ ...linkSessionValue, value: newValue });
1384
+ };
1385
+ const updateOptions = (newValue) => {
1386
+ setOptions([]);
1387
+ if (!newValue || !endpoint || newValue.length < minInputLength) {
1388
+ return;
1389
+ }
1390
+ debounceFetch(newValue)();
1391
+ };
1392
+ const debounceFetch = (newValue) => debounce(
1393
+ () => fetchOptions(endpoint, { ...requestParams, term: newValue }).then((newOptions) => {
1394
+ setOptions(formatOptions(newOptions));
1395
+ }),
1396
+ 400
1397
+ );
1333
1398
  return /* @__PURE__ */ React27.createElement(PropProvider, { ...propContext, value, setValue }, /* @__PURE__ */ React27.createElement(import_ui22.Stack, { gap: 1.5 }, /* @__PURE__ */ React27.createElement(import_ui22.Divider, null), /* @__PURE__ */ React27.createElement(
1334
1399
  import_ui22.Stack,
1335
1400
  {
@@ -1348,13 +1413,17 @@ var LinkControl = createControl((props) => {
1348
1413
  label: (0, import_i18n10.__)("Toggle Link", "elementor")
1349
1414
  }
1350
1415
  )
1351
- ), /* @__PURE__ */ React27.createElement(import_ui22.Collapse, { in: linkSessionValue?.meta?.isEnabled, timeout: "auto", unmountOnExit: true }, /* @__PURE__ */ React27.createElement(import_ui22.Stack, { gap: 1.5 }, /* @__PURE__ */ React27.createElement(PropKeyProvider, { bind: "href" }, /* @__PURE__ */ React27.createElement(
1416
+ ), /* @__PURE__ */ React27.createElement(import_ui22.Collapse, { in: linkSessionValue?.meta?.isEnabled, timeout: "auto", unmountOnExit: true }, /* @__PURE__ */ React27.createElement(import_ui22.Stack, { gap: 1.5 }, /* @__PURE__ */ React27.createElement(PropKeyProvider, { bind: "destination" }, /* @__PURE__ */ React27.createElement(
1352
1417
  AutocompleteControl,
1353
1418
  {
1354
- allowCustomValues: Object.keys(options).length ? allowCustomValues : true,
1355
1419
  options,
1356
- propType: import_editor_props17.urlPropTypeUtil,
1357
- placeholder
1420
+ allowCustomValues,
1421
+ placeholder,
1422
+ optionRestrictedPropTypeUtil: import_editor_props16.numberPropTypeUtil,
1423
+ onOptionChangeCallback: onOptionChange,
1424
+ onTextChangeCallback: onTextChange,
1425
+ minInputLength,
1426
+ customValue: value?.destination?.value?.toString()
1358
1427
  }
1359
1428
  )), /* @__PURE__ */ React27.createElement(PropKeyProvider, { bind: "isTargetBlank" }, /* @__PURE__ */ React27.createElement(SwitchControl, null))))));
1360
1429
  });
@@ -1362,16 +1431,53 @@ var ToggleIconControl = ({ enabled, onIconClick, label }) => {
1362
1431
  return /* @__PURE__ */ React27.createElement(import_ui22.IconButton, { size: SIZE3, onClick: onIconClick, "aria-label": label }, enabled ? /* @__PURE__ */ React27.createElement(import_icons6.MinusIcon, { fontSize: SIZE3 }) : /* @__PURE__ */ React27.createElement(import_icons6.PlusIcon, { fontSize: SIZE3 }));
1363
1432
  };
1364
1433
  var SwitchControl = () => {
1365
- const { value = false, setValue } = useBoundProp(import_editor_props17.booleanPropTypeUtil);
1366
- const onChange = () => {
1434
+ const { value = false, setValue } = useBoundProp(import_editor_props16.booleanPropTypeUtil);
1435
+ const onClick = () => {
1367
1436
  setValue(!value);
1368
1437
  };
1369
- return /* @__PURE__ */ React27.createElement(import_ui22.Grid, { container: true, alignItems: "center", flexWrap: "nowrap", justifyContent: "space-between" }, /* @__PURE__ */ React27.createElement(import_ui22.Grid, { item: true }, /* @__PURE__ */ React27.createElement(ControlLabel, null, (0, import_i18n10.__)("Open in new tab", "elementor"))), /* @__PURE__ */ React27.createElement(import_ui22.Grid, { item: true }, /* @__PURE__ */ React27.createElement(import_ui22.Switch, { checked: value, onChange })));
1438
+ return /* @__PURE__ */ React27.createElement(import_ui22.Grid, { container: true, alignItems: "center", flexWrap: "nowrap", justifyContent: "space-between" }, /* @__PURE__ */ React27.createElement(import_ui22.Grid, { item: true }, /* @__PURE__ */ React27.createElement(ControlLabel, null, (0, import_i18n10.__)("Open in new tab", "elementor"))), /* @__PURE__ */ React27.createElement(import_ui22.Grid, { item: true }, /* @__PURE__ */ React27.createElement(import_ui22.Switch, { checked: value, onClick })));
1370
1439
  };
1440
+ async function fetchOptions(ajaxUrl, params) {
1441
+ if (!params || !ajaxUrl) {
1442
+ return [];
1443
+ }
1444
+ try {
1445
+ const { data: response } = await (0, import_http.httpService)().get(ajaxUrl, { params });
1446
+ return response.data.value;
1447
+ } catch {
1448
+ return [];
1449
+ }
1450
+ }
1451
+ function formatOptions(options) {
1452
+ const compareKey = isCategorizedOptionPool(options) ? "groupLabel" : "label";
1453
+ return options.sort(
1454
+ (a, b) => a[compareKey] && b[compareKey] ? a[compareKey].localeCompare(b[compareKey]) : 0
1455
+ );
1456
+ }
1457
+ function generateFirstLoadedOption(unionValue) {
1458
+ const value = unionValue?.destination?.value;
1459
+ const label = unionValue?.label?.value;
1460
+ const type = unionValue?.destination?.$$type || "url";
1461
+ return value && label && type === "number" ? [
1462
+ {
1463
+ id: value.toString(),
1464
+ label
1465
+ }
1466
+ ] : [];
1467
+ }
1468
+ function debounce(fn, timeout) {
1469
+ let timer;
1470
+ return (...args) => {
1471
+ clearTimeout(timer);
1472
+ timer = setTimeout(() => {
1473
+ fn(...args);
1474
+ }, timeout);
1475
+ };
1476
+ }
1371
1477
 
1372
1478
  // src/controls/gap-control.tsx
1373
1479
  var React28 = __toESM(require("react"));
1374
- var import_editor_props18 = require("@elementor/editor-props");
1480
+ var import_editor_props17 = require("@elementor/editor-props");
1375
1481
  var import_icons7 = require("@elementor/icons");
1376
1482
  var import_ui23 = require("@elementor/ui");
1377
1483
  var import_i18n11 = require("@wordpress/i18n");
@@ -1380,15 +1486,15 @@ var GapControl = createControl(({ label }) => {
1380
1486
  value: directionValue,
1381
1487
  setValue: setDirectionValue,
1382
1488
  propType
1383
- } = useBoundProp(import_editor_props18.layoutDirectionPropTypeUtil);
1384
- const { value: sizeValue, setValue: setSizeValue } = useBoundProp(import_editor_props18.sizePropTypeUtil);
1489
+ } = useBoundProp(import_editor_props17.layoutDirectionPropTypeUtil);
1490
+ const { value: sizeValue, setValue: setSizeValue } = useBoundProp(import_editor_props17.sizePropTypeUtil);
1385
1491
  const isLinked = !directionValue && !sizeValue ? true : !!sizeValue;
1386
1492
  const onLinkToggle = () => {
1387
1493
  if (!isLinked) {
1388
1494
  setSizeValue(directionValue?.column.value);
1389
1495
  return;
1390
1496
  }
1391
- const value = sizeValue ? import_editor_props18.sizePropTypeUtil.create(sizeValue) : null;
1497
+ const value = sizeValue ? import_editor_props17.sizePropTypeUtil.create(sizeValue) : null;
1392
1498
  setDirectionValue({
1393
1499
  row: value,
1394
1500
  column: value
@@ -1415,158 +1521,299 @@ var Control4 = ({ bind, isLinked }) => {
1415
1521
  return /* @__PURE__ */ React28.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React28.createElement(SizeControl, null));
1416
1522
  };
1417
1523
 
1524
+ // src/controls/svg-media-control.tsx
1525
+ var React29 = __toESM(require("react"));
1526
+ var import_editor_props18 = require("@elementor/editor-props");
1527
+ var import_icons8 = require("@elementor/icons");
1528
+ var import_ui24 = require("@elementor/ui");
1529
+ var import_wp_media2 = require("@elementor/wp-media");
1530
+ var import_i18n12 = require("@wordpress/i18n");
1531
+ var TILE_SIZE = 8;
1532
+ var TILE_WHITE = "transparent";
1533
+ var TILE_BLACK = "#c1c1c1";
1534
+ var TILES_GRADIENT_FORMULA = `linear-gradient(45deg, ${TILE_BLACK} 25%, ${TILE_WHITE} 0, ${TILE_WHITE} 75%, ${TILE_BLACK} 0, ${TILE_BLACK})`;
1535
+ var StyledCard = (0, import_ui24.styled)(import_ui24.Card)`
1536
+ background-color: white;
1537
+ background-image: ${TILES_GRADIENT_FORMULA}, ${TILES_GRADIENT_FORMULA};
1538
+ background-size: ${TILE_SIZE}px ${TILE_SIZE}px;
1539
+ background-position:
1540
+ 0 0,
1541
+ ${TILE_SIZE / 2}px ${TILE_SIZE / 2}px;
1542
+ border: none;
1543
+ `;
1544
+ var StyledCardMediaContainer = (0, import_ui24.styled)(import_ui24.Stack)`
1545
+ position: relative;
1546
+ height: 140px;
1547
+ object-fit: contain;
1548
+ padding: 5px;
1549
+ justify-content: center;
1550
+ align-items: center;
1551
+ background-color: rgba( 255, 255, 255, 0.37 );
1552
+ `;
1553
+ var SvgMediaControl = createControl(() => {
1554
+ const { value, setValue } = useBoundProp(import_editor_props18.imageSrcPropTypeUtil);
1555
+ const { id, url } = value ?? {};
1556
+ const { data: attachment, isFetching } = (0, import_wp_media2.useWpMediaAttachment)(id?.value || null);
1557
+ const src = attachment?.url ?? url?.value ?? null;
1558
+ const { open } = (0, import_wp_media2.useWpMediaFrame)({
1559
+ types: ["image/svg+xml"],
1560
+ allowedExtensions: ["svg"],
1561
+ multiple: false,
1562
+ selected: id?.value || null,
1563
+ onSelect: (selectedAttachment) => {
1564
+ setValue({
1565
+ id: {
1566
+ $$type: "image-attachment-id",
1567
+ value: selectedAttachment.id
1568
+ },
1569
+ url: null
1570
+ });
1571
+ }
1572
+ });
1573
+ return /* @__PURE__ */ React29.createElement(import_ui24.Stack, { gap: 1 }, /* @__PURE__ */ React29.createElement(ControlLabel, null, " ", (0, import_i18n12.__)("Choose SVG", "elementor"), " "), /* @__PURE__ */ React29.createElement(ControlActions, null, /* @__PURE__ */ React29.createElement(StyledCard, { variant: "outlined" }, /* @__PURE__ */ React29.createElement(StyledCardMediaContainer, null, isFetching ? /* @__PURE__ */ React29.createElement(import_ui24.CircularProgress, { role: "progressbar" }) : /* @__PURE__ */ React29.createElement(
1574
+ import_ui24.CardMedia,
1575
+ {
1576
+ component: "img",
1577
+ image: src,
1578
+ alt: (0, import_i18n12.__)("Preview SVG", "elementor"),
1579
+ sx: { maxHeight: "140px", width: "50px" }
1580
+ }
1581
+ )), /* @__PURE__ */ React29.createElement(
1582
+ import_ui24.CardOverlay,
1583
+ {
1584
+ sx: {
1585
+ "&:hover": {
1586
+ backgroundColor: "rgba( 0, 0, 0, 0.75 )"
1587
+ }
1588
+ }
1589
+ },
1590
+ /* @__PURE__ */ React29.createElement(import_ui24.Stack, { gap: 1 }, /* @__PURE__ */ React29.createElement(
1591
+ import_ui24.Button,
1592
+ {
1593
+ size: "tiny",
1594
+ color: "inherit",
1595
+ variant: "outlined",
1596
+ onClick: () => open({ mode: "browse" })
1597
+ },
1598
+ (0, import_i18n12.__)("Select SVG", "elementor")
1599
+ ), /* @__PURE__ */ React29.createElement(
1600
+ import_ui24.Button,
1601
+ {
1602
+ size: "tiny",
1603
+ variant: "text",
1604
+ color: "inherit",
1605
+ startIcon: /* @__PURE__ */ React29.createElement(import_icons8.UploadIcon, null),
1606
+ onClick: () => open({ mode: "upload" })
1607
+ },
1608
+ (0, import_i18n12.__)("Upload SVG", "elementor")
1609
+ ))
1610
+ ))));
1611
+ });
1612
+
1418
1613
  // src/controls/background-control/background-control.tsx
1419
1614
  var React35 = __toESM(require("react"));
1420
- var import_editor_props20 = require("@elementor/editor-props");
1615
+ var import_editor_props22 = require("@elementor/editor-props");
1421
1616
  var import_ui30 = require("@elementor/ui");
1422
1617
  var import_i18n18 = require("@wordpress/i18n");
1423
1618
 
1424
1619
  // src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx
1425
1620
  var React34 = __toESM(require("react"));
1426
- var import_editor_props19 = require("@elementor/editor-props");
1621
+ var import_editor_props21 = require("@elementor/editor-props");
1427
1622
  var import_ui29 = require("@elementor/ui");
1428
- var import_wp_media2 = require("@elementor/wp-media");
1623
+ var import_wp_media3 = require("@elementor/wp-media");
1429
1624
  var import_i18n17 = require("@wordpress/i18n");
1430
1625
 
1626
+ // src/env.ts
1627
+ var import_env = require("@elementor/env");
1628
+ var { env } = (0, import_env.parseEnv)("@elementor/editor-controls");
1629
+
1431
1630
  // src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-attachment.tsx
1432
- var React29 = __toESM(require("react"));
1433
- var import_icons8 = require("@elementor/icons");
1434
- var import_ui24 = require("@elementor/ui");
1435
- var import_i18n12 = require("@wordpress/i18n");
1631
+ var React30 = __toESM(require("react"));
1632
+ var import_icons9 = require("@elementor/icons");
1633
+ var import_ui25 = require("@elementor/ui");
1634
+ var import_i18n13 = require("@wordpress/i18n");
1436
1635
  var attachmentControlOptions = [
1437
1636
  {
1438
1637
  value: "fixed",
1439
- label: (0, import_i18n12.__)("Fixed", "elementor"),
1440
- renderContent: ({ size }) => /* @__PURE__ */ React29.createElement(import_icons8.PinIcon, { fontSize: size }),
1638
+ label: (0, import_i18n13.__)("Fixed", "elementor"),
1639
+ renderContent: ({ size }) => /* @__PURE__ */ React30.createElement(import_icons9.PinIcon, { fontSize: size }),
1441
1640
  showTooltip: true
1442
1641
  },
1443
1642
  {
1444
1643
  value: "scroll",
1445
- label: (0, import_i18n12.__)("Scroll", "elementor"),
1446
- renderContent: ({ size }) => /* @__PURE__ */ React29.createElement(import_icons8.PinnedOffIcon, { fontSize: size }),
1644
+ label: (0, import_i18n13.__)("Scroll", "elementor"),
1645
+ renderContent: ({ size }) => /* @__PURE__ */ React30.createElement(import_icons9.PinnedOffIcon, { fontSize: size }),
1447
1646
  showTooltip: true
1448
1647
  }
1449
1648
  ];
1450
1649
  var BackgroundImageOverlayAttachment = () => {
1451
- return /* @__PURE__ */ React29.createElement(import_ui24.Grid, { container: true, gap: 8, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React29.createElement(import_ui24.Grid, { item: true, xs: 2 }, /* @__PURE__ */ React29.createElement(ControlLabel, null, (0, import_i18n12.__)("Attachment", "elementor"))), /* @__PURE__ */ React29.createElement(import_ui24.Grid, { item: true, justifyContent: "flex-end", xs: 8, sx: { display: "flex" } }, /* @__PURE__ */ React29.createElement(ToggleControl, { options: attachmentControlOptions })));
1650
+ return /* @__PURE__ */ React30.createElement(import_ui25.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React30.createElement(import_ui25.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React30.createElement(ControlLabel, null, (0, import_i18n13.__)("Attachment", "elementor"))), /* @__PURE__ */ React30.createElement(import_ui25.Grid, { item: true, xs: 6, sx: { display: "flex", justifyContent: "flex-end" } }, /* @__PURE__ */ React30.createElement(ToggleControl, { options: attachmentControlOptions })));
1452
1651
  };
1453
1652
 
1454
1653
  // src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-position.tsx
1455
- var React30 = __toESM(require("react"));
1456
- var import_ui25 = require("@elementor/ui");
1457
- var import_i18n13 = require("@wordpress/i18n");
1654
+ var React31 = __toESM(require("react"));
1655
+ var import_editor_props19 = require("@elementor/editor-props");
1656
+ var import_icons10 = require("@elementor/icons");
1657
+ var import_ui26 = require("@elementor/ui");
1658
+ var import_i18n14 = require("@wordpress/i18n");
1458
1659
  var backgroundPositionOptions = [
1459
- { label: (0, import_i18n13.__)("Center Center", "elementor"), value: "center center" },
1460
- { label: (0, import_i18n13.__)("Center Left", "elementor"), value: "center left" },
1461
- { label: (0, import_i18n13.__)("Center Right", "elementor"), value: "center right" },
1462
- { label: (0, import_i18n13.__)("Top Center", "elementor"), value: "top center" },
1463
- { label: (0, import_i18n13.__)("Top Left", "elementor"), value: "top left" },
1464
- { label: (0, import_i18n13.__)("Top Right", "elementor"), value: "top right" },
1465
- { label: (0, import_i18n13.__)("Bottom Center", "elementor"), value: "bottom center" },
1466
- { label: (0, import_i18n13.__)("Bottom Left", "elementor"), value: "bottom left" },
1467
- { label: (0, import_i18n13.__)("Bottom Right", "elementor"), value: "bottom right" }
1660
+ { label: (0, import_i18n14.__)("Center Center", "elementor"), value: "center center" },
1661
+ { label: (0, import_i18n14.__)("Center Left", "elementor"), value: "center left" },
1662
+ { label: (0, import_i18n14.__)("Center Right", "elementor"), value: "center right" },
1663
+ { label: (0, import_i18n14.__)("Top Center", "elementor"), value: "top center" },
1664
+ { label: (0, import_i18n14.__)("Top Left", "elementor"), value: "top left" },
1665
+ { label: (0, import_i18n14.__)("Top Right", "elementor"), value: "top right" },
1666
+ { label: (0, import_i18n14.__)("Bottom Center", "elementor"), value: "bottom center" },
1667
+ { label: (0, import_i18n14.__)("Bottom Left", "elementor"), value: "bottom left" },
1668
+ { label: (0, import_i18n14.__)("Bottom Right", "elementor"), value: "bottom right" },
1669
+ { label: (0, import_i18n14.__)("Custom", "elementor"), value: "custom" }
1468
1670
  ];
1469
1671
  var BackgroundImageOverlayPosition = () => {
1470
- return /* @__PURE__ */ React30.createElement(import_ui25.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React30.createElement(import_ui25.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React30.createElement(ControlLabel, null, (0, import_i18n13.__)("Position", "elementor"))), /* @__PURE__ */ React30.createElement(import_ui25.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React30.createElement(SelectControl, { options: backgroundPositionOptions })));
1672
+ const backgroundImageOffsetContext = useBoundProp(import_editor_props19.backgroundImagePositionOffsetPropTypeUtil);
1673
+ const stringPropContext = useBoundProp(import_editor_props19.stringPropTypeUtil);
1674
+ const isCustom = !!backgroundImageOffsetContext.value;
1675
+ const handlePositionChange = (event) => {
1676
+ const value = event.target.value || null;
1677
+ if (value === "custom") {
1678
+ backgroundImageOffsetContext.setValue({ x: null, y: null });
1679
+ } else {
1680
+ stringPropContext.setValue(value);
1681
+ }
1682
+ };
1683
+ return /* @__PURE__ */ React31.createElement(import_ui26.Grid, { container: true, spacing: 2 }, /* @__PURE__ */ React31.createElement(import_ui26.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React31.createElement(import_ui26.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React31.createElement(import_ui26.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React31.createElement(ControlLabel, null, (0, import_i18n14.__)("Position", "elementor"))), /* @__PURE__ */ React31.createElement(import_ui26.Grid, { item: true, xs: 6, sx: { display: "flex", justifyContent: "flex-end" } }, /* @__PURE__ */ React31.createElement(
1684
+ import_ui26.Select,
1685
+ {
1686
+ size: "tiny",
1687
+ value: (backgroundImageOffsetContext.value ? "custom" : stringPropContext.value) ?? "",
1688
+ onChange: handlePositionChange,
1689
+ fullWidth: true
1690
+ },
1691
+ backgroundPositionOptions.map(({ label, value }) => /* @__PURE__ */ React31.createElement(import_ui26.MenuItem, { key: value, value: value ?? "" }, label))
1692
+ )))), isCustom ? /* @__PURE__ */ React31.createElement(PropProvider, { ...backgroundImageOffsetContext }, /* @__PURE__ */ React31.createElement(import_ui26.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React31.createElement(import_ui26.Grid, { container: true, spacing: 2 }, /* @__PURE__ */ React31.createElement(import_ui26.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React31.createElement(PropKeyProvider, { bind: "x" }, /* @__PURE__ */ React31.createElement(SizeControl, { startIcon: /* @__PURE__ */ React31.createElement(import_icons10.LetterXIcon, { fontSize: "tiny" }) }))), /* @__PURE__ */ React31.createElement(import_ui26.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React31.createElement(PropKeyProvider, { bind: "y" }, /* @__PURE__ */ React31.createElement(SizeControl, { startIcon: /* @__PURE__ */ React31.createElement(import_icons10.LetterYIcon, { fontSize: "tiny" }) })))))) : null);
1471
1693
  };
1472
1694
 
1473
1695
  // src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-repeat.tsx
1474
- var React31 = __toESM(require("react"));
1475
- var import_icons9 = require("@elementor/icons");
1476
- var import_ui26 = require("@elementor/ui");
1477
- var import_i18n14 = require("@wordpress/i18n");
1696
+ var React32 = __toESM(require("react"));
1697
+ var import_icons11 = require("@elementor/icons");
1698
+ var import_ui27 = require("@elementor/ui");
1699
+ var import_i18n15 = require("@wordpress/i18n");
1478
1700
  var repeatControlOptions = [
1479
1701
  {
1480
1702
  value: "repeat",
1481
- label: (0, import_i18n14.__)("Repeat", "elementor"),
1482
- renderContent: ({ size }) => /* @__PURE__ */ React31.createElement(import_icons9.GridDotsIcon, { fontSize: size }),
1703
+ label: (0, import_i18n15.__)("Repeat", "elementor"),
1704
+ renderContent: ({ size }) => /* @__PURE__ */ React32.createElement(import_icons11.GridDotsIcon, { fontSize: size }),
1483
1705
  showTooltip: true
1484
1706
  },
1485
1707
  {
1486
1708
  value: "repeat-x",
1487
- label: (0, import_i18n14.__)("Repeat-x", "elementor"),
1488
- renderContent: ({ size }) => /* @__PURE__ */ React31.createElement(import_icons9.DotsHorizontalIcon, { fontSize: size }),
1709
+ label: (0, import_i18n15.__)("Repeat-x", "elementor"),
1710
+ renderContent: ({ size }) => /* @__PURE__ */ React32.createElement(import_icons11.DotsHorizontalIcon, { fontSize: size }),
1489
1711
  showTooltip: true
1490
1712
  },
1491
1713
  {
1492
1714
  value: "repeat-y",
1493
- label: (0, import_i18n14.__)("Repeat-y", "elementor"),
1494
- renderContent: ({ size }) => /* @__PURE__ */ React31.createElement(import_icons9.DotsVerticalIcon, { fontSize: size }),
1715
+ label: (0, import_i18n15.__)("Repeat-y", "elementor"),
1716
+ renderContent: ({ size }) => /* @__PURE__ */ React32.createElement(import_icons11.DotsVerticalIcon, { fontSize: size }),
1495
1717
  showTooltip: true
1496
1718
  },
1497
1719
  {
1498
1720
  value: "no-repeat",
1499
- label: (0, import_i18n14.__)("No-Repeat", "elementor"),
1500
- renderContent: ({ size }) => /* @__PURE__ */ React31.createElement(import_icons9.XIcon, { fontSize: size }),
1721
+ label: (0, import_i18n15.__)("No-Repeat", "elementor"),
1722
+ renderContent: ({ size }) => /* @__PURE__ */ React32.createElement(import_icons11.XIcon, { fontSize: size }),
1501
1723
  showTooltip: true
1502
1724
  }
1503
1725
  ];
1504
1726
  var BackgroundImageOverlayRepeat = () => {
1505
- return /* @__PURE__ */ React31.createElement(import_ui26.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React31.createElement(import_ui26.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React31.createElement(ControlLabel, null, (0, import_i18n14.__)("Repeat", "elementor"))), /* @__PURE__ */ React31.createElement(import_ui26.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React31.createElement(ToggleControl, { options: repeatControlOptions })));
1506
- };
1507
-
1508
- // src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-resolution.tsx
1509
- var React32 = __toESM(require("react"));
1510
- var import_ui27 = require("@elementor/ui");
1511
- var import_i18n15 = require("@wordpress/i18n");
1512
- var backgroundResolutionOptions = [
1513
- { label: (0, import_i18n15.__)("Thumbnail - 150 x 150", "elementor"), value: "thumbnail" },
1514
- { label: (0, import_i18n15.__)("Medium - 300 x 300", "elementor"), value: "medium" },
1515
- { label: (0, import_i18n15.__)("Medium Large - 768 x 768"), value: "medium_large" },
1516
- { label: (0, import_i18n15.__)("Large 1024 x 1024", "elementor"), value: "large" },
1517
- { label: (0, import_i18n15.__)("Full", "elementor"), value: "full" }
1518
- ];
1519
- var BackgroundImageOverlayResolution = () => {
1520
- return /* @__PURE__ */ React32.createElement(import_ui27.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React32.createElement(import_ui27.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React32.createElement(ControlLabel, null, (0, import_i18n15.__)("Resolution", "elementor"))), /* @__PURE__ */ React32.createElement(import_ui27.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React32.createElement(SelectControl, { options: backgroundResolutionOptions })));
1727
+ return /* @__PURE__ */ React32.createElement(import_ui27.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React32.createElement(import_ui27.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React32.createElement(ControlLabel, null, (0, import_i18n15.__)("Repeat", "elementor"))), /* @__PURE__ */ React32.createElement(import_ui27.Grid, { item: true, xs: 6, sx: { display: "flex", justifyContent: "flex-end" } }, /* @__PURE__ */ React32.createElement(ToggleControl, { options: repeatControlOptions })));
1521
1728
  };
1522
1729
 
1523
1730
  // src/controls/background-control/background-overlay/background-image-overlay/background-image-overlay-size.tsx
1524
1731
  var React33 = __toESM(require("react"));
1525
- var import_icons10 = require("@elementor/icons");
1732
+ var import_editor_props20 = require("@elementor/editor-props");
1733
+ var import_icons12 = require("@elementor/icons");
1526
1734
  var import_ui28 = require("@elementor/ui");
1527
1735
  var import_i18n16 = require("@wordpress/i18n");
1528
1736
  var sizeControlOptions = [
1529
1737
  {
1530
1738
  value: "auto",
1531
1739
  label: (0, import_i18n16.__)("Auto", "elementor"),
1532
- renderContent: () => "Auto",
1740
+ renderContent: ({ size }) => /* @__PURE__ */ React33.createElement(import_icons12.LetterAIcon, { fontSize: size }),
1533
1741
  showTooltip: true
1534
1742
  },
1535
1743
  {
1536
1744
  value: "cover",
1537
1745
  label: (0, import_i18n16.__)("Cover", "elementor"),
1538
- renderContent: ({ size }) => /* @__PURE__ */ React33.createElement(import_icons10.ArrowsMaximizeIcon, { fontSize: size }),
1746
+ renderContent: ({ size }) => /* @__PURE__ */ React33.createElement(import_icons12.ArrowsMaximizeIcon, { fontSize: size }),
1539
1747
  showTooltip: true
1540
1748
  },
1541
1749
  {
1542
1750
  value: "contain",
1543
1751
  label: (0, import_i18n16.__)("Contain", "elementor"),
1544
- renderContent: ({ size }) => /* @__PURE__ */ React33.createElement(import_icons10.ArrowBarBothIcon, { fontSize: size }),
1752
+ renderContent: ({ size }) => /* @__PURE__ */ React33.createElement(import_icons12.ArrowBarBothIcon, { fontSize: size }),
1753
+ showTooltip: true
1754
+ },
1755
+ {
1756
+ value: "custom",
1757
+ label: (0, import_i18n16.__)("Custom", "elementor"),
1758
+ renderContent: ({ size }) => /* @__PURE__ */ React33.createElement(import_icons12.PencilIcon, { fontSize: size }),
1545
1759
  showTooltip: true
1546
1760
  }
1547
1761
  ];
1548
1762
  var BackgroundImageOverlaySize = () => {
1549
- return /* @__PURE__ */ React33.createElement(import_ui28.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React33.createElement(import_ui28.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React33.createElement(ControlLabel, null, (0, import_i18n16.__)("Size", "elementor"))), /* @__PURE__ */ React33.createElement(import_ui28.Grid, { item: true, xs: 6, sx: { display: "flex", justifyContent: "flex-end" } }, /* @__PURE__ */ React33.createElement(ToggleControl, { options: sizeControlOptions })));
1763
+ const backgroundImageScaleContext = useBoundProp(import_editor_props20.backgroundImageSizeScalePropTypeUtil);
1764
+ const stringPropContext = useBoundProp(import_editor_props20.stringPropTypeUtil);
1765
+ const isCustom = !!backgroundImageScaleContext.value;
1766
+ const handleSizeChange = (size) => {
1767
+ if (size === "custom") {
1768
+ backgroundImageScaleContext.setValue({ width: null, height: null });
1769
+ } else {
1770
+ stringPropContext.setValue(size);
1771
+ }
1772
+ };
1773
+ return /* @__PURE__ */ React33.createElement(import_ui28.Grid, { container: true, spacing: 1.5 }, /* @__PURE__ */ React33.createElement(import_ui28.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React33.createElement(import_ui28.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React33.createElement(import_ui28.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React33.createElement(ControlLabel, null, (0, import_i18n16.__)("Size", "elementor"))), /* @__PURE__ */ React33.createElement(import_ui28.Grid, { item: true, xs: 6, sx: { display: "flex", justifyContent: "flex-end" } }, /* @__PURE__ */ React33.createElement(
1774
+ ControlToggleButtonGroup,
1775
+ {
1776
+ exclusive: true,
1777
+ items: sizeControlOptions,
1778
+ value: backgroundImageScaleContext.value ? "custom" : stringPropContext.value,
1779
+ onChange: handleSizeChange
1780
+ }
1781
+ )))), isCustom ? /* @__PURE__ */ React33.createElement(PropProvider, { ...backgroundImageScaleContext }, /* @__PURE__ */ React33.createElement(import_ui28.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React33.createElement(import_ui28.Grid, { container: true, spacing: 2 }, /* @__PURE__ */ React33.createElement(import_ui28.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React33.createElement(PropKeyProvider, { bind: "width" }, /* @__PURE__ */ React33.createElement(SizeControl, { startIcon: /* @__PURE__ */ React33.createElement(import_icons12.ArrowsMoveHorizontalIcon, { fontSize: "tiny" }) }))), /* @__PURE__ */ React33.createElement(import_ui28.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React33.createElement(PropKeyProvider, { bind: "height" }, /* @__PURE__ */ React33.createElement(SizeControl, { startIcon: /* @__PURE__ */ React33.createElement(import_icons12.ArrowsMoveVerticalIcon, { fontSize: "tiny" }) })))))) : null);
1550
1782
  };
1551
1783
 
1552
1784
  // src/controls/background-control/background-overlay/background-overlay-repeater-control.tsx
1553
- var defaultImagePlaceholderId = 1;
1554
- var initialBackgroundOverlay = {
1785
+ var initialBackgroundOverlay = (backgroundPlaceholderImage) => ({
1555
1786
  $$type: "background-image-overlay",
1556
1787
  value: {
1557
- "image-src": {
1558
- $$type: "image-src",
1788
+ image: {
1789
+ $$type: "image",
1559
1790
  value: {
1560
- id: {
1561
- $$type: "image-attachment-id",
1562
- value: defaultImagePlaceholderId
1791
+ src: {
1792
+ $$type: "image-src",
1793
+ value: {
1794
+ url: {
1795
+ $$type: "url",
1796
+ value: backgroundPlaceholderImage
1797
+ },
1798
+ id: null
1799
+ }
1800
+ },
1801
+ size: {
1802
+ $$type: "string",
1803
+ value: "large"
1563
1804
  }
1564
1805
  }
1565
1806
  }
1566
1807
  }
1567
- };
1808
+ });
1809
+ var backgroundResolutionOptions = [
1810
+ { label: (0, import_i18n17.__)("Thumbnail - 150 x 150", "elementor"), value: "thumbnail" },
1811
+ { label: (0, import_i18n17.__)("Medium - 300 x 300", "elementor"), value: "medium" },
1812
+ { label: (0, import_i18n17.__)("Large 1024 x 1024", "elementor"), value: "large" },
1813
+ { label: (0, import_i18n17.__)("Full", "elementor"), value: "full" }
1814
+ ];
1568
1815
  var BackgroundOverlayRepeaterControl = createControl(() => {
1569
- const { propType, value: overlayValues, setValue } = useBoundProp(import_editor_props19.backgroundOverlayPropTypeUtil);
1816
+ const { propType, value: overlayValues, setValue } = useBoundProp(import_editor_props21.backgroundOverlayPropTypeUtil);
1570
1817
  return /* @__PURE__ */ React34.createElement(PropProvider, { propType, value: overlayValues, setValue }, /* @__PURE__ */ React34.createElement(
1571
1818
  Repeater,
1572
1819
  {
@@ -1577,40 +1824,62 @@ var BackgroundOverlayRepeaterControl = createControl(() => {
1577
1824
  Icon: ItemIcon2,
1578
1825
  Label: ItemLabel2,
1579
1826
  Content: ItemContent2,
1580
- initialValues: initialBackgroundOverlay
1827
+ initialValues: initialBackgroundOverlay(env.background_placeholder_image)
1581
1828
  }
1582
1829
  }
1583
1830
  ));
1584
1831
  });
1585
- var ItemIcon2 = ({ value }) => /* @__PURE__ */ React34.createElement(import_ui29.UnstableColorIndicator, { size: "inherit", component: "span", value: value.value });
1586
1832
  var ItemContent2 = ({ bind, value }) => {
1587
1833
  return /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React34.createElement(Content2, { value }));
1588
1834
  };
1589
1835
  var Content2 = ({ value }) => {
1590
1836
  const activeTab = deriveOverlayType(value.$$type);
1591
1837
  const { getTabsProps, getTabProps, getTabPanelProps } = (0, import_ui29.useTabs)(activeTab);
1592
- return /* @__PURE__ */ React34.createElement(import_ui29.Box, { sx: { width: "100%" } }, /* @__PURE__ */ React34.createElement(import_ui29.Box, { sx: { borderBottom: 1, borderColor: "divider" } }, /* @__PURE__ */ React34.createElement(import_ui29.Tabs, { ...getTabsProps(), "aria-label": (0, import_i18n17.__)("Background Overlay", "elementor") }, /* @__PURE__ */ React34.createElement(import_ui29.Tab, { label: (0, import_i18n17.__)("Image", "elementor"), ...getTabProps("image") }), /* @__PURE__ */ React34.createElement(import_ui29.Tab, { label: (0, import_i18n17.__)("Color", "elementor"), ...getTabProps("color") }))), /* @__PURE__ */ React34.createElement(import_ui29.TabPanel, { ...getTabPanelProps("image") }, /* @__PURE__ */ React34.createElement(import_ui29.Stack, { gap: 1.5 }, /* @__PURE__ */ React34.createElement(ImageOverlayContent, null))), /* @__PURE__ */ React34.createElement(import_ui29.TabPanel, { ...getTabPanelProps("color") }, /* @__PURE__ */ React34.createElement(import_ui29.Grid, { container: true, spacing: 1, alignItems: "center" }, /* @__PURE__ */ React34.createElement(import_ui29.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React34.createElement(ColorControl, { propTypeUtil: import_editor_props19.backgroundColorOverlayPropTypeUtil })))));
1838
+ return /* @__PURE__ */ React34.createElement(import_ui29.Box, { sx: { width: "100%" } }, /* @__PURE__ */ React34.createElement(import_ui29.Box, { sx: { borderBottom: 1, borderColor: "divider" } }, /* @__PURE__ */ React34.createElement(import_ui29.Tabs, { ...getTabsProps(), "aria-label": (0, import_i18n17.__)("Background Overlay", "elementor") }, /* @__PURE__ */ React34.createElement(import_ui29.Tab, { label: (0, import_i18n17.__)("Image", "elementor"), ...getTabProps("image") }), /* @__PURE__ */ React34.createElement(import_ui29.Tab, { label: (0, import_i18n17.__)("Color", "elementor"), ...getTabProps("color") }))), /* @__PURE__ */ React34.createElement(import_ui29.TabPanel, { sx: { p: 1.5 }, ...getTabPanelProps("image") }, /* @__PURE__ */ React34.createElement(import_ui29.Stack, { gap: 1.5 }, /* @__PURE__ */ React34.createElement(ImageOverlayContent, null))), /* @__PURE__ */ React34.createElement(import_ui29.TabPanel, { ...getTabPanelProps("color"), sx: { p: 1.5 } }, /* @__PURE__ */ React34.createElement(import_ui29.Grid, { container: true, spacing: 1, alignItems: "center" }, /* @__PURE__ */ React34.createElement(import_ui29.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React34.createElement(ColorControl, { propTypeUtil: import_editor_props21.backgroundColorOverlayPropTypeUtil })))));
1593
1839
  };
1594
- var ItemLabel2 = ({ value }) => {
1595
- const type = value.$$type;
1596
- if (type === "background-color-overlay") {
1597
- return /* @__PURE__ */ React34.createElement(ItemLabelColor, { value });
1840
+ var ItemIcon2 = ({ value }) => {
1841
+ switch (value.$$type) {
1842
+ case "background-image-overlay":
1843
+ return /* @__PURE__ */ React34.createElement(ItemIconImage, { value });
1844
+ case "background-color-overlay":
1845
+ return /* @__PURE__ */ React34.createElement(ItemIconColor, { value });
1846
+ default:
1847
+ return null;
1598
1848
  }
1599
- if (type === "background-image-overlay") {
1600
- return /* @__PURE__ */ React34.createElement(ItemLabelImage, { value });
1849
+ };
1850
+ var ItemIconColor = ({ value }) => {
1851
+ return /* @__PURE__ */ React34.createElement(import_ui29.UnstableColorIndicator, { size: "inherit", component: "span", value: value.value });
1852
+ };
1853
+ var ItemIconImage = ({ value }) => {
1854
+ const { imageUrl } = useImage(value);
1855
+ return /* @__PURE__ */ React34.createElement(import_ui29.CardMedia, { image: imageUrl, sx: { height: 13, width: 13, borderRadius: "4px" } });
1856
+ };
1857
+ var ItemLabel2 = ({ value }) => {
1858
+ switch (value.$$type) {
1859
+ case "background-image-overlay":
1860
+ return /* @__PURE__ */ React34.createElement(ItemLabelImage, { value });
1861
+ case "background-color-overlay":
1862
+ return /* @__PURE__ */ React34.createElement(ItemLabelColor, { value });
1863
+ default:
1864
+ return null;
1601
1865
  }
1602
1866
  };
1603
1867
  var ItemLabelColor = ({ value }) => {
1604
1868
  return /* @__PURE__ */ React34.createElement("span", null, value.value);
1605
1869
  };
1606
1870
  var ItemLabelImage = ({ value }) => {
1607
- const { data: attachment } = (0, import_wp_media2.useWpMediaAttachment)(value?.value["image-src"]?.value.id.value || null);
1608
- const imageTitle = attachment?.title || null;
1871
+ const { imageTitle } = useImage(value);
1609
1872
  return /* @__PURE__ */ React34.createElement("span", null, imageTitle);
1610
1873
  };
1611
1874
  var ImageOverlayContent = () => {
1612
- const propContext = useBoundProp(import_editor_props19.backgroundImageOverlayPropTypeUtil);
1613
- return /* @__PURE__ */ React34.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "image-src" }, /* @__PURE__ */ React34.createElement(import_ui29.Grid, { container: true, spacing: 1, alignItems: "center" }, /* @__PURE__ */ React34.createElement(import_ui29.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React34.createElement(ImageMediaControl, null)))), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "resolution" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayResolution, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "position" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayPosition, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "repeat" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayRepeat, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "size" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlaySize, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "attachment" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayAttachment, null)));
1875
+ const propContext = useBoundProp(import_editor_props21.backgroundImageOverlayPropTypeUtil);
1876
+ return /* @__PURE__ */ React34.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "image" }, /* @__PURE__ */ React34.createElement(import_ui29.Grid, { container: true, spacing: 1, alignItems: "center" }, /* @__PURE__ */ React34.createElement(import_ui29.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React34.createElement(
1877
+ ImageControl,
1878
+ {
1879
+ resolutionLabel: (0, import_i18n17.__)("Resolution", "elementor"),
1880
+ sizes: backgroundResolutionOptions
1881
+ }
1882
+ )))), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "position" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayPosition, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "repeat" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayRepeat, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "size" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlaySize, null)), /* @__PURE__ */ React34.createElement(PropKeyProvider, { bind: "attachment" }, /* @__PURE__ */ React34.createElement(BackgroundImageOverlayAttachment, null)));
1614
1883
  };
1615
1884
  var deriveOverlayType = (type) => {
1616
1885
  if (type === "background-color-overlay") {
@@ -1621,10 +1890,24 @@ var deriveOverlayType = (type) => {
1621
1890
  }
1622
1891
  throw new Error(`Invalid overlay type: ${type}`);
1623
1892
  };
1893
+ var useImage = (image) => {
1894
+ let imageTitle, imageUrl = null;
1895
+ const imageSrc = image?.value.image.value?.src.value;
1896
+ const { data: attachment } = (0, import_wp_media3.useWpMediaAttachment)(imageSrc.id?.value || null);
1897
+ if (imageSrc.id) {
1898
+ const imageFileTypeExtension = attachment?.subtype ? `.${attachment.subtype}` : "";
1899
+ imageTitle = `${attachment?.title}${imageFileTypeExtension}` || null;
1900
+ imageUrl = attachment?.url || null;
1901
+ } else if (imageSrc.url) {
1902
+ imageUrl = imageSrc.url.value;
1903
+ imageTitle = imageUrl?.substring(imageUrl.lastIndexOf("/") + 1) || null;
1904
+ }
1905
+ return { imageTitle, imageUrl };
1906
+ };
1624
1907
 
1625
1908
  // src/controls/background-control/background-control.tsx
1626
1909
  var BackgroundControl = createControl(() => {
1627
- const propContext = useBoundProp(import_editor_props20.backgroundPropTypeUtil);
1910
+ const propContext = useBoundProp(import_editor_props22.backgroundPropTypeUtil);
1628
1911
  return /* @__PURE__ */ React35.createElement(PropProvider, { ...propContext }, /* @__PURE__ */ React35.createElement(import_ui30.Stack, { gap: 1.5 }, /* @__PURE__ */ React35.createElement(PropKeyProvider, { bind: "background-overlay" }, /* @__PURE__ */ React35.createElement(BackgroundOverlayRepeaterControl, null)), /* @__PURE__ */ React35.createElement(PropKeyProvider, { bind: "color" }, /* @__PURE__ */ React35.createElement(import_ui30.Grid, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap" }, /* @__PURE__ */ React35.createElement(import_ui30.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React35.createElement(ControlLabel, null, (0, import_i18n18.__)("Color", "elementor"))), /* @__PURE__ */ React35.createElement(import_ui30.Grid, { item: true, xs: 6 }, /* @__PURE__ */ React35.createElement(ColorControl, null))))));
1629
1912
  });
1630
1913
  // Annotate the CommonJS export names for ESM import in node:
@@ -1649,6 +1932,7 @@ var BackgroundControl = createControl(() => {
1649
1932
  SelectControl,
1650
1933
  SizeControl,
1651
1934
  StrokeControl,
1935
+ SvgMediaControl,
1652
1936
  TextAreaControl,
1653
1937
  TextControl,
1654
1938
  ToggleControl,