@prorobotech/openapi-k8s-toolkit 1.1.0-alpha.10 → 1.1.0-alpha.12

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 (20) hide show
  1. package/dist/openapi-k8s-toolkit.es.js +1133 -839
  2. package/dist/openapi-k8s-toolkit.es.js.map +1 -1
  3. package/dist/openapi-k8s-toolkit.umd.js +1132 -838
  4. package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
  5. package/dist/types/api/forms.d.ts +4 -0
  6. package/dist/types/components/molecules/BlackholeForm/index.d.ts +0 -1
  7. package/dist/types/components/molecules/BlackholeForm/molecules/index.d.ts +0 -1
  8. package/dist/types/components/molecules/ManageableSidebar/organisms/ManageableSidebarProvider/ManageableSidebarProvider.d.ts +1 -0
  9. package/dist/types/components/molecules/ManageableSidebar/organisms/ManageableSidebarProvider/utils.d.ts +2 -1
  10. package/dist/types/components/molecules/{BlackholeForm/molecules/YamlEditorSingleton → YamlEditorSingleton}/YamlEditorSingleton.d.ts +1 -1
  11. package/dist/types/components/molecules/index.d.ts +2 -1
  12. package/dist/types/components/organisms/DynamicComponents/molecules/Toggler/Toggler.d.ts +6 -0
  13. package/dist/types/components/organisms/DynamicComponents/molecules/Toggler/index.d.ts +1 -0
  14. package/dist/types/components/organisms/DynamicComponents/molecules/TogglerSegmented/TogglerSegmented.d.ts +6 -0
  15. package/dist/types/components/organisms/DynamicComponents/molecules/TogglerSegmented/index.d.ts +1 -0
  16. package/dist/types/components/organisms/DynamicComponents/molecules/index.d.ts +2 -0
  17. package/dist/types/components/organisms/DynamicComponents/types.d.ts +39 -0
  18. package/package.json +1 -1
  19. /package/dist/types/components/molecules/{BlackholeForm/molecules/YamlEditorSingleton → YamlEditorSingleton}/index.d.ts +0 -0
  20. /package/dist/types/components/molecules/{BlackholeForm/molecules/YamlEditorSingleton → YamlEditorSingleton}/styled.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import styled, { createGlobalStyle } from 'styled-components';
2
2
  import K, { useState, useRef, useLayoutEffect, useReducer, useEffect, useCallback, useMemo, Fragment, createContext, useContext, createElement, isValidElement, cloneElement, useInsertionEffect, useSyncExternalStore, memo, Suspense } from 'react';
3
- import { Input, Tree, Modal, Alert, theme, Select, Tag, Flex, Typography, Breadcrumb, Spin, Menu, Tooltip, Space, Button, Card as Card$1, Row, Col, Tabs, Form, Popover, notification, Dropdown, Table, Slider, InputNumber, Switch, Result, Progress, Checkbox, Empty } from 'antd';
3
+ import { Input, Tree, Modal, Alert, theme, Select, Tag, Flex, Typography, Breadcrumb, Spin, Menu, Tooltip, Space, Button, Card as Card$1, Row, Col, Tabs, Form, Popover, notification, Switch, Segmented, Dropdown, Table, Slider, InputNumber, Result, Progress, Checkbox, Empty } from 'antd';
4
4
  import { LoadingOutlined, ExclamationCircleFilled, CloseCircleFilled, CheckCircleFilled, PlusOutlined, ClearOutlined, MinusOutlined, CaretDownOutlined, CaretRightOutlined, InfoCircleOutlined, EyeOutlined, EyeInvisibleOutlined, SearchOutlined, MoreOutlined, CheckOutlined, CloseOutlined, BugOutlined, EllipsisOutlined } from '@ant-design/icons';
5
5
  import { useNavigate, Link, useLocation, useParams, useSearchParams } from 'react-router-dom';
6
6
  import { useQuery, useQueries, useQueryClient } from '@tanstack/react-query';
@@ -7887,19 +7887,54 @@ const patchEntryWithReplaceOp = async ({
7887
7887
  pathToValue,
7888
7888
  body
7889
7889
  }) => {
7890
- const patchData = [
7890
+ const config = {
7891
+ headers: {
7892
+ "Content-Type": "application/json-patch+json"
7893
+ }
7894
+ };
7895
+ const replaceOp = [
7891
7896
  {
7892
7897
  op: "replace",
7893
7898
  path: pathToValue,
7894
7899
  value: body
7895
7900
  }
7896
7901
  ];
7897
- return axios.patch(endpoint, patchData, {
7898
- method: "PATCH",
7902
+ try {
7903
+ return await axios.patch(endpoint, replaceOp, config);
7904
+ } catch (error) {
7905
+ if (!isAxiosError(error)) {
7906
+ throw error;
7907
+ }
7908
+ const status = error.response?.status;
7909
+ if (status !== 422) {
7910
+ throw error;
7911
+ }
7912
+ const addOp = [
7913
+ {
7914
+ op: "add",
7915
+ path: pathToValue,
7916
+ value: body
7917
+ }
7918
+ ];
7919
+ return axios.patch(endpoint, addOp, config);
7920
+ }
7921
+ };
7922
+ const patchEntryWithDeleteOp = async ({
7923
+ endpoint,
7924
+ pathToValue
7925
+ }) => {
7926
+ const config = {
7899
7927
  headers: {
7900
7928
  "Content-Type": "application/json-patch+json"
7901
7929
  }
7902
- });
7930
+ };
7931
+ const replaceOp = [
7932
+ {
7933
+ op: "remove",
7934
+ path: pathToValue
7935
+ }
7936
+ ];
7937
+ return axios.patch(endpoint, replaceOp, config);
7903
7938
  };
7904
7939
 
7905
7940
  const DeleteModal = ({ name, onClose, endpoint }) => {
@@ -9512,9 +9547,10 @@ const prepareDataForManageableSidebar = ({
9512
9547
  replaceValues,
9513
9548
  pathname,
9514
9549
  idToCompare,
9550
+ fallbackIdToCompare,
9515
9551
  currentTags
9516
9552
  }) => {
9517
- const foundData = data.find((el) => el.id === idToCompare);
9553
+ const foundData = data.find((el) => el.id === idToCompare) || (fallbackIdToCompare ? data.find((el) => el.id === fallbackIdToCompare) : void 0);
9518
9554
  if (!foundData) {
9519
9555
  return void 0;
9520
9556
  }
@@ -9544,6 +9580,7 @@ const ManageableSidebarProvider = ({
9544
9580
  replaceValues,
9545
9581
  pathname,
9546
9582
  idToCompare,
9583
+ fallbackIdToCompare,
9547
9584
  currentTags,
9548
9585
  hidden,
9549
9586
  noMarginTop
@@ -9580,6 +9617,7 @@ const ManageableSidebarProvider = ({
9580
9617
  replaceValues,
9581
9618
  pathname,
9582
9619
  idToCompare,
9620
+ fallbackIdToCompare,
9583
9621
  currentTags
9584
9622
  });
9585
9623
  if (!result) {
@@ -38426,6 +38464,263 @@ const OwnerRefs = ({
38426
38464
  ] });
38427
38465
  };
38428
38466
 
38467
+ const Toggler = ({ data, children }) => {
38468
+ const {
38469
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38470
+ id,
38471
+ reqIndex,
38472
+ jsonPathToValue,
38473
+ criteria,
38474
+ notificationSuccessMessage,
38475
+ notificationSuccessMessageDescription,
38476
+ notificationErrorMessage,
38477
+ notificationErrorMessageDescription,
38478
+ containerStyle,
38479
+ endpoint,
38480
+ pathToValue,
38481
+ valueToSubmit
38482
+ } = data;
38483
+ const [api, contextHolder] = notification.useNotification();
38484
+ const queryClient = useQueryClient();
38485
+ const { data: multiQueryData, isLoading: isMultiQueryLoading, isError: isMultiQueryErrors, errors } = useMultiQuery();
38486
+ const partsOfUrl = usePartsOfUrl();
38487
+ if (isMultiQueryLoading) {
38488
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
38489
+ }
38490
+ if (isMultiQueryErrors) {
38491
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
38492
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
38493
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
38494
+ ] });
38495
+ }
38496
+ const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
38497
+ acc[index.toString()] = value;
38498
+ return acc;
38499
+ }, {});
38500
+ const jsonRoot = multiQueryData[`req${reqIndex}`];
38501
+ if (jsonRoot === void 0) {
38502
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
38503
+ }
38504
+ const valueToCompare = jp.query(jsonRoot, `$${jsonPathToValue}`)[0];
38505
+ let valueToSwitch = false;
38506
+ if (criteria.type === "forSuccess") {
38507
+ if (criteria.operator === "exists") {
38508
+ valueToSwitch = valueToCompare !== void 0;
38509
+ }
38510
+ if (criteria.operator === "equals") {
38511
+ valueToSwitch = String(valueToCompare) === criteria.valueToCompare;
38512
+ }
38513
+ }
38514
+ if (criteria.type === "forError") {
38515
+ if (criteria.operator === "exists") {
38516
+ valueToSwitch = !valueToCompare;
38517
+ }
38518
+ if (criteria.operator === "equals") {
38519
+ valueToSwitch = String(valueToCompare) !== criteria.valueToCompare;
38520
+ }
38521
+ }
38522
+ const notificationSuccessMessagePrepared = notificationSuccessMessage ? parseAll({
38523
+ text: notificationSuccessMessage,
38524
+ replaceValues,
38525
+ multiQueryData
38526
+ }) : "Success";
38527
+ const notificationSuccessMessageDescriptionPrepared = notificationSuccessMessageDescription ? parseAll({
38528
+ text: notificationSuccessMessageDescription,
38529
+ replaceValues,
38530
+ multiQueryData
38531
+ }) : "Success";
38532
+ const notificationErrorMessagePrepared = notificationErrorMessage ? parseAll({
38533
+ text: notificationErrorMessage,
38534
+ replaceValues,
38535
+ multiQueryData
38536
+ }) : "Success";
38537
+ const notificationErrorMessageDescriptionPrepared = notificationErrorMessageDescription ? parseAll({
38538
+ text: notificationErrorMessageDescription,
38539
+ replaceValues,
38540
+ multiQueryData
38541
+ }) : "Success";
38542
+ const openNotificationSuccess = () => {
38543
+ api.success({
38544
+ message: notificationSuccessMessagePrepared,
38545
+ description: notificationSuccessMessageDescriptionPrepared,
38546
+ placement: "bottomRight"
38547
+ });
38548
+ };
38549
+ const openNotificationError = () => {
38550
+ api.error({
38551
+ message: notificationErrorMessagePrepared,
38552
+ description: notificationErrorMessageDescriptionPrepared,
38553
+ placement: "bottomRight"
38554
+ });
38555
+ };
38556
+ const endpointPrepared = endpoint ? parseAll({ text: endpoint, replaceValues, multiQueryData }) : "no-endpoint-provided";
38557
+ const pathToValuePrepared = pathToValue ? parseAll({ text: pathToValue, replaceValues, multiQueryData }) : "no-pathToValue-provided";
38558
+ const toggleOn = () => {
38559
+ patchEntryWithReplaceOp({
38560
+ endpoint: endpointPrepared,
38561
+ pathToValue: pathToValuePrepared,
38562
+ body: valueToSubmit.onValue
38563
+ }).then(() => {
38564
+ queryClient.invalidateQueries({ queryKey: ["multi"] });
38565
+ openNotificationSuccess();
38566
+ }).catch((error) => {
38567
+ openNotificationError();
38568
+ console.error(error);
38569
+ });
38570
+ };
38571
+ const toggleOff = () => {
38572
+ if (valueToSubmit.offValue !== void 0) {
38573
+ patchEntryWithReplaceOp({
38574
+ endpoint: endpointPrepared,
38575
+ pathToValue: pathToValuePrepared,
38576
+ body: valueToSubmit.offValue
38577
+ }).then(() => {
38578
+ queryClient.invalidateQueries({ queryKey: ["multi"] });
38579
+ openNotificationSuccess();
38580
+ }).catch((error) => {
38581
+ openNotificationError();
38582
+ console.error(error);
38583
+ });
38584
+ }
38585
+ if (valueToSubmit.toRemoveWhenOff) {
38586
+ patchEntryWithDeleteOp({
38587
+ endpoint: endpointPrepared,
38588
+ pathToValue: pathToValuePrepared
38589
+ }).then(() => {
38590
+ queryClient.invalidateQueries({ queryKey: ["multi"] });
38591
+ openNotificationSuccess();
38592
+ }).catch((error) => {
38593
+ openNotificationError();
38594
+ console.error(error);
38595
+ });
38596
+ }
38597
+ };
38598
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: containerStyle, children: [
38599
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
38600
+ Switch,
38601
+ {
38602
+ value: valueToSwitch,
38603
+ onChange: (checked) => {
38604
+ if (checked) {
38605
+ toggleOn();
38606
+ } else {
38607
+ toggleOff();
38608
+ }
38609
+ }
38610
+ }
38611
+ ),
38612
+ children,
38613
+ contextHolder
38614
+ ] });
38615
+ };
38616
+
38617
+ const TogglerSegmented = ({
38618
+ data,
38619
+ children
38620
+ }) => {
38621
+ const {
38622
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38623
+ id,
38624
+ reqIndex,
38625
+ jsonPathToValue,
38626
+ notificationSuccessMessage,
38627
+ notificationSuccessMessageDescription,
38628
+ notificationErrorMessage,
38629
+ notificationErrorMessageDescription,
38630
+ containerStyle,
38631
+ endpoint,
38632
+ pathToValue,
38633
+ possibleValues,
38634
+ valuesMap
38635
+ } = data;
38636
+ const [api, contextHolder] = notification.useNotification();
38637
+ const queryClient = useQueryClient();
38638
+ const { data: multiQueryData, isLoading: isMultiQueryLoading, isError: isMultiQueryErrors, errors } = useMultiQuery();
38639
+ const partsOfUrl = usePartsOfUrl();
38640
+ if (isMultiQueryLoading) {
38641
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." });
38642
+ }
38643
+ if (isMultiQueryErrors) {
38644
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
38645
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { children: "Errors:" }),
38646
+ /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: errors.map((e, i) => e && /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: typeof e === "string" ? e : e.message }, i)) })
38647
+ ] });
38648
+ }
38649
+ const replaceValues = partsOfUrl.partsOfUrl.reduce((acc, value, index) => {
38650
+ acc[index.toString()] = value;
38651
+ return acc;
38652
+ }, {});
38653
+ const jsonRoot = multiQueryData[`req${reqIndex}`];
38654
+ if (jsonRoot === void 0) {
38655
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No root for json path" });
38656
+ }
38657
+ const valueToCompare = jp.query(jsonRoot, `$${jsonPathToValue}`)[0];
38658
+ const valueToSegmented = valuesMap?.find((el) => el.value === valueToCompare)?.renderedValue;
38659
+ const notificationSuccessMessagePrepared = notificationSuccessMessage ? parseAll({
38660
+ text: notificationSuccessMessage,
38661
+ replaceValues,
38662
+ multiQueryData
38663
+ }) : "Success";
38664
+ const notificationSuccessMessageDescriptionPrepared = notificationSuccessMessageDescription ? parseAll({
38665
+ text: notificationSuccessMessageDescription,
38666
+ replaceValues,
38667
+ multiQueryData
38668
+ }) : "Success";
38669
+ const notificationErrorMessagePrepared = notificationErrorMessage ? parseAll({
38670
+ text: notificationErrorMessage,
38671
+ replaceValues,
38672
+ multiQueryData
38673
+ }) : "Success";
38674
+ const notificationErrorMessageDescriptionPrepared = notificationErrorMessageDescription ? parseAll({
38675
+ text: notificationErrorMessageDescription,
38676
+ replaceValues,
38677
+ multiQueryData
38678
+ }) : "Success";
38679
+ const openNotificationSuccess = () => {
38680
+ api.success({
38681
+ message: notificationSuccessMessagePrepared,
38682
+ description: notificationSuccessMessageDescriptionPrepared,
38683
+ placement: "bottomRight"
38684
+ });
38685
+ };
38686
+ const openNotificationError = () => {
38687
+ api.error({
38688
+ message: notificationErrorMessagePrepared,
38689
+ description: notificationErrorMessageDescriptionPrepared,
38690
+ placement: "bottomRight"
38691
+ });
38692
+ };
38693
+ const endpointPrepared = endpoint ? parseAll({ text: endpoint, replaceValues, multiQueryData }) : "no-endpoint-provided";
38694
+ const pathToValuePrepared = pathToValue ? parseAll({ text: pathToValue, replaceValues, multiQueryData }) : "no-pathToValue-provided";
38695
+ const onChange = (renderedValue) => {
38696
+ const valueFromMap = valuesMap?.find((el) => el.renderedValue === renderedValue)?.value;
38697
+ const valueToSend = valueFromMap || renderedValue;
38698
+ patchEntryWithReplaceOp({
38699
+ endpoint: endpointPrepared,
38700
+ pathToValue: pathToValuePrepared,
38701
+ body: valueToSend
38702
+ }).then(() => {
38703
+ queryClient.invalidateQueries({ queryKey: ["multi"] });
38704
+ openNotificationSuccess();
38705
+ }).catch((error) => {
38706
+ openNotificationError();
38707
+ console.error(error);
38708
+ });
38709
+ };
38710
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: containerStyle, children: [
38711
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
38712
+ Segmented,
38713
+ {
38714
+ options: possibleValues,
38715
+ value: valueToSegmented || "~n~e~v~e~r",
38716
+ onChange: (value) => onChange(value)
38717
+ }
38718
+ ),
38719
+ children,
38720
+ contextHolder
38721
+ ] });
38722
+ };
38723
+
38429
38724
  const DynamicComponents = {
38430
38725
  DefaultDiv,
38431
38726
  antdText: AntdText,
@@ -38463,7 +38758,9 @@ const DynamicComponents = {
38463
38758
  SecretBase64Plain,
38464
38759
  ResourceBadge,
38465
38760
  Events: Events$1,
38466
- OwnerRefs
38761
+ OwnerRefs,
38762
+ Toggler,
38763
+ TogglerSegmented
38467
38764
  };
38468
38765
 
38469
38766
  const prepareUrlsToFetchForDynamicRenderer = ({
@@ -39208,733 +39505,161 @@ const EnrichedTableProvider = ({
39208
39505
  );
39209
39506
  };
39210
39507
 
39211
- /**
39212
- * lodash (Custom Build) <https://lodash.com/>
39213
- * Build: `lodash modularize exports="npm" -o ./`
39214
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
39215
- * Released under MIT license <https://lodash.com/license>
39216
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
39217
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
39218
- */
39219
-
39220
- /** Used as the `TypeError` message for "Functions" methods. */
39221
- var FUNC_ERROR_TEXT = 'Expected a function';
39222
-
39223
- /** Used as references for various `Number` constants. */
39224
- var NAN = 0 / 0;
39508
+ function _defineProperty$1(obj, key, value) {
39509
+ if (key in obj) {
39510
+ Object.defineProperty(obj, key, {
39511
+ value: value,
39512
+ enumerable: true,
39513
+ configurable: true,
39514
+ writable: true
39515
+ });
39516
+ } else {
39517
+ obj[key] = value;
39518
+ }
39225
39519
 
39226
- /** `Object#toString` result references. */
39227
- var symbolTag = '[object Symbol]';
39520
+ return obj;
39521
+ }
39228
39522
 
39229
- /** Used to match leading and trailing whitespace. */
39230
- var reTrim = /^\s+|\s+$/g;
39523
+ function ownKeys$1(object, enumerableOnly) {
39524
+ var keys = Object.keys(object);
39231
39525
 
39232
- /** Used to detect bad signed hexadecimal string values. */
39233
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
39526
+ if (Object.getOwnPropertySymbols) {
39527
+ var symbols = Object.getOwnPropertySymbols(object);
39528
+ if (enumerableOnly) symbols = symbols.filter(function (sym) {
39529
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
39530
+ });
39531
+ keys.push.apply(keys, symbols);
39532
+ }
39234
39533
 
39235
- /** Used to detect binary string values. */
39236
- var reIsBinary = /^0b[01]+$/i;
39534
+ return keys;
39535
+ }
39237
39536
 
39238
- /** Used to detect octal string values. */
39239
- var reIsOctal = /^0o[0-7]+$/i;
39537
+ function _objectSpread2$1(target) {
39538
+ for (var i = 1; i < arguments.length; i++) {
39539
+ var source = arguments[i] != null ? arguments[i] : {};
39240
39540
 
39241
- /** Built-in method references without a dependency on `root`. */
39242
- var freeParseInt = parseInt;
39541
+ if (i % 2) {
39542
+ ownKeys$1(Object(source), true).forEach(function (key) {
39543
+ _defineProperty$1(target, key, source[key]);
39544
+ });
39545
+ } else if (Object.getOwnPropertyDescriptors) {
39546
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
39547
+ } else {
39548
+ ownKeys$1(Object(source)).forEach(function (key) {
39549
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
39550
+ });
39551
+ }
39552
+ }
39243
39553
 
39244
- /** Detect free variable `global` from Node.js. */
39245
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
39554
+ return target;
39555
+ }
39246
39556
 
39247
- /** Detect free variable `self`. */
39248
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
39557
+ function _objectWithoutPropertiesLoose(source, excluded) {
39558
+ if (source == null) return {};
39559
+ var target = {};
39560
+ var sourceKeys = Object.keys(source);
39561
+ var key, i;
39249
39562
 
39250
- /** Used as a reference to the global object. */
39251
- var root = freeGlobal || freeSelf || Function('return this')();
39563
+ for (i = 0; i < sourceKeys.length; i++) {
39564
+ key = sourceKeys[i];
39565
+ if (excluded.indexOf(key) >= 0) continue;
39566
+ target[key] = source[key];
39567
+ }
39252
39568
 
39253
- /** Used for built-in method references. */
39254
- var objectProto = Object.prototype;
39569
+ return target;
39570
+ }
39255
39571
 
39256
- /**
39257
- * Used to resolve the
39258
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
39259
- * of values.
39260
- */
39261
- var objectToString = objectProto.toString;
39572
+ function _objectWithoutProperties(source, excluded) {
39573
+ if (source == null) return {};
39262
39574
 
39263
- /* Built-in method references for those with the same name as other `lodash` methods. */
39264
- var nativeMax = Math.max,
39265
- nativeMin = Math.min;
39575
+ var target = _objectWithoutPropertiesLoose(source, excluded);
39266
39576
 
39267
- /**
39268
- * Gets the timestamp of the number of milliseconds that have elapsed since
39269
- * the Unix epoch (1 January 1970 00:00:00 UTC).
39270
- *
39271
- * @static
39272
- * @memberOf _
39273
- * @since 2.4.0
39274
- * @category Date
39275
- * @returns {number} Returns the timestamp.
39276
- * @example
39277
- *
39278
- * _.defer(function(stamp) {
39279
- * console.log(_.now() - stamp);
39280
- * }, _.now());
39281
- * // => Logs the number of milliseconds it took for the deferred invocation.
39282
- */
39283
- var now = function() {
39284
- return root.Date.now();
39285
- };
39577
+ var key, i;
39286
39578
 
39287
- /**
39288
- * Creates a debounced function that delays invoking `func` until after `wait`
39289
- * milliseconds have elapsed since the last time the debounced function was
39290
- * invoked. The debounced function comes with a `cancel` method to cancel
39291
- * delayed `func` invocations and a `flush` method to immediately invoke them.
39292
- * Provide `options` to indicate whether `func` should be invoked on the
39293
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
39294
- * with the last arguments provided to the debounced function. Subsequent
39295
- * calls to the debounced function return the result of the last `func`
39296
- * invocation.
39297
- *
39298
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
39299
- * invoked on the trailing edge of the timeout only if the debounced function
39300
- * is invoked more than once during the `wait` timeout.
39301
- *
39302
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
39303
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
39304
- *
39305
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
39306
- * for details over the differences between `_.debounce` and `_.throttle`.
39307
- *
39308
- * @static
39309
- * @memberOf _
39310
- * @since 0.1.0
39311
- * @category Function
39312
- * @param {Function} func The function to debounce.
39313
- * @param {number} [wait=0] The number of milliseconds to delay.
39314
- * @param {Object} [options={}] The options object.
39315
- * @param {boolean} [options.leading=false]
39316
- * Specify invoking on the leading edge of the timeout.
39317
- * @param {number} [options.maxWait]
39318
- * The maximum time `func` is allowed to be delayed before it's invoked.
39319
- * @param {boolean} [options.trailing=true]
39320
- * Specify invoking on the trailing edge of the timeout.
39321
- * @returns {Function} Returns the new debounced function.
39322
- * @example
39323
- *
39324
- * // Avoid costly calculations while the window size is in flux.
39325
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
39326
- *
39327
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
39328
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
39329
- * 'leading': true,
39330
- * 'trailing': false
39331
- * }));
39332
- *
39333
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
39334
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
39335
- * var source = new EventSource('/stream');
39336
- * jQuery(source).on('message', debounced);
39337
- *
39338
- * // Cancel the trailing debounced invocation.
39339
- * jQuery(window).on('popstate', debounced.cancel);
39340
- */
39341
- function debounce(func, wait, options) {
39342
- var lastArgs,
39343
- lastThis,
39344
- maxWait,
39345
- result,
39346
- timerId,
39347
- lastCallTime,
39348
- lastInvokeTime = 0,
39349
- leading = false,
39350
- maxing = false,
39351
- trailing = true;
39579
+ if (Object.getOwnPropertySymbols) {
39580
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
39352
39581
 
39353
- if (typeof func != 'function') {
39354
- throw new TypeError(FUNC_ERROR_TEXT);
39355
- }
39356
- wait = toNumber(wait) || 0;
39357
- if (isObject$2(options)) {
39358
- leading = !!options.leading;
39359
- maxing = 'maxWait' in options;
39360
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
39361
- trailing = 'trailing' in options ? !!options.trailing : trailing;
39582
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
39583
+ key = sourceSymbolKeys[i];
39584
+ if (excluded.indexOf(key) >= 0) continue;
39585
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
39586
+ target[key] = source[key];
39587
+ }
39362
39588
  }
39363
39589
 
39364
- function invokeFunc(time) {
39365
- var args = lastArgs,
39366
- thisArg = lastThis;
39590
+ return target;
39591
+ }
39367
39592
 
39368
- lastArgs = lastThis = undefined;
39369
- lastInvokeTime = time;
39370
- result = func.apply(thisArg, args);
39371
- return result;
39372
- }
39593
+ function _slicedToArray(arr, i) {
39594
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
39595
+ }
39373
39596
 
39374
- function leadingEdge(time) {
39375
- // Reset any `maxWait` timer.
39376
- lastInvokeTime = time;
39377
- // Start the timer for the trailing edge.
39378
- timerId = setTimeout(timerExpired, wait);
39379
- // Invoke the leading edge.
39380
- return leading ? invokeFunc(time) : result;
39381
- }
39597
+ function _arrayWithHoles(arr) {
39598
+ if (Array.isArray(arr)) return arr;
39599
+ }
39382
39600
 
39383
- function remainingWait(time) {
39384
- var timeSinceLastCall = time - lastCallTime,
39385
- timeSinceLastInvoke = time - lastInvokeTime,
39386
- result = wait - timeSinceLastCall;
39601
+ function _iterableToArrayLimit(arr, i) {
39602
+ if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
39603
+ var _arr = [];
39604
+ var _n = true;
39605
+ var _d = false;
39606
+ var _e = undefined;
39387
39607
 
39388
- return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
39608
+ try {
39609
+ for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
39610
+ _arr.push(_s.value);
39611
+
39612
+ if (i && _arr.length === i) break;
39613
+ }
39614
+ } catch (err) {
39615
+ _d = true;
39616
+ _e = err;
39617
+ } finally {
39618
+ try {
39619
+ if (!_n && _i["return"] != null) _i["return"]();
39620
+ } finally {
39621
+ if (_d) throw _e;
39622
+ }
39389
39623
  }
39390
39624
 
39391
- function shouldInvoke(time) {
39392
- var timeSinceLastCall = time - lastCallTime,
39393
- timeSinceLastInvoke = time - lastInvokeTime;
39625
+ return _arr;
39626
+ }
39394
39627
 
39395
- // Either this is the first call, activity has stopped and we're at the
39396
- // trailing edge, the system time has gone backwards and we're treating
39397
- // it as the trailing edge, or we've hit the `maxWait` limit.
39398
- return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
39399
- (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
39400
- }
39628
+ function _unsupportedIterableToArray(o, minLen) {
39629
+ if (!o) return;
39630
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
39631
+ var n = Object.prototype.toString.call(o).slice(8, -1);
39632
+ if (n === "Object" && o.constructor) n = o.constructor.name;
39633
+ if (n === "Map" || n === "Set") return Array.from(o);
39634
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
39635
+ }
39401
39636
 
39402
- function timerExpired() {
39403
- var time = now();
39404
- if (shouldInvoke(time)) {
39405
- return trailingEdge(time);
39406
- }
39407
- // Restart the timer.
39408
- timerId = setTimeout(timerExpired, remainingWait(time));
39409
- }
39637
+ function _arrayLikeToArray(arr, len) {
39638
+ if (len == null || len > arr.length) len = arr.length;
39410
39639
 
39411
- function trailingEdge(time) {
39412
- timerId = undefined;
39640
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
39413
39641
 
39414
- // Only invoke if we have `lastArgs` which means `func` has been
39415
- // debounced at least once.
39416
- if (trailing && lastArgs) {
39417
- return invokeFunc(time);
39418
- }
39419
- lastArgs = lastThis = undefined;
39420
- return result;
39421
- }
39642
+ return arr2;
39643
+ }
39422
39644
 
39423
- function cancel() {
39424
- if (timerId !== undefined) {
39425
- clearTimeout(timerId);
39426
- }
39427
- lastInvokeTime = 0;
39428
- lastArgs = lastCallTime = lastThis = timerId = undefined;
39429
- }
39645
+ function _nonIterableRest() {
39646
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39647
+ }
39430
39648
 
39431
- function flush() {
39432
- return timerId === undefined ? result : trailingEdge(now());
39649
+ function _defineProperty(obj, key, value) {
39650
+ if (key in obj) {
39651
+ Object.defineProperty(obj, key, {
39652
+ value: value,
39653
+ enumerable: true,
39654
+ configurable: true,
39655
+ writable: true
39656
+ });
39657
+ } else {
39658
+ obj[key] = value;
39433
39659
  }
39434
39660
 
39435
- function debounced() {
39436
- var time = now(),
39437
- isInvoking = shouldInvoke(time);
39438
-
39439
- lastArgs = arguments;
39440
- lastThis = this;
39441
- lastCallTime = time;
39442
-
39443
- if (isInvoking) {
39444
- if (timerId === undefined) {
39445
- return leadingEdge(lastCallTime);
39446
- }
39447
- if (maxing) {
39448
- // Handle invocations in a tight loop.
39449
- timerId = setTimeout(timerExpired, wait);
39450
- return invokeFunc(lastCallTime);
39451
- }
39452
- }
39453
- if (timerId === undefined) {
39454
- timerId = setTimeout(timerExpired, wait);
39455
- }
39456
- return result;
39457
- }
39458
- debounced.cancel = cancel;
39459
- debounced.flush = flush;
39460
- return debounced;
39461
- }
39462
-
39463
- /**
39464
- * Checks if `value` is the
39465
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
39466
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
39467
- *
39468
- * @static
39469
- * @memberOf _
39470
- * @since 0.1.0
39471
- * @category Lang
39472
- * @param {*} value The value to check.
39473
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
39474
- * @example
39475
- *
39476
- * _.isObject({});
39477
- * // => true
39478
- *
39479
- * _.isObject([1, 2, 3]);
39480
- * // => true
39481
- *
39482
- * _.isObject(_.noop);
39483
- * // => true
39484
- *
39485
- * _.isObject(null);
39486
- * // => false
39487
- */
39488
- function isObject$2(value) {
39489
- var type = typeof value;
39490
- return !!value && (type == 'object' || type == 'function');
39491
- }
39492
-
39493
- /**
39494
- * Checks if `value` is object-like. A value is object-like if it's not `null`
39495
- * and has a `typeof` result of "object".
39496
- *
39497
- * @static
39498
- * @memberOf _
39499
- * @since 4.0.0
39500
- * @category Lang
39501
- * @param {*} value The value to check.
39502
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
39503
- * @example
39504
- *
39505
- * _.isObjectLike({});
39506
- * // => true
39507
- *
39508
- * _.isObjectLike([1, 2, 3]);
39509
- * // => true
39510
- *
39511
- * _.isObjectLike(_.noop);
39512
- * // => false
39513
- *
39514
- * _.isObjectLike(null);
39515
- * // => false
39516
- */
39517
- function isObjectLike(value) {
39518
- return !!value && typeof value == 'object';
39519
- }
39520
-
39521
- /**
39522
- * Checks if `value` is classified as a `Symbol` primitive or object.
39523
- *
39524
- * @static
39525
- * @memberOf _
39526
- * @since 4.0.0
39527
- * @category Lang
39528
- * @param {*} value The value to check.
39529
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
39530
- * @example
39531
- *
39532
- * _.isSymbol(Symbol.iterator);
39533
- * // => true
39534
- *
39535
- * _.isSymbol('abc');
39536
- * // => false
39537
- */
39538
- function isSymbol(value) {
39539
- return typeof value == 'symbol' ||
39540
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
39541
- }
39542
-
39543
- /**
39544
- * Converts `value` to a number.
39545
- *
39546
- * @static
39547
- * @memberOf _
39548
- * @since 4.0.0
39549
- * @category Lang
39550
- * @param {*} value The value to process.
39551
- * @returns {number} Returns the number.
39552
- * @example
39553
- *
39554
- * _.toNumber(3.2);
39555
- * // => 3.2
39556
- *
39557
- * _.toNumber(Number.MIN_VALUE);
39558
- * // => 5e-324
39559
- *
39560
- * _.toNumber(Infinity);
39561
- * // => Infinity
39562
- *
39563
- * _.toNumber('3.2');
39564
- * // => 3.2
39565
- */
39566
- function toNumber(value) {
39567
- if (typeof value == 'number') {
39568
- return value;
39569
- }
39570
- if (isSymbol(value)) {
39571
- return NAN;
39572
- }
39573
- if (isObject$2(value)) {
39574
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
39575
- value = isObject$2(other) ? (other + '') : other;
39576
- }
39577
- if (typeof value != 'string') {
39578
- return value === 0 ? value : +value;
39579
- }
39580
- value = value.replace(reTrim, '');
39581
- var isBinary = reIsBinary.test(value);
39582
- return (isBinary || reIsOctal.test(value))
39583
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
39584
- : (reIsBadHex.test(value) ? NAN : +value);
39585
- }
39586
-
39587
- var lodash_debounce = debounce;
39588
-
39589
- const debounce$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_debounce);
39590
-
39591
- function useUnmount(func) {
39592
- const funcRef = useRef(func);
39593
- funcRef.current = func;
39594
- useEffect(
39595
- () => () => {
39596
- funcRef.current();
39597
- },
39598
- []
39599
- );
39600
- }
39601
-
39602
- // src/useDebounceCallback/useDebounceCallback.ts
39603
- function useDebounceCallback(func, delay = 500, options) {
39604
- const debouncedFunc = useRef();
39605
- useUnmount(() => {
39606
- if (debouncedFunc.current) {
39607
- debouncedFunc.current.cancel();
39608
- }
39609
- });
39610
- const debounced = useMemo(() => {
39611
- const debouncedFuncInstance = debounce$1(func, delay, options);
39612
- const wrappedFunc = (...args) => {
39613
- return debouncedFuncInstance(...args);
39614
- };
39615
- wrappedFunc.cancel = () => {
39616
- debouncedFuncInstance.cancel();
39617
- };
39618
- wrappedFunc.isPending = () => {
39619
- return !!debouncedFunc.current;
39620
- };
39621
- wrappedFunc.flush = () => {
39622
- return debouncedFuncInstance.flush();
39623
- };
39624
- return wrappedFunc;
39625
- }, [func, delay, options]);
39626
- useEffect(() => {
39627
- debouncedFunc.current = debounce$1(func, delay, options);
39628
- }, [func, delay, options]);
39629
- return debounced;
39630
- }
39631
-
39632
- function floorToDecimal(num, decimalPlaces) {
39633
- const factor = 10 ** decimalPlaces;
39634
- return Math.floor(num * factor) / factor;
39635
- }
39636
- const parseQuotaValue = (key, val) => {
39637
- let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
39638
- if (key === "cpu") {
39639
- if (val.endsWith("m")) {
39640
- numericValue /= 1e3;
39641
- }
39642
- return floorToDecimal(numericValue, 1);
39643
- }
39644
- if (val.endsWith("m")) {
39645
- numericValue /= 1e3;
39646
- } else if (val.endsWith("k")) {
39647
- numericValue /= 1e6;
39648
- } else if (val.endsWith("M")) {
39649
- numericValue /= 1e3;
39650
- } else if (val.endsWith("G")) {
39651
- numericValue /= 1;
39652
- } else if (val.endsWith("T")) {
39653
- numericValue *= 1e3;
39654
- } else if (val.endsWith("Ki")) {
39655
- numericValue /= 1024;
39656
- numericValue /= 1e6;
39657
- } else if (val.endsWith("Mi")) {
39658
- numericValue /= 1e3;
39659
- numericValue /= 1e3;
39660
- } else if (/^\d+(\.\d+)?$/.test(val)) {
39661
- numericValue /= 1e9;
39662
- } else {
39663
- throw new Error("Invalid value");
39664
- }
39665
- return floorToDecimal(numericValue, 1);
39666
- };
39667
- const parseQuotaValueCpu = (val) => {
39668
- if (typeof val === "string") {
39669
- let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
39670
- if (val.endsWith("m")) {
39671
- numericValue /= 1e3;
39672
- }
39673
- return floorToDecimal(numericValue, 1);
39674
- }
39675
- return 0;
39676
- };
39677
- const parseQuotaValueMemoryAndStorage = (val) => {
39678
- if (typeof val === "string") {
39679
- let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
39680
- if (val.endsWith("k")) {
39681
- numericValue /= 1e6;
39682
- } else if (val.endsWith("m")) {
39683
- numericValue /= 1e3;
39684
- } else if (val.endsWith("M")) {
39685
- numericValue /= 1e3;
39686
- } else if (val.endsWith("G")) {
39687
- numericValue /= 1;
39688
- } else if (val.endsWith("T")) {
39689
- numericValue *= 1e3;
39690
- } else if (val.endsWith("P")) {
39691
- numericValue *= 1e6;
39692
- } else if (val.endsWith("E")) {
39693
- numericValue *= 1e9;
39694
- } else if (val.endsWith("Ki")) {
39695
- numericValue *= 1024 / 1e9;
39696
- } else if (val.endsWith("Mi")) {
39697
- numericValue /= 1048.576;
39698
- } else if (val.endsWith("Gi")) {
39699
- numericValue *= 1.073741824;
39700
- } else if (val.endsWith("Ti")) {
39701
- numericValue *= 1.099511628;
39702
- } else if (val.endsWith("Pi")) {
39703
- numericValue *= 1.125899907;
39704
- } else if (val.endsWith("Ei")) {
39705
- numericValue *= 1.152921505;
39706
- } else if (val === "0") {
39707
- return 0;
39708
- } else {
39709
- throw new Error("Invalid value");
39710
- }
39711
- return floorToDecimal(numericValue, 1);
39712
- }
39713
- return 0;
39714
- };
39715
-
39716
- const findAllPathsForObject = (obj, targetKey, targetValue, currentPath = []) => {
39717
- let paths = [];
39718
- if (typeof obj !== "object" || obj === null) {
39719
- return paths;
39720
- }
39721
- if (obj[targetKey] === targetValue) {
39722
- paths.push([...currentPath]);
39723
- }
39724
- for (const key in obj) {
39725
- if (obj.hasOwnProperty(key)) {
39726
- const value = obj[key];
39727
- if (typeof value === "object" && value !== null) {
39728
- const newPath = [...currentPath, key];
39729
- const subPaths = findAllPathsForObject(value, targetKey, targetValue, newPath);
39730
- paths = paths.concat(subPaths);
39731
- }
39732
- }
39733
- }
39734
- return paths;
39735
- };
39736
- const normalizeValuesForQuotasToNumber = (object, properties) => {
39737
- const newObject = _$1.cloneDeep(object);
39738
- const cpuPaths = findAllPathsForObject(properties, "type", "rangeInputCpu");
39739
- const memoryPaths = findAllPathsForObject(properties, "type", "rangeInputMemory");
39740
- memoryPaths.forEach((path) => {
39741
- const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
39742
- const value = _$1.get(newObject, cleanPath);
39743
- if (value || value === 0) {
39744
- _$1.set(newObject, cleanPath, parseQuotaValueMemoryAndStorage(value));
39745
- }
39746
- });
39747
- cpuPaths.forEach((path) => {
39748
- const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
39749
- const value = _$1.get(newObject, cleanPath);
39750
- if (value || value === 0) {
39751
- _$1.set(newObject, cleanPath, parseQuotaValueCpu(value));
39752
- }
39753
- });
39754
- return newObject;
39755
- };
39756
-
39757
- const getAllPathsFromObj = (obj, prefix = []) => {
39758
- const entries = Array.isArray(obj) ? obj.map((value, index) => [index, value]) : Object.entries(obj);
39759
- return entries.flatMap(([key, value]) => {
39760
- const currentPath = [...prefix, key];
39761
- return typeof value === "object" && value !== null ? [currentPath, ...getAllPathsFromObj(value, currentPath)] : [currentPath];
39762
- });
39763
- };
39764
-
39765
- const getPrefixSubarrays = (arr) => {
39766
- return arr.map((_, index) => arr.slice(0, index + 1));
39767
- };
39768
-
39769
- const deepMerge = (a, b) => {
39770
- const result = { ...a };
39771
- for (const key of Object.keys(b)) {
39772
- const aVal = a[key];
39773
- const bVal = b[key];
39774
- if (aVal !== null && bVal !== null && typeof aVal === "object" && typeof bVal === "object" && !Array.isArray(aVal) && !Array.isArray(bVal)) {
39775
- result[key] = deepMerge(aVal, bVal);
39776
- } else {
39777
- result[key] = bVal;
39778
- }
39779
- }
39780
- return result;
39781
- };
39782
-
39783
- function _defineProperty$1(obj, key, value) {
39784
- if (key in obj) {
39785
- Object.defineProperty(obj, key, {
39786
- value: value,
39787
- enumerable: true,
39788
- configurable: true,
39789
- writable: true
39790
- });
39791
- } else {
39792
- obj[key] = value;
39793
- }
39794
-
39795
- return obj;
39796
- }
39797
-
39798
- function ownKeys$1(object, enumerableOnly) {
39799
- var keys = Object.keys(object);
39800
-
39801
- if (Object.getOwnPropertySymbols) {
39802
- var symbols = Object.getOwnPropertySymbols(object);
39803
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
39804
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
39805
- });
39806
- keys.push.apply(keys, symbols);
39807
- }
39808
-
39809
- return keys;
39810
- }
39811
-
39812
- function _objectSpread2$1(target) {
39813
- for (var i = 1; i < arguments.length; i++) {
39814
- var source = arguments[i] != null ? arguments[i] : {};
39815
-
39816
- if (i % 2) {
39817
- ownKeys$1(Object(source), true).forEach(function (key) {
39818
- _defineProperty$1(target, key, source[key]);
39819
- });
39820
- } else if (Object.getOwnPropertyDescriptors) {
39821
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
39822
- } else {
39823
- ownKeys$1(Object(source)).forEach(function (key) {
39824
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
39825
- });
39826
- }
39827
- }
39828
-
39829
- return target;
39830
- }
39831
-
39832
- function _objectWithoutPropertiesLoose(source, excluded) {
39833
- if (source == null) return {};
39834
- var target = {};
39835
- var sourceKeys = Object.keys(source);
39836
- var key, i;
39837
-
39838
- for (i = 0; i < sourceKeys.length; i++) {
39839
- key = sourceKeys[i];
39840
- if (excluded.indexOf(key) >= 0) continue;
39841
- target[key] = source[key];
39842
- }
39843
-
39844
- return target;
39845
- }
39846
-
39847
- function _objectWithoutProperties(source, excluded) {
39848
- if (source == null) return {};
39849
-
39850
- var target = _objectWithoutPropertiesLoose(source, excluded);
39851
-
39852
- var key, i;
39853
-
39854
- if (Object.getOwnPropertySymbols) {
39855
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
39856
-
39857
- for (i = 0; i < sourceSymbolKeys.length; i++) {
39858
- key = sourceSymbolKeys[i];
39859
- if (excluded.indexOf(key) >= 0) continue;
39860
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
39861
- target[key] = source[key];
39862
- }
39863
- }
39864
-
39865
- return target;
39866
- }
39867
-
39868
- function _slicedToArray(arr, i) {
39869
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
39870
- }
39871
-
39872
- function _arrayWithHoles(arr) {
39873
- if (Array.isArray(arr)) return arr;
39874
- }
39875
-
39876
- function _iterableToArrayLimit(arr, i) {
39877
- if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
39878
- var _arr = [];
39879
- var _n = true;
39880
- var _d = false;
39881
- var _e = undefined;
39882
-
39883
- try {
39884
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
39885
- _arr.push(_s.value);
39886
-
39887
- if (i && _arr.length === i) break;
39888
- }
39889
- } catch (err) {
39890
- _d = true;
39891
- _e = err;
39892
- } finally {
39893
- try {
39894
- if (!_n && _i["return"] != null) _i["return"]();
39895
- } finally {
39896
- if (_d) throw _e;
39897
- }
39898
- }
39899
-
39900
- return _arr;
39901
- }
39902
-
39903
- function _unsupportedIterableToArray(o, minLen) {
39904
- if (!o) return;
39905
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
39906
- var n = Object.prototype.toString.call(o).slice(8, -1);
39907
- if (n === "Object" && o.constructor) n = o.constructor.name;
39908
- if (n === "Map" || n === "Set") return Array.from(o);
39909
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
39910
- }
39911
-
39912
- function _arrayLikeToArray(arr, len) {
39913
- if (len == null || len > arr.length) len = arr.length;
39914
-
39915
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
39916
-
39917
- return arr2;
39918
- }
39919
-
39920
- function _nonIterableRest() {
39921
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39922
- }
39923
-
39924
- function _defineProperty(obj, key, value) {
39925
- if (key in obj) {
39926
- Object.defineProperty(obj, key, {
39927
- value: value,
39928
- enumerable: true,
39929
- configurable: true,
39930
- writable: true
39931
- });
39932
- } else {
39933
- obj[key] = value;
39934
- }
39935
-
39936
- return obj;
39937
- }
39661
+ return obj;
39662
+ }
39938
39663
 
39939
39664
  function ownKeys(object, enumerableOnly) {
39940
39665
  var keys = Object.keys(object);
@@ -40000,7 +39725,7 @@ function curry$1(fn) {
40000
39725
  };
40001
39726
  }
40002
39727
 
40003
- function isObject$1(value) {
39728
+ function isObject$2(value) {
40004
39729
  return {}.toString.call(value).includes('Object');
40005
39730
  }
40006
39731
 
@@ -40017,7 +39742,7 @@ function hasOwnProperty(object, property) {
40017
39742
  }
40018
39743
 
40019
39744
  function validateChanges(initial, changes) {
40020
- if (!isObject$1(changes)) errorHandler$1('changeType');
39745
+ if (!isObject$2(changes)) errorHandler$1('changeType');
40021
39746
  if (Object.keys(changes).some(function (field) {
40022
39747
  return !hasOwnProperty(initial, field);
40023
39748
  })) errorHandler$1('changeField');
@@ -40029,15 +39754,15 @@ function validateSelector(selector) {
40029
39754
  }
40030
39755
 
40031
39756
  function validateHandler(handler) {
40032
- if (!(isFunction(handler) || isObject$1(handler))) errorHandler$1('handlerType');
40033
- if (isObject$1(handler) && Object.values(handler).some(function (_handler) {
39757
+ if (!(isFunction(handler) || isObject$2(handler))) errorHandler$1('handlerType');
39758
+ if (isObject$2(handler) && Object.values(handler).some(function (_handler) {
40034
39759
  return !isFunction(_handler);
40035
39760
  })) errorHandler$1('handlersType');
40036
39761
  }
40037
39762
 
40038
39763
  function validateInitial(initial) {
40039
39764
  if (!initial) errorHandler$1('initialIsRequired');
40040
- if (!isObject$1(initial)) errorHandler$1('initialType');
39765
+ if (!isObject$2(initial)) errorHandler$1('initialType');
40041
39766
  if (isEmpty$1(initial)) errorHandler$1('initialContent');
40042
39767
  }
40043
39768
 
@@ -40137,7 +39862,7 @@ function curry(fn) {
40137
39862
  };
40138
39863
  }
40139
39864
 
40140
- function isObject(value) {
39865
+ function isObject$1(value) {
40141
39866
  return {}.toString.call(value).includes('Object');
40142
39867
  }
40143
39868
 
@@ -40149,7 +39874,7 @@ function isObject(value) {
40149
39874
 
40150
39875
  function validateConfig(config) {
40151
39876
  if (!config) errorHandler('configIsRequired');
40152
- if (!isObject(config)) errorHandler('configType');
39877
+ if (!isObject$1(config)) errorHandler('configType');
40153
39878
 
40154
39879
  if (config.urls) {
40155
39880
  informAboutDeprecation();
@@ -47285,120 +47010,6 @@ function stringify(value, replacer, options) {
47285
47010
  }
47286
47011
 
47287
47012
  const BorderRadiusContainer$1 = styled.div`
47288
- height: 100%;
47289
- border: 1px solid ${({ $colorBorder }) => $colorBorder};
47290
- border-radius: 8px;
47291
- padding: 2px;
47292
-
47293
- .monaco-editor,
47294
- .overflow-guard {
47295
- border-radius: 8px;
47296
- }
47297
- `;
47298
- const Styled$k = {
47299
- BorderRadiusContainer: BorderRadiusContainer$1
47300
- };
47301
-
47302
- const YamlEditor = ({ theme: theme$1, currentValues, onChange, editorUri }) => {
47303
- const { token } = theme.useToken();
47304
- const [yamlData, setYamlData] = useState("");
47305
- const editorRef = useRef(null);
47306
- const monacoRef = useRef(null);
47307
- const isFocusedRef = useRef(false);
47308
- const pendingExternalYamlRef = useRef(null);
47309
- const isApplyingExternalUpdateRef = useRef(false);
47310
- useEffect(() => {
47311
- const next = stringify(currentValues, {
47312
- // Use literal block scalar for multiline strings
47313
- blockQuote: "literal",
47314
- // Preserve line breaks
47315
- lineWidth: 0,
47316
- // Use double quotes for strings that need escaping
47317
- doubleQuotedAsJSON: false
47318
- });
47319
- if (isFocusedRef.current) {
47320
- pendingExternalYamlRef.current = next ?? "";
47321
- return;
47322
- }
47323
- setYamlData(next ?? "");
47324
- }, [currentValues]);
47325
- useEffect(() => {
47326
- const editor = editorRef.current;
47327
- const monaco = monacoRef.current;
47328
- if (editor && monaco) {
47329
- if (isFocusedRef.current) return;
47330
- const uri = monaco.Uri.parse(editorUri);
47331
- let model = editor.getModel() || monaco.editor.getModel(uri);
47332
- if (!model) {
47333
- model = monaco.editor.createModel(yamlData ?? "", "yaml", uri);
47334
- }
47335
- if (model) {
47336
- monaco.editor.setModelLanguage(model, "yaml");
47337
- const current = model.getValue();
47338
- if ((yamlData ?? "") !== current) {
47339
- isApplyingExternalUpdateRef.current = true;
47340
- model.setValue(yamlData ?? "");
47341
- }
47342
- }
47343
- }
47344
- }, [yamlData, editorUri]);
47345
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$k.BorderRadiusContainer, { $colorBorder: token.colorBorder, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
47346
- Ft,
47347
- {
47348
- language: "yaml",
47349
- path: editorUri,
47350
- keepCurrentModel: true,
47351
- width: "100%",
47352
- height: "100%",
47353
- defaultValue: yamlData ?? "",
47354
- onMount: (editor, m) => {
47355
- editorRef.current = editor;
47356
- monacoRef.current = m;
47357
- try {
47358
- isFocusedRef.current = !!editor.hasTextFocus?.();
47359
- } catch {
47360
- isFocusedRef.current = false;
47361
- }
47362
- editor.onDidFocusEditorText(() => {
47363
- isFocusedRef.current = true;
47364
- });
47365
- editor.onDidBlurEditorText(() => {
47366
- isFocusedRef.current = false;
47367
- if (pendingExternalYamlRef.current !== null) {
47368
- setYamlData(pendingExternalYamlRef.current);
47369
- pendingExternalYamlRef.current = null;
47370
- }
47371
- });
47372
- const uri = m.Uri.parse("inmemory://openapi-ui/form.yaml");
47373
- let model = editor.getModel() || m.editor.getModel(uri);
47374
- if (!model) {
47375
- model = m.editor.createModel(yamlData ?? "", "yaml", uri);
47376
- }
47377
- if (model) {
47378
- m.editor.setModelLanguage(model, "yaml");
47379
- }
47380
- },
47381
- onChange: (value) => {
47382
- if (isApplyingExternalUpdateRef.current) {
47383
- isApplyingExternalUpdateRef.current = false;
47384
- setYamlData(value || "");
47385
- return;
47386
- }
47387
- try {
47388
- onChange(parse(value || ""));
47389
- } catch {
47390
- }
47391
- setYamlData(value || "");
47392
- },
47393
- theme: theme$1 === "dark" ? "vs-dark" : theme$1 === void 0 ? "vs-dark" : "vs",
47394
- options: {
47395
- theme: theme$1 === "dark" ? "vs-dark" : theme$1 === void 0 ? "vs-dark" : "vs"
47396
- }
47397
- }
47398
- ) });
47399
- };
47400
-
47401
- const BorderRadiusContainer = styled.div`
47402
47013
  height: ${({ $designNewLayoutHeight }) => $designNewLayoutHeight ? `${$designNewLayoutHeight}px` : "75vh"};
47403
47014
  border: 1px solid ${({ $colorBorder }) => $colorBorder};
47404
47015
  border-radius: 8px;
@@ -47422,12 +47033,13 @@ const BigText$1 = styled.div`
47422
47033
  font-size: 16px;
47423
47034
  line-height: 24px;
47424
47035
  `;
47425
- const Styled$j = {
47426
- BorderRadiusContainer,
47036
+ const Styled$k = {
47037
+ BorderRadiusContainer: BorderRadiusContainer$1,
47427
47038
  ControlsRowContainer: ControlsRowContainer$1,
47428
47039
  BigText: BigText$1
47429
47040
  };
47430
47041
 
47042
+ const NOTIFICATION_KEY = "yaml-data-changed";
47431
47043
  const YamlEditorSingleton = ({
47432
47044
  theme: theme$1,
47433
47045
  cluster,
@@ -47452,14 +47064,14 @@ const YamlEditorSingleton = ({
47452
47064
  const initialPrefillYamlRef = useRef(null);
47453
47065
  const latestPrefillYamlRef = useRef(null);
47454
47066
  const firstLoadRef = useRef(true);
47455
- const handleReload = () => {
47067
+ const handleReload = useCallback(() => {
47068
+ api.destroy(NOTIFICATION_KEY);
47456
47069
  const nextYaml = latestPrefillYamlRef.current ?? initialPrefillYamlRef.current;
47457
47070
  if (nextYaml !== null) {
47458
47071
  setYamlData(nextYaml);
47459
47072
  }
47460
- };
47073
+ }, [api]);
47461
47074
  const openNotificationYamlChanged = useCallback(() => {
47462
- const key = `open${Date.now()}`;
47463
47075
  const btn = /* @__PURE__ */ jsxRuntimeExports.jsx(
47464
47076
  Button,
47465
47077
  {
@@ -47467,25 +47079,21 @@ const YamlEditorSingleton = ({
47467
47079
  size: "small",
47468
47080
  onClick: () => {
47469
47081
  handleReload();
47470
- api.destroy(key);
47471
47082
  },
47472
47083
  children: "Reload"
47473
47084
  }
47474
47085
  );
47475
47086
  api.info({
47087
+ key: NOTIFICATION_KEY,
47476
47088
  message: "Data changed",
47477
- description: "Reload will flush changes and reload data to latest",
47089
+ description: "The source data has been updated. Reload to apply the latest changes (will discard your edits).",
47478
47090
  btn,
47479
- key,
47480
- onClose: () => console.log("Notification closed"),
47481
47091
  placement: "bottomRight",
47482
47092
  duration: 30
47483
- // keep it open until user closes
47484
47093
  });
47485
- }, [api]);
47094
+ }, [api, handleReload]);
47486
47095
  useEffect(() => {
47487
47096
  if (prefillValuesSchema === void 0) return;
47488
- console.log(prefillValuesSchema);
47489
47097
  const nextYaml = stringify(prefillValuesSchema);
47490
47098
  if (firstLoadRef.current) {
47491
47099
  initialPrefillYamlRef.current = nextYaml;
@@ -47549,7 +47157,7 @@ const YamlEditorSingleton = ({
47549
47157
  };
47550
47158
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
47551
47159
  contextHolder,
47552
- /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$j.BorderRadiusContainer, { $designNewLayoutHeight: designNewLayoutHeight, $colorBorder: token.colorBorder, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
47160
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$k.BorderRadiusContainer, { $designNewLayoutHeight: designNewLayoutHeight, $colorBorder: token.colorBorder, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
47553
47161
  Ft,
47554
47162
  {
47555
47163
  defaultLanguage: "yaml",
@@ -47568,7 +47176,7 @@ const YamlEditorSingleton = ({
47568
47176
  }
47569
47177
  }
47570
47178
  ) }),
47571
- !readOnly && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$j.ControlsRowContainer, { $bgColor: token.colorPrimaryBg, $designNewLayout: designNewLayout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: designNewLayout ? 10 : 16, align: "center", children: [
47179
+ !readOnly && /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$k.ControlsRowContainer, { $bgColor: token.colorPrimaryBg, $designNewLayout: designNewLayout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: designNewLayout ? 10 : 16, align: "center", children: [
47572
47180
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "primary", onClick: onSubmit, loading: isLoading, children: "Submit" }),
47573
47181
  backlink && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => navigate(backlink), children: "Cancel" }),
47574
47182
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: handleReload, children: "Reload" })
@@ -47579,7 +47187,7 @@ const YamlEditorSingleton = ({
47579
47187
  open: !!error,
47580
47188
  onOk: () => setError(void 0),
47581
47189
  onCancel: () => setError(void 0),
47582
- title: /* @__PURE__ */ jsxRuntimeExports.jsx(Typography.Text, { type: "danger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$j.BigText, { children: "Error!" }) }),
47190
+ title: /* @__PURE__ */ jsxRuntimeExports.jsx(Typography.Text, { type: "danger", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$k.BigText, { children: "Error!" }) }),
47583
47191
  cancelButtonProps: { style: { display: "none" } },
47584
47192
  children: [
47585
47193
  "An error has occurred: ",
@@ -47590,6 +47198,692 @@ const YamlEditorSingleton = ({
47590
47198
  ] });
47591
47199
  };
47592
47200
 
47201
+ /**
47202
+ * lodash (Custom Build) <https://lodash.com/>
47203
+ * Build: `lodash modularize exports="npm" -o ./`
47204
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
47205
+ * Released under MIT license <https://lodash.com/license>
47206
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
47207
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
47208
+ */
47209
+
47210
+ /** Used as the `TypeError` message for "Functions" methods. */
47211
+ var FUNC_ERROR_TEXT = 'Expected a function';
47212
+
47213
+ /** Used as references for various `Number` constants. */
47214
+ var NAN = 0 / 0;
47215
+
47216
+ /** `Object#toString` result references. */
47217
+ var symbolTag = '[object Symbol]';
47218
+
47219
+ /** Used to match leading and trailing whitespace. */
47220
+ var reTrim = /^\s+|\s+$/g;
47221
+
47222
+ /** Used to detect bad signed hexadecimal string values. */
47223
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
47224
+
47225
+ /** Used to detect binary string values. */
47226
+ var reIsBinary = /^0b[01]+$/i;
47227
+
47228
+ /** Used to detect octal string values. */
47229
+ var reIsOctal = /^0o[0-7]+$/i;
47230
+
47231
+ /** Built-in method references without a dependency on `root`. */
47232
+ var freeParseInt = parseInt;
47233
+
47234
+ /** Detect free variable `global` from Node.js. */
47235
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
47236
+
47237
+ /** Detect free variable `self`. */
47238
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
47239
+
47240
+ /** Used as a reference to the global object. */
47241
+ var root = freeGlobal || freeSelf || Function('return this')();
47242
+
47243
+ /** Used for built-in method references. */
47244
+ var objectProto = Object.prototype;
47245
+
47246
+ /**
47247
+ * Used to resolve the
47248
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
47249
+ * of values.
47250
+ */
47251
+ var objectToString = objectProto.toString;
47252
+
47253
+ /* Built-in method references for those with the same name as other `lodash` methods. */
47254
+ var nativeMax = Math.max,
47255
+ nativeMin = Math.min;
47256
+
47257
+ /**
47258
+ * Gets the timestamp of the number of milliseconds that have elapsed since
47259
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
47260
+ *
47261
+ * @static
47262
+ * @memberOf _
47263
+ * @since 2.4.0
47264
+ * @category Date
47265
+ * @returns {number} Returns the timestamp.
47266
+ * @example
47267
+ *
47268
+ * _.defer(function(stamp) {
47269
+ * console.log(_.now() - stamp);
47270
+ * }, _.now());
47271
+ * // => Logs the number of milliseconds it took for the deferred invocation.
47272
+ */
47273
+ var now = function() {
47274
+ return root.Date.now();
47275
+ };
47276
+
47277
+ /**
47278
+ * Creates a debounced function that delays invoking `func` until after `wait`
47279
+ * milliseconds have elapsed since the last time the debounced function was
47280
+ * invoked. The debounced function comes with a `cancel` method to cancel
47281
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
47282
+ * Provide `options` to indicate whether `func` should be invoked on the
47283
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
47284
+ * with the last arguments provided to the debounced function. Subsequent
47285
+ * calls to the debounced function return the result of the last `func`
47286
+ * invocation.
47287
+ *
47288
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
47289
+ * invoked on the trailing edge of the timeout only if the debounced function
47290
+ * is invoked more than once during the `wait` timeout.
47291
+ *
47292
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
47293
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
47294
+ *
47295
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
47296
+ * for details over the differences between `_.debounce` and `_.throttle`.
47297
+ *
47298
+ * @static
47299
+ * @memberOf _
47300
+ * @since 0.1.0
47301
+ * @category Function
47302
+ * @param {Function} func The function to debounce.
47303
+ * @param {number} [wait=0] The number of milliseconds to delay.
47304
+ * @param {Object} [options={}] The options object.
47305
+ * @param {boolean} [options.leading=false]
47306
+ * Specify invoking on the leading edge of the timeout.
47307
+ * @param {number} [options.maxWait]
47308
+ * The maximum time `func` is allowed to be delayed before it's invoked.
47309
+ * @param {boolean} [options.trailing=true]
47310
+ * Specify invoking on the trailing edge of the timeout.
47311
+ * @returns {Function} Returns the new debounced function.
47312
+ * @example
47313
+ *
47314
+ * // Avoid costly calculations while the window size is in flux.
47315
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
47316
+ *
47317
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
47318
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
47319
+ * 'leading': true,
47320
+ * 'trailing': false
47321
+ * }));
47322
+ *
47323
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
47324
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
47325
+ * var source = new EventSource('/stream');
47326
+ * jQuery(source).on('message', debounced);
47327
+ *
47328
+ * // Cancel the trailing debounced invocation.
47329
+ * jQuery(window).on('popstate', debounced.cancel);
47330
+ */
47331
+ function debounce(func, wait, options) {
47332
+ var lastArgs,
47333
+ lastThis,
47334
+ maxWait,
47335
+ result,
47336
+ timerId,
47337
+ lastCallTime,
47338
+ lastInvokeTime = 0,
47339
+ leading = false,
47340
+ maxing = false,
47341
+ trailing = true;
47342
+
47343
+ if (typeof func != 'function') {
47344
+ throw new TypeError(FUNC_ERROR_TEXT);
47345
+ }
47346
+ wait = toNumber(wait) || 0;
47347
+ if (isObject(options)) {
47348
+ leading = !!options.leading;
47349
+ maxing = 'maxWait' in options;
47350
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
47351
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
47352
+ }
47353
+
47354
+ function invokeFunc(time) {
47355
+ var args = lastArgs,
47356
+ thisArg = lastThis;
47357
+
47358
+ lastArgs = lastThis = undefined;
47359
+ lastInvokeTime = time;
47360
+ result = func.apply(thisArg, args);
47361
+ return result;
47362
+ }
47363
+
47364
+ function leadingEdge(time) {
47365
+ // Reset any `maxWait` timer.
47366
+ lastInvokeTime = time;
47367
+ // Start the timer for the trailing edge.
47368
+ timerId = setTimeout(timerExpired, wait);
47369
+ // Invoke the leading edge.
47370
+ return leading ? invokeFunc(time) : result;
47371
+ }
47372
+
47373
+ function remainingWait(time) {
47374
+ var timeSinceLastCall = time - lastCallTime,
47375
+ timeSinceLastInvoke = time - lastInvokeTime,
47376
+ result = wait - timeSinceLastCall;
47377
+
47378
+ return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
47379
+ }
47380
+
47381
+ function shouldInvoke(time) {
47382
+ var timeSinceLastCall = time - lastCallTime,
47383
+ timeSinceLastInvoke = time - lastInvokeTime;
47384
+
47385
+ // Either this is the first call, activity has stopped and we're at the
47386
+ // trailing edge, the system time has gone backwards and we're treating
47387
+ // it as the trailing edge, or we've hit the `maxWait` limit.
47388
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
47389
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
47390
+ }
47391
+
47392
+ function timerExpired() {
47393
+ var time = now();
47394
+ if (shouldInvoke(time)) {
47395
+ return trailingEdge(time);
47396
+ }
47397
+ // Restart the timer.
47398
+ timerId = setTimeout(timerExpired, remainingWait(time));
47399
+ }
47400
+
47401
+ function trailingEdge(time) {
47402
+ timerId = undefined;
47403
+
47404
+ // Only invoke if we have `lastArgs` which means `func` has been
47405
+ // debounced at least once.
47406
+ if (trailing && lastArgs) {
47407
+ return invokeFunc(time);
47408
+ }
47409
+ lastArgs = lastThis = undefined;
47410
+ return result;
47411
+ }
47412
+
47413
+ function cancel() {
47414
+ if (timerId !== undefined) {
47415
+ clearTimeout(timerId);
47416
+ }
47417
+ lastInvokeTime = 0;
47418
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
47419
+ }
47420
+
47421
+ function flush() {
47422
+ return timerId === undefined ? result : trailingEdge(now());
47423
+ }
47424
+
47425
+ function debounced() {
47426
+ var time = now(),
47427
+ isInvoking = shouldInvoke(time);
47428
+
47429
+ lastArgs = arguments;
47430
+ lastThis = this;
47431
+ lastCallTime = time;
47432
+
47433
+ if (isInvoking) {
47434
+ if (timerId === undefined) {
47435
+ return leadingEdge(lastCallTime);
47436
+ }
47437
+ if (maxing) {
47438
+ // Handle invocations in a tight loop.
47439
+ timerId = setTimeout(timerExpired, wait);
47440
+ return invokeFunc(lastCallTime);
47441
+ }
47442
+ }
47443
+ if (timerId === undefined) {
47444
+ timerId = setTimeout(timerExpired, wait);
47445
+ }
47446
+ return result;
47447
+ }
47448
+ debounced.cancel = cancel;
47449
+ debounced.flush = flush;
47450
+ return debounced;
47451
+ }
47452
+
47453
+ /**
47454
+ * Checks if `value` is the
47455
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
47456
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
47457
+ *
47458
+ * @static
47459
+ * @memberOf _
47460
+ * @since 0.1.0
47461
+ * @category Lang
47462
+ * @param {*} value The value to check.
47463
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
47464
+ * @example
47465
+ *
47466
+ * _.isObject({});
47467
+ * // => true
47468
+ *
47469
+ * _.isObject([1, 2, 3]);
47470
+ * // => true
47471
+ *
47472
+ * _.isObject(_.noop);
47473
+ * // => true
47474
+ *
47475
+ * _.isObject(null);
47476
+ * // => false
47477
+ */
47478
+ function isObject(value) {
47479
+ var type = typeof value;
47480
+ return !!value && (type == 'object' || type == 'function');
47481
+ }
47482
+
47483
+ /**
47484
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
47485
+ * and has a `typeof` result of "object".
47486
+ *
47487
+ * @static
47488
+ * @memberOf _
47489
+ * @since 4.0.0
47490
+ * @category Lang
47491
+ * @param {*} value The value to check.
47492
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
47493
+ * @example
47494
+ *
47495
+ * _.isObjectLike({});
47496
+ * // => true
47497
+ *
47498
+ * _.isObjectLike([1, 2, 3]);
47499
+ * // => true
47500
+ *
47501
+ * _.isObjectLike(_.noop);
47502
+ * // => false
47503
+ *
47504
+ * _.isObjectLike(null);
47505
+ * // => false
47506
+ */
47507
+ function isObjectLike(value) {
47508
+ return !!value && typeof value == 'object';
47509
+ }
47510
+
47511
+ /**
47512
+ * Checks if `value` is classified as a `Symbol` primitive or object.
47513
+ *
47514
+ * @static
47515
+ * @memberOf _
47516
+ * @since 4.0.0
47517
+ * @category Lang
47518
+ * @param {*} value The value to check.
47519
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
47520
+ * @example
47521
+ *
47522
+ * _.isSymbol(Symbol.iterator);
47523
+ * // => true
47524
+ *
47525
+ * _.isSymbol('abc');
47526
+ * // => false
47527
+ */
47528
+ function isSymbol(value) {
47529
+ return typeof value == 'symbol' ||
47530
+ (isObjectLike(value) && objectToString.call(value) == symbolTag);
47531
+ }
47532
+
47533
+ /**
47534
+ * Converts `value` to a number.
47535
+ *
47536
+ * @static
47537
+ * @memberOf _
47538
+ * @since 4.0.0
47539
+ * @category Lang
47540
+ * @param {*} value The value to process.
47541
+ * @returns {number} Returns the number.
47542
+ * @example
47543
+ *
47544
+ * _.toNumber(3.2);
47545
+ * // => 3.2
47546
+ *
47547
+ * _.toNumber(Number.MIN_VALUE);
47548
+ * // => 5e-324
47549
+ *
47550
+ * _.toNumber(Infinity);
47551
+ * // => Infinity
47552
+ *
47553
+ * _.toNumber('3.2');
47554
+ * // => 3.2
47555
+ */
47556
+ function toNumber(value) {
47557
+ if (typeof value == 'number') {
47558
+ return value;
47559
+ }
47560
+ if (isSymbol(value)) {
47561
+ return NAN;
47562
+ }
47563
+ if (isObject(value)) {
47564
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
47565
+ value = isObject(other) ? (other + '') : other;
47566
+ }
47567
+ if (typeof value != 'string') {
47568
+ return value === 0 ? value : +value;
47569
+ }
47570
+ value = value.replace(reTrim, '');
47571
+ var isBinary = reIsBinary.test(value);
47572
+ return (isBinary || reIsOctal.test(value))
47573
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
47574
+ : (reIsBadHex.test(value) ? NAN : +value);
47575
+ }
47576
+
47577
+ var lodash_debounce = debounce;
47578
+
47579
+ const debounce$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_debounce);
47580
+
47581
+ function useUnmount(func) {
47582
+ const funcRef = useRef(func);
47583
+ funcRef.current = func;
47584
+ useEffect(
47585
+ () => () => {
47586
+ funcRef.current();
47587
+ },
47588
+ []
47589
+ );
47590
+ }
47591
+
47592
+ // src/useDebounceCallback/useDebounceCallback.ts
47593
+ function useDebounceCallback(func, delay = 500, options) {
47594
+ const debouncedFunc = useRef();
47595
+ useUnmount(() => {
47596
+ if (debouncedFunc.current) {
47597
+ debouncedFunc.current.cancel();
47598
+ }
47599
+ });
47600
+ const debounced = useMemo(() => {
47601
+ const debouncedFuncInstance = debounce$1(func, delay, options);
47602
+ const wrappedFunc = (...args) => {
47603
+ return debouncedFuncInstance(...args);
47604
+ };
47605
+ wrappedFunc.cancel = () => {
47606
+ debouncedFuncInstance.cancel();
47607
+ };
47608
+ wrappedFunc.isPending = () => {
47609
+ return !!debouncedFunc.current;
47610
+ };
47611
+ wrappedFunc.flush = () => {
47612
+ return debouncedFuncInstance.flush();
47613
+ };
47614
+ return wrappedFunc;
47615
+ }, [func, delay, options]);
47616
+ useEffect(() => {
47617
+ debouncedFunc.current = debounce$1(func, delay, options);
47618
+ }, [func, delay, options]);
47619
+ return debounced;
47620
+ }
47621
+
47622
+ function floorToDecimal(num, decimalPlaces) {
47623
+ const factor = 10 ** decimalPlaces;
47624
+ return Math.floor(num * factor) / factor;
47625
+ }
47626
+ const parseQuotaValue = (key, val) => {
47627
+ let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
47628
+ if (key === "cpu") {
47629
+ if (val.endsWith("m")) {
47630
+ numericValue /= 1e3;
47631
+ }
47632
+ return floorToDecimal(numericValue, 1);
47633
+ }
47634
+ if (val.endsWith("m")) {
47635
+ numericValue /= 1e3;
47636
+ } else if (val.endsWith("k")) {
47637
+ numericValue /= 1e6;
47638
+ } else if (val.endsWith("M")) {
47639
+ numericValue /= 1e3;
47640
+ } else if (val.endsWith("G")) {
47641
+ numericValue /= 1;
47642
+ } else if (val.endsWith("T")) {
47643
+ numericValue *= 1e3;
47644
+ } else if (val.endsWith("Ki")) {
47645
+ numericValue /= 1024;
47646
+ numericValue /= 1e6;
47647
+ } else if (val.endsWith("Mi")) {
47648
+ numericValue /= 1e3;
47649
+ numericValue /= 1e3;
47650
+ } else if (/^\d+(\.\d+)?$/.test(val)) {
47651
+ numericValue /= 1e9;
47652
+ } else {
47653
+ throw new Error("Invalid value");
47654
+ }
47655
+ return floorToDecimal(numericValue, 1);
47656
+ };
47657
+ const parseQuotaValueCpu = (val) => {
47658
+ if (typeof val === "string") {
47659
+ let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
47660
+ if (val.endsWith("m")) {
47661
+ numericValue /= 1e3;
47662
+ }
47663
+ return floorToDecimal(numericValue, 1);
47664
+ }
47665
+ return 0;
47666
+ };
47667
+ const parseQuotaValueMemoryAndStorage = (val) => {
47668
+ if (typeof val === "string") {
47669
+ let numericValue = parseFloat(val.replace(/[a-zA-Zа-яА-Я]/g, ""));
47670
+ if (val.endsWith("k")) {
47671
+ numericValue /= 1e6;
47672
+ } else if (val.endsWith("m")) {
47673
+ numericValue /= 1e3;
47674
+ } else if (val.endsWith("M")) {
47675
+ numericValue /= 1e3;
47676
+ } else if (val.endsWith("G")) {
47677
+ numericValue /= 1;
47678
+ } else if (val.endsWith("T")) {
47679
+ numericValue *= 1e3;
47680
+ } else if (val.endsWith("P")) {
47681
+ numericValue *= 1e6;
47682
+ } else if (val.endsWith("E")) {
47683
+ numericValue *= 1e9;
47684
+ } else if (val.endsWith("Ki")) {
47685
+ numericValue *= 1024 / 1e9;
47686
+ } else if (val.endsWith("Mi")) {
47687
+ numericValue /= 1048.576;
47688
+ } else if (val.endsWith("Gi")) {
47689
+ numericValue *= 1.073741824;
47690
+ } else if (val.endsWith("Ti")) {
47691
+ numericValue *= 1.099511628;
47692
+ } else if (val.endsWith("Pi")) {
47693
+ numericValue *= 1.125899907;
47694
+ } else if (val.endsWith("Ei")) {
47695
+ numericValue *= 1.152921505;
47696
+ } else if (val === "0") {
47697
+ return 0;
47698
+ } else {
47699
+ throw new Error("Invalid value");
47700
+ }
47701
+ return floorToDecimal(numericValue, 1);
47702
+ }
47703
+ return 0;
47704
+ };
47705
+
47706
+ const findAllPathsForObject = (obj, targetKey, targetValue, currentPath = []) => {
47707
+ let paths = [];
47708
+ if (typeof obj !== "object" || obj === null) {
47709
+ return paths;
47710
+ }
47711
+ if (obj[targetKey] === targetValue) {
47712
+ paths.push([...currentPath]);
47713
+ }
47714
+ for (const key in obj) {
47715
+ if (obj.hasOwnProperty(key)) {
47716
+ const value = obj[key];
47717
+ if (typeof value === "object" && value !== null) {
47718
+ const newPath = [...currentPath, key];
47719
+ const subPaths = findAllPathsForObject(value, targetKey, targetValue, newPath);
47720
+ paths = paths.concat(subPaths);
47721
+ }
47722
+ }
47723
+ }
47724
+ return paths;
47725
+ };
47726
+ const normalizeValuesForQuotasToNumber = (object, properties) => {
47727
+ const newObject = _$1.cloneDeep(object);
47728
+ const cpuPaths = findAllPathsForObject(properties, "type", "rangeInputCpu");
47729
+ const memoryPaths = findAllPathsForObject(properties, "type", "rangeInputMemory");
47730
+ memoryPaths.forEach((path) => {
47731
+ const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
47732
+ const value = _$1.get(newObject, cleanPath);
47733
+ if (value || value === 0) {
47734
+ _$1.set(newObject, cleanPath, parseQuotaValueMemoryAndStorage(value));
47735
+ }
47736
+ });
47737
+ cpuPaths.forEach((path) => {
47738
+ const cleanPath = path.filter((el) => typeof el === "string").filter((el) => el !== "properties");
47739
+ const value = _$1.get(newObject, cleanPath);
47740
+ if (value || value === 0) {
47741
+ _$1.set(newObject, cleanPath, parseQuotaValueCpu(value));
47742
+ }
47743
+ });
47744
+ return newObject;
47745
+ };
47746
+
47747
+ const getAllPathsFromObj = (obj, prefix = []) => {
47748
+ const entries = Array.isArray(obj) ? obj.map((value, index) => [index, value]) : Object.entries(obj);
47749
+ return entries.flatMap(([key, value]) => {
47750
+ const currentPath = [...prefix, key];
47751
+ return typeof value === "object" && value !== null ? [currentPath, ...getAllPathsFromObj(value, currentPath)] : [currentPath];
47752
+ });
47753
+ };
47754
+
47755
+ const getPrefixSubarrays = (arr) => {
47756
+ return arr.map((_, index) => arr.slice(0, index + 1));
47757
+ };
47758
+
47759
+ const deepMerge = (a, b) => {
47760
+ const result = { ...a };
47761
+ for (const key of Object.keys(b)) {
47762
+ const aVal = a[key];
47763
+ const bVal = b[key];
47764
+ if (aVal !== null && bVal !== null && typeof aVal === "object" && typeof bVal === "object" && !Array.isArray(aVal) && !Array.isArray(bVal)) {
47765
+ result[key] = deepMerge(aVal, bVal);
47766
+ } else {
47767
+ result[key] = bVal;
47768
+ }
47769
+ }
47770
+ return result;
47771
+ };
47772
+
47773
+ const BorderRadiusContainer = styled.div`
47774
+ height: 100%;
47775
+ border: 1px solid ${({ $colorBorder }) => $colorBorder};
47776
+ border-radius: 8px;
47777
+ padding: 2px;
47778
+
47779
+ .monaco-editor,
47780
+ .overflow-guard {
47781
+ border-radius: 8px;
47782
+ }
47783
+ `;
47784
+ const Styled$j = {
47785
+ BorderRadiusContainer
47786
+ };
47787
+
47788
+ const YamlEditor = ({ theme: theme$1, currentValues, onChange, editorUri }) => {
47789
+ const { token } = theme.useToken();
47790
+ const [yamlData, setYamlData] = useState("");
47791
+ const editorRef = useRef(null);
47792
+ const monacoRef = useRef(null);
47793
+ const isFocusedRef = useRef(false);
47794
+ const pendingExternalYamlRef = useRef(null);
47795
+ const isApplyingExternalUpdateRef = useRef(false);
47796
+ useEffect(() => {
47797
+ const next = stringify(currentValues, {
47798
+ // Use literal block scalar for multiline strings
47799
+ blockQuote: "literal",
47800
+ // Preserve line breaks
47801
+ lineWidth: 0,
47802
+ // Use double quotes for strings that need escaping
47803
+ doubleQuotedAsJSON: false
47804
+ });
47805
+ if (isFocusedRef.current) {
47806
+ pendingExternalYamlRef.current = next ?? "";
47807
+ return;
47808
+ }
47809
+ setYamlData(next ?? "");
47810
+ }, [currentValues]);
47811
+ useEffect(() => {
47812
+ const editor = editorRef.current;
47813
+ const monaco = monacoRef.current;
47814
+ if (editor && monaco) {
47815
+ if (isFocusedRef.current) return;
47816
+ const uri = monaco.Uri.parse(editorUri);
47817
+ let model = editor.getModel() || monaco.editor.getModel(uri);
47818
+ if (!model) {
47819
+ model = monaco.editor.createModel(yamlData ?? "", "yaml", uri);
47820
+ }
47821
+ if (model) {
47822
+ monaco.editor.setModelLanguage(model, "yaml");
47823
+ const current = model.getValue();
47824
+ if ((yamlData ?? "") !== current) {
47825
+ isApplyingExternalUpdateRef.current = true;
47826
+ model.setValue(yamlData ?? "");
47827
+ }
47828
+ }
47829
+ }
47830
+ }, [yamlData, editorUri]);
47831
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Styled$j.BorderRadiusContainer, { $colorBorder: token.colorBorder, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
47832
+ Ft,
47833
+ {
47834
+ language: "yaml",
47835
+ path: editorUri,
47836
+ keepCurrentModel: true,
47837
+ width: "100%",
47838
+ height: "100%",
47839
+ defaultValue: yamlData ?? "",
47840
+ onMount: (editor, m) => {
47841
+ editorRef.current = editor;
47842
+ monacoRef.current = m;
47843
+ try {
47844
+ isFocusedRef.current = !!editor.hasTextFocus?.();
47845
+ } catch {
47846
+ isFocusedRef.current = false;
47847
+ }
47848
+ editor.onDidFocusEditorText(() => {
47849
+ isFocusedRef.current = true;
47850
+ });
47851
+ editor.onDidBlurEditorText(() => {
47852
+ isFocusedRef.current = false;
47853
+ if (pendingExternalYamlRef.current !== null) {
47854
+ setYamlData(pendingExternalYamlRef.current);
47855
+ pendingExternalYamlRef.current = null;
47856
+ }
47857
+ });
47858
+ const uri = m.Uri.parse("inmemory://openapi-ui/form.yaml");
47859
+ let model = editor.getModel() || m.editor.getModel(uri);
47860
+ if (!model) {
47861
+ model = m.editor.createModel(yamlData ?? "", "yaml", uri);
47862
+ }
47863
+ if (model) {
47864
+ m.editor.setModelLanguage(model, "yaml");
47865
+ }
47866
+ },
47867
+ onChange: (value) => {
47868
+ if (isApplyingExternalUpdateRef.current) {
47869
+ isApplyingExternalUpdateRef.current = false;
47870
+ setYamlData(value || "");
47871
+ return;
47872
+ }
47873
+ try {
47874
+ onChange(parse(value || ""));
47875
+ } catch {
47876
+ }
47877
+ setYamlData(value || "");
47878
+ },
47879
+ theme: theme$1 === "dark" ? "vs-dark" : theme$1 === void 0 ? "vs-dark" : "vs",
47880
+ options: {
47881
+ theme: theme$1 === "dark" ? "vs-dark" : theme$1 === void 0 ? "vs-dark" : "vs"
47882
+ }
47883
+ }
47884
+ ) });
47885
+ };
47886
+
47593
47887
  const getStringByName = (name) => {
47594
47888
  if (typeof name === "string") {
47595
47889
  return name;