@littlebox/strapi-suite 1.0.52 → 1.0.54

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 (27) hide show
  1. package/README.md +29 -0
  2. package/dist/_chunks/{App-C-h--Kv_.js → App-B7_8BaVG.js} +2 -2
  3. package/dist/_chunks/{App-C1HyspTk.mjs → App-BfGB2pF_.mjs} +2 -2
  4. package/dist/_chunks/{SlugInput-CU9_b0dd.mjs → SlugInput-CvgVtZza.mjs} +1 -1
  5. package/dist/_chunks/{SlugInput-3gkr6B0t.js → SlugInput-eCwgqJtH.js} +1 -1
  6. package/dist/_chunks/{en-CLNZnNeq.js → en-D89cXiov.js} +16 -1
  7. package/dist/_chunks/{en-F6RYx79c.mjs → en-knG97mCH.mjs} +16 -1
  8. package/dist/_chunks/{index-DQ3vX9So.mjs → index-97f0S4q6.mjs} +1632 -65
  9. package/dist/_chunks/{index-60sq8G6p.js → index-DnXsi_Ar.js} +1629 -62
  10. package/dist/admin/index.js +1 -1
  11. package/dist/admin/index.mjs +1 -1
  12. package/dist/admin/src/core/utils/tabs.d.ts +53 -0
  13. package/dist/admin/src/ctb/TabSelect.d.ts +31 -0
  14. package/dist/admin/src/ctb/TabsEditor.d.ts +21 -0
  15. package/dist/admin/src/ctb/registerTabsInContentTypeBuilder.d.ts +1 -0
  16. package/dist/admin/src/ctb/tabBadges.d.ts +14 -0
  17. package/dist/admin/src/editView/TabSection.d.ts +6 -0
  18. package/dist/admin/src/editView/TabsBar.d.ts +10 -0
  19. package/dist/admin/src/editView/mutateEditViewLayout.d.ts +12 -0
  20. package/dist/admin/src/editView/sectionVisibility.d.ts +7 -0
  21. package/dist/admin/src/editView/tabsStore.d.ts +13 -0
  22. package/dist/server/index.js +426 -313
  23. package/dist/server/index.mjs +426 -313
  24. package/dist/server/src/middlewares/tabs.d.ts +4 -0
  25. package/dist/server/src/utils/groupByContentTypeTabs.d.ts +7 -0
  26. package/dist/server/src/utils/tabs.d.ts +17 -0
  27. package/package.json +6 -3
@@ -1,12 +1,16 @@
1
1
  import { getFetchClient, unstable_useContentManagerContext } from "@strapi/strapi/admin";
2
2
  import * as React from "react";
3
- import React__default, { useRef, useEffect, useState } from "react";
3
+ import React__default, { useRef, useEffect, useState, useSyncExternalStore, useMemo, useLayoutEffect } from "react";
4
4
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
5
5
  import { useLocation } from "react-router-dom";
6
- import { Dialog, Button, Box, Typography, SingleSelect, SingleSelectOption, Flex, IconButton, Toggle, Card, Loader } from "@strapi/design-system";
6
+ import { Dialog, Button, Box, Typography, SingleSelect, SingleSelectOption, Flex, IconButton, Toggle, Card, Loader, Divider, Field, TextInput, Tabs, Badge } from "@strapi/design-system";
7
7
  import { useIntl } from "react-intl";
8
- import { WarningCircle, Cross, Sparkle } from "@strapi/icons";
8
+ import { WarningCircle, Cross, Sparkle, Plus, Drag, Trash } from "@strapi/icons";
9
9
  import styled from "styled-components";
10
+ import { useSensors, useSensor, PointerSensor, DndContext, closestCenter } from "@dnd-kit/core";
11
+ import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
12
+ import { SortableContext, verticalListSortingStrategy, arrayMove, useSortable } from "@dnd-kit/sortable";
13
+ import { CSS } from "@dnd-kit/utilities";
10
14
  const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
11
15
  const v = glob[path];
12
16
  if (v) {
@@ -72,7 +76,7 @@ function baseClone(src, circulars, clones) {
72
76
  function clone(src) {
73
77
  return baseClone(src, [], []);
74
78
  }
75
- const toString$2 = Object.prototype.toString;
79
+ const toString$6 = Object.prototype.toString;
76
80
  const errorToString = Error.prototype.toString;
77
81
  const regExpToString = RegExp.prototype.toString;
78
82
  const symbolToString$1 = typeof Symbol !== "undefined" ? Symbol.prototype.toString : () => "";
@@ -89,7 +93,7 @@ function printSimpleValue(val, quoteStrings = false) {
89
93
  if (typeOf === "string") return quoteStrings ? `"${val}"` : val;
90
94
  if (typeOf === "function") return "[Function " + (val.name || "anonymous") + "]";
91
95
  if (typeOf === "symbol") return symbolToString$1.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
92
- const tag = toString$2.call(val).slice(8, -1);
96
+ const tag = toString$6.call(val).slice(8, -1);
93
97
  if (tag === "Date") return isNaN(val.getTime()) ? "" + val : val.toISOString(val);
94
98
  if (tag === "Error" || val instanceof Error) return "[" + errorToString.call(val) + "]";
95
99
  if (tag === "RegExp") return regExpToString.call(val);
@@ -253,15 +257,15 @@ function isKey$3(value, object2) {
253
257
  return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object2 != null && value in Object(object2);
254
258
  }
255
259
  var _isKey = isKey$3;
256
- function isObject$3(value) {
260
+ function isObject$4(value) {
257
261
  var type = typeof value;
258
262
  return value != null && (type == "object" || type == "function");
259
263
  }
260
- var isObject_1 = isObject$3;
261
- var baseGetTag$3 = _baseGetTag, isObject$2 = isObject_1;
264
+ var isObject_1 = isObject$4;
265
+ var baseGetTag$3 = _baseGetTag, isObject$3 = isObject_1;
262
266
  var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
263
267
  function isFunction$2(value) {
264
- if (!isObject$2(value)) {
268
+ if (!isObject$3(value)) {
265
269
  return false;
266
270
  }
267
271
  var tag = baseGetTag$3(value);
@@ -296,7 +300,7 @@ function toSource$2(func) {
296
300
  return "";
297
301
  }
298
302
  var _toSource = toSource$2;
299
- var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$1 = isObject_1, toSource$1 = _toSource;
303
+ var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$2 = isObject_1, toSource$1 = _toSource;
300
304
  var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
301
305
  var reIsHostCtor = /^\[object .+?Constructor\]$/;
302
306
  var funcProto = Function.prototype, objectProto$9 = Object.prototype;
@@ -306,7 +310,7 @@ var reIsNative = RegExp(
306
310
  "^" + funcToString.call(hasOwnProperty$7).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
307
311
  );
308
312
  function baseIsNative$1(value) {
309
- if (!isObject$1(value) || isMasked(value)) {
313
+ if (!isObject$2(value) || isMasked(value)) {
310
314
  return false;
311
315
  }
312
316
  var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
@@ -595,16 +599,16 @@ function baseToString$1(value) {
595
599
  }
596
600
  var _baseToString = baseToString$1;
597
601
  var baseToString = _baseToString;
598
- function toString$1(value) {
602
+ function toString$5(value) {
599
603
  return value == null ? "" : baseToString(value);
600
604
  }
601
- var toString_1 = toString$1;
602
- var isArray$5 = isArray_1, isKey$2 = _isKey, stringToPath = _stringToPath, toString = toString_1;
605
+ var toString_1 = toString$5;
606
+ var isArray$5 = isArray_1, isKey$2 = _isKey, stringToPath = _stringToPath, toString$4 = toString_1;
603
607
  function castPath$2(value, object2) {
604
608
  if (isArray$5(value)) {
605
609
  return value;
606
610
  }
607
- return isKey$2(value, object2) ? [value] : stringToPath(toString(value));
611
+ return isKey$2(value, object2) ? [value] : stringToPath(toString$4(value));
608
612
  }
609
613
  var _castPath = castPath$2;
610
614
  var baseGetTag$2 = _baseGetTag, isObjectLike$3 = isObjectLike_1;
@@ -706,8 +710,8 @@ class Condition {
706
710
  function toArray(value) {
707
711
  return value == null ? [] : [].concat(value);
708
712
  }
709
- function _extends$2() {
710
- _extends$2 = Object.assign || function(target) {
713
+ function _extends$4() {
714
+ _extends$4 = Object.assign || function(target) {
711
715
  for (var i = 1; i < arguments.length; i++) {
712
716
  var source = arguments[i];
713
717
  for (var key in source) {
@@ -718,13 +722,13 @@ function _extends$2() {
718
722
  }
719
723
  return target;
720
724
  };
721
- return _extends$2.apply(this, arguments);
725
+ return _extends$4.apply(this, arguments);
722
726
  }
723
727
  let strReg = /\$\{\s*(\w+)\s*\}/g;
724
728
  class ValidationError extends Error {
725
729
  static formatError(message, params) {
726
730
  const path = params.label || params.path || "this";
727
- if (path !== params.path) params = _extends$2({}, params, {
731
+ if (path !== params.path) params = _extends$4({}, params, {
728
732
  path
729
733
  });
730
734
  if (typeof message === "string") return message.replace(strReg, (_, key) => printValue(params[key]));
@@ -816,7 +820,7 @@ var defineProperty$1 = function() {
816
820
  }();
817
821
  var _defineProperty = defineProperty$1;
818
822
  var defineProperty = _defineProperty;
819
- function baseAssignValue$1(object2, key, value) {
823
+ function baseAssignValue$2(object2, key, value) {
820
824
  if (key == "__proto__" && defineProperty) {
821
825
  defineProperty(object2, key, {
822
826
  "configurable": true,
@@ -828,7 +832,7 @@ function baseAssignValue$1(object2, key, value) {
828
832
  object2[key] = value;
829
833
  }
830
834
  }
831
- var _baseAssignValue = baseAssignValue$1;
835
+ var _baseAssignValue = baseAssignValue$2;
832
836
  function createBaseFor$1(fromRight) {
833
837
  return function(object2, iteratee, keysFunc) {
834
838
  var index2 = -1, iterable = Object(object2), props = keysFunc(object2), length = props.length;
@@ -970,10 +974,10 @@ function keys$3(object2) {
970
974
  }
971
975
  var keys_1 = keys$3;
972
976
  var baseFor = _baseFor, keys$2 = keys_1;
973
- function baseForOwn$1(object2, iteratee) {
977
+ function baseForOwn$2(object2, iteratee) {
974
978
  return object2 && baseFor(object2, iteratee, keys$2);
975
979
  }
976
- var _baseForOwn = baseForOwn$1;
980
+ var _baseForOwn = baseForOwn$2;
977
981
  var ListCache$2 = _ListCache;
978
982
  function stackClear$1() {
979
983
  this.__data__ = new ListCache$2();
@@ -1390,9 +1394,9 @@ function baseIsMatch$1(object2, source, matchData, customizer) {
1390
1394
  return true;
1391
1395
  }
1392
1396
  var _baseIsMatch = baseIsMatch$1;
1393
- var isObject = isObject_1;
1397
+ var isObject$1 = isObject_1;
1394
1398
  function isStrictComparable$2(value) {
1395
- return value === value && !isObject(value);
1399
+ return value === value && !isObject$1(value);
1396
1400
  }
1397
1401
  var _isStrictComparable = isStrictComparable$2;
1398
1402
  var isStrictComparable$1 = _isStrictComparable, keys = keys_1;
@@ -1485,7 +1489,7 @@ function property$1(path) {
1485
1489
  }
1486
1490
  var property_1 = property$1;
1487
1491
  var baseMatches = _baseMatches, baseMatchesProperty = _baseMatchesProperty, identity = identity_1, isArray = isArray_1, property = property_1;
1488
- function baseIteratee$1(value) {
1492
+ function baseIteratee$2(value) {
1489
1493
  if (typeof value == "function") {
1490
1494
  return value;
1491
1495
  }
@@ -1497,13 +1501,13 @@ function baseIteratee$1(value) {
1497
1501
  }
1498
1502
  return property(value);
1499
1503
  }
1500
- var _baseIteratee = baseIteratee$1;
1501
- var baseAssignValue = _baseAssignValue, baseForOwn = _baseForOwn, baseIteratee = _baseIteratee;
1504
+ var _baseIteratee = baseIteratee$2;
1505
+ var baseAssignValue$1 = _baseAssignValue, baseForOwn$1 = _baseForOwn, baseIteratee$1 = _baseIteratee;
1502
1506
  function mapValues(object2, iteratee) {
1503
1507
  var result = {};
1504
- iteratee = baseIteratee(iteratee);
1505
- baseForOwn(object2, function(value, key, object3) {
1506
- baseAssignValue(result, key, iteratee(value, key, object3));
1508
+ iteratee = baseIteratee$1(iteratee);
1509
+ baseForOwn$1(object2, function(value, key, object3) {
1510
+ baseAssignValue$1(result, key, iteratee(value, key, object3));
1507
1511
  });
1508
1512
  return result;
1509
1513
  }
@@ -1654,8 +1658,8 @@ class Reference {
1654
1658
  }
1655
1659
  }
1656
1660
  Reference.prototype.__isYupRef = true;
1657
- function _extends$1() {
1658
- _extends$1 = Object.assign || function(target) {
1661
+ function _extends$3() {
1662
+ _extends$3 = Object.assign || function(target) {
1659
1663
  for (var i = 1; i < arguments.length; i++) {
1660
1664
  var source = arguments[i];
1661
1665
  for (var key in source) {
@@ -1666,7 +1670,7 @@ function _extends$1() {
1666
1670
  }
1667
1671
  return target;
1668
1672
  };
1669
- return _extends$1.apply(this, arguments);
1673
+ return _extends$3.apply(this, arguments);
1670
1674
  }
1671
1675
  function _objectWithoutPropertiesLoose(source, excluded) {
1672
1676
  if (source == null) return {};
@@ -1704,7 +1708,7 @@ function createValidation(config2) {
1704
1708
  return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
1705
1709
  }
1706
1710
  function createError(overrides = {}) {
1707
- const nextParams = mapValues$1(_extends$1({
1711
+ const nextParams = mapValues$1(_extends$3({
1708
1712
  value,
1709
1713
  originalValue,
1710
1714
  label,
@@ -1714,7 +1718,7 @@ function createValidation(config2) {
1714
1718
  error.params = nextParams;
1715
1719
  return error;
1716
1720
  }
1717
- let ctx = _extends$1({
1721
+ let ctx = _extends$3({
1718
1722
  path,
1719
1723
  parent,
1720
1724
  type: name,
@@ -1836,8 +1840,8 @@ class ReferenceSet {
1836
1840
  return next;
1837
1841
  }
1838
1842
  }
1839
- function _extends() {
1840
- _extends = Object.assign || function(target) {
1843
+ function _extends$2() {
1844
+ _extends$2 = Object.assign || function(target) {
1841
1845
  for (var i = 1; i < arguments.length; i++) {
1842
1846
  var source = arguments[i];
1843
1847
  for (var key in source) {
@@ -1848,7 +1852,7 @@ function _extends() {
1848
1852
  }
1849
1853
  return target;
1850
1854
  };
1851
- return _extends.apply(this, arguments);
1855
+ return _extends$2.apply(this, arguments);
1852
1856
  }
1853
1857
  class BaseSchema {
1854
1858
  constructor(options) {
@@ -1863,7 +1867,7 @@ class BaseSchema {
1863
1867
  this.typeError(mixed.notType);
1864
1868
  });
1865
1869
  this.type = (options == null ? void 0 : options.type) || "mixed";
1866
- this.spec = _extends({
1870
+ this.spec = _extends$2({
1867
1871
  strip: false,
1868
1872
  strict: false,
1869
1873
  abortEarly: true,
@@ -1891,12 +1895,12 @@ class BaseSchema {
1891
1895
  next._blacklistError = this._blacklistError;
1892
1896
  next._whitelist = this._whitelist.clone();
1893
1897
  next._blacklist = this._blacklist.clone();
1894
- next.exclusiveTests = _extends({}, this.exclusiveTests);
1898
+ next.exclusiveTests = _extends$2({}, this.exclusiveTests);
1895
1899
  next.deps = [...this.deps];
1896
1900
  next.conditions = [...this.conditions];
1897
1901
  next.tests = [...this.tests];
1898
1902
  next.transforms = [...this.transforms];
1899
- next.spec = clone(_extends({}, this.spec, spec));
1903
+ next.spec = clone(_extends$2({}, this.spec, spec));
1900
1904
  return next;
1901
1905
  }
1902
1906
  label(label) {
@@ -1929,7 +1933,7 @@ class BaseSchema {
1929
1933
  if (schema.type !== this.type && this.type !== "mixed") throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
1930
1934
  let base = this;
1931
1935
  let combined = schema.clone();
1932
- const mergedSpec = _extends({}, base.spec, combined.spec);
1936
+ const mergedSpec = _extends$2({}, base.spec, combined.spec);
1933
1937
  combined.spec = mergedSpec;
1934
1938
  combined._typeError || (combined._typeError = base._typeError);
1935
1939
  combined._whitelistError || (combined._whitelistError = base._whitelistError);
@@ -1968,7 +1972,7 @@ class BaseSchema {
1968
1972
  * @param {*=} options.context
1969
1973
  */
1970
1974
  cast(value, options = {}) {
1971
- let resolvedSchema = this.resolve(_extends({
1975
+ let resolvedSchema = this.resolve(_extends$2({
1972
1976
  value
1973
1977
  }, options));
1974
1978
  let result = resolvedSchema._cast(value, options);
@@ -2000,7 +2004,7 @@ attempted value: ${formattedValue}
2000
2004
  } = options;
2001
2005
  let value = _value;
2002
2006
  if (!strict) {
2003
- value = this._cast(value, _extends({
2007
+ value = this._cast(value, _extends$2({
2004
2008
  assert: false
2005
2009
  }, options));
2006
2010
  }
@@ -2037,7 +2041,7 @@ attempted value: ${formattedValue}
2037
2041
  });
2038
2042
  }
2039
2043
  validate(value, options, maybeCb) {
2040
- let schema = this.resolve(_extends({}, options, {
2044
+ let schema = this.resolve(_extends$2({}, options, {
2041
2045
  value
2042
2046
  }));
2043
2047
  return typeof maybeCb === "function" ? schema._validate(value, options, maybeCb) : new Promise((resolve, reject) => schema._validate(value, options, (err, value2) => {
@@ -2046,11 +2050,11 @@ attempted value: ${formattedValue}
2046
2050
  }));
2047
2051
  }
2048
2052
  validateSync(value, options) {
2049
- let schema = this.resolve(_extends({}, options, {
2053
+ let schema = this.resolve(_extends$2({}, options, {
2050
2054
  value
2051
2055
  }));
2052
2056
  let result;
2053
- schema._validate(value, _extends({}, options, {
2057
+ schema._validate(value, _extends$2({}, options, {
2054
2058
  sync: true
2055
2059
  }), (err, value2) => {
2056
2060
  if (err) throw err;
@@ -2298,7 +2302,7 @@ for (const method of ["validate", "validateSync"]) BaseSchema.prototype[`${metho
2298
2302
  parentPath,
2299
2303
  schema
2300
2304
  } = getIn(this, path, value, options.context);
2301
- return schema[method](parent && parent[parentPath], _extends({}, options, {
2305
+ return schema[method](parent && parent[parentPath], _extends$2({}, options, {
2302
2306
  parent,
2303
2307
  path
2304
2308
  }));
@@ -2312,7 +2316,7 @@ let rUrl = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFD
2312
2316
  let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
2313
2317
  let isTrimmed = (value) => isAbsent(value) || value === value.trim();
2314
2318
  let objStringTag = {}.toString();
2315
- function create() {
2319
+ function create$2() {
2316
2320
  return new StringSchema();
2317
2321
  }
2318
2322
  class StringSchema extends BaseSchema {
@@ -2449,7 +2453,7 @@ class StringSchema extends BaseSchema {
2449
2453
  });
2450
2454
  }
2451
2455
  }
2452
- create.prototype = StringSchema.prototype;
2456
+ create$2.prototype = StringSchema.prototype;
2453
2457
  var isoReg = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;
2454
2458
  function parseIsoDate(date2) {
2455
2459
  var numericKeys = [1, 4, 5, 6, 7, 10, 11], minutesOffset = 0, timestamp, struct;
@@ -2528,11 +2532,373 @@ class DateSchema extends BaseSchema {
2528
2532
  }
2529
2533
  }
2530
2534
  DateSchema.INVALID_DATE = invalidDate;
2531
- var toposort$1 = { exports: {} };
2532
- toposort$1.exports = function(edges) {
2535
+ function arrayReduce$1(array2, iteratee, accumulator, initAccum) {
2536
+ var index2 = -1, length = array2 == null ? 0 : array2.length;
2537
+ if (initAccum && length) {
2538
+ accumulator = array2[++index2];
2539
+ }
2540
+ while (++index2 < length) {
2541
+ accumulator = iteratee(accumulator, array2[index2], index2, array2);
2542
+ }
2543
+ return accumulator;
2544
+ }
2545
+ var _arrayReduce = arrayReduce$1;
2546
+ function basePropertyOf$1(object2) {
2547
+ return function(key) {
2548
+ return object2 == null ? void 0 : object2[key];
2549
+ };
2550
+ }
2551
+ var _basePropertyOf = basePropertyOf$1;
2552
+ var basePropertyOf = _basePropertyOf;
2553
+ var deburredLetters = {
2554
+ // Latin-1 Supplement block.
2555
+ "À": "A",
2556
+ "Á": "A",
2557
+ "Â": "A",
2558
+ "Ã": "A",
2559
+ "Ä": "A",
2560
+ "Å": "A",
2561
+ "à": "a",
2562
+ "á": "a",
2563
+ "â": "a",
2564
+ "ã": "a",
2565
+ "ä": "a",
2566
+ "å": "a",
2567
+ "Ç": "C",
2568
+ "ç": "c",
2569
+ "Ð": "D",
2570
+ "ð": "d",
2571
+ "È": "E",
2572
+ "É": "E",
2573
+ "Ê": "E",
2574
+ "Ë": "E",
2575
+ "è": "e",
2576
+ "é": "e",
2577
+ "ê": "e",
2578
+ "ë": "e",
2579
+ "Ì": "I",
2580
+ "Í": "I",
2581
+ "Î": "I",
2582
+ "Ï": "I",
2583
+ "ì": "i",
2584
+ "í": "i",
2585
+ "î": "i",
2586
+ "ï": "i",
2587
+ "Ñ": "N",
2588
+ "ñ": "n",
2589
+ "Ò": "O",
2590
+ "Ó": "O",
2591
+ "Ô": "O",
2592
+ "Õ": "O",
2593
+ "Ö": "O",
2594
+ "Ø": "O",
2595
+ "ò": "o",
2596
+ "ó": "o",
2597
+ "ô": "o",
2598
+ "õ": "o",
2599
+ "ö": "o",
2600
+ "ø": "o",
2601
+ "Ù": "U",
2602
+ "Ú": "U",
2603
+ "Û": "U",
2604
+ "Ü": "U",
2605
+ "ù": "u",
2606
+ "ú": "u",
2607
+ "û": "u",
2608
+ "ü": "u",
2609
+ "Ý": "Y",
2610
+ "ý": "y",
2611
+ "ÿ": "y",
2612
+ "Æ": "Ae",
2613
+ "æ": "ae",
2614
+ "Þ": "Th",
2615
+ "þ": "th",
2616
+ "ß": "ss",
2617
+ // Latin Extended-A block.
2618
+ "Ā": "A",
2619
+ "Ă": "A",
2620
+ "Ą": "A",
2621
+ "ā": "a",
2622
+ "ă": "a",
2623
+ "ą": "a",
2624
+ "Ć": "C",
2625
+ "Ĉ": "C",
2626
+ "Ċ": "C",
2627
+ "Č": "C",
2628
+ "ć": "c",
2629
+ "ĉ": "c",
2630
+ "ċ": "c",
2631
+ "č": "c",
2632
+ "Ď": "D",
2633
+ "Đ": "D",
2634
+ "ď": "d",
2635
+ "đ": "d",
2636
+ "Ē": "E",
2637
+ "Ĕ": "E",
2638
+ "Ė": "E",
2639
+ "Ę": "E",
2640
+ "Ě": "E",
2641
+ "ē": "e",
2642
+ "ĕ": "e",
2643
+ "ė": "e",
2644
+ "ę": "e",
2645
+ "ě": "e",
2646
+ "Ĝ": "G",
2647
+ "Ğ": "G",
2648
+ "Ġ": "G",
2649
+ "Ģ": "G",
2650
+ "ĝ": "g",
2651
+ "ğ": "g",
2652
+ "ġ": "g",
2653
+ "ģ": "g",
2654
+ "Ĥ": "H",
2655
+ "Ħ": "H",
2656
+ "ĥ": "h",
2657
+ "ħ": "h",
2658
+ "Ĩ": "I",
2659
+ "Ī": "I",
2660
+ "Ĭ": "I",
2661
+ "Į": "I",
2662
+ "İ": "I",
2663
+ "ĩ": "i",
2664
+ "ī": "i",
2665
+ "ĭ": "i",
2666
+ "į": "i",
2667
+ "ı": "i",
2668
+ "Ĵ": "J",
2669
+ "ĵ": "j",
2670
+ "Ķ": "K",
2671
+ "ķ": "k",
2672
+ "ĸ": "k",
2673
+ "Ĺ": "L",
2674
+ "Ļ": "L",
2675
+ "Ľ": "L",
2676
+ "Ŀ": "L",
2677
+ "Ł": "L",
2678
+ "ĺ": "l",
2679
+ "ļ": "l",
2680
+ "ľ": "l",
2681
+ "ŀ": "l",
2682
+ "ł": "l",
2683
+ "Ń": "N",
2684
+ "Ņ": "N",
2685
+ "Ň": "N",
2686
+ "Ŋ": "N",
2687
+ "ń": "n",
2688
+ "ņ": "n",
2689
+ "ň": "n",
2690
+ "ŋ": "n",
2691
+ "Ō": "O",
2692
+ "Ŏ": "O",
2693
+ "Ő": "O",
2694
+ "ō": "o",
2695
+ "ŏ": "o",
2696
+ "ő": "o",
2697
+ "Ŕ": "R",
2698
+ "Ŗ": "R",
2699
+ "Ř": "R",
2700
+ "ŕ": "r",
2701
+ "ŗ": "r",
2702
+ "ř": "r",
2703
+ "Ś": "S",
2704
+ "Ŝ": "S",
2705
+ "Ş": "S",
2706
+ "Š": "S",
2707
+ "ś": "s",
2708
+ "ŝ": "s",
2709
+ "ş": "s",
2710
+ "š": "s",
2711
+ "Ţ": "T",
2712
+ "Ť": "T",
2713
+ "Ŧ": "T",
2714
+ "ţ": "t",
2715
+ "ť": "t",
2716
+ "ŧ": "t",
2717
+ "Ũ": "U",
2718
+ "Ū": "U",
2719
+ "Ŭ": "U",
2720
+ "Ů": "U",
2721
+ "Ű": "U",
2722
+ "Ų": "U",
2723
+ "ũ": "u",
2724
+ "ū": "u",
2725
+ "ŭ": "u",
2726
+ "ů": "u",
2727
+ "ű": "u",
2728
+ "ų": "u",
2729
+ "Ŵ": "W",
2730
+ "ŵ": "w",
2731
+ "Ŷ": "Y",
2732
+ "ŷ": "y",
2733
+ "Ÿ": "Y",
2734
+ "Ź": "Z",
2735
+ "Ż": "Z",
2736
+ "Ž": "Z",
2737
+ "ź": "z",
2738
+ "ż": "z",
2739
+ "ž": "z",
2740
+ "IJ": "IJ",
2741
+ "ij": "ij",
2742
+ "Œ": "Oe",
2743
+ "œ": "oe",
2744
+ "ʼn": "'n",
2745
+ "ſ": "s"
2746
+ };
2747
+ var deburrLetter$1 = basePropertyOf(deburredLetters);
2748
+ var _deburrLetter = deburrLetter$1;
2749
+ var deburrLetter = _deburrLetter, toString$3 = toString_1;
2750
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
2751
+ var rsComboMarksRange$3 = "\\u0300-\\u036f", reComboHalfMarksRange$3 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$3 = "\\u20d0-\\u20ff", rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3;
2752
+ var rsCombo$2 = "[" + rsComboRange$3 + "]";
2753
+ var reComboMark = RegExp(rsCombo$2, "g");
2754
+ function deburr$1(string2) {
2755
+ string2 = toString$3(string2);
2756
+ return string2 && string2.replace(reLatin, deburrLetter).replace(reComboMark, "");
2757
+ }
2758
+ var deburr_1 = deburr$1;
2759
+ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
2760
+ function asciiWords$1(string2) {
2761
+ return string2.match(reAsciiWord) || [];
2762
+ }
2763
+ var _asciiWords = asciiWords$1;
2764
+ var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
2765
+ function hasUnicodeWord$1(string2) {
2766
+ return reHasUnicodeWord.test(string2);
2767
+ }
2768
+ var _hasUnicodeWord = hasUnicodeWord$1;
2769
+ var rsAstralRange$2 = "\\ud800-\\udfff", rsComboMarksRange$2 = "\\u0300-\\u036f", reComboHalfMarksRange$2 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$2 = "\\u20d0-\\u20ff", rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2, rsDingbatRange = "\\u2700-\\u27bf", rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff", rsMathOpRange = "\\xac\\xb1\\xd7\\xf7", rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", rsPunctuationRange = "\\u2000-\\u206f", rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde", rsVarRange$2 = "\\ufe0e\\ufe0f", rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
2770
+ var rsApos$1 = "['’]", rsBreak = "[" + rsBreakRange + "]", rsCombo$1 = "[" + rsComboRange$2 + "]", rsDigits = "\\d+", rsDingbat = "[" + rsDingbatRange + "]", rsLower = "[" + rsLowerRange + "]", rsMisc = "[^" + rsAstralRange$2 + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]", rsFitz$1 = "\\ud83c[\\udffb-\\udfff]", rsModifier$1 = "(?:" + rsCombo$1 + "|" + rsFitz$1 + ")", rsNonAstral$1 = "[^" + rsAstralRange$2 + "]", rsRegional$1 = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair$1 = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsUpper = "[" + rsUpperRange + "]", rsZWJ$2 = "\\u200d";
2771
+ var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")", rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")", rsOptContrLower = "(?:" + rsApos$1 + "(?:d|ll|m|re|s|t|ve))?", rsOptContrUpper = "(?:" + rsApos$1 + "(?:D|LL|M|RE|S|T|VE))?", reOptMod$1 = rsModifier$1 + "?", rsOptVar$1 = "[" + rsVarRange$2 + "]?", rsOptJoin$1 = "(?:" + rsZWJ$2 + "(?:" + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join("|") + ")" + rsOptVar$1 + reOptMod$1 + ")*", rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1, rsEmoji = "(?:" + [rsDingbat, rsRegional$1, rsSurrPair$1].join("|") + ")" + rsSeq$1;
2772
+ var reUnicodeWord = RegExp([
2773
+ rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
2774
+ rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")",
2775
+ rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
2776
+ rsUpper + "+" + rsOptContrUpper,
2777
+ rsOrdUpper,
2778
+ rsOrdLower,
2779
+ rsDigits,
2780
+ rsEmoji
2781
+ ].join("|"), "g");
2782
+ function unicodeWords$1(string2) {
2783
+ return string2.match(reUnicodeWord) || [];
2784
+ }
2785
+ var _unicodeWords = unicodeWords$1;
2786
+ var asciiWords = _asciiWords, hasUnicodeWord = _hasUnicodeWord, toString$2 = toString_1, unicodeWords = _unicodeWords;
2787
+ function words$1(string2, pattern, guard) {
2788
+ string2 = toString$2(string2);
2789
+ pattern = guard ? void 0 : pattern;
2790
+ if (pattern === void 0) {
2791
+ return hasUnicodeWord(string2) ? unicodeWords(string2) : asciiWords(string2);
2792
+ }
2793
+ return string2.match(pattern) || [];
2794
+ }
2795
+ var words_1 = words$1;
2796
+ var arrayReduce = _arrayReduce, deburr = deburr_1, words = words_1;
2797
+ var rsApos = "['’]";
2798
+ var reApos = RegExp(rsApos, "g");
2799
+ function createCompounder$2(callback) {
2800
+ return function(string2) {
2801
+ return arrayReduce(words(deburr(string2).replace(reApos, "")), callback, "");
2802
+ };
2803
+ }
2804
+ var _createCompounder = createCompounder$2;
2805
+ var createCompounder$1 = _createCompounder;
2806
+ var snakeCase = createCompounder$1(function(result, word, index2) {
2807
+ return result + (index2 ? "_" : "") + word.toLowerCase();
2808
+ });
2809
+ var snakeCase_1 = snakeCase;
2810
+ const snakeCase$1 = /* @__PURE__ */ getDefaultExportFromCjs(snakeCase_1);
2811
+ function baseSlice$1(array2, start, end) {
2812
+ var index2 = -1, length = array2.length;
2813
+ if (start < 0) {
2814
+ start = -start > length ? 0 : length + start;
2815
+ }
2816
+ end = end > length ? length : end;
2817
+ if (end < 0) {
2818
+ end += length;
2819
+ }
2820
+ length = start > end ? 0 : end - start >>> 0;
2821
+ start >>>= 0;
2822
+ var result = Array(length);
2823
+ while (++index2 < length) {
2824
+ result[index2] = array2[index2 + start];
2825
+ }
2826
+ return result;
2827
+ }
2828
+ var _baseSlice = baseSlice$1;
2829
+ var baseSlice = _baseSlice;
2830
+ function castSlice$1(array2, start, end) {
2831
+ var length = array2.length;
2832
+ end = end === void 0 ? length : end;
2833
+ return !start && end >= length ? array2 : baseSlice(array2, start, end);
2834
+ }
2835
+ var _castSlice = castSlice$1;
2836
+ var rsAstralRange$1 = "\\ud800-\\udfff", rsComboMarksRange$1 = "\\u0300-\\u036f", reComboHalfMarksRange$1 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$1 = "\\u20d0-\\u20ff", rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1, rsVarRange$1 = "\\ufe0e\\ufe0f";
2837
+ var rsZWJ$1 = "\\u200d";
2838
+ var reHasUnicode = RegExp("[" + rsZWJ$1 + rsAstralRange$1 + rsComboRange$1 + rsVarRange$1 + "]");
2839
+ function hasUnicode$2(string2) {
2840
+ return reHasUnicode.test(string2);
2841
+ }
2842
+ var _hasUnicode = hasUnicode$2;
2843
+ function asciiToArray$1(string2) {
2844
+ return string2.split("");
2845
+ }
2846
+ var _asciiToArray = asciiToArray$1;
2847
+ var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = "\\ufe0e\\ufe0f";
2848
+ var rsAstral = "[" + rsAstralRange + "]", rsCombo = "[" + rsComboRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ = "\\u200d";
2849
+ var reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
2850
+ var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
2851
+ function unicodeToArray$1(string2) {
2852
+ return string2.match(reUnicode) || [];
2853
+ }
2854
+ var _unicodeToArray = unicodeToArray$1;
2855
+ var asciiToArray = _asciiToArray, hasUnicode$1 = _hasUnicode, unicodeToArray = _unicodeToArray;
2856
+ function stringToArray$1(string2) {
2857
+ return hasUnicode$1(string2) ? unicodeToArray(string2) : asciiToArray(string2);
2858
+ }
2859
+ var _stringToArray = stringToArray$1;
2860
+ var castSlice = _castSlice, hasUnicode = _hasUnicode, stringToArray = _stringToArray, toString$1 = toString_1;
2861
+ function createCaseFirst$1(methodName) {
2862
+ return function(string2) {
2863
+ string2 = toString$1(string2);
2864
+ var strSymbols = hasUnicode(string2) ? stringToArray(string2) : void 0;
2865
+ var chr = strSymbols ? strSymbols[0] : string2.charAt(0);
2866
+ var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string2.slice(1);
2867
+ return chr[methodName]() + trailing;
2868
+ };
2869
+ }
2870
+ var _createCaseFirst = createCaseFirst$1;
2871
+ var createCaseFirst = _createCaseFirst;
2872
+ var upperFirst$1 = createCaseFirst("toUpperCase");
2873
+ var upperFirst_1 = upperFirst$1;
2874
+ var toString = toString_1, upperFirst = upperFirst_1;
2875
+ function capitalize$1(string2) {
2876
+ return upperFirst(toString(string2).toLowerCase());
2877
+ }
2878
+ var capitalize_1 = capitalize$1;
2879
+ var capitalize = capitalize_1, createCompounder = _createCompounder;
2880
+ var camelCase = createCompounder(function(result, word, index2) {
2881
+ word = word.toLowerCase();
2882
+ return result + (index2 ? capitalize(word) : word);
2883
+ });
2884
+ var camelCase_1 = camelCase;
2885
+ const camelCase$1 = /* @__PURE__ */ getDefaultExportFromCjs(camelCase_1);
2886
+ var baseAssignValue = _baseAssignValue, baseForOwn = _baseForOwn, baseIteratee = _baseIteratee;
2887
+ function mapKeys(object2, iteratee) {
2888
+ var result = {};
2889
+ iteratee = baseIteratee(iteratee);
2890
+ baseForOwn(object2, function(value, key, object3) {
2891
+ baseAssignValue(result, iteratee(value, key, object3), value);
2892
+ });
2893
+ return result;
2894
+ }
2895
+ var mapKeys_1 = mapKeys;
2896
+ const mapKeys$1 = /* @__PURE__ */ getDefaultExportFromCjs(mapKeys_1);
2897
+ var toposort$2 = { exports: {} };
2898
+ toposort$2.exports = function(edges) {
2533
2899
  return toposort(uniqueNodes(edges), edges);
2534
2900
  };
2535
- toposort$1.exports.array = toposort;
2901
+ toposort$2.exports.array = toposort;
2536
2902
  function toposort(nodes, edges) {
2537
2903
  var cursor = nodes.length, sorted = new Array(cursor), visited = {}, i = cursor, outgoingEdges = makeOutgoingEdges(edges), nodesHash = makeNodesHash(nodes);
2538
2904
  edges.forEach(function(edge) {
@@ -2598,6 +2964,510 @@ function makeNodesHash(arr) {
2598
2964
  }
2599
2965
  return res;
2600
2966
  }
2967
+ var toposortExports = toposort$2.exports;
2968
+ const toposort$1 = /* @__PURE__ */ getDefaultExportFromCjs(toposortExports);
2969
+ function sortFields(fields, excludes = []) {
2970
+ let edges = [];
2971
+ let nodes = [];
2972
+ function addNode(depPath, key) {
2973
+ var node = propertyExpr.split(depPath)[0];
2974
+ if (!~nodes.indexOf(node)) nodes.push(node);
2975
+ if (!~excludes.indexOf(`${key}-${node}`)) edges.push([key, node]);
2976
+ }
2977
+ for (const key in fields) if (has$1(fields, key)) {
2978
+ let value = fields[key];
2979
+ if (!~nodes.indexOf(key)) nodes.push(key);
2980
+ if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);
2981
+ else if (isSchema(value) && "deps" in value) value.deps.forEach((path) => addNode(path, key));
2982
+ }
2983
+ return toposort$1.array(nodes, edges).reverse();
2984
+ }
2985
+ function findIndex(arr, err) {
2986
+ let idx = Infinity;
2987
+ arr.some((key, ii) => {
2988
+ var _err$path;
2989
+ if (((_err$path = err.path) == null ? void 0 : _err$path.indexOf(key)) !== -1) {
2990
+ idx = ii;
2991
+ return true;
2992
+ }
2993
+ });
2994
+ return idx;
2995
+ }
2996
+ function sortByKeyOrder(keys2) {
2997
+ return (a, b) => {
2998
+ return findIndex(keys2, a) - findIndex(keys2, b);
2999
+ };
3000
+ }
3001
+ function _extends$1() {
3002
+ _extends$1 = Object.assign || function(target) {
3003
+ for (var i = 1; i < arguments.length; i++) {
3004
+ var source = arguments[i];
3005
+ for (var key in source) {
3006
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
3007
+ target[key] = source[key];
3008
+ }
3009
+ }
3010
+ }
3011
+ return target;
3012
+ };
3013
+ return _extends$1.apply(this, arguments);
3014
+ }
3015
+ let isObject = (obj) => Object.prototype.toString.call(obj) === "[object Object]";
3016
+ function unknown(ctx, value) {
3017
+ let known = Object.keys(ctx.fields);
3018
+ return Object.keys(value).filter((key) => known.indexOf(key) === -1);
3019
+ }
3020
+ const defaultSort = sortByKeyOrder([]);
3021
+ class ObjectSchema extends BaseSchema {
3022
+ constructor(spec) {
3023
+ super({
3024
+ type: "object"
3025
+ });
3026
+ this.fields = /* @__PURE__ */ Object.create(null);
3027
+ this._sortErrors = defaultSort;
3028
+ this._nodes = [];
3029
+ this._excludedEdges = [];
3030
+ this.withMutation(() => {
3031
+ this.transform(function coerce(value) {
3032
+ if (typeof value === "string") {
3033
+ try {
3034
+ value = JSON.parse(value);
3035
+ } catch (err) {
3036
+ value = null;
3037
+ }
3038
+ }
3039
+ if (this.isType(value)) return value;
3040
+ return null;
3041
+ });
3042
+ if (spec) {
3043
+ this.shape(spec);
3044
+ }
3045
+ });
3046
+ }
3047
+ _typeCheck(value) {
3048
+ return isObject(value) || typeof value === "function";
3049
+ }
3050
+ _cast(_value, options = {}) {
3051
+ var _options$stripUnknown;
3052
+ let value = super._cast(_value, options);
3053
+ if (value === void 0) return this.getDefault();
3054
+ if (!this._typeCheck(value)) return value;
3055
+ let fields = this.fields;
3056
+ let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
3057
+ let props = this._nodes.concat(Object.keys(value).filter((v) => this._nodes.indexOf(v) === -1));
3058
+ let intermediateValue = {};
3059
+ let innerOptions = _extends$1({}, options, {
3060
+ parent: intermediateValue,
3061
+ __validating: options.__validating || false
3062
+ });
3063
+ let isChanged = false;
3064
+ for (const prop of props) {
3065
+ let field = fields[prop];
3066
+ let exists = has$1(value, prop);
3067
+ if (field) {
3068
+ let fieldValue;
3069
+ let inputValue = value[prop];
3070
+ innerOptions.path = (options.path ? `${options.path}.` : "") + prop;
3071
+ field = field.resolve({
3072
+ value: inputValue,
3073
+ context: options.context,
3074
+ parent: intermediateValue
3075
+ });
3076
+ let fieldSpec = "spec" in field ? field.spec : void 0;
3077
+ let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
3078
+ if (fieldSpec == null ? void 0 : fieldSpec.strip) {
3079
+ isChanged = isChanged || prop in value;
3080
+ continue;
3081
+ }
3082
+ fieldValue = !options.__validating || !strict ? (
3083
+ // TODO: use _cast, this is double resolving
3084
+ field.cast(value[prop], innerOptions)
3085
+ ) : value[prop];
3086
+ if (fieldValue !== void 0) {
3087
+ intermediateValue[prop] = fieldValue;
3088
+ }
3089
+ } else if (exists && !strip) {
3090
+ intermediateValue[prop] = value[prop];
3091
+ }
3092
+ if (intermediateValue[prop] !== value[prop]) {
3093
+ isChanged = true;
3094
+ }
3095
+ }
3096
+ return isChanged ? intermediateValue : value;
3097
+ }
3098
+ _validate(_value, opts = {}, callback) {
3099
+ let errors = [];
3100
+ let {
3101
+ sync,
3102
+ from = [],
3103
+ originalValue = _value,
3104
+ abortEarly = this.spec.abortEarly,
3105
+ recursive = this.spec.recursive
3106
+ } = opts;
3107
+ from = [{
3108
+ schema: this,
3109
+ value: originalValue
3110
+ }, ...from];
3111
+ opts.__validating = true;
3112
+ opts.originalValue = originalValue;
3113
+ opts.from = from;
3114
+ super._validate(_value, opts, (err, value) => {
3115
+ if (err) {
3116
+ if (!ValidationError.isError(err) || abortEarly) {
3117
+ return void callback(err, value);
3118
+ }
3119
+ errors.push(err);
3120
+ }
3121
+ if (!recursive || !isObject(value)) {
3122
+ callback(errors[0] || null, value);
3123
+ return;
3124
+ }
3125
+ originalValue = originalValue || value;
3126
+ let tests = this._nodes.map((key) => (_, cb) => {
3127
+ let path = key.indexOf(".") === -1 ? (opts.path ? `${opts.path}.` : "") + key : `${opts.path || ""}["${key}"]`;
3128
+ let field = this.fields[key];
3129
+ if (field && "validate" in field) {
3130
+ field.validate(value[key], _extends$1({}, opts, {
3131
+ // @ts-ignore
3132
+ path,
3133
+ from,
3134
+ // inner fields are always strict:
3135
+ // 1. this isn't strict so the casting will also have cast inner values
3136
+ // 2. this is strict in which case the nested values weren't cast either
3137
+ strict: true,
3138
+ parent: value,
3139
+ originalValue: originalValue[key]
3140
+ }), cb);
3141
+ return;
3142
+ }
3143
+ cb(null);
3144
+ });
3145
+ runTests({
3146
+ tests,
3147
+ value,
3148
+ errors,
3149
+ endEarly: abortEarly,
3150
+ sort: this._sortErrors,
3151
+ path: opts.path
3152
+ }, callback);
3153
+ });
3154
+ }
3155
+ clone(spec) {
3156
+ const next = super.clone(spec);
3157
+ next.fields = _extends$1({}, this.fields);
3158
+ next._nodes = this._nodes;
3159
+ next._excludedEdges = this._excludedEdges;
3160
+ next._sortErrors = this._sortErrors;
3161
+ return next;
3162
+ }
3163
+ concat(schema) {
3164
+ let next = super.concat(schema);
3165
+ let nextFields = next.fields;
3166
+ for (let [field, schemaOrRef] of Object.entries(this.fields)) {
3167
+ const target = nextFields[field];
3168
+ if (target === void 0) {
3169
+ nextFields[field] = schemaOrRef;
3170
+ } else if (target instanceof BaseSchema && schemaOrRef instanceof BaseSchema) {
3171
+ nextFields[field] = schemaOrRef.concat(target);
3172
+ }
3173
+ }
3174
+ return next.withMutation(() => next.shape(nextFields));
3175
+ }
3176
+ getDefaultFromShape() {
3177
+ let dft = {};
3178
+ this._nodes.forEach((key) => {
3179
+ const field = this.fields[key];
3180
+ dft[key] = "default" in field ? field.getDefault() : void 0;
3181
+ });
3182
+ return dft;
3183
+ }
3184
+ _getDefault() {
3185
+ if ("default" in this.spec) {
3186
+ return super._getDefault();
3187
+ }
3188
+ if (!this._nodes.length) {
3189
+ return void 0;
3190
+ }
3191
+ return this.getDefaultFromShape();
3192
+ }
3193
+ shape(additions, excludes = []) {
3194
+ let next = this.clone();
3195
+ let fields = Object.assign(next.fields, additions);
3196
+ next.fields = fields;
3197
+ next._sortErrors = sortByKeyOrder(Object.keys(fields));
3198
+ if (excludes.length) {
3199
+ if (!Array.isArray(excludes[0])) excludes = [excludes];
3200
+ let keys2 = excludes.map(([first, second]) => `${first}-${second}`);
3201
+ next._excludedEdges = next._excludedEdges.concat(keys2);
3202
+ }
3203
+ next._nodes = sortFields(fields, next._excludedEdges);
3204
+ return next;
3205
+ }
3206
+ pick(keys2) {
3207
+ const picked = {};
3208
+ for (const key of keys2) {
3209
+ if (this.fields[key]) picked[key] = this.fields[key];
3210
+ }
3211
+ return this.clone().withMutation((next) => {
3212
+ next.fields = {};
3213
+ return next.shape(picked);
3214
+ });
3215
+ }
3216
+ omit(keys2) {
3217
+ const next = this.clone();
3218
+ const fields = next.fields;
3219
+ next.fields = {};
3220
+ for (const key of keys2) {
3221
+ delete fields[key];
3222
+ }
3223
+ return next.withMutation(() => next.shape(fields));
3224
+ }
3225
+ from(from, to, alias) {
3226
+ let fromGetter = propertyExpr.getter(from, true);
3227
+ return this.transform((obj) => {
3228
+ if (obj == null) return obj;
3229
+ let newObj = obj;
3230
+ if (has$1(obj, from)) {
3231
+ newObj = _extends$1({}, obj);
3232
+ if (!alias) delete newObj[from];
3233
+ newObj[to] = fromGetter(obj);
3234
+ }
3235
+ return newObj;
3236
+ });
3237
+ }
3238
+ noUnknown(noAllow = true, message = object.noUnknown) {
3239
+ if (typeof noAllow === "string") {
3240
+ message = noAllow;
3241
+ noAllow = true;
3242
+ }
3243
+ let next = this.test({
3244
+ name: "noUnknown",
3245
+ exclusive: true,
3246
+ message,
3247
+ test(value) {
3248
+ if (value == null) return true;
3249
+ const unknownKeys = unknown(this.schema, value);
3250
+ return !noAllow || unknownKeys.length === 0 || this.createError({
3251
+ params: {
3252
+ unknown: unknownKeys.join(", ")
3253
+ }
3254
+ });
3255
+ }
3256
+ });
3257
+ next.spec.noUnknown = noAllow;
3258
+ return next;
3259
+ }
3260
+ unknown(allow = true, message = object.noUnknown) {
3261
+ return this.noUnknown(!allow, message);
3262
+ }
3263
+ transformKeys(fn) {
3264
+ return this.transform((obj) => obj && mapKeys$1(obj, (_, key) => fn(key)));
3265
+ }
3266
+ camelCase() {
3267
+ return this.transformKeys(camelCase$1);
3268
+ }
3269
+ snakeCase() {
3270
+ return this.transformKeys(snakeCase$1);
3271
+ }
3272
+ constantCase() {
3273
+ return this.transformKeys((key) => snakeCase$1(key).toUpperCase());
3274
+ }
3275
+ describe() {
3276
+ let base = super.describe();
3277
+ base.fields = mapValues$1(this.fields, (value) => value.describe());
3278
+ return base;
3279
+ }
3280
+ }
3281
+ function create$1(spec) {
3282
+ return new ObjectSchema(spec);
3283
+ }
3284
+ create$1.prototype = ObjectSchema.prototype;
3285
+ function _extends() {
3286
+ _extends = Object.assign || function(target) {
3287
+ for (var i = 1; i < arguments.length; i++) {
3288
+ var source = arguments[i];
3289
+ for (var key in source) {
3290
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
3291
+ target[key] = source[key];
3292
+ }
3293
+ }
3294
+ }
3295
+ return target;
3296
+ };
3297
+ return _extends.apply(this, arguments);
3298
+ }
3299
+ function create(type) {
3300
+ return new ArraySchema(type);
3301
+ }
3302
+ class ArraySchema extends BaseSchema {
3303
+ constructor(type) {
3304
+ super({
3305
+ type: "array"
3306
+ });
3307
+ this.innerType = type;
3308
+ this.withMutation(() => {
3309
+ this.transform(function(values) {
3310
+ if (typeof values === "string") try {
3311
+ values = JSON.parse(values);
3312
+ } catch (err) {
3313
+ values = null;
3314
+ }
3315
+ return this.isType(values) ? values : null;
3316
+ });
3317
+ });
3318
+ }
3319
+ _typeCheck(v) {
3320
+ return Array.isArray(v);
3321
+ }
3322
+ get _subType() {
3323
+ return this.innerType;
3324
+ }
3325
+ _cast(_value, _opts) {
3326
+ const value = super._cast(_value, _opts);
3327
+ if (!this._typeCheck(value) || !this.innerType) return value;
3328
+ let isChanged = false;
3329
+ const castArray = value.map((v, idx) => {
3330
+ const castElement = this.innerType.cast(v, _extends({}, _opts, {
3331
+ path: `${_opts.path || ""}[${idx}]`
3332
+ }));
3333
+ if (castElement !== v) {
3334
+ isChanged = true;
3335
+ }
3336
+ return castElement;
3337
+ });
3338
+ return isChanged ? castArray : value;
3339
+ }
3340
+ _validate(_value, options = {}, callback) {
3341
+ var _options$abortEarly, _options$recursive;
3342
+ let errors = [];
3343
+ options.sync;
3344
+ let path = options.path;
3345
+ let innerType = this.innerType;
3346
+ let endEarly = (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly;
3347
+ let recursive = (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive;
3348
+ let originalValue = options.originalValue != null ? options.originalValue : _value;
3349
+ super._validate(_value, options, (err, value) => {
3350
+ if (err) {
3351
+ if (!ValidationError.isError(err) || endEarly) {
3352
+ return void callback(err, value);
3353
+ }
3354
+ errors.push(err);
3355
+ }
3356
+ if (!recursive || !innerType || !this._typeCheck(value)) {
3357
+ callback(errors[0] || null, value);
3358
+ return;
3359
+ }
3360
+ originalValue = originalValue || value;
3361
+ let tests = new Array(value.length);
3362
+ for (let idx = 0; idx < value.length; idx++) {
3363
+ let item = value[idx];
3364
+ let path2 = `${options.path || ""}[${idx}]`;
3365
+ let innerOptions = _extends({}, options, {
3366
+ path: path2,
3367
+ strict: true,
3368
+ parent: value,
3369
+ index: idx,
3370
+ originalValue: originalValue[idx]
3371
+ });
3372
+ tests[idx] = (_, cb) => innerType.validate(item, innerOptions, cb);
3373
+ }
3374
+ runTests({
3375
+ path,
3376
+ value,
3377
+ errors,
3378
+ endEarly,
3379
+ tests
3380
+ }, callback);
3381
+ });
3382
+ }
3383
+ clone(spec) {
3384
+ const next = super.clone(spec);
3385
+ next.innerType = this.innerType;
3386
+ return next;
3387
+ }
3388
+ concat(schema) {
3389
+ let next = super.concat(schema);
3390
+ next.innerType = this.innerType;
3391
+ if (schema.innerType) next.innerType = next.innerType ? (
3392
+ // @ts-expect-error Lazy doesn't have concat()
3393
+ next.innerType.concat(schema.innerType)
3394
+ ) : schema.innerType;
3395
+ return next;
3396
+ }
3397
+ of(schema) {
3398
+ let next = this.clone();
3399
+ if (!isSchema(schema)) throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: " + printValue(schema));
3400
+ next.innerType = schema;
3401
+ return next;
3402
+ }
3403
+ length(length, message = array.length) {
3404
+ return this.test({
3405
+ message,
3406
+ name: "length",
3407
+ exclusive: true,
3408
+ params: {
3409
+ length
3410
+ },
3411
+ test(value) {
3412
+ return isAbsent(value) || value.length === this.resolve(length);
3413
+ }
3414
+ });
3415
+ }
3416
+ min(min, message) {
3417
+ message = message || array.min;
3418
+ return this.test({
3419
+ message,
3420
+ name: "min",
3421
+ exclusive: true,
3422
+ params: {
3423
+ min
3424
+ },
3425
+ // FIXME(ts): Array<typeof T>
3426
+ test(value) {
3427
+ return isAbsent(value) || value.length >= this.resolve(min);
3428
+ }
3429
+ });
3430
+ }
3431
+ max(max, message) {
3432
+ message = message || array.max;
3433
+ return this.test({
3434
+ message,
3435
+ name: "max",
3436
+ exclusive: true,
3437
+ params: {
3438
+ max
3439
+ },
3440
+ test(value) {
3441
+ return isAbsent(value) || value.length <= this.resolve(max);
3442
+ }
3443
+ });
3444
+ }
3445
+ ensure() {
3446
+ return this.default(() => []).transform((val, original) => {
3447
+ if (this._typeCheck(val)) return val;
3448
+ return original == null ? [] : [].concat(original);
3449
+ });
3450
+ }
3451
+ compact(rejector) {
3452
+ let reject = !rejector ? (v) => !!v : (v, i, a) => !rejector(v, i, a);
3453
+ return this.transform((values) => values != null ? values.filter(reject) : values);
3454
+ }
3455
+ describe() {
3456
+ let base = super.describe();
3457
+ if (this.innerType) base.innerType = this.innerType.describe();
3458
+ return base;
3459
+ }
3460
+ nullable(isNullable = true) {
3461
+ return super.nullable(isNullable);
3462
+ }
3463
+ defined() {
3464
+ return super.defined();
3465
+ }
3466
+ required(msg) {
3467
+ return super.required(msg);
3468
+ }
3469
+ }
3470
+ create.prototype = ArraySchema.prototype;
2601
3471
  const PLUGIN_ID = "littlebox-strapi-suite";
2602
3472
  const SLUG_LANGUAGE_STRATEGY = "language";
2603
3473
  const SLUG_CONTENT_STRATEGY = "content";
@@ -3045,7 +3915,7 @@ const DangerModal = ({ open, title, text, button }) => {
3045
3915
  /* @__PURE__ */ jsx(Dialog.Footer, { children: /* @__PURE__ */ jsx(Dialog.Action, { children: /* @__PURE__ */ jsx(Button, { fullWidth: true, variant: "danger-light", children: button }) }) })
3046
3916
  ] }) }) });
3047
3917
  };
3048
- const PageAttributesBox = ({ document }) => {
3918
+ const PageAttributesBox = ({ document: document2 }) => {
3049
3919
  const { formatMessage } = useIntl();
3050
3920
  const location = useLocation();
3051
3921
  const { form } = unstable_useContentManagerContext();
@@ -3094,13 +3964,13 @@ const PageAttributesBox = ({ document }) => {
3094
3964
  form.onChange(mockEvent);
3095
3965
  }
3096
3966
  async function fectchAttributes() {
3097
- if (document && document.documentId) {
3967
+ if (document2 && document2.documentId) {
3098
3968
  const fetchDocumentAttributes$1 = new fetchDocumentAttributes();
3099
3969
  const outputFetchDocumentAttributes = await fetchDocumentAttributes$1.execute(
3100
- document.documentId,
3970
+ document2.documentId,
3101
3971
  {
3102
3972
  locale: getCurrentLocate(),
3103
- state: document.publishedAt ? "published" : "draft"
3973
+ state: document2.publishedAt ? "published" : "draft"
3104
3974
  }
3105
3975
  );
3106
3976
  setAttributes(outputFetchDocumentAttributes);
@@ -3111,7 +3981,7 @@ const PageAttributesBox = ({ document }) => {
3111
3981
  const outputFetchSlugs = await fetchSlugs.execute({ locale: getCurrentLocate() });
3112
3982
  const filteredParents = [];
3113
3983
  outputFetchSlugs.forEach((parent) => {
3114
- if (!document || parent.contentId !== document.documentId) {
3984
+ if (!document2 || parent.contentId !== document2.documentId) {
3115
3985
  filteredParents.push(parent);
3116
3986
  }
3117
3987
  });
@@ -3815,7 +4685,7 @@ const DocumentTranslateModal = ({ open, locales, targetLocale, translate, close
3815
4685
  ] })
3816
4686
  ] }) }) });
3817
4687
  };
3818
- const DocumentTranslateBox = ({ document }) => {
4688
+ const DocumentTranslateBox = ({ document: document2 }) => {
3819
4689
  const { formatMessage } = useIntl();
3820
4690
  const context = unstable_useContentManagerContext();
3821
4691
  const [appSettings, setAppSettings] = React.useState();
@@ -3849,7 +4719,7 @@ const DocumentTranslateBox = ({ document }) => {
3849
4719
  });
3850
4720
  }
3851
4721
  function getDocumentId() {
3852
- const documentId = document?.documentId || context.id;
4722
+ const documentId = document2?.documentId || context.id;
3853
4723
  return documentId && documentId !== "create" ? documentId : void 0;
3854
4724
  }
3855
4725
  async function translate(sourceLocale, overwrite) {
@@ -3915,6 +4785,693 @@ const DocumentTranslateBox = ({ document }) => {
3915
4785
  ] })
3916
4786
  };
3917
4787
  };
4788
+ const TABS_PLUGIN_KEY = "littlebox-strapi-suite";
4789
+ const TABS_HASH_PARAM = "ltbTab";
4790
+ const TABS_BAR_FIELD_TYPE = "ltb-tabs-bar";
4791
+ const TABS_SECTION_FIELD_TYPE = "ltb-tab-section";
4792
+ function toTabKey(name) {
4793
+ return (name ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
4794
+ }
4795
+ function generateTabId() {
4796
+ return `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
4797
+ }
4798
+ function readTabs(pluginOptions) {
4799
+ const tabs = pluginOptions?.[TABS_PLUGIN_KEY]?.tabs;
4800
+ if (!Array.isArray(tabs)) return [];
4801
+ return tabs.filter((tab) => tab && typeof tab.id === "string" && typeof tab.name === "string");
4802
+ }
4803
+ function padTabs(next, previous) {
4804
+ const previousLength = Array.isArray(previous) ? previous.length : 0;
4805
+ const padding = Math.max(previousLength - next.length, 0);
4806
+ return [...next, ...Array(padding).fill(null)];
4807
+ }
4808
+ function readAttributeTabId(attribute) {
4809
+ const id = attribute?.pluginOptions?.[TABS_PLUGIN_KEY]?.tab;
4810
+ return typeof id === "string" && id !== "" ? id : null;
4811
+ }
4812
+ const SYSTEM_KEYS = [
4813
+ "id",
4814
+ "documentId",
4815
+ "locale",
4816
+ "createdAt",
4817
+ "updatedAt",
4818
+ "publishedAt",
4819
+ "createdBy",
4820
+ "updatedBy",
4821
+ "localizations"
4822
+ ];
4823
+ function attributeNames(attributes) {
4824
+ if (Array.isArray(attributes)) {
4825
+ return attributes.map((attribute) => attribute?.name).filter((name) => typeof name === "string");
4826
+ }
4827
+ return attributes && typeof attributes === "object" ? Object.keys(attributes) : [];
4828
+ }
4829
+ function getConflictingTabIds(tabs, attributes) {
4830
+ const reserved = /* @__PURE__ */ new Set([...SYSTEM_KEYS, ...attributeNames(attributes)]);
4831
+ return new Set(tabs.filter((tab) => reserved.has(toTabKey(tab.name))).map((tab) => tab.id));
4832
+ }
4833
+ function validateTabs(tabs) {
4834
+ const keys2 = /* @__PURE__ */ new Set();
4835
+ for (const tab of tabs) {
4836
+ if (!tab.name || tab.name.trim() === "") return "name.required";
4837
+ const key = toTabKey(tab.name);
4838
+ if (key === "") return "key.empty";
4839
+ if (keys2.has(key)) return "key.duplicated";
4840
+ keys2.add(key);
4841
+ }
4842
+ return null;
4843
+ }
4844
+ function omitPluginKey(pluginOptions) {
4845
+ const { [TABS_PLUGIN_KEY]: _removed, ...rest } = pluginOptions;
4846
+ return rest;
4847
+ }
4848
+ function cleanAttribute(attribute, validIds) {
4849
+ if (!attribute?.pluginOptions || !(TABS_PLUGIN_KEY in attribute.pluginOptions)) return attribute;
4850
+ const id = readAttributeTabId(attribute);
4851
+ if (id && validIds.has(id)) return attribute;
4852
+ return { ...attribute, pluginOptions: omitPluginKey(attribute.pluginOptions) };
4853
+ }
4854
+ function cleanContentTypeSchema(schema) {
4855
+ const current = schema;
4856
+ if (!current || typeof current !== "object") return schema;
4857
+ const tabs = readTabs(current.pluginOptions);
4858
+ const validIds = new Set(tabs.map((tab) => tab.id));
4859
+ let changed = false;
4860
+ const next = { ...current };
4861
+ if (current.pluginOptions && TABS_PLUGIN_KEY in current.pluginOptions) {
4862
+ const storedTabs = current.pluginOptions[TABS_PLUGIN_KEY]?.tabs;
4863
+ if (tabs.length === 0) {
4864
+ next.pluginOptions = omitPluginKey(current.pluginOptions);
4865
+ changed = true;
4866
+ } else if (!Array.isArray(storedTabs) || storedTabs.length !== tabs.length) {
4867
+ next.pluginOptions = {
4868
+ ...current.pluginOptions,
4869
+ [TABS_PLUGIN_KEY]: { ...current.pluginOptions[TABS_PLUGIN_KEY], tabs }
4870
+ };
4871
+ changed = true;
4872
+ }
4873
+ }
4874
+ const clean = (attribute) => {
4875
+ const cleaned = cleanAttribute(attribute, validIds);
4876
+ if (cleaned !== attribute) changed = true;
4877
+ return cleaned;
4878
+ };
4879
+ if (Array.isArray(current.attributes)) {
4880
+ next.attributes = current.attributes.map(clean);
4881
+ } else if (current.attributes && typeof current.attributes === "object") {
4882
+ next.attributes = Object.fromEntries(
4883
+ Object.entries(current.attributes).map(([name, attribute]) => [name, clean(attribute)])
4884
+ );
4885
+ }
4886
+ return changed ? next : schema;
4887
+ }
4888
+ function fieldTabId(field, validIds) {
4889
+ const id = readAttributeTabId(field.attribute);
4890
+ return id && validIds.has(id) ? id : null;
4891
+ }
4892
+ function pickFields(panels, predicate) {
4893
+ return panels.map((panel) => panel.map((row) => row.filter(predicate)).filter((row) => row.length > 0)).filter((panel) => panel.length > 0);
4894
+ }
4895
+ function groupLayoutByTabs(panels, tabs) {
4896
+ const validIds = new Set(tabs.map((tab) => tab.id));
4897
+ return {
4898
+ rootPanels: pickFields(panels, (field) => fieldTabId(field, validIds) === null),
4899
+ sections: tabs.map((tab) => ({
4900
+ tab,
4901
+ panels: pickFields(panels, (field) => fieldTabId(field, validIds) === tab.id)
4902
+ }))
4903
+ };
4904
+ }
4905
+ function componentLeafPath(field, components, depth = 0) {
4906
+ const attribute = field.attribute;
4907
+ if (attribute?.type !== "component") return field.name;
4908
+ if (depth > 10) return null;
4909
+ const inner = components[attribute.component]?.layout?.flat() ?? [];
4910
+ for (const child of inner) {
4911
+ const path = componentLeafPath(child, components, depth + 1);
4912
+ if (path) return `${field.name}.${path}`;
4913
+ }
4914
+ return null;
4915
+ }
4916
+ function findAnchorName(panels, components = {}) {
4917
+ const fields = panels.flat(2);
4918
+ const plain = fields.find((field) => field.attribute?.type !== "component");
4919
+ if (plain) return plain.name;
4920
+ for (const field of fields) {
4921
+ const path = componentLeafPath(field, components);
4922
+ if (path) return path;
4923
+ }
4924
+ return null;
4925
+ }
4926
+ function readTabFromHash(hash) {
4927
+ const value = new URLSearchParams((hash ?? "").replace(/^#/, "")).get(TABS_HASH_PARAM);
4928
+ return value ? value : null;
4929
+ }
4930
+ function pickInitialTab(keys2, hashKey, currentKey) {
4931
+ if (hashKey && keys2.includes(hashKey)) return hashKey;
4932
+ if (currentKey && keys2.includes(currentKey)) return currentKey;
4933
+ return keys2[0] ?? null;
4934
+ }
4935
+ function tabHash(key) {
4936
+ return `#${TABS_HASH_PARAM}=${encodeURIComponent(key)}`;
4937
+ }
4938
+ function mapFieldsToTabKeys(panels, tabs) {
4939
+ const keysById = new Map(tabs.map((tab) => [tab.id, toTabKey(tab.name)]));
4940
+ const result = {};
4941
+ panels.flat(2).forEach((field) => {
4942
+ const id = readAttributeTabId(field.attribute);
4943
+ const key = id ? keysById.get(id) : void 0;
4944
+ if (key !== void 0) result[field.name] = key;
4945
+ });
4946
+ return result;
4947
+ }
4948
+ function countErrorsByTab(errors, fieldTabKeys) {
4949
+ const counts = {};
4950
+ if (!errors || typeof errors !== "object") return counts;
4951
+ Object.entries(errors).forEach(([name, error]) => {
4952
+ const key = fieldTabKeys[name];
4953
+ if (key !== void 0 && error) counts[key] = (counts[key] ?? 0) + 1;
4954
+ });
4955
+ return counts;
4956
+ }
4957
+ const EDIT_VIEW_PATH = /\/content-manager\/(collection-types\/[^/]+\/[^/]+|single-types\/[^/]+)\/?$/;
4958
+ const NON_EDIT_SEGMENTS = /* @__PURE__ */ new Set(["history", "preview", "configurations"]);
4959
+ function isEditViewPath(pathname) {
4960
+ if (!EDIT_VIEW_PATH.test(pathname)) return false;
4961
+ const lastSegment = pathname.replace(/\/$/, "").split("/").pop() ?? "";
4962
+ return !NON_EDIT_SEGMENTS.has(lastSegment);
4963
+ }
4964
+ const TabRow = ({
4965
+ tab,
4966
+ onRename,
4967
+ onRemove
4968
+ }) => {
4969
+ const { formatMessage } = useIntl();
4970
+ const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: tab.id });
4971
+ return /* @__PURE__ */ jsx(
4972
+ Box,
4973
+ {
4974
+ ref: setNodeRef,
4975
+ style: { transform: CSS.Transform.toString(transform), transition },
4976
+ paddingBottom: 2,
4977
+ children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
4978
+ /* @__PURE__ */ jsx(
4979
+ IconButton,
4980
+ {
4981
+ ...attributes,
4982
+ ...listeners,
4983
+ type: "button",
4984
+ variant: "ghost",
4985
+ label: formatMessage({
4986
+ id: getTranslation("tabs.ctb.reorder"),
4987
+ defaultMessage: "Drag to reorder"
4988
+ }),
4989
+ style: { cursor: "grab" },
4990
+ children: /* @__PURE__ */ jsx(Drag, {})
4991
+ }
4992
+ ),
4993
+ /* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
4994
+ TextInput,
4995
+ {
4996
+ "aria-label": formatMessage({
4997
+ id: getTranslation("tabs.ctb.name.placeholder"),
4998
+ defaultMessage: "Tab name"
4999
+ }),
5000
+ placeholder: formatMessage({
5001
+ id: getTranslation("tabs.ctb.name.placeholder"),
5002
+ defaultMessage: "Tab name"
5003
+ }),
5004
+ value: tab.name,
5005
+ onChange: (event) => onRename(event.target.value)
5006
+ }
5007
+ ) }),
5008
+ /* @__PURE__ */ jsx(
5009
+ IconButton,
5010
+ {
5011
+ type: "button",
5012
+ variant: "ghost",
5013
+ label: formatMessage({
5014
+ id: getTranslation("tabs.ctb.remove"),
5015
+ defaultMessage: "Remove tab"
5016
+ }),
5017
+ onClick: onRemove,
5018
+ children: /* @__PURE__ */ jsx(Trash, {})
5019
+ }
5020
+ )
5021
+ ] })
5022
+ }
5023
+ );
5024
+ };
5025
+ const TabsEditor = ({ name, value, error, intlLabel, description, onChange }) => {
5026
+ const { formatMessage } = useIntl();
5027
+ const tabs = readTabs({ [TABS_PLUGIN_KEY]: { tabs: value } });
5028
+ const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }));
5029
+ const change = (next) => onChange({ target: { name, value: padTabs(next, value) } });
5030
+ const handleDragEnd = ({ active, over }) => {
5031
+ if (!over || active.id === over.id) return;
5032
+ const oldIndex = tabs.findIndex((tab) => tab.id === active.id);
5033
+ const newIndex = tabs.findIndex((tab) => tab.id === over.id);
5034
+ change(arrayMove(tabs, oldIndex, newIndex));
5035
+ };
5036
+ return /* @__PURE__ */ jsxs(Box, { children: [
5037
+ /* @__PURE__ */ jsx(Box, { paddingTop: 2, paddingBottom: 4, children: /* @__PURE__ */ jsx(Divider, {}) }),
5038
+ /* @__PURE__ */ jsxs(Field.Root, { name, id: name, error, children: [
5039
+ /* @__PURE__ */ jsx(Field.Label, { style: { fontSize: "1.4rem" }, children: formatMessage(intlLabel, intlLabel.values) }),
5040
+ description && /* @__PURE__ */ jsx(Box, { paddingBottom: 2, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: formatMessage(description, description.values) }) }),
5041
+ tabs.length === 0 && /* @__PURE__ */ jsx(Box, { paddingBottom: 2, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral500", children: formatMessage({
5042
+ id: getTranslation("tabs.ctb.empty"),
5043
+ defaultMessage: "No tabs yet."
5044
+ }) }) }),
5045
+ /* @__PURE__ */ jsx(
5046
+ DndContext,
5047
+ {
5048
+ sensors,
5049
+ collisionDetection: closestCenter,
5050
+ modifiers: [restrictToVerticalAxis],
5051
+ onDragEnd: handleDragEnd,
5052
+ children: /* @__PURE__ */ jsx(SortableContext, { items: tabs.map((tab) => tab.id), strategy: verticalListSortingStrategy, children: tabs.map((tab) => /* @__PURE__ */ jsx(
5053
+ TabRow,
5054
+ {
5055
+ tab,
5056
+ onRename: (tabName) => change(
5057
+ tabs.map(
5058
+ (current) => current.id === tab.id ? { ...current, name: tabName } : current
5059
+ )
5060
+ ),
5061
+ onRemove: () => change(tabs.filter((current) => current.id !== tab.id))
5062
+ },
5063
+ tab.id
5064
+ )) })
5065
+ }
5066
+ ),
5067
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
5068
+ Button,
5069
+ {
5070
+ type: "button",
5071
+ variant: "secondary",
5072
+ startIcon: /* @__PURE__ */ jsx(Plus, {}),
5073
+ onClick: () => change([...tabs, { id: generateTabId(), name: "" }]),
5074
+ children: formatMessage({ id: getTranslation("tabs.ctb.add"), defaultMessage: "Add tab" })
5075
+ }
5076
+ ) }),
5077
+ /* @__PURE__ */ jsx(Field.Error, {})
5078
+ ] })
5079
+ ] });
5080
+ };
5081
+ const TabSelect = ({
5082
+ name,
5083
+ value,
5084
+ error,
5085
+ intlLabel,
5086
+ description,
5087
+ options = [],
5088
+ onChange
5089
+ }) => {
5090
+ const { formatMessage } = useIntl();
5091
+ return /* @__PURE__ */ jsxs(
5092
+ Field.Root,
5093
+ {
5094
+ name,
5095
+ id: name,
5096
+ error,
5097
+ hint: description ? formatMessage(description) : void 0,
5098
+ children: [
5099
+ /* @__PURE__ */ jsx(Field.Label, { style: { fontSize: "1.6rem", paddingTop: "11px", paddingBottom: "12px" }, children: formatMessage(intlLabel) }),
5100
+ /* @__PURE__ */ jsx(
5101
+ SingleSelect,
5102
+ {
5103
+ value: value ?? "",
5104
+ onChange: (next) => onChange({ target: { name, value: String(next), type: "select" } }),
5105
+ children: options.map(({ key, value: optionValue, metadatas }) => /* @__PURE__ */ jsx(
5106
+ SingleSelectOption,
5107
+ {
5108
+ value: optionValue,
5109
+ disabled: metadatas.disabled,
5110
+ hidden: metadatas.hidden,
5111
+ children: formatMessage(metadatas.intlLabel)
5112
+ },
5113
+ key
5114
+ ))
5115
+ }
5116
+ ),
5117
+ /* @__PURE__ */ jsx(Field.Hint, {}),
5118
+ /* @__PURE__ */ jsx(Field.Error, {})
5119
+ ]
5120
+ }
5121
+ );
5122
+ };
5123
+ const TABS_EDITOR_INPUT = "ltbTabsEditor";
5124
+ const TAB_SELECT_INPUT = "ltbTabSelect";
5125
+ const TAB_FIELD_TYPES = [
5126
+ "biginteger",
5127
+ "blocks",
5128
+ "boolean",
5129
+ "component",
5130
+ "date",
5131
+ "datetime",
5132
+ "decimal",
5133
+ "dynamiczone",
5134
+ "email",
5135
+ "enumeration",
5136
+ "float",
5137
+ "integer",
5138
+ "json",
5139
+ "media",
5140
+ "password",
5141
+ "relation",
5142
+ "richtext",
5143
+ "string",
5144
+ "text",
5145
+ "time",
5146
+ "uid"
5147
+ ];
5148
+ function registerTabsInContentTypeBuilder(app) {
5149
+ const forms = app.getPlugin("content-type-builder")?.apis?.forms;
5150
+ if (!forms) return;
5151
+ forms.components.add({ id: TABS_EDITOR_INPUT, component: TabsEditor });
5152
+ forms.components.add({ id: TAB_SELECT_INPUT, component: TabSelect });
5153
+ forms.addContentTypeSchemaMutation((nextSchema) => cleanContentTypeSchema(nextSchema));
5154
+ forms.extendContentType({
5155
+ validator: () => ({
5156
+ [TABS_PLUGIN_KEY]: create$1().shape({
5157
+ tabs: create().test("ltb-tabs", function(tabs) {
5158
+ const error = validateTabs(readTabs({ [TABS_PLUGIN_KEY]: { tabs } }));
5159
+ return error === null ? true : this.createError({ message: getTranslation(`tabs.ctb.error.${error}`) });
5160
+ })
5161
+ })
5162
+ }),
5163
+ form: {
5164
+ advanced: () => [
5165
+ {
5166
+ name: `pluginOptions.${TABS_PLUGIN_KEY}.tabs`,
5167
+ type: TABS_EDITOR_INPUT,
5168
+ size: 12,
5169
+ intlLabel: { id: getTranslation("tabs.ctb.content-type.label"), defaultMessage: "Tabs" },
5170
+ description: {
5171
+ id: getTranslation("tabs.ctb.content-type.description"),
5172
+ defaultMessage: "Organize the fields of this content type in tabs. Fields in a tab are returned by the REST API inside a property named after the tab."
5173
+ }
5174
+ }
5175
+ ]
5176
+ }
5177
+ });
5178
+ forms.extendFields(TAB_FIELD_TYPES, {
5179
+ form: {
5180
+ advanced: ({ contentTypeSchema, forTarget }) => {
5181
+ if (forTarget !== "contentType") return [];
5182
+ const tabs = readTabs(
5183
+ contentTypeSchema?.pluginOptions ?? contentTypeSchema?.schema?.pluginOptions
5184
+ );
5185
+ if (tabs.length === 0) return [];
5186
+ const conflicting = getConflictingTabIds(
5187
+ tabs,
5188
+ contentTypeSchema?.attributes ?? contentTypeSchema?.schema?.attributes
5189
+ );
5190
+ return [
5191
+ {
5192
+ name: `pluginOptions.${TABS_PLUGIN_KEY}.tab`,
5193
+ type: TAB_SELECT_INPUT,
5194
+ size: 12,
5195
+ intlLabel: { id: getTranslation("tabs.ctb.field.label"), defaultMessage: "Tab" },
5196
+ description: {
5197
+ id: getTranslation("tabs.ctb.field.description"),
5198
+ defaultMessage: "Tab where this field is shown. Fields without a tab are always visible."
5199
+ },
5200
+ options: [
5201
+ {
5202
+ key: "__null_reset_value__",
5203
+ value: "",
5204
+ metadatas: {
5205
+ intlLabel: {
5206
+ id: getTranslation("tabs.ctb.field.none"),
5207
+ defaultMessage: "None (always visible)"
5208
+ }
5209
+ }
5210
+ },
5211
+ ...tabs.map((tab) => ({
5212
+ key: tab.id,
5213
+ value: tab.id,
5214
+ metadatas: conflicting.has(tab.id) ? {
5215
+ disabled: true,
5216
+ // The CTB select formats option labels without values, so the text is prebuilt.
5217
+ intlLabel: {
5218
+ id: `${TABS_PLUGIN_KEY}.tab.${tab.id}.conflict`,
5219
+ defaultMessage: `${tab.name} (conflicts with a field name)`
5220
+ }
5221
+ } : {
5222
+ intlLabel: {
5223
+ id: `${TABS_PLUGIN_KEY}.tab.${tab.id}`,
5224
+ defaultMessage: tab.name
5225
+ }
5226
+ }
5227
+ }))
5228
+ ]
5229
+ }
5230
+ ];
5231
+ }
5232
+ }
5233
+ });
5234
+ }
5235
+ const BADGE_ATTRIBUTE = "data-ltb-tab-badge";
5236
+ const ROW_SELECTOR = "li[aria-label]";
5237
+ const CTB_STATE_KEY = "content-type-builder_dataManagerProvider";
5238
+ const CTB_CONTENT_TYPE_PATH = /\/plugins\/content-type-builder\/content-types\/([^/]+)\/?$/;
5239
+ function ctbContentTypeUid(pathname) {
5240
+ const match = pathname.match(CTB_CONTENT_TYPE_PATH);
5241
+ return match ? decodeURIComponent(match[1]) : null;
5242
+ }
5243
+ function buildFieldTabNames(contentType) {
5244
+ const tabs = readTabs(contentType?.pluginOptions);
5245
+ if (tabs.length === 0) return {};
5246
+ const namesById = new Map(tabs.map((tab) => [tab.id, tab.name]));
5247
+ const attributes = Array.isArray(contentType?.attributes) ? contentType.attributes.map((attribute) => [attribute?.name, attribute]) : Object.entries(contentType?.attributes ?? {});
5248
+ const result = {};
5249
+ attributes.forEach(([name, attribute]) => {
5250
+ const id = readAttributeTabId(attribute);
5251
+ const tabName = id ? namesById.get(id) : void 0;
5252
+ if (typeof name === "string" && tabName !== void 0) result[name] = tabName;
5253
+ });
5254
+ return result;
5255
+ }
5256
+ function findNameElement(row, name) {
5257
+ const walker = row.ownerDocument.createTreeWalker(row, NodeFilter.SHOW_TEXT);
5258
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
5259
+ if (node.textContent === name) return node.parentElement;
5260
+ }
5261
+ return null;
5262
+ }
5263
+ function createBadge(doc) {
5264
+ const badge = doc.createElement("span");
5265
+ badge.setAttribute(BADGE_ATTRIBUTE, "");
5266
+ Object.assign(badge.style, {
5267
+ flexShrink: "0",
5268
+ marginLeft: "8px",
5269
+ padding: "2px 8px",
5270
+ borderRadius: "4px",
5271
+ fontSize: "1.1rem",
5272
+ fontWeight: "600",
5273
+ lineHeight: "1.6rem",
5274
+ whiteSpace: "nowrap",
5275
+ color: "#7b79ff",
5276
+ backgroundColor: "rgba(123, 121, 255, 0.16)"
5277
+ });
5278
+ return badge;
5279
+ }
5280
+ function syncTabBadges(root2, fieldTabNames) {
5281
+ root2.querySelectorAll(ROW_SELECTOR).forEach((row) => {
5282
+ if (row.parentElement?.closest(ROW_SELECTOR)) return;
5283
+ const name = row.getAttribute("aria-label") ?? "";
5284
+ const nameElement = findNameElement(row, name);
5285
+ if (!nameElement) return;
5286
+ const existing = nameElement.nextElementSibling?.hasAttribute(BADGE_ATTRIBUTE) ? nameElement.nextElementSibling : null;
5287
+ const tabName = fieldTabNames[name];
5288
+ if (!tabName) {
5289
+ existing?.remove();
5290
+ return;
5291
+ }
5292
+ const badge = existing ?? createBadge(row.ownerDocument);
5293
+ if (badge.textContent !== tabName) badge.textContent = tabName;
5294
+ if (!existing) nameElement.after(badge);
5295
+ });
5296
+ }
5297
+ function startTabBadges(app) {
5298
+ if (typeof window === "undefined" || typeof MutationObserver === "undefined") return;
5299
+ let scheduled = false;
5300
+ let storeUnsubscribe = null;
5301
+ const update = () => {
5302
+ scheduled = false;
5303
+ const uid = ctbContentTypeUid(window.location.pathname);
5304
+ if (!uid) return;
5305
+ const store = app?.store;
5306
+ if (store && !storeUnsubscribe) storeUnsubscribe = store.subscribe(schedule);
5307
+ const contentType = store?.getState?.()[CTB_STATE_KEY]?.current?.contentTypes?.[uid];
5308
+ syncTabBadges(document, buildFieldTabNames(contentType));
5309
+ };
5310
+ function schedule() {
5311
+ if (scheduled) return;
5312
+ scheduled = true;
5313
+ requestAnimationFrame(update);
5314
+ }
5315
+ const observer = new MutationObserver((mutations) => {
5316
+ const onlyBadges = mutations.every(
5317
+ (mutation) => [...mutation.addedNodes, ...mutation.removedNodes].every(
5318
+ (node) => node instanceof Element && node.hasAttribute(BADGE_ATTRIBUTE)
5319
+ )
5320
+ );
5321
+ if (!onlyBadges) schedule();
5322
+ });
5323
+ observer.observe(document.body, { childList: true, subtree: true });
5324
+ }
5325
+ function pseudoField(name, type, extra) {
5326
+ return {
5327
+ name,
5328
+ label: "",
5329
+ type,
5330
+ size: 12,
5331
+ visible: true,
5332
+ disabled: false,
5333
+ required: false,
5334
+ unique: false,
5335
+ hint: "",
5336
+ placeholder: "",
5337
+ attribute: { type },
5338
+ ...extra
5339
+ };
5340
+ }
5341
+ function mutateEditViewLayout(args, pathname = typeof window !== "undefined" ? window.location.pathname : "") {
5342
+ const tabs = readTabs(args.layout?.options);
5343
+ const panels = args.layout?.layout ?? [];
5344
+ if (tabs.length === 0 || !isEditViewPath(pathname)) return args;
5345
+ const { rootPanels, sections } = groupLayoutByTabs(panels, tabs);
5346
+ const anchor = findAnchorName(rootPanels, args.layout?.components) ?? findAnchorName(panels, args.layout?.components);
5347
+ if (!anchor) return args;
5348
+ const bar = pseudoField(anchor, TABS_BAR_FIELD_TYPE, {
5349
+ ltbTabs: tabs.map((tab) => ({ ...tab, key: toTabKey(tab.name) })),
5350
+ ltbFieldTabKeys: mapFieldsToTabKeys(panels, tabs)
5351
+ });
5352
+ return {
5353
+ ...args,
5354
+ layout: {
5355
+ ...args.layout,
5356
+ layout: [
5357
+ ...rootPanels,
5358
+ [[bar]],
5359
+ ...sections.flatMap(({ tab, panels: tabPanels }) => [
5360
+ [[pseudoField(anchor, TABS_SECTION_FIELD_TYPE, { ltbTabKey: toTabKey(tab.name) })]],
5361
+ ...tabPanels
5362
+ ])
5363
+ ]
5364
+ }
5365
+ };
5366
+ }
5367
+ function createTabsStore() {
5368
+ let active = null;
5369
+ const listeners = /* @__PURE__ */ new Set();
5370
+ return {
5371
+ get: () => active,
5372
+ set(key) {
5373
+ if (key === active) return;
5374
+ active = key;
5375
+ listeners.forEach((listener) => listener());
5376
+ },
5377
+ subscribe(listener) {
5378
+ listeners.add(listener);
5379
+ return () => {
5380
+ listeners.delete(listener);
5381
+ };
5382
+ }
5383
+ };
5384
+ }
5385
+ const tabsStore = createTabsStore();
5386
+ function selectTab(key) {
5387
+ tabsStore.set(key);
5388
+ const { pathname, search } = window.location;
5389
+ window.history.replaceState(window.history.state, "", `${pathname}${search}${tabHash(key)}`);
5390
+ }
5391
+ const TabsBar = ({ ltbTabs = [], ltbFieldTabKeys = {} }) => {
5392
+ const { formatMessage } = useIntl();
5393
+ const { form } = unstable_useContentManagerContext();
5394
+ const errors = form?.errors;
5395
+ const active = useSyncExternalStore(tabsStore.subscribe, tabsStore.get);
5396
+ const keys2 = useMemo(() => ltbTabs.map((tab) => tab.key), [ltbTabs]);
5397
+ const errorCounts = useMemo(
5398
+ () => countErrorsByTab(errors, ltbFieldTabKeys),
5399
+ [errors, ltbFieldTabKeys]
5400
+ );
5401
+ useLayoutEffect(() => {
5402
+ const initial = pickInitialTab(keys2, readTabFromHash(window.location.hash), tabsStore.get());
5403
+ if (initial) tabsStore.set(initial);
5404
+ }, [keys2.join("|")]);
5405
+ const previousErrors = useRef(errors);
5406
+ useEffect(() => {
5407
+ if (previousErrors.current === errors) return;
5408
+ previousErrors.current = errors;
5409
+ if (active && (errorCounts[active] ?? 0) > 0) return;
5410
+ const tabWithErrors = ltbTabs.find((tab) => (errorCounts[tab.key] ?? 0) > 0);
5411
+ if (tabWithErrors) selectTab(tabWithErrors.key);
5412
+ }, [errors]);
5413
+ return /* @__PURE__ */ jsx(Box, { "data-ltb-tabs-bar": "", children: /* @__PURE__ */ jsx(Tabs.Root, { variant: "simple", value: active ?? keys2[0], onValueChange: selectTab, children: /* @__PURE__ */ jsx(
5414
+ Tabs.List,
5415
+ {
5416
+ "aria-label": formatMessage({
5417
+ id: getTranslation("tabs.edit-view.label"),
5418
+ defaultMessage: "Content tabs"
5419
+ }),
5420
+ children: ltbTabs.map((tab) => {
5421
+ const count = errorCounts[tab.key] ?? 0;
5422
+ return /* @__PURE__ */ jsx(Tabs.Trigger, { value: tab.key, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
5423
+ tab.name,
5424
+ count > 0 && /* @__PURE__ */ jsx(
5425
+ Badge,
5426
+ {
5427
+ backgroundColor: "danger100",
5428
+ textColor: "danger600",
5429
+ title: formatMessage(
5430
+ {
5431
+ id: getTranslation("tabs.edit-view.errors"),
5432
+ defaultMessage: "{count, plural, one {# error} other {# errors}}"
5433
+ },
5434
+ { count }
5435
+ ),
5436
+ children: count
5437
+ }
5438
+ )
5439
+ ] }) }, tab.id);
5440
+ })
5441
+ }
5442
+ ) }) });
5443
+ };
5444
+ const BAR_SELECTOR = "[data-ltb-tabs-bar]";
5445
+ const SECTION_SELECTOR = "[data-ltb-tab-section]";
5446
+ function applySectionVisibility(marker, visible) {
5447
+ let panel = marker;
5448
+ while (panel?.parentElement && !panel.parentElement.querySelector(BAR_SELECTOR)) {
5449
+ panel = panel.parentElement;
5450
+ }
5451
+ if (!panel?.parentElement) return null;
5452
+ panel.style.display = "none";
5453
+ let sibling = panel.nextElementSibling;
5454
+ while (sibling && !sibling.querySelector(SECTION_SELECTOR) && !sibling.querySelector(BAR_SELECTOR)) {
5455
+ sibling.style.display = visible ? "" : "none";
5456
+ sibling = sibling.nextElementSibling;
5457
+ }
5458
+ return panel.parentElement;
5459
+ }
5460
+ const TabSection = ({ ltbTabKey = "" }) => {
5461
+ const ref = useRef(null);
5462
+ const active = useSyncExternalStore(tabsStore.subscribe, tabsStore.get);
5463
+ useLayoutEffect(() => {
5464
+ const marker = ref.current;
5465
+ if (!marker || active === null) return;
5466
+ const visible = active === ltbTabKey;
5467
+ const container = applySectionVisibility(marker, visible);
5468
+ if (!container) return;
5469
+ const observer = new MutationObserver(() => applySectionVisibility(marker, visible));
5470
+ observer.observe(container, { childList: true });
5471
+ return () => observer.disconnect();
5472
+ }, [active, ltbTabKey]);
5473
+ return /* @__PURE__ */ jsx("span", { ref, "data-ltb-tab-section": ltbTabKey, hidden: true });
5474
+ };
3918
5475
  const index = {
3919
5476
  async register(app) {
3920
5477
  app.addMenuLink({
@@ -3925,7 +5482,7 @@ const index = {
3925
5482
  defaultMessage: config.pluginId
3926
5483
  },
3927
5484
  position: 999,
3928
- Component: () => import("./App-C1HyspTk.mjs")
5485
+ Component: () => import("./App-BfGB2pF_.mjs")
3929
5486
  });
3930
5487
  app.customFields.register({
3931
5488
  name: "ltbslug",
@@ -3943,7 +5500,7 @@ const index = {
3943
5500
  components: {
3944
5501
  Input: async () => import(
3945
5502
  /* webpackChunkName: "input-slug-component" */
3946
- "./SlugInput-CU9_b0dd.mjs"
5503
+ "./SlugInput-CvgVtZza.mjs"
3947
5504
  )
3948
5505
  },
3949
5506
  options: {
@@ -3977,13 +5534,18 @@ const index = {
3977
5534
  ],
3978
5535
  advanced: [],
3979
5536
  validator: (args) => ({
3980
- targetField: create().required({
5537
+ targetField: create$2().required({
3981
5538
  id: getTranslation(`module.${config.uuid.modules.slug}.field.slug.target.error`),
3982
5539
  defaultMessage: "The target field is required"
3983
5540
  })
3984
5541
  })
3985
5542
  }
3986
5543
  });
5544
+ app.addFields([
5545
+ { type: TABS_BAR_FIELD_TYPE, Component: TabsBar },
5546
+ { type: TABS_SECTION_FIELD_TYPE, Component: TabSection }
5547
+ ]);
5548
+ startTabBadges(app);
3987
5549
  app.registerPlugin({
3988
5550
  id: config.pluginId,
3989
5551
  initializer: Initializer,
@@ -3995,7 +5557,7 @@ const index = {
3995
5557
  return Promise.all(
3996
5558
  locales.map(async (locale) => {
3997
5559
  try {
3998
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => import("./en-F6RYx79c.mjs") }), `./core/translations/${locale}.json`, 4);
5560
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./core/translations/en.json": () => import("./en-knG97mCH.mjs") }), `./core/translations/${locale}.json`, 4);
3999
5561
  return { data, locale };
4000
5562
  } catch {
4001
5563
  return { data: {}, locale };
@@ -4020,6 +5582,11 @@ const index = {
4020
5582
  PageAttributesBox,
4021
5583
  DocumentTranslateBox
4022
5584
  ]);
5585
+ registerTabsInContentTypeBuilder(app);
5586
+ app.registerHook(
5587
+ "Admin/CM/pages/EditView/mutate-edit-view-layout",
5588
+ (args) => mutateEditViewLayout(args)
5589
+ );
4023
5590
  }
4024
5591
  };
4025
5592
  export {