@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.24 → 6.2.3-dev.26

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 (88) hide show
  1. package/dist/browser/assets/{entry-CSJBrcX5.js → entry-DhaRsTID.js} +2 -3
  2. package/dist/browser/assets/{projection-entry-D67cdPsg.js → projection-entry-qrF_MLsE.js} +7 -13
  3. package/dist/browser/{documents-C-lAnv6o.js → documents-CRzouuNR.js} +45 -35
  4. package/dist/browser/{documents-C-lAnv6o.js.map → documents-CRzouuNR.js.map} +1 -1
  5. package/dist/browser/{editor-CQ4wUFK5.js → editor-C7KBR_ar.js} +1063 -66
  6. package/dist/browser/editor-C7KBR_ar.js.map +1 -0
  7. package/dist/browser/{editor-DNV-46lY.js → editor-CiR6XQBO.js} +2 -3
  8. package/dist/browser/{editor-DNV-46lY.js.map → editor-CiR6XQBO.js.map} +1 -1
  9. package/dist/browser/editors/document-model-editor/module.js +1 -1
  10. package/dist/browser/editors/document-model-editor/module.js.map +1 -1
  11. package/dist/browser/editors/generic-drive-explorer/index.js +74 -63
  12. package/dist/browser/editors/generic-drive-explorer/index.js.map +1 -1
  13. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  14. package/dist/browser/editors/generic-drive-explorer/module.js.map +1 -1
  15. package/dist/browser/{src-CVV6HzQZ-D-OQvEkh.js → folder-view-DSgXN79D.js} +901 -1643
  16. package/dist/browser/folder-view-DSgXN79D.js.map +1 -0
  17. package/dist/browser/{graphql-editor-DoXZvdNr.js → graphql-editor-Cgi5UOrF.js} +97 -85
  18. package/dist/browser/graphql-editor-Cgi5UOrF.js.map +1 -0
  19. package/dist/{node/hooks-Di3FASx-.mjs → browser/hooks-eQxBX7g4.js} +824 -444
  20. package/dist/browser/{hooks-Bh1JCohS.js.map → hooks-eQxBX7g4.js.map} +1 -1
  21. package/dist/browser/index.js +20 -17
  22. package/dist/browser/index.js.map +1 -1
  23. package/dist/browser/{json-editor-DBhkG5TF.js → json-editor-DfRD-pfk.js} +7 -7
  24. package/dist/browser/{json-editor-DBhkG5TF.js.map → json-editor-DfRD-pfk.js.map} +1 -1
  25. package/dist/browser/{parser-BBzK7bLd.js → parser-DtbeHA3H.js} +7 -6
  26. package/dist/browser/{parser-BBzK7bLd.js.map → parser-DtbeHA3H.js.map} +1 -1
  27. package/dist/browser/{chunk-BVTlhY3a.js → rolldown-runtime-DC62tzP2.js} +12 -3
  28. package/dist/browser/src-CrUksCLW-B2dkRdgq.js +5254 -0
  29. package/dist/browser/src-CrUksCLW-B2dkRdgq.js.map +1 -0
  30. package/dist/browser/{state-schemas-B47wHvDV.js → state-schemas-B5Bk_l1s.js} +12 -10
  31. package/dist/browser/{state-schemas-B47wHvDV.js.map → state-schemas-B5Bk_l1s.js.map} +1 -1
  32. package/dist/browser/{tslib.es6-CeIASJ2O.js → tslib.es6-Cno80yFJ.js} +1 -1
  33. package/dist/browser/{tslib.es6-CeIASJ2O.js.map → tslib.es6-Cno80yFJ.js.map} +1 -1
  34. package/dist/node/{documents-XAQfHX5Q.mjs → documents-D70S9PZL.mjs} +2 -2
  35. package/dist/node/documents-D70S9PZL.mjs.map +1 -0
  36. package/dist/node/{editor-BiiLqEe9.mjs → editor-96sMeumV.mjs} +986 -68
  37. package/dist/node/editor-96sMeumV.mjs.map +1 -0
  38. package/dist/node/{editor-Cp2TC5MJ.mjs → editor-wqvKwcO5.mjs} +2 -3
  39. package/dist/node/{editor-Cp2TC5MJ.mjs.map → editor-wqvKwcO5.mjs.map} +1 -1
  40. package/dist/node/editors/document-model-editor/module.mjs +1 -1
  41. package/dist/node/editors/document-model-editor/module.mjs.map +1 -1
  42. package/dist/node/editors/generic-drive-explorer/index.mjs +25 -19
  43. package/dist/node/editors/generic-drive-explorer/index.mjs.map +1 -1
  44. package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
  45. package/dist/node/editors/generic-drive-explorer/module.mjs.map +1 -1
  46. package/dist/node/{src-CVV6HzQZ-CvqjXbXk.mjs → folder-view-ktfv2Cvw.mjs} +891 -2311
  47. package/dist/node/{src-CVV6HzQZ-CvqjXbXk.mjs.map → folder-view-ktfv2Cvw.mjs.map} +1 -1
  48. package/dist/node/{graphql-BvV3tC1U.mjs → graphql-Dp4j7rmx.mjs} +50 -49
  49. package/dist/node/{graphql-BvV3tC1U.mjs.map → graphql-Dp4j7rmx.mjs.map} +1 -1
  50. package/dist/node/{graphql-editor-BhF6KN6y.mjs → graphql-editor-CBJXEY_C.mjs} +76 -61
  51. package/dist/node/graphql-editor-CBJXEY_C.mjs.map +1 -0
  52. package/dist/{browser/hooks-Bh1JCohS.js → node/hooks-C2b46djt.mjs} +824 -444
  53. package/dist/node/{hooks-Di3FASx-.mjs.map → hooks-C2b46djt.mjs.map} +1 -1
  54. package/dist/node/index.mjs +20 -18
  55. package/dist/node/index.mjs.map +1 -1
  56. package/dist/node/{json-editor-Cqc0zuz0.mjs → json-editor-DaqHARBD.mjs} +7 -7
  57. package/dist/node/{json-editor-Cqc0zuz0.mjs.map → json-editor-DaqHARBD.mjs.map} +1 -1
  58. package/dist/node/{schema-context-mHmP3Cl6.mjs → schema-context-CojjnSE6.mjs} +6 -5
  59. package/dist/node/schema-context-CojjnSE6.mjs.map +1 -0
  60. package/dist/node/src-CrUksCLW-TvF37aMo.mjs +5935 -0
  61. package/dist/node/src-CrUksCLW-TvF37aMo.mjs.map +1 -0
  62. package/dist/node/{state-schemas-DXG02fMh.mjs → state-schemas-BHuo0GPl.mjs} +13 -10
  63. package/dist/node/{state-schemas-DXG02fMh.mjs.map → state-schemas-BHuo0GPl.mjs.map} +1 -1
  64. package/dist/node/{tslib.es6-DdiHgz9e.mjs → tslib.es6-VORZjfk3.mjs} +45 -7
  65. package/dist/node/{tslib.es6-DdiHgz9e.mjs.map → tslib.es6-VORZjfk3.mjs.map} +1 -1
  66. package/package.json +11 -10
  67. package/dist/browser/button-sZQCXeCo.js +0 -803
  68. package/dist/browser/button-sZQCXeCo.js.map +0 -1
  69. package/dist/browser/dist-D3_ER0Dn.js +0 -2314
  70. package/dist/browser/dist-D3_ER0Dn.js.map +0 -1
  71. package/dist/browser/editor-CQ4wUFK5.js.map +0 -1
  72. package/dist/browser/folder-view-CzItU0hn.js +0 -957
  73. package/dist/browser/folder-view-CzItU0hn.js.map +0 -1
  74. package/dist/browser/graphql-editor-DoXZvdNr.js.map +0 -1
  75. package/dist/browser/schema-context-p2bhyog_.js +0 -69
  76. package/dist/browser/schema-context-p2bhyog_.js.map +0 -1
  77. package/dist/browser/src-CVV6HzQZ-D-OQvEkh.js.map +0 -1
  78. package/dist/node/button-5bnYEAVq.mjs +0 -785
  79. package/dist/node/button-5bnYEAVq.mjs.map +0 -1
  80. package/dist/node/chunk-17FXJ3dL.mjs +0 -31
  81. package/dist/node/dist-Bf_PIbO7.mjs +0 -2314
  82. package/dist/node/dist-Bf_PIbO7.mjs.map +0 -1
  83. package/dist/node/documents-XAQfHX5Q.mjs.map +0 -1
  84. package/dist/node/editor-BiiLqEe9.mjs.map +0 -1
  85. package/dist/node/folder-view-m_rH84Nz.mjs +0 -962
  86. package/dist/node/folder-view-m_rH84Nz.mjs.map +0 -1
  87. package/dist/node/graphql-editor-BhF6KN6y.mjs.map +0 -1
  88. package/dist/node/schema-context-mHmP3Cl6.mjs.map +0 -1
@@ -1,8 +1,7 @@
1
- import { t as require_graphql } from "./graphql-BvV3tC1U.mjs";
2
- import { a as Slot, i as Primitive, t as Modal } from "./src-CVV6HzQZ-CvqjXbXk.mjs";
3
- import { h as twMerge } from "./dist-Bf_PIbO7.mjs";
4
- import { t as SchemaContextProvider } from "./schema-context-mHmP3Cl6.mjs";
5
- import { _ as pascalCase, a as compareStringsWithoutWhitespace, c as isEmptyOperationSchema, f as makeOperationInitialDoc, g as constantCase, l as makeEmptyOperationSchema, m as renameSchemaType, n as ensureValidOperationSchemaInputName, o as handleModelNameChange, s as initializeModelSchema, t as Button, u as makeInitialSchemaDoc, v as snakeCase } from "./button-5bnYEAVq.mjs";
1
+ import { i as __exportAll } from "./tslib.es6-VORZjfk3.mjs";
2
+ import { t as require_graphql } from "./graphql-Dp4j7rmx.mjs";
3
+ import { i as Primitive, m as twMerge, t as Modal } from "./src-CrUksCLW-TvF37aMo.mjs";
4
+ import { n as safeParseSdl, t as SchemaContextProvider } from "./schema-context-CojjnSE6.mjs";
6
5
  import { addModule, addOperation, addOperationError, deleteModule, deleteOperation, deleteOperationError, generateId, releaseNewVersion, setAuthorName, setAuthorWebsite, setInitialState, setModelDescription, setModelExtension, setModelId, setModelName, setModuleName, setOperationDescription, setOperationErrorName, setOperationName, setOperationSchema, setStateSchema } from "@powerhousedao/shared/document-model";
7
6
  import { z } from "zod";
8
7
  import * as React$1 from "react";
@@ -10,7 +9,129 @@ import React, { Suspense, forwardRef, lazy, useCallback, useEffect, useId, useIm
10
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
10
  import { ConnectSelect, DocumentToolbar, ModalButton } from "@powerhousedao/design-system/connect";
12
11
  import { usePHToast, useSelectedDocumentOfType, useSetPHDocumentEditorConfig } from "@powerhousedao/reactor-browser";
12
+ import { getPHCustomScalarByTypeName } from "@powerhousedao/document-engineering/graphql";
13
13
  import * as n from "zod/v4/core";
14
+ //#region ../../node_modules/.pnpm/@radix-ui+react-compose-refs@1.1.3_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-compose-refs/dist/index.mjs
15
+ var import_graphql = require_graphql();
16
+ function setRef(ref, value) {
17
+ if (typeof ref === "function") return ref(value);
18
+ else if (ref !== null && ref !== void 0) ref.current = value;
19
+ }
20
+ function composeRefs(...refs) {
21
+ return (node) => {
22
+ let hasCleanup = false;
23
+ const cleanups = refs.map((ref) => {
24
+ const cleanup = setRef(ref, node);
25
+ if (!hasCleanup && typeof cleanup == "function") hasCleanup = true;
26
+ return cleanup;
27
+ });
28
+ if (hasCleanup) return () => {
29
+ for (let i = 0; i < cleanups.length; i++) {
30
+ const cleanup = cleanups[i];
31
+ if (typeof cleanup == "function") cleanup();
32
+ else setRef(refs[i], null);
33
+ }
34
+ };
35
+ };
36
+ }
37
+ function useComposedRefs(...refs) {
38
+ return React$1.useCallback(composeRefs(...refs), refs);
39
+ }
40
+ //#endregion
41
+ //#region ../../node_modules/.pnpm/@radix-ui+react-slot@1.3.0_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-slot/dist/index.mjs
42
+ // @__NO_SIDE_EFFECTS__
43
+ function createSlot(ownerName) {
44
+ const Slot2 = React$1.forwardRef((props, forwardedRef) => {
45
+ let { children, ...slotProps } = props;
46
+ let slottableElement = null;
47
+ let hasSlottable = false;
48
+ const newChildren = [];
49
+ if (isLazyComponent(children) && typeof use === "function") children = use(children._payload);
50
+ React$1.Children.forEach(children, (maybeSlottable) => {
51
+ if (isSlottable(maybeSlottable)) {
52
+ hasSlottable = true;
53
+ const slottable = maybeSlottable;
54
+ let child = "child" in slottable.props ? slottable.props.child : slottable.props.children;
55
+ if (isLazyComponent(child) && typeof use === "function") child = use(child._payload);
56
+ slottableElement = getSlottableElementFromSlottable(slottable, child);
57
+ newChildren.push(slottableElement?.props?.children);
58
+ } else newChildren.push(maybeSlottable);
59
+ });
60
+ if (slottableElement) slottableElement = React$1.cloneElement(slottableElement, void 0, newChildren);
61
+ else if (!hasSlottable && React$1.Children.count(children) === 1 && React$1.isValidElement(children)) slottableElement = children;
62
+ const slottableElementRef = slottableElement ? getElementRef(slottableElement) : void 0;
63
+ const composedRef = useComposedRefs(forwardedRef, slottableElementRef);
64
+ if (!slottableElement) {
65
+ if (children || children === 0) throw new Error(hasSlottable ? createSlottableError(ownerName) : createSlotError(ownerName));
66
+ return children;
67
+ }
68
+ const mergedProps = mergeProps(slotProps, slottableElement.props ?? {});
69
+ if (slottableElement.type !== React$1.Fragment) mergedProps.ref = forwardedRef ? composedRef : slottableElementRef;
70
+ return React$1.cloneElement(slottableElement, mergedProps);
71
+ });
72
+ Slot2.displayName = `${ownerName}.Slot`;
73
+ return Slot2;
74
+ }
75
+ var Slot = /* @__PURE__ */ createSlot("Slot");
76
+ var SLOTTABLE_IDENTIFIER = Symbol.for("radix.slottable");
77
+ var getSlottableElementFromSlottable = (slottable, child) => {
78
+ if ("child" in slottable.props) {
79
+ const child2 = slottable.props.child;
80
+ if (!React$1.isValidElement(child2)) return null;
81
+ return React$1.cloneElement(child2, void 0, slottable.props.children(child2.props.children));
82
+ }
83
+ return React$1.isValidElement(child) ? child : null;
84
+ };
85
+ function mergeProps(slotProps, childProps) {
86
+ const overrideProps = { ...childProps };
87
+ for (const propName in childProps) {
88
+ const slotPropValue = slotProps[propName];
89
+ const childPropValue = childProps[propName];
90
+ if (/^on[A-Z]/.test(propName)) {
91
+ if (slotPropValue && childPropValue) overrideProps[propName] = (...args) => {
92
+ const result = childPropValue(...args);
93
+ slotPropValue(...args);
94
+ return result;
95
+ };
96
+ else if (slotPropValue) overrideProps[propName] = slotPropValue;
97
+ } else if (propName === "style") overrideProps[propName] = {
98
+ ...slotPropValue,
99
+ ...childPropValue
100
+ };
101
+ else if (propName === "className") overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
102
+ }
103
+ return {
104
+ ...slotProps,
105
+ ...overrideProps
106
+ };
107
+ }
108
+ function getElementRef(element) {
109
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
110
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
111
+ if (mayWarn) return element.ref;
112
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
113
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
114
+ if (mayWarn) return element.props.ref;
115
+ return element.props.ref || element.ref;
116
+ }
117
+ function isSlottable(child) {
118
+ return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
119
+ }
120
+ var REACT_LAZY_TYPE = Symbol.for("react.lazy");
121
+ function isLazyComponent(element) {
122
+ return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
123
+ }
124
+ function isPromiseLike(value) {
125
+ return typeof value === "object" && value !== null && "then" in value;
126
+ }
127
+ var createSlotError = (ownerName) => {
128
+ return `${ownerName} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`;
129
+ };
130
+ var createSlottableError = (ownerName) => {
131
+ return `${ownerName} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`;
132
+ };
133
+ var use = React$1[" use ".trim().toString()];
134
+ //#endregion
14
135
  //#region ../../node_modules/.pnpm/clsx@2.0.0/node_modules/clsx/dist/clsx.mjs
15
136
  function r$1(e) {
16
137
  var t, f, n = "";
@@ -45,7 +166,7 @@ const cva = (base, config) => {
45
166
  acc[key] = value;
46
167
  return acc;
47
168
  }, {});
48
- return cx(base, getVariantClassNames, config === null || config === void 0 ? void 0 : (ref = config.compoundVariants) === null || ref === void 0 ? void 0 : ref.reduce((acc, param1) => {
169
+ const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (ref = config.compoundVariants) === null || ref === void 0 ? void 0 : ref.reduce((acc, param1) => {
49
170
  let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param1;
50
171
  return Object.entries(compoundVariantOptions).every((param) => {
51
172
  let [key, value] = param;
@@ -61,7 +182,8 @@ const cva = (base, config) => {
61
182
  cvClass,
62
183
  cvClassName
63
184
  ] : acc;
64
- }, []), props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
185
+ }, []);
186
+ return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
65
187
  };
66
188
  };
67
189
  //#endregion
@@ -69,8 +191,8 @@ const cva = (base, config) => {
69
191
  var isCheckBoxInput = (element) => element.type === "checkbox";
70
192
  var isDateObject = (value) => value instanceof Date;
71
193
  var isNullOrUndefined = (value) => value == null;
72
- const isObjectType = (value) => typeof value === "object";
73
- var isObject = (value) => !isNullOrUndefined(value) && !Array.isArray(value) && isObjectType(value) && !isDateObject(value);
194
+ const isObjectType$1 = (value) => typeof value === "object";
195
+ var isObject = (value) => !isNullOrUndefined(value) && !Array.isArray(value) && isObjectType$1(value) && !isDateObject(value);
74
196
  var getEventValue = (event) => isObject(event) && event.target ? isCheckBoxInput(event.target) ? event.target.checked : event.target.value : event;
75
197
  var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
76
198
  var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
@@ -233,7 +355,7 @@ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) =>
233
355
  isGlobal && (_names.watchAll = true);
234
356
  return formValues;
235
357
  };
236
- var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
358
+ var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType$1(value);
237
359
  function deepEqual(object1, object2, _internal_visited = /* @__PURE__ */ new WeakSet()) {
238
360
  if (isPrimitive(object1) || isPrimitive(object2)) return Object.is(object1, object2);
239
361
  if (isDateObject(object1) && isDateObject(object2)) return Object.is(object1.getTime(), object2.getTime());
@@ -742,9 +864,10 @@ function getDirtyFields(data, formValues, dirtyFieldsFromValues) {
742
864
  if (!dirtyFieldsFromValues) dirtyFieldsFromValues = markFieldsDirty(formValues);
743
865
  for (const key in data) {
744
866
  const value = data[key];
745
- if (isTraversable(value)) if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});
746
- else getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
747
- else {
867
+ if (isTraversable(value)) {
868
+ if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});
869
+ else getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
870
+ } else {
748
871
  const formValue = formValues[key];
749
872
  dirtyFieldsFromValues[key] = !deepEqual(value, formValue);
750
873
  }
@@ -1264,12 +1387,15 @@ function createFormControl(props = {}) {
1264
1387
  !fieldReference.disabled && set(_formValues, name, getFieldValueAs(value, fieldReference));
1265
1388
  fieldValue = isHTMLElement(fieldReference.ref) && isNullOrUndefined(value) ? "" : value;
1266
1389
  if (isMultipleSelect(fieldReference.ref)) [...fieldReference.ref.options].forEach((optionRef) => optionRef.selected = fieldValue.includes(optionRef.value));
1267
- else if (fieldReference.refs) if (isCheckBoxInput(fieldReference.ref)) fieldReference.refs.forEach((checkboxRef) => {
1268
- if (!checkboxRef.defaultChecked || !checkboxRef.disabled) if (Array.isArray(fieldValue)) checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
1269
- else checkboxRef.checked = fieldValue === checkboxRef.value || !!fieldValue;
1270
- });
1271
- else fieldReference.refs.forEach((radioRef) => radioRef.checked = radioRef.value === fieldValue);
1272
- else if (isFileInput(fieldReference.ref)) fieldReference.ref.value = "";
1390
+ else if (fieldReference.refs) {
1391
+ if (isCheckBoxInput(fieldReference.ref)) fieldReference.refs.forEach((checkboxRef) => {
1392
+ if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {
1393
+ if (Array.isArray(fieldValue)) checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
1394
+ else checkboxRef.checked = fieldValue === checkboxRef.value || !!fieldValue;
1395
+ }
1396
+ });
1397
+ else fieldReference.refs.forEach((radioRef) => radioRef.checked = radioRef.value === fieldValue);
1398
+ } else if (isFileInput(fieldReference.ref)) fieldReference.ref.value = "";
1273
1399
  else {
1274
1400
  fieldReference.ref.value = fieldValue;
1275
1401
  if (!fieldReference.ref.type) _subjects.state.next({
@@ -1407,7 +1533,7 @@ function createFormControl(props = {}) {
1407
1533
  const field = get(_fields, fieldName);
1408
1534
  return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
1409
1535
  }))).every(Boolean);
1410
- !(!validationResult && !_formState.isValid) && _setValid();
1536
+ (validationResult || _formState.isValid) && _setValid();
1411
1537
  } else validationResult = isValid = await executeBuiltInValidation(_fields);
1412
1538
  _subjects.state.next({
1413
1539
  ...!isString(name) || (_proxyFormState.isValid || _proxySubscribeFormState.isValid) && isValid !== _formState.isValid ? {} : { name },
@@ -1647,7 +1773,7 @@ function createFormControl(props = {}) {
1647
1773
  if (!keepStateOptions.keepDefaultValues) _defaultValues = updatedValues;
1648
1774
  if (!keepStateOptions.keepValues) {
1649
1775
  if (keepStateOptions.keepDirtyValues) {
1650
- const fieldsToCheck = new Set([..._names.mount, ...Object.keys(getDirtyFields(_defaultValues, _formValues))]);
1776
+ const fieldsToCheck = /* @__PURE__ */ new Set([..._names.mount, ...Object.keys(getDirtyFields(_defaultValues, _formValues))]);
1651
1777
  for (const fieldName of Array.from(fieldsToCheck)) {
1652
1778
  const isDirty = get(_formState.dirtyFields, fieldName);
1653
1779
  const existingValue = get(_formValues, fieldName);
@@ -1854,18 +1980,20 @@ function useForm(props = {}) {
1854
1980
  isReady: false,
1855
1981
  defaultValues: isFunction(props.defaultValues) ? void 0 : props.defaultValues
1856
1982
  });
1857
- if (!_formControl.current) if (props.formControl) {
1858
- _formControl.current = {
1859
- ...props.formControl,
1860
- formState
1861
- };
1862
- if (props.defaultValues && !isFunction(props.defaultValues)) props.formControl.reset(props.defaultValues, props.resetOptions);
1863
- } else {
1864
- const { formControl, ...rest } = createFormControl(props);
1865
- _formControl.current = {
1866
- ...rest,
1867
- formState
1868
- };
1983
+ if (!_formControl.current) {
1984
+ if (props.formControl) {
1985
+ _formControl.current = {
1986
+ ...props.formControl,
1987
+ formState
1988
+ };
1989
+ if (props.defaultValues && !isFunction(props.defaultValues)) props.formControl.reset(props.defaultValues, props.resetOptions);
1990
+ } else {
1991
+ const { formControl, ...rest } = createFormControl(props);
1992
+ _formControl.current = {
1993
+ ...rest,
1994
+ formState
1995
+ };
1996
+ }
1869
1997
  }
1870
1998
  const control = _formControl.current.control;
1871
1999
  control._options = props;
@@ -1933,6 +2061,783 @@ function useForm(props = {}) {
1933
2061
  return _formControl.current;
1934
2062
  }
1935
2063
  //#endregion
2064
+ //#region ../../node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js
2065
+ const SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
2066
+ const SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
2067
+ const SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
2068
+ const DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
2069
+ const SPLIT_REPLACE_VALUE = "$1\0$2";
2070
+ const DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
2071
+ /**
2072
+ * Split any cased input strings into an array of words.
2073
+ */
2074
+ function split(value) {
2075
+ let result = value.trim();
2076
+ result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
2077
+ result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
2078
+ let start = 0;
2079
+ let end = result.length;
2080
+ while (result.charAt(start) === "\0") start++;
2081
+ if (start === end) return [];
2082
+ while (result.charAt(end - 1) === "\0") end--;
2083
+ return result.slice(start, end).split(/\0/g);
2084
+ }
2085
+ /**
2086
+ * Split the input string into an array of words, separating numbers.
2087
+ */
2088
+ function splitSeparateNumbers(value) {
2089
+ const words = split(value);
2090
+ for (let i = 0; i < words.length; i++) {
2091
+ const word = words[i];
2092
+ const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
2093
+ if (match) {
2094
+ const offset = match.index + (match[1] ?? match[2]).length;
2095
+ words.splice(i, 1, word.slice(0, offset), word.slice(offset));
2096
+ }
2097
+ }
2098
+ return words;
2099
+ }
2100
+ /**
2101
+ * Convert a string to space separated lower case (`foo bar`).
2102
+ */
2103
+ function noCase(input, options) {
2104
+ const [prefix, words, suffix] = splitPrefixSuffix(input, options);
2105
+ return prefix + words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? " ") + suffix;
2106
+ }
2107
+ /**
2108
+ * Convert a string to pascal case (`FooBar`).
2109
+ */
2110
+ function pascalCase(input, options) {
2111
+ const [prefix, words, suffix] = splitPrefixSuffix(input, options);
2112
+ const lower = lowerFactory(options?.locale);
2113
+ const upper = upperFactory(options?.locale);
2114
+ const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
2115
+ return prefix + words.map(transform).join(options?.delimiter ?? "") + suffix;
2116
+ }
2117
+ /**
2118
+ * Convert a string to constant case (`FOO_BAR`).
2119
+ */
2120
+ function constantCase(input, options) {
2121
+ const [prefix, words, suffix] = splitPrefixSuffix(input, options);
2122
+ return prefix + words.map(upperFactory(options?.locale)).join(options?.delimiter ?? "_") + suffix;
2123
+ }
2124
+ /**
2125
+ * Convert a string to path case (`Foo bar`).
2126
+ */
2127
+ function sentenceCase(input, options) {
2128
+ const [prefix, words, suffix] = splitPrefixSuffix(input, options);
2129
+ const lower = lowerFactory(options?.locale);
2130
+ const transform = capitalCaseTransformFactory(lower, upperFactory(options?.locale));
2131
+ return prefix + words.map((word, index) => {
2132
+ if (index === 0) return transform(word);
2133
+ return lower(word);
2134
+ }).join(options?.delimiter ?? " ") + suffix;
2135
+ }
2136
+ /**
2137
+ * Convert a string to snake case (`foo_bar`).
2138
+ */
2139
+ function snakeCase(input, options) {
2140
+ return noCase(input, {
2141
+ delimiter: "_",
2142
+ ...options
2143
+ });
2144
+ }
2145
+ function lowerFactory(locale) {
2146
+ return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
2147
+ }
2148
+ function upperFactory(locale) {
2149
+ return locale === false ? (input) => input.toUpperCase() : (input) => input.toLocaleUpperCase(locale);
2150
+ }
2151
+ function capitalCaseTransformFactory(lower, upper) {
2152
+ return (word) => `${upper(word[0])}${lower(word.slice(1))}`;
2153
+ }
2154
+ function pascalCaseTransformFactory(lower, upper) {
2155
+ return (word, index) => {
2156
+ const char0 = word[0];
2157
+ return (index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0)) + lower(word.slice(1));
2158
+ };
2159
+ }
2160
+ function splitPrefixSuffix(input, options = {}) {
2161
+ const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
2162
+ const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
2163
+ const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
2164
+ let prefixIndex = 0;
2165
+ let suffixIndex = input.length;
2166
+ while (prefixIndex < input.length) {
2167
+ const char = input.charAt(prefixIndex);
2168
+ if (!prefixCharacters.includes(char)) break;
2169
+ prefixIndex++;
2170
+ }
2171
+ while (suffixIndex > prefixIndex) {
2172
+ const index = suffixIndex - 1;
2173
+ const char = input.charAt(index);
2174
+ if (!suffixCharacters.includes(char)) break;
2175
+ suffixIndex = index;
2176
+ }
2177
+ return [
2178
+ input.slice(0, prefixIndex),
2179
+ splitFn(input.slice(prefixIndex, suffixIndex)),
2180
+ input.slice(suffixIndex)
2181
+ ];
2182
+ }
2183
+ //#endregion
2184
+ //#region editors/document-model-editor/constants/graphql-kinds.ts
2185
+ const STRING_GQL_PRIMITIVE_NAME = "String";
2186
+ const BOOLEAN_GQL_PRIMITIVE_NAME = "Boolean";
2187
+ const FLOAT_GQL_PRIMITIVE_NAME = "Float";
2188
+ const gqlPrimitiveNodeNamesList = [
2189
+ STRING_GQL_PRIMITIVE_NAME,
2190
+ BOOLEAN_GQL_PRIMITIVE_NAME,
2191
+ "Int",
2192
+ FLOAT_GQL_PRIMITIVE_NAME,
2193
+ "ID"
2194
+ ];
2195
+ //#endregion
2196
+ //#region editors/document-model-editor/utils/helpers.ts
2197
+ function makeStateSchemaNameForScope(modelName, scope) {
2198
+ const modelNamePascalCase = pascalCase(modelName);
2199
+ const scopePascalCase = pascalCase(scope);
2200
+ return scopePascalCase === "Global" ? `${modelNamePascalCase}State` : `${modelNamePascalCase}${scopePascalCase}State`;
2201
+ }
2202
+ function makeInitialSchemaDoc(modelName, scope) {
2203
+ return `type ${makeStateSchemaNameForScope(modelName, scope)} {
2204
+ "Add your ${scope} state fields here"
2205
+ _placeholder: String
2206
+ }`;
2207
+ }
2208
+ function makeOperationInitialDoc(name) {
2209
+ return `input ${pascalCase(name)}Input {
2210
+ "Add your inputs here"
2211
+ _placeholder: String
2212
+ }`;
2213
+ }
2214
+ function makeEmptyOperationSchema(operationName) {
2215
+ return `input ${pascalCase(operationName)}Input {\n _empty: Boolean\n}`;
2216
+ }
2217
+ function isEmptyOperationSchema(schema) {
2218
+ if (!schema) return false;
2219
+ return /_empty:\s*Boolean/.test(schema) && !schema.replace(/_empty:\s*Boolean/, "").match(/\w+:\s*\w+/);
2220
+ }
2221
+ function safeParseJsonRecord(json) {
2222
+ try {
2223
+ return JSON.parse(json);
2224
+ } catch (_error) {
2225
+ return null;
2226
+ }
2227
+ }
2228
+ function makeMinimalObjectForStateType(args) {
2229
+ const { sharedSchemaDocumentNode, stateTypeDefinitionNode, existingValue } = args;
2230
+ const existingValueObject = safeParseJsonRecord(existingValue);
2231
+ if (!existingValueObject) return existingValue;
2232
+ const stateTypeDefinitionFields = stateTypeDefinitionNode.fields;
2233
+ if (!stateTypeDefinitionFields?.length) return existingValue;
2234
+ const minimalObject = makeMinimalValuesForObjectFields({
2235
+ schemaDocumentNode: sharedSchemaDocumentNode,
2236
+ fieldDefinitionNodes: stateTypeDefinitionFields,
2237
+ existingValueObject,
2238
+ visitedTypes: /* @__PURE__ */ new Set([stateTypeDefinitionNode.name.value])
2239
+ });
2240
+ return JSON.stringify(minimalObject, null, 2);
2241
+ }
2242
+ function makeMinimalValuesForObjectFields(args) {
2243
+ const { schemaDocumentNode, existingValueObject, fieldDefinitionNodes, visitedTypes } = args;
2244
+ const newJson = {};
2245
+ for (const astNode of fieldDefinitionNodes) {
2246
+ const fieldName = getASTNodeName(astNode);
2247
+ if (!fieldName) continue;
2248
+ const minimalValue = makeMinimalValueForASTNode({
2249
+ fieldName,
2250
+ astNode,
2251
+ schemaDocumentNode,
2252
+ existingValueObject,
2253
+ visitedTypes
2254
+ });
2255
+ newJson[astNode.name.value] = minimalValue;
2256
+ }
2257
+ return newJson;
2258
+ }
2259
+ function makeMinimalValueForASTNode(args) {
2260
+ const { fieldName, astNode, schemaDocumentNode, existingValueObject, visitedTypes } = args;
2261
+ const existingFieldValue = existingValueObject?.[fieldName];
2262
+ let node = astNode;
2263
+ if (isFieldDefinitionNode(astNode)) node = getASTNodeTypeNode(node);
2264
+ const isNonNull = isNonNullNode(node);
2265
+ if (isNonNull) node = getASTNodeTypeNode(node);
2266
+ if (isListTypeNode(node)) return makeMinimalValueForGqlListNode(node, existingFieldValue, isNonNull, schemaDocumentNode, visitedTypes);
2267
+ if (isGqlPrimitiveNode(node)) return makeMinimalValueForGQLPrimitiveNode(node, existingFieldValue, isNonNull);
2268
+ const namedTypeDefinitionNode = getNamedTypeDefinitionNode(node, schemaDocumentNode);
2269
+ if (isEnumTypeDefinitionNode(namedTypeDefinitionNode)) return makeMinimalValueForGqlEnum(namedTypeDefinitionNode, existingFieldValue, isNonNull);
2270
+ if (isScalarTypeDefinitionNode(namedTypeDefinitionNode)) return makeMinimalValueForGqlScalar(namedTypeDefinitionNode, existingFieldValue, isNonNull);
2271
+ if (isUnionTypeDefinitionNode(namedTypeDefinitionNode)) return makeMinimalValueForGqlUnion(namedTypeDefinitionNode, existingFieldValue, schemaDocumentNode, existingValueObject, isNonNull, visitedTypes);
2272
+ if (isObjectTypeDefinitionNode(namedTypeDefinitionNode)) return makeMinimalValueForGqlObject(namedTypeDefinitionNode, schemaDocumentNode, existingValueObject, existingFieldValue, isNonNull, visitedTypes);
2273
+ return existingFieldValue;
2274
+ }
2275
+ function isFieldDefinitionNode(astNodeTypeNode) {
2276
+ if (!astNodeTypeNode) return false;
2277
+ return astNodeTypeNode.kind === import_graphql.Kind.FIELD_DEFINITION;
2278
+ }
2279
+ function isNonNullNode(astNode) {
2280
+ if (!astNode) return false;
2281
+ return astNode.kind === import_graphql.Kind.NON_NULL_TYPE;
2282
+ }
2283
+ function isGqlPrimitiveNode(astNodeTypeNode) {
2284
+ if (!astNodeTypeNode) return false;
2285
+ const name = getASTNodeName(astNodeTypeNode);
2286
+ return gqlPrimitiveNodeNamesList.includes(name);
2287
+ }
2288
+ function isListTypeNode(astNodeTypeNode) {
2289
+ if (!astNodeTypeNode) return false;
2290
+ return astNodeTypeNode.kind === import_graphql.Kind.LIST_TYPE;
2291
+ }
2292
+ function isEnumTypeDefinitionNode(definitionNode) {
2293
+ if (!definitionNode) return false;
2294
+ return definitionNode.kind === import_graphql.Kind.ENUM_TYPE_DEFINITION;
2295
+ }
2296
+ function isScalarTypeDefinitionNode(definitionNode) {
2297
+ if (!definitionNode) return false;
2298
+ return definitionNode.kind === import_graphql.Kind.SCALAR_TYPE_DEFINITION;
2299
+ }
2300
+ function isUnionTypeDefinitionNode(definitionNode) {
2301
+ if (!definitionNode) return false;
2302
+ return definitionNode.kind === import_graphql.Kind.UNION_TYPE_DEFINITION;
2303
+ }
2304
+ function isObjectTypeDefinitionNode(definitionNode) {
2305
+ if (!definitionNode) return false;
2306
+ return definitionNode.kind === import_graphql.Kind.OBJECT_TYPE_DEFINITION;
2307
+ }
2308
+ function getASTNodeName(astNode) {
2309
+ if (!astNode) return null;
2310
+ if (!("name" in astNode)) return null;
2311
+ if (!astNode.name) return null;
2312
+ if (!("value" in astNode.name)) return null;
2313
+ return astNode.name.value;
2314
+ }
2315
+ function getASTNodeTypeNode(astNode) {
2316
+ if (!astNode) return null;
2317
+ if (!("type" in astNode)) return null;
2318
+ return astNode.type;
2319
+ }
2320
+ function makeMinimalValueForGQLPrimitiveNode(primitiveTypeNode, existingFieldValue, isNonNull) {
2321
+ const name = getASTNodeName(primitiveTypeNode);
2322
+ if (!name) return null;
2323
+ switch (name) {
2324
+ case "ID":
2325
+ if (z.string().safeParse(existingFieldValue).success) return existingFieldValue;
2326
+ return isNonNull ? "placeholder-id" : null;
2327
+ case BOOLEAN_GQL_PRIMITIVE_NAME:
2328
+ if (z.boolean().safeParse(existingFieldValue).success) return existingFieldValue;
2329
+ return isNonNull ? false : null;
2330
+ case "Int":
2331
+ if (z.number().safeParse(existingFieldValue).success) return existingFieldValue;
2332
+ return isNonNull ? 0 : null;
2333
+ case FLOAT_GQL_PRIMITIVE_NAME:
2334
+ if (z.number().safeParse(existingFieldValue).success) return existingFieldValue;
2335
+ return isNonNull ? 0 : null;
2336
+ case STRING_GQL_PRIMITIVE_NAME:
2337
+ if (z.string().safeParse(existingFieldValue).success) return existingFieldValue;
2338
+ return isNonNull ? "" : null;
2339
+ }
2340
+ return isNonNull ? existingFieldValue : null;
2341
+ }
2342
+ function makeMinimalValueForGqlEnum(namedTypeDefinitionNode, existingFieldValue, isNonNull) {
2343
+ const enumValues = namedTypeDefinitionNode.values?.map((value) => value.name.value) ?? [];
2344
+ if (typeof existingFieldValue === "string" && enumValues.includes(existingFieldValue)) return existingFieldValue;
2345
+ if (isNonNull) return enumValues[0];
2346
+ return null;
2347
+ }
2348
+ function makeMinimalValueForGqlScalar(scalarTypeDefinitionNode, existingFieldValue, isNonNull) {
2349
+ if (!isNonNull && !existingFieldValue) return null;
2350
+ const name = getASTNodeName(scalarTypeDefinitionNode);
2351
+ if (!name) {
2352
+ console.error("No name for scalar type definition node", scalarTypeDefinitionNode);
2353
+ return null;
2354
+ }
2355
+ const scalar = getPHCustomScalarByTypeName(name);
2356
+ if (!scalar) return null;
2357
+ if (scalar.schema.safeParse(existingFieldValue).success) return existingFieldValue;
2358
+ if (!isNonNull) return null;
2359
+ const minimalValue = scalar.getDefaultValue?.();
2360
+ if (minimalValue) return minimalValue;
2361
+ return existingFieldValue;
2362
+ }
2363
+ function makeMinimalValueForGqlUnion(namedTypeDefinitionNode, existingFieldValue, schemaDocumentNode, existingValueObject, isNonNull, visitedTypes) {
2364
+ if (!isNonNull && !existingFieldValue) return null;
2365
+ if (!namedTypeDefinitionNode.types?.length) return null;
2366
+ const firstNamedTypeDefinitionNode = namedTypeDefinitionNode.types?.at(0);
2367
+ if (!firstNamedTypeDefinitionNode) return null;
2368
+ const firstNamedTypeObjectDefinitionNode = getNamedTypeDefinitionNode(firstNamedTypeDefinitionNode, schemaDocumentNode);
2369
+ if (!isObjectTypeDefinitionNode(firstNamedTypeObjectDefinitionNode)) return null;
2370
+ return makeMinimalValueForGqlObject(firstNamedTypeObjectDefinitionNode, schemaDocumentNode, existingValueObject, existingFieldValue, isNonNull, visitedTypes);
2371
+ }
2372
+ function makeMinimalValueForGqlListNode(listTypeNode, existingFieldValue, isNonNull, schemaDocumentNode, visitedTypes) {
2373
+ if (!isNonNull && !Array.isArray(existingFieldValue)) return null;
2374
+ if (isNonNull && !Array.isArray(existingFieldValue)) return [];
2375
+ return existingFieldValue.map((item, index) => makeMinimalValueForASTNode({
2376
+ fieldName: String(index),
2377
+ astNode: listTypeNode.type,
2378
+ schemaDocumentNode,
2379
+ existingValueObject: { [index]: item },
2380
+ visitedTypes
2381
+ }));
2382
+ }
2383
+ function makeMinimalValueForGqlObject(objectTypeDefinitionNode, schemaDocumentNode, _existingValueObject, existingFieldValue, isNonNull, visitedTypes) {
2384
+ const typeName = objectTypeDefinitionNode.name.value;
2385
+ if (visitedTypes?.has(typeName)) return null;
2386
+ if (!isNonNull && !existingFieldValue) return null;
2387
+ const fields = objectTypeDefinitionNode.fields;
2388
+ if (!fields?.length) return {};
2389
+ const newVisitedTypes = new Set(visitedTypes);
2390
+ newVisitedTypes.add(typeName);
2391
+ return makeMinimalValuesForObjectFields({
2392
+ schemaDocumentNode,
2393
+ existingValueObject: existingFieldValue && typeof existingFieldValue === "object" && !Array.isArray(existingFieldValue) ? existingFieldValue : null,
2394
+ fieldDefinitionNodes: fields,
2395
+ visitedTypes: newVisitedTypes
2396
+ });
2397
+ }
2398
+ function getNamedTypeDefinitionNode(astNodeTypeNode, schemaDocumentNode) {
2399
+ if (!astNodeTypeNode) return null;
2400
+ const name = getASTNodeName(astNodeTypeNode);
2401
+ if (!name) return null;
2402
+ const definitionNode = schemaDocumentNode.definitions.find((def) => "kind" in def && "name" in def && def.name?.value === name);
2403
+ if (!definitionNode) return null;
2404
+ return definitionNode;
2405
+ }
2406
+ function removeWhitespace(str) {
2407
+ return str.replace(/\s+|\\n|\\t/g, "").toLowerCase();
2408
+ }
2409
+ function compareStringsWithoutWhitespace(str1, str2) {
2410
+ if (str1 === null || str2 === null || str1 === void 0 || str2 === void 0) return false;
2411
+ return removeWhitespace(str1) === removeWhitespace(str2);
2412
+ }
2413
+ function renameSchemaType(sdl, oldName, newName, scope) {
2414
+ const typeSuffix = scope === "global" ? "State" : "LocalState";
2415
+ const oldTypeName = `${pascalCase(oldName)}${typeSuffix}`;
2416
+ const newTypeName = `${pascalCase(newName)}${typeSuffix}`;
2417
+ const ast = safeParseSdl(sdl);
2418
+ if (!ast) return sdl;
2419
+ const updatedAst = (0, import_graphql.visit)(ast, { ObjectTypeDefinition: (node) => {
2420
+ if (node.name.value === oldTypeName) return {
2421
+ ...node,
2422
+ name: {
2423
+ ...node.name,
2424
+ value: newTypeName
2425
+ }
2426
+ };
2427
+ } });
2428
+ return (0, import_graphql.print)(updatedAst);
2429
+ }
2430
+ function initializeModelSchema(modelName) {
2431
+ return makeInitialSchemaDoc(modelName, "global");
2432
+ }
2433
+ function updateModelSchemaNames(params) {
2434
+ const { oldName, newName, globalStateSchema, localStateSchema, setStateSchema } = params;
2435
+ setStateSchema(renameSchemaType(globalStateSchema, oldName, newName, "global"), "global");
2436
+ if (localStateSchema) setStateSchema(renameSchemaType(localStateSchema, oldName, newName, "local"), "local");
2437
+ }
2438
+ function handleModelNameChange(params) {
2439
+ const { newName, globalStateSchema, setStateSchema } = params;
2440
+ if (!!!globalStateSchema) {
2441
+ setStateSchema(initializeModelSchema(newName), "global");
2442
+ return;
2443
+ }
2444
+ updateModelSchemaNames(params);
2445
+ }
2446
+ function validateStateObject(sharedSchemaDocumentNode, stateTypeDefinitionNode, stateValue) {
2447
+ let stateObjectJson;
2448
+ try {
2449
+ stateObjectJson = JSON.parse(stateValue);
2450
+ } catch (error) {
2451
+ return [new Error("Invalid JSON object", { cause: error })];
2452
+ }
2453
+ const typeDefByName = indexTypeDefinitions(sharedSchemaDocumentNode);
2454
+ const stateTypeName = stateTypeDefinitionNode.name.value;
2455
+ if (!typeDefByName.has(stateTypeName)) return [/* @__PURE__ */ new Error(`State type "${stateTypeName}" was not found in sharedSchemaDocumentNode`)];
2456
+ const inputSuffix = "Input";
2457
+ const generatedInputDefs = generateInputTypesForObjectTree(stateTypeName, typeDefByName, inputSuffix);
2458
+ const augmentedDoc = {
2459
+ ...sharedSchemaDocumentNode,
2460
+ definitions: [...sharedSchemaDocumentNode.definitions, ...generatedInputDefs]
2461
+ };
2462
+ let schema;
2463
+ try {
2464
+ schema = (0, import_graphql.buildASTSchema)(augmentedDoc, { assumeValidSDL: false });
2465
+ } catch (e) {
2466
+ return [new Error("Failed to build schema from SDL", { cause: e })];
2467
+ }
2468
+ const inputTypeName = `${stateTypeName}${inputSuffix}`;
2469
+ const opDoc = (0, import_graphql.parse)(`query($v: ${inputTypeName}!) { __typename }`);
2470
+ const op = (0, import_graphql.getOperationAST)(opDoc);
2471
+ if (!op) return [/* @__PURE__ */ new Error("Failed to create validation operation AST")];
2472
+ const { errors } = (0, import_graphql.getVariableValues)(schema, op.variableDefinitions ?? [], { v: stateObjectJson });
2473
+ const recursiveTypeErrors = detectRecursiveTypes(stateTypeDefinitionNode, typeDefByName);
2474
+ const recursiveFieldNames = new Set(recursiveTypeErrors.map((e) => e.field));
2475
+ const validationErrors = errors ? graphQLErrorsToStateValidationErrors(errors).filter((e) => {
2476
+ if (e instanceof StateValidationError && e.kind === "NON_NULL") {
2477
+ const rootField = e.path[0];
2478
+ if (typeof rootField === "string" && recursiveFieldNames.has(rootField)) return false;
2479
+ }
2480
+ return true;
2481
+ }) : [];
2482
+ validationErrors.unshift(...recursiveTypeErrors);
2483
+ const missingOptionalErrors = detectMissingOptionalFields(sharedSchemaDocumentNode, stateTypeDefinitionNode, stateObjectJson);
2484
+ validationErrors.push(...missingOptionalErrors);
2485
+ return validationErrors;
2486
+ }
2487
+ /**
2488
+ * Indexes object/input/enum/scalar/interface/union type definition nodes by name.
2489
+ * Note: only AST definitions that have a "name" field are indexed.
2490
+ */
2491
+ function indexTypeDefinitions(doc) {
2492
+ const map = /* @__PURE__ */ new Map();
2493
+ for (const def of doc.definitions) if (def.kind === import_graphql.Kind.OBJECT_TYPE_DEFINITION || def.kind === import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION || def.kind === import_graphql.Kind.ENUM_TYPE_DEFINITION || def.kind === import_graphql.Kind.SCALAR_TYPE_DEFINITION || def.kind === import_graphql.Kind.INTERFACE_TYPE_DEFINITION || def.kind === import_graphql.Kind.UNION_TYPE_DEFINITION || def.kind === import_graphql.Kind.OBJECT_TYPE_EXTENSION || def.kind === import_graphql.Kind.INPUT_OBJECT_TYPE_EXTENSION || def.kind === import_graphql.Kind.ENUM_TYPE_EXTENSION || def.kind === import_graphql.Kind.INTERFACE_TYPE_EXTENSION || def.kind === import_graphql.Kind.UNION_TYPE_EXTENSION) {
2494
+ const name = def.name.value;
2495
+ if (!map.has(name)) map.set(name, def);
2496
+ }
2497
+ return map;
2498
+ }
2499
+ /**
2500
+ * Generates InputObjectTypeDefinitionNode(s) for a root object type and any nested
2501
+ * object types reachable via fields, converting object references to their *Input equivalents*.
2502
+ */
2503
+ function generateInputTypesForObjectTree(rootObjectTypeName, typeDefByName, inputSuffix) {
2504
+ const generated = /* @__PURE__ */ new Map();
2505
+ const visiting = /* @__PURE__ */ new Set();
2506
+ const ensureInputForObject = (objectTypeName) => {
2507
+ const inputName = `${objectTypeName}${inputSuffix}`;
2508
+ if (generated.has(inputName)) return;
2509
+ if (visiting.has(objectTypeName)) return;
2510
+ visiting.add(objectTypeName);
2511
+ const def = typeDefByName.get(objectTypeName);
2512
+ if (!def) throw new import_graphql.GraphQLError(`Unknown referenced type "${objectTypeName}"`);
2513
+ if (def.kind !== import_graphql.Kind.OBJECT_TYPE_DEFINITION && def.kind !== import_graphql.Kind.OBJECT_TYPE_EXTENSION) throw new import_graphql.GraphQLError(`Type "${objectTypeName}" is not an object type; cannot generate input from kind "${def.kind}"`);
2514
+ const objDef = def;
2515
+ const inputFields = objDef.fields?.map((f) => {
2516
+ return {
2517
+ kind: import_graphql.Kind.INPUT_VALUE_DEFINITION,
2518
+ name: f.name,
2519
+ description: f.description,
2520
+ directives: [],
2521
+ type: convertOutputTypeNodeToInputTypeNode(f.type, typeDefByName, inputSuffix, ensureInputForObject),
2522
+ defaultValue: void 0
2523
+ };
2524
+ }) ?? [];
2525
+ const inputDef = {
2526
+ kind: import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION,
2527
+ name: {
2528
+ kind: import_graphql.Kind.NAME,
2529
+ value: inputName
2530
+ },
2531
+ description: objDef.description,
2532
+ directives: [],
2533
+ fields: inputFields
2534
+ };
2535
+ generated.set(inputName, inputDef);
2536
+ visiting.delete(objectTypeName);
2537
+ };
2538
+ ensureInputForObject(rootObjectTypeName);
2539
+ return Array.from(generated.values());
2540
+ }
2541
+ function convertOutputTypeNodeToInputTypeNode(typeNode, typeDefByName, inputSuffix, ensureInputForObject) {
2542
+ switch (typeNode.kind) {
2543
+ case import_graphql.Kind.NON_NULL_TYPE: return {
2544
+ kind: import_graphql.Kind.NON_NULL_TYPE,
2545
+ type: convertOutputTypeNodeToInputTypeNode(typeNode.type, typeDefByName, inputSuffix, ensureInputForObject)
2546
+ };
2547
+ case import_graphql.Kind.LIST_TYPE: return {
2548
+ kind: import_graphql.Kind.LIST_TYPE,
2549
+ type: convertOutputTypeNodeToInputTypeNode(typeNode.type, typeDefByName, inputSuffix, ensureInputForObject)
2550
+ };
2551
+ case import_graphql.Kind.NAMED_TYPE: {
2552
+ const named = typeNode;
2553
+ const name = named.name.value;
2554
+ const def = typeDefByName.get(name);
2555
+ if (def?.kind === import_graphql.Kind.OBJECT_TYPE_DEFINITION || def?.kind === import_graphql.Kind.OBJECT_TYPE_EXTENSION) {
2556
+ ensureInputForObject(name);
2557
+ return {
2558
+ kind: import_graphql.Kind.NAMED_TYPE,
2559
+ name: {
2560
+ kind: import_graphql.Kind.NAME,
2561
+ value: `${name}${inputSuffix}`
2562
+ }
2563
+ };
2564
+ }
2565
+ if (!def || def.kind === import_graphql.Kind.SCALAR_TYPE_DEFINITION || def.kind === import_graphql.Kind.ENUM_TYPE_DEFINITION || def.kind === import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION || def.kind === import_graphql.Kind.INPUT_OBJECT_TYPE_EXTENSION) return named;
2566
+ if (def.kind === import_graphql.Kind.INTERFACE_TYPE_DEFINITION || def.kind === import_graphql.Kind.UNION_TYPE_DEFINITION) throw new import_graphql.GraphQLError(`Type "${name}" (${def.kind}) cannot be used in an input type`);
2567
+ throw new import_graphql.GraphQLError(`Unsupported named type "${name}" of kind "${def.kind}"`);
2568
+ }
2569
+ default: throw new import_graphql.GraphQLError(`Unsupported TypeNode kind: ${JSON.stringify(typeNode)}`);
2570
+ }
2571
+ }
2572
+ var StateValidationError = class extends Error {
2573
+ payload;
2574
+ originalMessage;
2575
+ constructor(payload, originalMessage) {
2576
+ super(payload.kind);
2577
+ this.name = "StateValidationError";
2578
+ this.payload = payload;
2579
+ this.originalMessage = originalMessage;
2580
+ Object.setPrototypeOf(this, new.target.prototype);
2581
+ }
2582
+ get kind() {
2583
+ return this.payload.kind;
2584
+ }
2585
+ get path() {
2586
+ return this.payload.path;
2587
+ }
2588
+ get field() {
2589
+ return this.payload.field;
2590
+ }
2591
+ };
2592
+ function extractInputPath(message) {
2593
+ const match = message.match(/at\s+"([^"]+)"/);
2594
+ if (!match) return [];
2595
+ const parts = match[1].split(".").filter(Boolean);
2596
+ return (parts[0] === "v" ? parts.slice(1) : parts).map((p) => /^\d+$/.test(p) ? Number(p) : p);
2597
+ }
2598
+ const RE_MISSING_REQUIRED_FIELD = /Field "([^"]+)" of required type "([^"]+)" was not provided\./;
2599
+ const RE_UNKNOWN_FIELD = /Field "([^"]+)" is not defined by type "([^"]+)"\.(?: Did you mean "([^"]+)"\?)?/;
2600
+ function extractMissingRequiredField(message) {
2601
+ const m = message.match(RE_MISSING_REQUIRED_FIELD);
2602
+ if (!m) return null;
2603
+ return {
2604
+ field: m[1],
2605
+ expectedType: m[2]
2606
+ };
2607
+ }
2608
+ function extractUnknownField(message) {
2609
+ const m = message.match(RE_UNKNOWN_FIELD);
2610
+ if (!m) return null;
2611
+ return {
2612
+ field: m[1],
2613
+ typeName: m[2],
2614
+ didYouMean: m[3]
2615
+ };
2616
+ }
2617
+ function lastFieldFromPath(path) {
2618
+ for (let i = path.length - 1; i >= 0; i--) if (typeof path[i] === "string") return path[i];
2619
+ }
2620
+ function extractExpectedType(message) {
2621
+ let m = message.match(/Expected non-nullable type "([^"]+)"/);
2622
+ if (m?.[1]) return m[1];
2623
+ m = message.match(/Expected type "([^"]+)"/);
2624
+ if (m?.[1]) return m[1];
2625
+ m = message.match(/;\s*([_A-Za-z][_0-9A-Za-z]*)\s+cannot represent/i);
2626
+ if (m?.[1]) return m[1];
2627
+ }
2628
+ function graphQLErrorsToStateValidationErrors(errors) {
2629
+ const out = [];
2630
+ for (const e of errors) {
2631
+ const originalMessage = e.message;
2632
+ const missing = extractMissingRequiredField(originalMessage);
2633
+ if (missing) {
2634
+ out.push(new StateValidationError({
2635
+ kind: "MISSING",
2636
+ path: [missing.field],
2637
+ field: missing.field,
2638
+ expectedType: missing.expectedType
2639
+ }, originalMessage));
2640
+ continue;
2641
+ }
2642
+ const unknown = extractUnknownField(originalMessage);
2643
+ if (unknown) {
2644
+ out.push(new StateValidationError({
2645
+ kind: "UNKNOWN_FIELD",
2646
+ path: [unknown.field],
2647
+ field: unknown.field,
2648
+ didYouMean: unknown.didYouMean
2649
+ }, originalMessage));
2650
+ continue;
2651
+ }
2652
+ const path = extractInputPath(originalMessage);
2653
+ const field = lastFieldFromPath(path) ?? "value";
2654
+ const expectedType = extractExpectedType(originalMessage);
2655
+ if (originalMessage.includes("Expected non-nullable type") && originalMessage.includes("not to be null")) {
2656
+ out.push(new StateValidationError({
2657
+ kind: "NON_NULL",
2658
+ path,
2659
+ field,
2660
+ expectedType
2661
+ }, originalMessage));
2662
+ continue;
2663
+ }
2664
+ if (originalMessage.includes("cannot represent") || originalMessage.includes("Expected type")) {
2665
+ out.push(new StateValidationError({
2666
+ kind: "TYPE",
2667
+ path,
2668
+ field,
2669
+ expectedType,
2670
+ details: originalMessage
2671
+ }, originalMessage));
2672
+ continue;
2673
+ }
2674
+ out.push(new StateValidationError({
2675
+ kind: "TYPE",
2676
+ path,
2677
+ field,
2678
+ details: originalMessage
2679
+ }, originalMessage));
2680
+ }
2681
+ return out;
2682
+ }
2683
+ /**
2684
+ * Finds all fields defined in the schema that are missing from the state object.
2685
+ * Returns information about each missing field including whether it's required.
2686
+ */
2687
+ function findMissingFields(sharedSchemaDocumentNode, rootTypeNode, value, basePath = []) {
2688
+ let stateObjectJson;
2689
+ try {
2690
+ stateObjectJson = typeof value === "string" ? JSON.parse(value) : value;
2691
+ } catch {
2692
+ return [];
2693
+ }
2694
+ const typeByName = indexObjectTypes(sharedSchemaDocumentNode);
2695
+ const missingFields = [];
2696
+ for (const field of rootTypeNode.fields ?? []) {
2697
+ const fieldName = field.name.value;
2698
+ const fieldPath = [...basePath, fieldName];
2699
+ const isRequired = field.type.kind === import_graphql.Kind.NON_NULL_TYPE;
2700
+ const underlyingType = isRequired ? field.type.type : field.type;
2701
+ if (!(fieldName in stateObjectJson)) {
2702
+ missingFields.push({
2703
+ fieldName,
2704
+ path: fieldPath,
2705
+ isRequired,
2706
+ type: underlyingType
2707
+ });
2708
+ continue;
2709
+ }
2710
+ const namedType = unwrapNamedType(field.type);
2711
+ const childType = namedType ? typeByName.get(namedType) : void 0;
2712
+ if (childType && typeof stateObjectJson[fieldName] === "object" && stateObjectJson[fieldName] !== null && !Array.isArray(stateObjectJson[fieldName])) {
2713
+ const nestedMissing = findMissingFields(sharedSchemaDocumentNode, childType, stateObjectJson[fieldName], fieldPath);
2714
+ missingFields.push(...nestedMissing);
2715
+ }
2716
+ }
2717
+ return missingFields;
2718
+ }
2719
+ /**
2720
+ * Detects optional fields defined in the schema that are missing from the state object.
2721
+ * Returns StateValidationError[] for each missing optional field.
2722
+ */
2723
+ function detectMissingOptionalFields(sharedSchemaDocumentNode, rootTypeNode, value) {
2724
+ return findMissingFields(sharedSchemaDocumentNode, rootTypeNode, value).filter((field) => !field.isRequired).map((field) => new StateValidationError({
2725
+ kind: "MISSING_OPTIONAL",
2726
+ path: field.path,
2727
+ field: field.fieldName,
2728
+ expectedType: typeNodeToString(field.type)
2729
+ }));
2730
+ }
2731
+ /**
2732
+ * Detects fields that have recursive types (types that reference themselves directly or indirectly).
2733
+ * Returns a RECURSIVE_TYPE error for each field that contains a recursive type.
2734
+ */
2735
+ function detectRecursiveTypes(stateTypeDefinitionNode, typeDefByName) {
2736
+ const errors = [];
2737
+ for (const field of stateTypeDefinitionNode.fields ?? []) {
2738
+ const fieldName = field.name.value;
2739
+ const namedTypeName = getNamedTypeName(field.type);
2740
+ if (!namedTypeName) continue;
2741
+ if (isRecursiveType(namedTypeName, typeDefByName, /* @__PURE__ */ new Set())) errors.push(new StateValidationError({
2742
+ kind: "RECURSIVE_TYPE",
2743
+ path: [fieldName],
2744
+ field: fieldName,
2745
+ typeName: namedTypeName
2746
+ }));
2747
+ }
2748
+ return errors;
2749
+ }
2750
+ /**
2751
+ * Gets the named type name from a TypeNode, unwrapping NonNull and List types.
2752
+ */
2753
+ function getNamedTypeName(typeNode) {
2754
+ if (typeNode.kind === import_graphql.Kind.NAMED_TYPE) return typeNode.name.value;
2755
+ if (typeNode.kind === import_graphql.Kind.NON_NULL_TYPE || typeNode.kind === import_graphql.Kind.LIST_TYPE) return getNamedTypeName(typeNode.type);
2756
+ return null;
2757
+ }
2758
+ /**
2759
+ * Checks if a type is recursive (references itself directly or indirectly through required fields).
2760
+ */
2761
+ function isRecursiveType(typeName, typeDefByName, visitedTypes) {
2762
+ if (visitedTypes.has(typeName)) return true;
2763
+ const typeDef = typeDefByName.get(typeName);
2764
+ if (!typeDef || typeDef.kind !== import_graphql.Kind.OBJECT_TYPE_DEFINITION) return false;
2765
+ visitedTypes.add(typeName);
2766
+ for (const field of typeDef.fields ?? []) {
2767
+ if (field.type.kind !== import_graphql.Kind.NON_NULL_TYPE) continue;
2768
+ const innerType = field.type.type;
2769
+ let fieldTypeName = null;
2770
+ if (innerType.kind === import_graphql.Kind.NAMED_TYPE) fieldTypeName = innerType.name.value;
2771
+ else if (innerType.kind === import_graphql.Kind.LIST_TYPE) fieldTypeName = getNamedTypeName(innerType);
2772
+ if (fieldTypeName && isRecursiveType(fieldTypeName, typeDefByName, visitedTypes)) return true;
2773
+ }
2774
+ visitedTypes.delete(typeName);
2775
+ return false;
2776
+ }
2777
+ /**
2778
+ * Converts a TypeNode to its string representation (e.g., "String", "Int!", "[String]!")
2779
+ */
2780
+ function typeNodeToString(typeNode) {
2781
+ switch (typeNode.kind) {
2782
+ case import_graphql.Kind.NAMED_TYPE: return typeNode.name.value;
2783
+ case import_graphql.Kind.NON_NULL_TYPE: return `${typeNodeToString(typeNode.type)}!`;
2784
+ case import_graphql.Kind.LIST_TYPE: return `[${typeNodeToString(typeNode.type)}]`;
2785
+ }
2786
+ }
2787
+ function indexObjectTypes(doc) {
2788
+ const map = /* @__PURE__ */ new Map();
2789
+ for (const def of doc.definitions) if (def.kind === import_graphql.Kind.OBJECT_TYPE_DEFINITION) map.set(def.name.value, def);
2790
+ return map;
2791
+ }
2792
+ function unwrapNamedType(typeNode) {
2793
+ if (typeNode.kind === import_graphql.Kind.NAMED_TYPE) return typeNode.name.value;
2794
+ if (typeNode.kind === import_graphql.Kind.NON_NULL_TYPE) return unwrapNamedType(typeNode.type);
2795
+ if (typeNode.kind === import_graphql.Kind.LIST_TYPE) return unwrapNamedType(typeNode.type);
2796
+ }
2797
+ //#endregion
2798
+ //#region editors/document-model-editor/utils/linting.ts
2799
+ function ensureDocumentContainsNodeWithNameAndType(doc, nodeName, nodeType) {
2800
+ const parsedDoc = safeParseSdl(doc);
2801
+ if (!parsedDoc) return true;
2802
+ return parsedDoc.definitions.some((def) => {
2803
+ return def.kind === import_graphql.Kind[nodeType] && "name" in def && def.name?.value === nodeName;
2804
+ });
2805
+ }
2806
+ function createNodeTypeAndNameDiagnostic(doc, errorMessage) {
2807
+ const parsedDoc = safeParseSdl(doc);
2808
+ if (!parsedDoc) return void 0;
2809
+ const firstNode = parsedDoc.definitions[0];
2810
+ const nameNode = "name" in firstNode ? firstNode.name : null;
2811
+ return {
2812
+ from: nameNode?.loc?.start ?? firstNode.loc?.start ?? 0,
2813
+ to: nameNode?.loc?.end ?? firstNode.loc?.end ?? 0,
2814
+ severity: "error",
2815
+ message: errorMessage
2816
+ };
2817
+ }
2818
+ function ensureValidStateSchemaName(doc, modelName, scope) {
2819
+ if (!safeParseSdl(doc)) return [];
2820
+ const requiredTypeName = makeStateSchemaNameForScope(modelName, scope);
2821
+ if (!ensureDocumentContainsNodeWithNameAndType(doc, requiredTypeName, "OBJECT_TYPE_DEFINITION")) return [createNodeTypeAndNameDiagnostic(doc, `${sentenceCase(scope)} state schema must be named ${requiredTypeName}`)].filter((d) => d !== void 0);
2822
+ return [];
2823
+ }
2824
+ function ensureValidOperationSchemaInputName(doc, operationName) {
2825
+ if (!doc || !safeParseSdl(doc)) return [];
2826
+ const requiredTypeName = `${pascalCase(operationName)}Input`;
2827
+ if (!ensureDocumentContainsNodeWithNameAndType(doc, requiredTypeName, "INPUT_OBJECT_TYPE_DEFINITION")) return [createNodeTypeAndNameDiagnostic(doc, `Operation schema must contain an input type named ${requiredTypeName}`)].filter((d) => d !== void 0);
2828
+ return [];
2829
+ }
2830
+ //#endregion
2831
+ //#region editors/document-model-editor/components/button.tsx
2832
+ const Button = forwardRef((props, ref) => {
2833
+ const { className, ...rest } = props;
2834
+ return /* @__PURE__ */ jsx("button", {
2835
+ ref,
2836
+ ...rest,
2837
+ className: twMerge("h-10 rounded-md border border-border bg-background px-4 py-2 text-sm font-medium whitespace-nowrap text-foreground transition-colors hover:hover-effect focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:disabled-effect", className)
2838
+ });
2839
+ });
2840
+ //#endregion
1936
2841
  //#region editors/document-model-editor/components/divider.tsx
1937
2842
  function Divider({ className, size = "sm", margin = "md" }) {
1938
2843
  function getSize() {
@@ -1945,7 +2850,9 @@ function Divider({ className, size = "sm", margin = "md" }) {
1945
2850
  if (margin === "md") return "my-6";
1946
2851
  return "my-8";
1947
2852
  }
1948
- return /* @__PURE__ */ jsx("div", { className: twMerge("bg-secondary", getSize(), getMargin(), className) });
2853
+ const sizeClass = getSize();
2854
+ const marginClass = getMargin();
2855
+ return /* @__PURE__ */ jsx("div", { className: twMerge("bg-secondary", sizeClass, marginClass, className) });
1949
2856
  }
1950
2857
  //#endregion
1951
2858
  //#region ../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.71.2_react@19.2.6_/node_modules/@hookform/resolvers/dist/resolvers.mjs
@@ -1954,12 +2861,14 @@ const r = (t, r, o) => {
1954
2861
  const s = get(o, r);
1955
2862
  t.setCustomValidity(s && s.message || ""), t.reportValidity();
1956
2863
  }
1957
- }, o = (e, t) => {
2864
+ };
2865
+ const o = (e, t) => {
1958
2866
  for (const o in t.fields) {
1959
2867
  const s = t.fields[o];
1960
2868
  s && s.ref && "reportValidity" in s.ref ? r(s.ref, o, e) : s && s.refs && s.refs.forEach((t) => r(t, o, e));
1961
2869
  }
1962
- }, s$1 = (r, s) => {
2870
+ };
2871
+ const s$1 = (r, s) => {
1963
2872
  s.shouldUseNativeValidation && o(r, s);
1964
2873
  const n = {};
1965
2874
  for (const o in r) {
@@ -1970,7 +2879,8 @@ const r = (t, r, o) => {
1970
2879
  } else set(n, o, c);
1971
2880
  }
1972
2881
  return n;
1973
- }, i$1 = (e, t) => {
2882
+ };
2883
+ const i$1 = (e, t) => {
1974
2884
  const r = n$1(t);
1975
2885
  return e.some((e) => n$1(e).match(`^${r}\\.\\d+`));
1976
2886
  };
@@ -2401,32 +3311,38 @@ function ModelMetadata(props) {
2401
3311
  }
2402
3312
  function ModelNameForm(props) {
2403
3313
  const { name, globalStateSchema, localStateSchema, setModelName, setStateSchema } = props;
3314
+ const onSubmit = useCallback((newName) => {
3315
+ if (name === newName) return;
3316
+ setModelName(newName);
3317
+ if (!!!globalStateSchema) {
3318
+ const initialSchemaDoc = makeInitialSchemaDoc(newName, "global");
3319
+ setStateSchema(initialSchemaDoc, "global");
3320
+ return;
3321
+ }
3322
+ const newSchema = renameSchemaType(globalStateSchema, name, newName, "global");
3323
+ setStateSchema(newSchema, "global");
3324
+ if (localStateSchema) {
3325
+ const newLocalStateSchema = renameSchemaType(localStateSchema, name, newName, "local");
3326
+ setStateSchema(newLocalStateSchema, "local");
3327
+ }
3328
+ handleModelNameChange({
3329
+ oldName: name,
3330
+ newName,
3331
+ globalStateSchema,
3332
+ localStateSchema,
3333
+ setStateSchema
3334
+ });
3335
+ }, [
3336
+ name,
3337
+ globalStateSchema,
3338
+ localStateSchema,
3339
+ setStateSchema,
3340
+ setModelName
3341
+ ]);
2404
3342
  return /* @__PURE__ */ jsx(TextField, {
2405
3343
  name: "name",
2406
3344
  value: name,
2407
- onSubmit: useCallback((newName) => {
2408
- if (name === newName) return;
2409
- setModelName(newName);
2410
- if (!!!globalStateSchema) {
2411
- setStateSchema(makeInitialSchemaDoc(newName, "global"), "global");
2412
- return;
2413
- }
2414
- setStateSchema(renameSchemaType(globalStateSchema, name, newName, "global"), "global");
2415
- if (localStateSchema) setStateSchema(renameSchemaType(localStateSchema, name, newName, "local"), "local");
2416
- handleModelNameChange({
2417
- oldName: name,
2418
- newName,
2419
- globalStateSchema,
2420
- localStateSchema,
2421
- setStateSchema
2422
- });
2423
- }, [
2424
- name,
2425
- globalStateSchema,
2426
- localStateSchema,
2427
- setStateSchema,
2428
- setModelName
2429
- ]),
3345
+ onSubmit,
2430
3346
  placeholder: "Model name",
2431
3347
  className: "border-none pl-0 text-xl font-bold text-foreground",
2432
3348
  required: true,
@@ -2627,7 +3543,7 @@ function OperationErrors({ operation, addOperationError, deleteOperationError, s
2627
3543
  }
2628
3544
  //#endregion
2629
3545
  //#region editors/document-model-editor/components/operation.tsx
2630
- const GraphqlEditor = lazy(() => import("./graphql-editor-BhF6KN6y.mjs"));
3546
+ const GraphqlEditor = lazy(() => import("./graphql-editor-CBJXEY_C.mjs"));
2631
3547
  function Operation(props) {
2632
3548
  const { operation, module, allOperationNames, lastCreatedOperationId, onAddOperationAndInitialSchema, updateOperationName, deleteOperation, updateOperationSchema, setOperationDescription, addOperationError, deleteOperationError, setOperationErrorName, toggleNoInputRequired } = props;
2633
3549
  const noInputRequired = isEmptyOperationSchema(operation.schema);
@@ -3069,7 +3985,6 @@ function useSelectedDocumentModelDocument() {
3069
3985
  }
3070
3986
  //#endregion
3071
3987
  //#region editors/document-model-editor/utils/change-classification.ts
3072
- var import_graphql = require_graphql();
3073
3988
  function isShapeTypeNode(node) {
3074
3989
  return node.kind === import_graphql.Kind.OBJECT_TYPE_DEFINITION || node.kind === import_graphql.Kind.INPUT_OBJECT_TYPE_DEFINITION || node.kind === import_graphql.Kind.ENUM_TYPE_DEFINITION;
3075
3990
  }
@@ -3364,7 +4279,8 @@ function useVersionAdvisory(args) {
3364
4279
  }
3365
4280
  //#endregion
3366
4281
  //#region editors/document-model-editor/editor.tsx
3367
- const StateSchemas = lazy(() => import("./state-schemas-DXG02fMh.mjs"));
4282
+ var editor_exports = /* @__PURE__ */ __exportAll({ default: () => Editor });
4283
+ const StateSchemas = lazy(() => import("./state-schemas-BHuo0GPl.mjs"));
3368
4284
  const noopSetStateSchema = () => void 0;
3369
4285
  const noopSetInitialState = () => void 0;
3370
4286
  function Editor() {
@@ -3388,10 +4304,11 @@ function Editor() {
3388
4304
  useEffect(() => {
3389
4305
  if (!shouldSetInitialName.current || !documentNodeName) return;
3390
4306
  const initialSchemaDoc = initializeModelSchema(documentNodeName);
3391
- dispatch([setModelName({ name: documentNodeName }), setStateSchema({
4307
+ const actions = [setModelName({ name: documentNodeName }), setStateSchema({
3392
4308
  schema: initialSchemaDoc,
3393
4309
  scope: "global"
3394
- })]);
4310
+ })];
4311
+ dispatch(actions);
3395
4312
  shouldSetInitialName.current = false;
3396
4313
  }, [documentNodeName, dispatch]);
3397
4314
  const { guardedDispatch, prompt, releaseFirst, keepEditing, cancelAdvisory, markVersionInDevelopment } = useVersionAdvisory({
@@ -3542,11 +4459,12 @@ function Editor() {
3542
4459
  return;
3543
4460
  }
3544
4461
  const id = generateId();
4462
+ const errorCode = pascalCase(errorName);
3545
4463
  guardedDispatch(addOperationError({
3546
4464
  id,
3547
4465
  operationId,
3548
4466
  errorName,
3549
- errorCode: pascalCase(errorName)
4467
+ errorCode
3550
4468
  }));
3551
4469
  resolve(id);
3552
4470
  } catch (error) {
@@ -3674,6 +4592,6 @@ function Editor() {
3674
4592
  });
3675
4593
  }
3676
4594
  //#endregion
3677
- export { Editor as default };
4595
+ export { makeInitialSchemaDoc as a, validateStateObject as c, Editor as default, StateValidationError as i, Button as n, makeMinimalObjectForStateType as o, ensureValidStateSchemaName as r, makeStateSchemaNameForScope as s, editor_exports as t };
3678
4596
 
3679
- //# sourceMappingURL=editor-BiiLqEe9.mjs.map
4597
+ //# sourceMappingURL=editor-96sMeumV.mjs.map