@prorobotech/openapi-k8s-toolkit 1.1.0-alpha.11 → 1.1.0-alpha.13

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