@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,17 +1,217 @@
1
- import { c as Kind, t as parse } from "./parser-BBzK7bLd.js";
2
- import { mt as print } from "./documents-C-lAnv6o.js";
3
- 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-sZQCXeCo.js";
4
- import { a as Slot, i as Primitive, t as Modal } from "./src-CVV6HzQZ-D-OQvEkh.js";
5
- import { h as twMerge } from "./dist-D3_ER0Dn.js";
6
- import { t as SchemaContextProvider } from "./schema-context-p2bhyog_.js";
1
+ import { n as __exportAll } from "./rolldown-runtime-DC62tzP2.js";
2
+ import { c as Kind, p as GraphQLError, t as parse } from "./parser-DtbeHA3H.js";
3
+ import { a as printSchema, gt as visit, mt as print, n as initialSchemaStr, o as buildASTSchema, r as typeDefsDoc, t as hiddenQueryTypeDefDoc, y as getVariableValues } from "./documents-CRzouuNR.js";
4
+ import { i as Primitive, m as twMerge, t as Modal } from "./src-CrUksCLW-B2dkRdgq.js";
7
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";
8
6
  import { z } from "zod";
9
7
  import * as React$1 from "react";
10
- import React, { Suspense, forwardRef, lazy, useCallback, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
8
+ import React, { Suspense, createContext, forwardRef, lazy, useCallback, useContext, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
11
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
10
  import { ConnectSelect, DocumentToolbar, ModalButton } from "@powerhousedao/design-system/connect";
13
11
  import { usePHToast, useSelectedDocumentOfType, useSetPHDocumentEditorConfig } from "@powerhousedao/reactor-browser";
12
+ import { getPHCustomScalarByTypeName } from "@powerhousedao/document-engineering/graphql";
14
13
  import * as n from "zod/v4/core";
14
+ //#region ../../node_modules/.pnpm/graphql@16.12.0/node_modules/graphql/utilities/getOperationAST.mjs
15
+ /**
16
+ * Returns an operation AST given a document AST and optionally an operation
17
+ * name. If a name is not provided, an operation is only returned if only one is
18
+ * provided in the document.
19
+ */
20
+ function getOperationAST(documentAST, operationName) {
21
+ let operation = null;
22
+ for (const definition of documentAST.definitions) if (definition.kind === Kind.OPERATION_DEFINITION) {
23
+ var _definition$name;
24
+ if (operationName == null) {
25
+ if (operation) return null;
26
+ operation = definition;
27
+ } else if (((_definition$name = definition.name) === null || _definition$name === void 0 ? void 0 : _definition$name.value) === operationName) return definition;
28
+ }
29
+ return operation;
30
+ }
31
+ //#endregion
32
+ //#region editors/document-model-editor/context/schema-context.tsx
33
+ const hiddenQueryTypeDefinitions = safeParseSdl(hiddenQueryTypeDefDoc)?.definitions ?? [];
34
+ const standardLibCustomScalarDefinitions = safeParseSdl(typeDefsDoc)?.definitions ?? [];
35
+ const alwaysIncludedDefinitions = [...hiddenQueryTypeDefinitions, ...standardLibCustomScalarDefinitions];
36
+ function makeSharedSchemaSdl(globalStateSchemaSdl, localStateSchemaSdl, operationSchemasSdl) {
37
+ const definitions = [...alwaysIncludedDefinitions];
38
+ for (const sdl of [
39
+ globalStateSchemaSdl,
40
+ localStateSchemaSdl,
41
+ operationSchemasSdl
42
+ ]) {
43
+ if (!sdl) continue;
44
+ const ast = safeParseSdl(sdl);
45
+ if (!ast) continue;
46
+ definitions.push(...ast.definitions);
47
+ }
48
+ const documentNode = {
49
+ kind: Kind.DOCUMENT,
50
+ definitions
51
+ };
52
+ return printSchema(buildASTSchema(documentNode));
53
+ }
54
+ function safeParseSdl(sdl) {
55
+ try {
56
+ if (!sdl) return null;
57
+ return parse(sdl);
58
+ } catch (_error) {
59
+ return null;
60
+ }
61
+ }
62
+ const SchemaContext = createContext({
63
+ sharedSchema: initialSchemaStr,
64
+ error: void 0
65
+ });
66
+ function parseSharedSchemaSdl(globalStateSchemaSdl, localStateSchemaSdl, operationSchemasSdl) {
67
+ try {
68
+ return {
69
+ sharedSchema: makeSharedSchemaSdl(globalStateSchemaSdl, localStateSchemaSdl, operationSchemasSdl),
70
+ error: void 0
71
+ };
72
+ } catch (error) {
73
+ return {
74
+ sharedSchema: initialSchemaStr,
75
+ error: error instanceof Error ? error : new Error(typeof error === "string" ? error : JSON.stringify(error), { cause: error })
76
+ };
77
+ }
78
+ }
79
+ function SchemaContextProvider(props) {
80
+ const { children, globalStateSchemaSdl, localStateSchemaSdl, operationSchemasSdl } = props;
81
+ const sharedSchemaSdl = useMemo(() => parseSharedSchemaSdl(globalStateSchemaSdl, localStateSchemaSdl, operationSchemasSdl), [
82
+ globalStateSchemaSdl,
83
+ localStateSchemaSdl,
84
+ operationSchemasSdl
85
+ ]);
86
+ return /* @__PURE__ */ jsx(SchemaContext.Provider, {
87
+ value: sharedSchemaSdl,
88
+ children
89
+ });
90
+ }
91
+ function useSchemaContext() {
92
+ return useContext(SchemaContext);
93
+ }
94
+ //#endregion
95
+ //#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
96
+ function setRef(ref, value) {
97
+ if (typeof ref === "function") return ref(value);
98
+ else if (ref !== null && ref !== void 0) ref.current = value;
99
+ }
100
+ function composeRefs(...refs) {
101
+ return (node) => {
102
+ let hasCleanup = false;
103
+ const cleanups = refs.map((ref) => {
104
+ const cleanup = setRef(ref, node);
105
+ if (!hasCleanup && typeof cleanup == "function") hasCleanup = true;
106
+ return cleanup;
107
+ });
108
+ if (hasCleanup) return () => {
109
+ for (let i = 0; i < cleanups.length; i++) {
110
+ const cleanup = cleanups[i];
111
+ if (typeof cleanup == "function") cleanup();
112
+ else setRef(refs[i], null);
113
+ }
114
+ };
115
+ };
116
+ }
117
+ function useComposedRefs(...refs) {
118
+ return React$1.useCallback(composeRefs(...refs), refs);
119
+ }
120
+ //#endregion
121
+ //#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
122
+ // @__NO_SIDE_EFFECTS__
123
+ function createSlot(ownerName) {
124
+ const Slot2 = React$1.forwardRef((props, forwardedRef) => {
125
+ let { children, ...slotProps } = props;
126
+ let slottableElement = null;
127
+ let hasSlottable = false;
128
+ const newChildren = [];
129
+ if (isLazyComponent(children) && typeof use === "function") children = use(children._payload);
130
+ React$1.Children.forEach(children, (maybeSlottable) => {
131
+ if (isSlottable(maybeSlottable)) {
132
+ hasSlottable = true;
133
+ const slottable = maybeSlottable;
134
+ let child = "child" in slottable.props ? slottable.props.child : slottable.props.children;
135
+ if (isLazyComponent(child) && typeof use === "function") child = use(child._payload);
136
+ slottableElement = getSlottableElementFromSlottable(slottable, child);
137
+ newChildren.push(slottableElement?.props?.children);
138
+ } else newChildren.push(maybeSlottable);
139
+ });
140
+ if (slottableElement) slottableElement = React$1.cloneElement(slottableElement, void 0, newChildren);
141
+ else if (!hasSlottable && React$1.Children.count(children) === 1 && React$1.isValidElement(children)) slottableElement = children;
142
+ const slottableElementRef = slottableElement ? getElementRef(slottableElement) : void 0;
143
+ const composedRef = useComposedRefs(forwardedRef, slottableElementRef);
144
+ if (!slottableElement) {
145
+ if (children || children === 0) throw new Error(hasSlottable ? createSlottableError(ownerName) : createSlotError(ownerName));
146
+ return children;
147
+ }
148
+ const mergedProps = mergeProps(slotProps, slottableElement.props ?? {});
149
+ if (slottableElement.type !== React$1.Fragment) mergedProps.ref = forwardedRef ? composedRef : slottableElementRef;
150
+ return React$1.cloneElement(slottableElement, mergedProps);
151
+ });
152
+ Slot2.displayName = `${ownerName}.Slot`;
153
+ return Slot2;
154
+ }
155
+ var Slot = /* @__PURE__ */ createSlot("Slot");
156
+ var SLOTTABLE_IDENTIFIER = Symbol.for("radix.slottable");
157
+ var getSlottableElementFromSlottable = (slottable, child) => {
158
+ if ("child" in slottable.props) {
159
+ const child2 = slottable.props.child;
160
+ if (!React$1.isValidElement(child2)) return null;
161
+ return React$1.cloneElement(child2, void 0, slottable.props.children(child2.props.children));
162
+ }
163
+ return React$1.isValidElement(child) ? child : null;
164
+ };
165
+ function mergeProps(slotProps, childProps) {
166
+ const overrideProps = { ...childProps };
167
+ for (const propName in childProps) {
168
+ const slotPropValue = slotProps[propName];
169
+ const childPropValue = childProps[propName];
170
+ if (/^on[A-Z]/.test(propName)) {
171
+ if (slotPropValue && childPropValue) overrideProps[propName] = (...args) => {
172
+ const result = childPropValue(...args);
173
+ slotPropValue(...args);
174
+ return result;
175
+ };
176
+ else if (slotPropValue) overrideProps[propName] = slotPropValue;
177
+ } else if (propName === "style") overrideProps[propName] = {
178
+ ...slotPropValue,
179
+ ...childPropValue
180
+ };
181
+ else if (propName === "className") overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
182
+ }
183
+ return {
184
+ ...slotProps,
185
+ ...overrideProps
186
+ };
187
+ }
188
+ function getElementRef(element) {
189
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
190
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
191
+ if (mayWarn) return element.ref;
192
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
193
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
194
+ if (mayWarn) return element.props.ref;
195
+ return element.props.ref || element.ref;
196
+ }
197
+ function isSlottable(child) {
198
+ return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
199
+ }
200
+ var REACT_LAZY_TYPE = Symbol.for("react.lazy");
201
+ function isLazyComponent(element) {
202
+ return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
203
+ }
204
+ function isPromiseLike(value) {
205
+ return typeof value === "object" && value !== null && "then" in value;
206
+ }
207
+ var createSlotError = (ownerName) => {
208
+ return `${ownerName} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`;
209
+ };
210
+ var createSlottableError = (ownerName) => {
211
+ return `${ownerName} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`;
212
+ };
213
+ var use = React$1[" use ".trim().toString()];
214
+ //#endregion
15
215
  //#region ../../node_modules/.pnpm/clsx@2.0.0/node_modules/clsx/dist/clsx.mjs
16
216
  function r$1(e) {
17
217
  var t, f, n = "";
@@ -46,7 +246,7 @@ const cva = (base, config) => {
46
246
  acc[key] = value;
47
247
  return acc;
48
248
  }, {});
49
- return cx(base, getVariantClassNames, config === null || config === void 0 ? void 0 : (ref = config.compoundVariants) === null || ref === void 0 ? void 0 : ref.reduce((acc, param1) => {
249
+ const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (ref = config.compoundVariants) === null || ref === void 0 ? void 0 : ref.reduce((acc, param1) => {
50
250
  let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param1;
51
251
  return Object.entries(compoundVariantOptions).every((param) => {
52
252
  let [key, value] = param;
@@ -62,7 +262,8 @@ const cva = (base, config) => {
62
262
  cvClass,
63
263
  cvClassName
64
264
  ] : acc;
65
- }, []), props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
265
+ }, []);
266
+ return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
66
267
  };
67
268
  };
68
269
  //#endregion
@@ -743,9 +944,10 @@ function getDirtyFields(data, formValues, dirtyFieldsFromValues) {
743
944
  if (!dirtyFieldsFromValues) dirtyFieldsFromValues = markFieldsDirty(formValues);
744
945
  for (const key in data) {
745
946
  const value = data[key];
746
- if (isTraversable(value)) if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});
747
- else getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
748
- else {
947
+ if (isTraversable(value)) {
948
+ if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});
949
+ else getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
950
+ } else {
749
951
  const formValue = formValues[key];
750
952
  dirtyFieldsFromValues[key] = !deepEqual(value, formValue);
751
953
  }
@@ -1265,12 +1467,15 @@ function createFormControl(props = {}) {
1265
1467
  !fieldReference.disabled && set(_formValues, name, getFieldValueAs(value, fieldReference));
1266
1468
  fieldValue = isHTMLElement(fieldReference.ref) && isNullOrUndefined(value) ? "" : value;
1267
1469
  if (isMultipleSelect(fieldReference.ref)) [...fieldReference.ref.options].forEach((optionRef) => optionRef.selected = fieldValue.includes(optionRef.value));
1268
- else if (fieldReference.refs) if (isCheckBoxInput(fieldReference.ref)) fieldReference.refs.forEach((checkboxRef) => {
1269
- if (!checkboxRef.defaultChecked || !checkboxRef.disabled) if (Array.isArray(fieldValue)) checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
1270
- else checkboxRef.checked = fieldValue === checkboxRef.value || !!fieldValue;
1271
- });
1272
- else fieldReference.refs.forEach((radioRef) => radioRef.checked = radioRef.value === fieldValue);
1273
- else if (isFileInput(fieldReference.ref)) fieldReference.ref.value = "";
1470
+ else if (fieldReference.refs) {
1471
+ if (isCheckBoxInput(fieldReference.ref)) fieldReference.refs.forEach((checkboxRef) => {
1472
+ if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {
1473
+ if (Array.isArray(fieldValue)) checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);
1474
+ else checkboxRef.checked = fieldValue === checkboxRef.value || !!fieldValue;
1475
+ }
1476
+ });
1477
+ else fieldReference.refs.forEach((radioRef) => radioRef.checked = radioRef.value === fieldValue);
1478
+ } else if (isFileInput(fieldReference.ref)) fieldReference.ref.value = "";
1274
1479
  else {
1275
1480
  fieldReference.ref.value = fieldValue;
1276
1481
  if (!fieldReference.ref.type) _subjects.state.next({
@@ -1408,7 +1613,7 @@ function createFormControl(props = {}) {
1408
1613
  const field = get(_fields, fieldName);
1409
1614
  return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
1410
1615
  }))).every(Boolean);
1411
- !(!validationResult && !_formState.isValid) && _setValid();
1616
+ (validationResult || _formState.isValid) && _setValid();
1412
1617
  } else validationResult = isValid = await executeBuiltInValidation(_fields);
1413
1618
  _subjects.state.next({
1414
1619
  ...!isString(name) || (_proxyFormState.isValid || _proxySubscribeFormState.isValid) && isValid !== _formState.isValid ? {} : { name },
@@ -1648,7 +1853,7 @@ function createFormControl(props = {}) {
1648
1853
  if (!keepStateOptions.keepDefaultValues) _defaultValues = updatedValues;
1649
1854
  if (!keepStateOptions.keepValues) {
1650
1855
  if (keepStateOptions.keepDirtyValues) {
1651
- const fieldsToCheck = new Set([..._names.mount, ...Object.keys(getDirtyFields(_defaultValues, _formValues))]);
1856
+ const fieldsToCheck = /* @__PURE__ */ new Set([..._names.mount, ...Object.keys(getDirtyFields(_defaultValues, _formValues))]);
1652
1857
  for (const fieldName of Array.from(fieldsToCheck)) {
1653
1858
  const isDirty = get(_formState.dirtyFields, fieldName);
1654
1859
  const existingValue = get(_formValues, fieldName);
@@ -1855,18 +2060,20 @@ function useForm(props = {}) {
1855
2060
  isReady: false,
1856
2061
  defaultValues: isFunction(props.defaultValues) ? void 0 : props.defaultValues
1857
2062
  });
1858
- if (!_formControl.current) if (props.formControl) {
1859
- _formControl.current = {
1860
- ...props.formControl,
1861
- formState
1862
- };
1863
- if (props.defaultValues && !isFunction(props.defaultValues)) props.formControl.reset(props.defaultValues, props.resetOptions);
1864
- } else {
1865
- const { formControl, ...rest } = createFormControl(props);
1866
- _formControl.current = {
1867
- ...rest,
1868
- formState
1869
- };
2063
+ if (!_formControl.current) {
2064
+ if (props.formControl) {
2065
+ _formControl.current = {
2066
+ ...props.formControl,
2067
+ formState
2068
+ };
2069
+ if (props.defaultValues && !isFunction(props.defaultValues)) props.formControl.reset(props.defaultValues, props.resetOptions);
2070
+ } else {
2071
+ const { formControl, ...rest } = createFormControl(props);
2072
+ _formControl.current = {
2073
+ ...rest,
2074
+ formState
2075
+ };
2076
+ }
1870
2077
  }
1871
2078
  const control = _formControl.current.control;
1872
2079
  control._options = props;
@@ -1934,6 +2141,782 @@ function useForm(props = {}) {
1934
2141
  return _formControl.current;
1935
2142
  }
1936
2143
  //#endregion
2144
+ //#region ../../node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js
2145
+ const SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
2146
+ const SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
2147
+ const SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
2148
+ const DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
2149
+ const SPLIT_REPLACE_VALUE = "$1\0$2";
2150
+ const DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
2151
+ /**
2152
+ * Split any cased input strings into an array of words.
2153
+ */
2154
+ function split(value) {
2155
+ let result = value.trim();
2156
+ result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
2157
+ result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
2158
+ let start = 0;
2159
+ let end = result.length;
2160
+ while (result.charAt(start) === "\0") start++;
2161
+ if (start === end) return [];
2162
+ while (result.charAt(end - 1) === "\0") end--;
2163
+ return result.slice(start, end).split(/\0/g);
2164
+ }
2165
+ /**
2166
+ * Split the input string into an array of words, separating numbers.
2167
+ */
2168
+ function splitSeparateNumbers(value) {
2169
+ const words = split(value);
2170
+ for (let i = 0; i < words.length; i++) {
2171
+ const word = words[i];
2172
+ const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
2173
+ if (match) {
2174
+ const offset = match.index + (match[1] ?? match[2]).length;
2175
+ words.splice(i, 1, word.slice(0, offset), word.slice(offset));
2176
+ }
2177
+ }
2178
+ return words;
2179
+ }
2180
+ /**
2181
+ * Convert a string to space separated lower case (`foo bar`).
2182
+ */
2183
+ function noCase(input, options) {
2184
+ const [prefix, words, suffix] = splitPrefixSuffix(input, options);
2185
+ return prefix + words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? " ") + suffix;
2186
+ }
2187
+ /**
2188
+ * Convert a string to pascal case (`FooBar`).
2189
+ */
2190
+ function pascalCase(input, options) {
2191
+ const [prefix, words, suffix] = splitPrefixSuffix(input, options);
2192
+ const lower = lowerFactory(options?.locale);
2193
+ const upper = upperFactory(options?.locale);
2194
+ const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
2195
+ return prefix + words.map(transform).join(options?.delimiter ?? "") + suffix;
2196
+ }
2197
+ /**
2198
+ * Convert a string to constant case (`FOO_BAR`).
2199
+ */
2200
+ function constantCase(input, options) {
2201
+ const [prefix, words, suffix] = splitPrefixSuffix(input, options);
2202
+ return prefix + words.map(upperFactory(options?.locale)).join(options?.delimiter ?? "_") + suffix;
2203
+ }
2204
+ /**
2205
+ * Convert a string to path case (`Foo bar`).
2206
+ */
2207
+ function sentenceCase(input, options) {
2208
+ const [prefix, words, suffix] = splitPrefixSuffix(input, options);
2209
+ const lower = lowerFactory(options?.locale);
2210
+ const transform = capitalCaseTransformFactory(lower, upperFactory(options?.locale));
2211
+ return prefix + words.map((word, index) => {
2212
+ if (index === 0) return transform(word);
2213
+ return lower(word);
2214
+ }).join(options?.delimiter ?? " ") + suffix;
2215
+ }
2216
+ /**
2217
+ * Convert a string to snake case (`foo_bar`).
2218
+ */
2219
+ function snakeCase(input, options) {
2220
+ return noCase(input, {
2221
+ delimiter: "_",
2222
+ ...options
2223
+ });
2224
+ }
2225
+ function lowerFactory(locale) {
2226
+ return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
2227
+ }
2228
+ function upperFactory(locale) {
2229
+ return locale === false ? (input) => input.toUpperCase() : (input) => input.toLocaleUpperCase(locale);
2230
+ }
2231
+ function capitalCaseTransformFactory(lower, upper) {
2232
+ return (word) => `${upper(word[0])}${lower(word.slice(1))}`;
2233
+ }
2234
+ function pascalCaseTransformFactory(lower, upper) {
2235
+ return (word, index) => {
2236
+ const char0 = word[0];
2237
+ return (index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0)) + lower(word.slice(1));
2238
+ };
2239
+ }
2240
+ function splitPrefixSuffix(input, options = {}) {
2241
+ const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
2242
+ const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
2243
+ const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
2244
+ let prefixIndex = 0;
2245
+ let suffixIndex = input.length;
2246
+ while (prefixIndex < input.length) {
2247
+ const char = input.charAt(prefixIndex);
2248
+ if (!prefixCharacters.includes(char)) break;
2249
+ prefixIndex++;
2250
+ }
2251
+ while (suffixIndex > prefixIndex) {
2252
+ const index = suffixIndex - 1;
2253
+ const char = input.charAt(index);
2254
+ if (!suffixCharacters.includes(char)) break;
2255
+ suffixIndex = index;
2256
+ }
2257
+ return [
2258
+ input.slice(0, prefixIndex),
2259
+ splitFn(input.slice(prefixIndex, suffixIndex)),
2260
+ input.slice(suffixIndex)
2261
+ ];
2262
+ }
2263
+ //#endregion
2264
+ //#region editors/document-model-editor/constants/graphql-kinds.ts
2265
+ const STRING_GQL_PRIMITIVE_NAME = "String";
2266
+ const BOOLEAN_GQL_PRIMITIVE_NAME = "Boolean";
2267
+ const FLOAT_GQL_PRIMITIVE_NAME = "Float";
2268
+ const gqlPrimitiveNodeNamesList = [
2269
+ STRING_GQL_PRIMITIVE_NAME,
2270
+ BOOLEAN_GQL_PRIMITIVE_NAME,
2271
+ "Int",
2272
+ FLOAT_GQL_PRIMITIVE_NAME,
2273
+ "ID"
2274
+ ];
2275
+ //#endregion
2276
+ //#region editors/document-model-editor/utils/helpers.ts
2277
+ function makeStateSchemaNameForScope(modelName, scope) {
2278
+ const modelNamePascalCase = pascalCase(modelName);
2279
+ const scopePascalCase = pascalCase(scope);
2280
+ return scopePascalCase === "Global" ? `${modelNamePascalCase}State` : `${modelNamePascalCase}${scopePascalCase}State`;
2281
+ }
2282
+ function makeInitialSchemaDoc(modelName, scope) {
2283
+ return `type ${makeStateSchemaNameForScope(modelName, scope)} {
2284
+ "Add your ${scope} state fields here"
2285
+ _placeholder: String
2286
+ }`;
2287
+ }
2288
+ function makeOperationInitialDoc(name) {
2289
+ return `input ${pascalCase(name)}Input {
2290
+ "Add your inputs here"
2291
+ _placeholder: String
2292
+ }`;
2293
+ }
2294
+ function makeEmptyOperationSchema(operationName) {
2295
+ return `input ${pascalCase(operationName)}Input {\n _empty: Boolean\n}`;
2296
+ }
2297
+ function isEmptyOperationSchema(schema) {
2298
+ if (!schema) return false;
2299
+ return /_empty:\s*Boolean/.test(schema) && !schema.replace(/_empty:\s*Boolean/, "").match(/\w+:\s*\w+/);
2300
+ }
2301
+ function safeParseJsonRecord(json) {
2302
+ try {
2303
+ return JSON.parse(json);
2304
+ } catch (_error) {
2305
+ return null;
2306
+ }
2307
+ }
2308
+ function makeMinimalObjectForStateType(args) {
2309
+ const { sharedSchemaDocumentNode, stateTypeDefinitionNode, existingValue } = args;
2310
+ const existingValueObject = safeParseJsonRecord(existingValue);
2311
+ if (!existingValueObject) return existingValue;
2312
+ const stateTypeDefinitionFields = stateTypeDefinitionNode.fields;
2313
+ if (!stateTypeDefinitionFields?.length) return existingValue;
2314
+ const minimalObject = makeMinimalValuesForObjectFields({
2315
+ schemaDocumentNode: sharedSchemaDocumentNode,
2316
+ fieldDefinitionNodes: stateTypeDefinitionFields,
2317
+ existingValueObject,
2318
+ visitedTypes: /* @__PURE__ */ new Set([stateTypeDefinitionNode.name.value])
2319
+ });
2320
+ return JSON.stringify(minimalObject, null, 2);
2321
+ }
2322
+ function makeMinimalValuesForObjectFields(args) {
2323
+ const { schemaDocumentNode, existingValueObject, fieldDefinitionNodes, visitedTypes } = args;
2324
+ const newJson = {};
2325
+ for (const astNode of fieldDefinitionNodes) {
2326
+ const fieldName = getASTNodeName(astNode);
2327
+ if (!fieldName) continue;
2328
+ const minimalValue = makeMinimalValueForASTNode({
2329
+ fieldName,
2330
+ astNode,
2331
+ schemaDocumentNode,
2332
+ existingValueObject,
2333
+ visitedTypes
2334
+ });
2335
+ newJson[astNode.name.value] = minimalValue;
2336
+ }
2337
+ return newJson;
2338
+ }
2339
+ function makeMinimalValueForASTNode(args) {
2340
+ const { fieldName, astNode, schemaDocumentNode, existingValueObject, visitedTypes } = args;
2341
+ const existingFieldValue = existingValueObject?.[fieldName];
2342
+ let node = astNode;
2343
+ if (isFieldDefinitionNode(astNode)) node = getASTNodeTypeNode(node);
2344
+ const isNonNull = isNonNullNode(node);
2345
+ if (isNonNull) node = getASTNodeTypeNode(node);
2346
+ if (isListTypeNode(node)) return makeMinimalValueForGqlListNode(node, existingFieldValue, isNonNull, schemaDocumentNode, visitedTypes);
2347
+ if (isGqlPrimitiveNode(node)) return makeMinimalValueForGQLPrimitiveNode(node, existingFieldValue, isNonNull);
2348
+ const namedTypeDefinitionNode = getNamedTypeDefinitionNode(node, schemaDocumentNode);
2349
+ if (isEnumTypeDefinitionNode(namedTypeDefinitionNode)) return makeMinimalValueForGqlEnum(namedTypeDefinitionNode, existingFieldValue, isNonNull);
2350
+ if (isScalarTypeDefinitionNode(namedTypeDefinitionNode)) return makeMinimalValueForGqlScalar(namedTypeDefinitionNode, existingFieldValue, isNonNull);
2351
+ if (isUnionTypeDefinitionNode(namedTypeDefinitionNode)) return makeMinimalValueForGqlUnion(namedTypeDefinitionNode, existingFieldValue, schemaDocumentNode, existingValueObject, isNonNull, visitedTypes);
2352
+ if (isObjectTypeDefinitionNode(namedTypeDefinitionNode)) return makeMinimalValueForGqlObject(namedTypeDefinitionNode, schemaDocumentNode, existingValueObject, existingFieldValue, isNonNull, visitedTypes);
2353
+ return existingFieldValue;
2354
+ }
2355
+ function isFieldDefinitionNode(astNodeTypeNode) {
2356
+ if (!astNodeTypeNode) return false;
2357
+ return astNodeTypeNode.kind === Kind.FIELD_DEFINITION;
2358
+ }
2359
+ function isNonNullNode(astNode) {
2360
+ if (!astNode) return false;
2361
+ return astNode.kind === Kind.NON_NULL_TYPE;
2362
+ }
2363
+ function isGqlPrimitiveNode(astNodeTypeNode) {
2364
+ if (!astNodeTypeNode) return false;
2365
+ const name = getASTNodeName(astNodeTypeNode);
2366
+ return gqlPrimitiveNodeNamesList.includes(name);
2367
+ }
2368
+ function isListTypeNode(astNodeTypeNode) {
2369
+ if (!astNodeTypeNode) return false;
2370
+ return astNodeTypeNode.kind === Kind.LIST_TYPE;
2371
+ }
2372
+ function isEnumTypeDefinitionNode(definitionNode) {
2373
+ if (!definitionNode) return false;
2374
+ return definitionNode.kind === Kind.ENUM_TYPE_DEFINITION;
2375
+ }
2376
+ function isScalarTypeDefinitionNode(definitionNode) {
2377
+ if (!definitionNode) return false;
2378
+ return definitionNode.kind === Kind.SCALAR_TYPE_DEFINITION;
2379
+ }
2380
+ function isUnionTypeDefinitionNode(definitionNode) {
2381
+ if (!definitionNode) return false;
2382
+ return definitionNode.kind === Kind.UNION_TYPE_DEFINITION;
2383
+ }
2384
+ function isObjectTypeDefinitionNode(definitionNode) {
2385
+ if (!definitionNode) return false;
2386
+ return definitionNode.kind === Kind.OBJECT_TYPE_DEFINITION;
2387
+ }
2388
+ function getASTNodeName(astNode) {
2389
+ if (!astNode) return null;
2390
+ if (!("name" in astNode)) return null;
2391
+ if (!astNode.name) return null;
2392
+ if (!("value" in astNode.name)) return null;
2393
+ return astNode.name.value;
2394
+ }
2395
+ function getASTNodeTypeNode(astNode) {
2396
+ if (!astNode) return null;
2397
+ if (!("type" in astNode)) return null;
2398
+ return astNode.type;
2399
+ }
2400
+ function makeMinimalValueForGQLPrimitiveNode(primitiveTypeNode, existingFieldValue, isNonNull) {
2401
+ const name = getASTNodeName(primitiveTypeNode);
2402
+ if (!name) return null;
2403
+ switch (name) {
2404
+ case "ID":
2405
+ if (z.string().safeParse(existingFieldValue).success) return existingFieldValue;
2406
+ return isNonNull ? "placeholder-id" : null;
2407
+ case BOOLEAN_GQL_PRIMITIVE_NAME:
2408
+ if (z.boolean().safeParse(existingFieldValue).success) return existingFieldValue;
2409
+ return isNonNull ? false : null;
2410
+ case "Int":
2411
+ if (z.number().safeParse(existingFieldValue).success) return existingFieldValue;
2412
+ return isNonNull ? 0 : null;
2413
+ case FLOAT_GQL_PRIMITIVE_NAME:
2414
+ if (z.number().safeParse(existingFieldValue).success) return existingFieldValue;
2415
+ return isNonNull ? 0 : null;
2416
+ case STRING_GQL_PRIMITIVE_NAME:
2417
+ if (z.string().safeParse(existingFieldValue).success) return existingFieldValue;
2418
+ return isNonNull ? "" : null;
2419
+ }
2420
+ return isNonNull ? existingFieldValue : null;
2421
+ }
2422
+ function makeMinimalValueForGqlEnum(namedTypeDefinitionNode, existingFieldValue, isNonNull) {
2423
+ const enumValues = namedTypeDefinitionNode.values?.map((value) => value.name.value) ?? [];
2424
+ if (typeof existingFieldValue === "string" && enumValues.includes(existingFieldValue)) return existingFieldValue;
2425
+ if (isNonNull) return enumValues[0];
2426
+ return null;
2427
+ }
2428
+ function makeMinimalValueForGqlScalar(scalarTypeDefinitionNode, existingFieldValue, isNonNull) {
2429
+ if (!isNonNull && !existingFieldValue) return null;
2430
+ const name = getASTNodeName(scalarTypeDefinitionNode);
2431
+ if (!name) {
2432
+ console.error("No name for scalar type definition node", scalarTypeDefinitionNode);
2433
+ return null;
2434
+ }
2435
+ const scalar = getPHCustomScalarByTypeName(name);
2436
+ if (!scalar) return null;
2437
+ if (scalar.schema.safeParse(existingFieldValue).success) return existingFieldValue;
2438
+ if (!isNonNull) return null;
2439
+ const minimalValue = scalar.getDefaultValue?.();
2440
+ if (minimalValue) return minimalValue;
2441
+ return existingFieldValue;
2442
+ }
2443
+ function makeMinimalValueForGqlUnion(namedTypeDefinitionNode, existingFieldValue, schemaDocumentNode, existingValueObject, isNonNull, visitedTypes) {
2444
+ if (!isNonNull && !existingFieldValue) return null;
2445
+ if (!namedTypeDefinitionNode.types?.length) return null;
2446
+ const firstNamedTypeDefinitionNode = namedTypeDefinitionNode.types?.at(0);
2447
+ if (!firstNamedTypeDefinitionNode) return null;
2448
+ const firstNamedTypeObjectDefinitionNode = getNamedTypeDefinitionNode(firstNamedTypeDefinitionNode, schemaDocumentNode);
2449
+ if (!isObjectTypeDefinitionNode(firstNamedTypeObjectDefinitionNode)) return null;
2450
+ return makeMinimalValueForGqlObject(firstNamedTypeObjectDefinitionNode, schemaDocumentNode, existingValueObject, existingFieldValue, isNonNull, visitedTypes);
2451
+ }
2452
+ function makeMinimalValueForGqlListNode(listTypeNode, existingFieldValue, isNonNull, schemaDocumentNode, visitedTypes) {
2453
+ if (!isNonNull && !Array.isArray(existingFieldValue)) return null;
2454
+ if (isNonNull && !Array.isArray(existingFieldValue)) return [];
2455
+ return existingFieldValue.map((item, index) => makeMinimalValueForASTNode({
2456
+ fieldName: String(index),
2457
+ astNode: listTypeNode.type,
2458
+ schemaDocumentNode,
2459
+ existingValueObject: { [index]: item },
2460
+ visitedTypes
2461
+ }));
2462
+ }
2463
+ function makeMinimalValueForGqlObject(objectTypeDefinitionNode, schemaDocumentNode, _existingValueObject, existingFieldValue, isNonNull, visitedTypes) {
2464
+ const typeName = objectTypeDefinitionNode.name.value;
2465
+ if (visitedTypes?.has(typeName)) return null;
2466
+ if (!isNonNull && !existingFieldValue) return null;
2467
+ const fields = objectTypeDefinitionNode.fields;
2468
+ if (!fields?.length) return {};
2469
+ const newVisitedTypes = new Set(visitedTypes);
2470
+ newVisitedTypes.add(typeName);
2471
+ return makeMinimalValuesForObjectFields({
2472
+ schemaDocumentNode,
2473
+ existingValueObject: existingFieldValue && typeof existingFieldValue === "object" && !Array.isArray(existingFieldValue) ? existingFieldValue : null,
2474
+ fieldDefinitionNodes: fields,
2475
+ visitedTypes: newVisitedTypes
2476
+ });
2477
+ }
2478
+ function getNamedTypeDefinitionNode(astNodeTypeNode, schemaDocumentNode) {
2479
+ if (!astNodeTypeNode) return null;
2480
+ const name = getASTNodeName(astNodeTypeNode);
2481
+ if (!name) return null;
2482
+ const definitionNode = schemaDocumentNode.definitions.find((def) => "kind" in def && "name" in def && def.name?.value === name);
2483
+ if (!definitionNode) return null;
2484
+ return definitionNode;
2485
+ }
2486
+ function removeWhitespace(str) {
2487
+ return str.replace(/\s+|\\n|\\t/g, "").toLowerCase();
2488
+ }
2489
+ function compareStringsWithoutWhitespace(str1, str2) {
2490
+ if (str1 === null || str2 === null || str1 === void 0 || str2 === void 0) return false;
2491
+ return removeWhitespace(str1) === removeWhitespace(str2);
2492
+ }
2493
+ function renameSchemaType(sdl, oldName, newName, scope) {
2494
+ const typeSuffix = scope === "global" ? "State" : "LocalState";
2495
+ const oldTypeName = `${pascalCase(oldName)}${typeSuffix}`;
2496
+ const newTypeName = `${pascalCase(newName)}${typeSuffix}`;
2497
+ const ast = safeParseSdl(sdl);
2498
+ if (!ast) return sdl;
2499
+ const updatedAst = visit(ast, { ObjectTypeDefinition: (node) => {
2500
+ if (node.name.value === oldTypeName) return {
2501
+ ...node,
2502
+ name: {
2503
+ ...node.name,
2504
+ value: newTypeName
2505
+ }
2506
+ };
2507
+ } });
2508
+ return print(updatedAst);
2509
+ }
2510
+ function initializeModelSchema(modelName) {
2511
+ return makeInitialSchemaDoc(modelName, "global");
2512
+ }
2513
+ function updateModelSchemaNames(params) {
2514
+ const { oldName, newName, globalStateSchema, localStateSchema, setStateSchema } = params;
2515
+ setStateSchema(renameSchemaType(globalStateSchema, oldName, newName, "global"), "global");
2516
+ if (localStateSchema) setStateSchema(renameSchemaType(localStateSchema, oldName, newName, "local"), "local");
2517
+ }
2518
+ function handleModelNameChange(params) {
2519
+ const { newName, globalStateSchema, setStateSchema } = params;
2520
+ if (!!!globalStateSchema) {
2521
+ setStateSchema(initializeModelSchema(newName), "global");
2522
+ return;
2523
+ }
2524
+ updateModelSchemaNames(params);
2525
+ }
2526
+ function validateStateObject(sharedSchemaDocumentNode, stateTypeDefinitionNode, stateValue) {
2527
+ let stateObjectJson;
2528
+ try {
2529
+ stateObjectJson = JSON.parse(stateValue);
2530
+ } catch (error) {
2531
+ return [new Error("Invalid JSON object", { cause: error })];
2532
+ }
2533
+ const typeDefByName = indexTypeDefinitions(sharedSchemaDocumentNode);
2534
+ const stateTypeName = stateTypeDefinitionNode.name.value;
2535
+ if (!typeDefByName.has(stateTypeName)) return [/* @__PURE__ */ new Error(`State type "${stateTypeName}" was not found in sharedSchemaDocumentNode`)];
2536
+ const inputSuffix = "Input";
2537
+ const generatedInputDefs = generateInputTypesForObjectTree(stateTypeName, typeDefByName, inputSuffix);
2538
+ const augmentedDoc = {
2539
+ ...sharedSchemaDocumentNode,
2540
+ definitions: [...sharedSchemaDocumentNode.definitions, ...generatedInputDefs]
2541
+ };
2542
+ let schema;
2543
+ try {
2544
+ schema = buildASTSchema(augmentedDoc, { assumeValidSDL: false });
2545
+ } catch (e) {
2546
+ return [new Error("Failed to build schema from SDL", { cause: e })];
2547
+ }
2548
+ const inputTypeName = `${stateTypeName}${inputSuffix}`;
2549
+ const op = getOperationAST(parse(`query($v: ${inputTypeName}!) { __typename }`));
2550
+ if (!op) return [/* @__PURE__ */ new Error("Failed to create validation operation AST")];
2551
+ const { errors } = getVariableValues(schema, op.variableDefinitions ?? [], { v: stateObjectJson });
2552
+ const recursiveTypeErrors = detectRecursiveTypes(stateTypeDefinitionNode, typeDefByName);
2553
+ const recursiveFieldNames = new Set(recursiveTypeErrors.map((e) => e.field));
2554
+ const validationErrors = errors ? graphQLErrorsToStateValidationErrors(errors).filter((e) => {
2555
+ if (e instanceof StateValidationError && e.kind === "NON_NULL") {
2556
+ const rootField = e.path[0];
2557
+ if (typeof rootField === "string" && recursiveFieldNames.has(rootField)) return false;
2558
+ }
2559
+ return true;
2560
+ }) : [];
2561
+ validationErrors.unshift(...recursiveTypeErrors);
2562
+ const missingOptionalErrors = detectMissingOptionalFields(sharedSchemaDocumentNode, stateTypeDefinitionNode, stateObjectJson);
2563
+ validationErrors.push(...missingOptionalErrors);
2564
+ return validationErrors;
2565
+ }
2566
+ /**
2567
+ * Indexes object/input/enum/scalar/interface/union type definition nodes by name.
2568
+ * Note: only AST definitions that have a "name" field are indexed.
2569
+ */
2570
+ function indexTypeDefinitions(doc) {
2571
+ const map = /* @__PURE__ */ new Map();
2572
+ for (const def of doc.definitions) if (def.kind === Kind.OBJECT_TYPE_DEFINITION || def.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION || def.kind === Kind.ENUM_TYPE_DEFINITION || def.kind === Kind.SCALAR_TYPE_DEFINITION || def.kind === Kind.INTERFACE_TYPE_DEFINITION || def.kind === Kind.UNION_TYPE_DEFINITION || def.kind === Kind.OBJECT_TYPE_EXTENSION || def.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION || def.kind === Kind.ENUM_TYPE_EXTENSION || def.kind === Kind.INTERFACE_TYPE_EXTENSION || def.kind === Kind.UNION_TYPE_EXTENSION) {
2573
+ const name = def.name.value;
2574
+ if (!map.has(name)) map.set(name, def);
2575
+ }
2576
+ return map;
2577
+ }
2578
+ /**
2579
+ * Generates InputObjectTypeDefinitionNode(s) for a root object type and any nested
2580
+ * object types reachable via fields, converting object references to their *Input equivalents*.
2581
+ */
2582
+ function generateInputTypesForObjectTree(rootObjectTypeName, typeDefByName, inputSuffix) {
2583
+ const generated = /* @__PURE__ */ new Map();
2584
+ const visiting = /* @__PURE__ */ new Set();
2585
+ const ensureInputForObject = (objectTypeName) => {
2586
+ const inputName = `${objectTypeName}${inputSuffix}`;
2587
+ if (generated.has(inputName)) return;
2588
+ if (visiting.has(objectTypeName)) return;
2589
+ visiting.add(objectTypeName);
2590
+ const def = typeDefByName.get(objectTypeName);
2591
+ if (!def) throw new GraphQLError(`Unknown referenced type "${objectTypeName}"`);
2592
+ if (def.kind !== Kind.OBJECT_TYPE_DEFINITION && def.kind !== Kind.OBJECT_TYPE_EXTENSION) throw new GraphQLError(`Type "${objectTypeName}" is not an object type; cannot generate input from kind "${def.kind}"`);
2593
+ const objDef = def;
2594
+ const inputFields = objDef.fields?.map((f) => {
2595
+ return {
2596
+ kind: Kind.INPUT_VALUE_DEFINITION,
2597
+ name: f.name,
2598
+ description: f.description,
2599
+ directives: [],
2600
+ type: convertOutputTypeNodeToInputTypeNode(f.type, typeDefByName, inputSuffix, ensureInputForObject),
2601
+ defaultValue: void 0
2602
+ };
2603
+ }) ?? [];
2604
+ const inputDef = {
2605
+ kind: Kind.INPUT_OBJECT_TYPE_DEFINITION,
2606
+ name: {
2607
+ kind: Kind.NAME,
2608
+ value: inputName
2609
+ },
2610
+ description: objDef.description,
2611
+ directives: [],
2612
+ fields: inputFields
2613
+ };
2614
+ generated.set(inputName, inputDef);
2615
+ visiting.delete(objectTypeName);
2616
+ };
2617
+ ensureInputForObject(rootObjectTypeName);
2618
+ return Array.from(generated.values());
2619
+ }
2620
+ function convertOutputTypeNodeToInputTypeNode(typeNode, typeDefByName, inputSuffix, ensureInputForObject) {
2621
+ switch (typeNode.kind) {
2622
+ case Kind.NON_NULL_TYPE: return {
2623
+ kind: Kind.NON_NULL_TYPE,
2624
+ type: convertOutputTypeNodeToInputTypeNode(typeNode.type, typeDefByName, inputSuffix, ensureInputForObject)
2625
+ };
2626
+ case Kind.LIST_TYPE: return {
2627
+ kind: Kind.LIST_TYPE,
2628
+ type: convertOutputTypeNodeToInputTypeNode(typeNode.type, typeDefByName, inputSuffix, ensureInputForObject)
2629
+ };
2630
+ case Kind.NAMED_TYPE: {
2631
+ const named = typeNode;
2632
+ const name = named.name.value;
2633
+ const def = typeDefByName.get(name);
2634
+ if (def?.kind === Kind.OBJECT_TYPE_DEFINITION || def?.kind === Kind.OBJECT_TYPE_EXTENSION) {
2635
+ ensureInputForObject(name);
2636
+ return {
2637
+ kind: Kind.NAMED_TYPE,
2638
+ name: {
2639
+ kind: Kind.NAME,
2640
+ value: `${name}${inputSuffix}`
2641
+ }
2642
+ };
2643
+ }
2644
+ if (!def || def.kind === Kind.SCALAR_TYPE_DEFINITION || def.kind === Kind.ENUM_TYPE_DEFINITION || def.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION || def.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION) return named;
2645
+ if (def.kind === Kind.INTERFACE_TYPE_DEFINITION || def.kind === Kind.UNION_TYPE_DEFINITION) throw new GraphQLError(`Type "${name}" (${def.kind}) cannot be used in an input type`);
2646
+ throw new GraphQLError(`Unsupported named type "${name}" of kind "${def.kind}"`);
2647
+ }
2648
+ default: throw new GraphQLError(`Unsupported TypeNode kind: ${JSON.stringify(typeNode)}`);
2649
+ }
2650
+ }
2651
+ var StateValidationError = class extends Error {
2652
+ payload;
2653
+ originalMessage;
2654
+ constructor(payload, originalMessage) {
2655
+ super(payload.kind);
2656
+ this.name = "StateValidationError";
2657
+ this.payload = payload;
2658
+ this.originalMessage = originalMessage;
2659
+ Object.setPrototypeOf(this, new.target.prototype);
2660
+ }
2661
+ get kind() {
2662
+ return this.payload.kind;
2663
+ }
2664
+ get path() {
2665
+ return this.payload.path;
2666
+ }
2667
+ get field() {
2668
+ return this.payload.field;
2669
+ }
2670
+ };
2671
+ function extractInputPath(message) {
2672
+ const match = message.match(/at\s+"([^"]+)"/);
2673
+ if (!match) return [];
2674
+ const parts = match[1].split(".").filter(Boolean);
2675
+ return (parts[0] === "v" ? parts.slice(1) : parts).map((p) => /^\d+$/.test(p) ? Number(p) : p);
2676
+ }
2677
+ const RE_MISSING_REQUIRED_FIELD = /Field "([^"]+)" of required type "([^"]+)" was not provided\./;
2678
+ const RE_UNKNOWN_FIELD = /Field "([^"]+)" is not defined by type "([^"]+)"\.(?: Did you mean "([^"]+)"\?)?/;
2679
+ function extractMissingRequiredField(message) {
2680
+ const m = message.match(RE_MISSING_REQUIRED_FIELD);
2681
+ if (!m) return null;
2682
+ return {
2683
+ field: m[1],
2684
+ expectedType: m[2]
2685
+ };
2686
+ }
2687
+ function extractUnknownField(message) {
2688
+ const m = message.match(RE_UNKNOWN_FIELD);
2689
+ if (!m) return null;
2690
+ return {
2691
+ field: m[1],
2692
+ typeName: m[2],
2693
+ didYouMean: m[3]
2694
+ };
2695
+ }
2696
+ function lastFieldFromPath(path) {
2697
+ for (let i = path.length - 1; i >= 0; i--) if (typeof path[i] === "string") return path[i];
2698
+ }
2699
+ function extractExpectedType(message) {
2700
+ let m = message.match(/Expected non-nullable type "([^"]+)"/);
2701
+ if (m?.[1]) return m[1];
2702
+ m = message.match(/Expected type "([^"]+)"/);
2703
+ if (m?.[1]) return m[1];
2704
+ m = message.match(/;\s*([_A-Za-z][_0-9A-Za-z]*)\s+cannot represent/i);
2705
+ if (m?.[1]) return m[1];
2706
+ }
2707
+ function graphQLErrorsToStateValidationErrors(errors) {
2708
+ const out = [];
2709
+ for (const e of errors) {
2710
+ const originalMessage = e.message;
2711
+ const missing = extractMissingRequiredField(originalMessage);
2712
+ if (missing) {
2713
+ out.push(new StateValidationError({
2714
+ kind: "MISSING",
2715
+ path: [missing.field],
2716
+ field: missing.field,
2717
+ expectedType: missing.expectedType
2718
+ }, originalMessage));
2719
+ continue;
2720
+ }
2721
+ const unknown = extractUnknownField(originalMessage);
2722
+ if (unknown) {
2723
+ out.push(new StateValidationError({
2724
+ kind: "UNKNOWN_FIELD",
2725
+ path: [unknown.field],
2726
+ field: unknown.field,
2727
+ didYouMean: unknown.didYouMean
2728
+ }, originalMessage));
2729
+ continue;
2730
+ }
2731
+ const path = extractInputPath(originalMessage);
2732
+ const field = lastFieldFromPath(path) ?? "value";
2733
+ const expectedType = extractExpectedType(originalMessage);
2734
+ if (originalMessage.includes("Expected non-nullable type") && originalMessage.includes("not to be null")) {
2735
+ out.push(new StateValidationError({
2736
+ kind: "NON_NULL",
2737
+ path,
2738
+ field,
2739
+ expectedType
2740
+ }, originalMessage));
2741
+ continue;
2742
+ }
2743
+ if (originalMessage.includes("cannot represent") || originalMessage.includes("Expected type")) {
2744
+ out.push(new StateValidationError({
2745
+ kind: "TYPE",
2746
+ path,
2747
+ field,
2748
+ expectedType,
2749
+ details: originalMessage
2750
+ }, originalMessage));
2751
+ continue;
2752
+ }
2753
+ out.push(new StateValidationError({
2754
+ kind: "TYPE",
2755
+ path,
2756
+ field,
2757
+ details: originalMessage
2758
+ }, originalMessage));
2759
+ }
2760
+ return out;
2761
+ }
2762
+ /**
2763
+ * Finds all fields defined in the schema that are missing from the state object.
2764
+ * Returns information about each missing field including whether it's required.
2765
+ */
2766
+ function findMissingFields(sharedSchemaDocumentNode, rootTypeNode, value, basePath = []) {
2767
+ let stateObjectJson;
2768
+ try {
2769
+ stateObjectJson = typeof value === "string" ? JSON.parse(value) : value;
2770
+ } catch {
2771
+ return [];
2772
+ }
2773
+ const typeByName = indexObjectTypes(sharedSchemaDocumentNode);
2774
+ const missingFields = [];
2775
+ for (const field of rootTypeNode.fields ?? []) {
2776
+ const fieldName = field.name.value;
2777
+ const fieldPath = [...basePath, fieldName];
2778
+ const isRequired = field.type.kind === Kind.NON_NULL_TYPE;
2779
+ const underlyingType = isRequired ? field.type.type : field.type;
2780
+ if (!(fieldName in stateObjectJson)) {
2781
+ missingFields.push({
2782
+ fieldName,
2783
+ path: fieldPath,
2784
+ isRequired,
2785
+ type: underlyingType
2786
+ });
2787
+ continue;
2788
+ }
2789
+ const namedType = unwrapNamedType(field.type);
2790
+ const childType = namedType ? typeByName.get(namedType) : void 0;
2791
+ if (childType && typeof stateObjectJson[fieldName] === "object" && stateObjectJson[fieldName] !== null && !Array.isArray(stateObjectJson[fieldName])) {
2792
+ const nestedMissing = findMissingFields(sharedSchemaDocumentNode, childType, stateObjectJson[fieldName], fieldPath);
2793
+ missingFields.push(...nestedMissing);
2794
+ }
2795
+ }
2796
+ return missingFields;
2797
+ }
2798
+ /**
2799
+ * Detects optional fields defined in the schema that are missing from the state object.
2800
+ * Returns StateValidationError[] for each missing optional field.
2801
+ */
2802
+ function detectMissingOptionalFields(sharedSchemaDocumentNode, rootTypeNode, value) {
2803
+ return findMissingFields(sharedSchemaDocumentNode, rootTypeNode, value).filter((field) => !field.isRequired).map((field) => new StateValidationError({
2804
+ kind: "MISSING_OPTIONAL",
2805
+ path: field.path,
2806
+ field: field.fieldName,
2807
+ expectedType: typeNodeToString(field.type)
2808
+ }));
2809
+ }
2810
+ /**
2811
+ * Detects fields that have recursive types (types that reference themselves directly or indirectly).
2812
+ * Returns a RECURSIVE_TYPE error for each field that contains a recursive type.
2813
+ */
2814
+ function detectRecursiveTypes(stateTypeDefinitionNode, typeDefByName) {
2815
+ const errors = [];
2816
+ for (const field of stateTypeDefinitionNode.fields ?? []) {
2817
+ const fieldName = field.name.value;
2818
+ const namedTypeName = getNamedTypeName(field.type);
2819
+ if (!namedTypeName) continue;
2820
+ if (isRecursiveType(namedTypeName, typeDefByName, /* @__PURE__ */ new Set())) errors.push(new StateValidationError({
2821
+ kind: "RECURSIVE_TYPE",
2822
+ path: [fieldName],
2823
+ field: fieldName,
2824
+ typeName: namedTypeName
2825
+ }));
2826
+ }
2827
+ return errors;
2828
+ }
2829
+ /**
2830
+ * Gets the named type name from a TypeNode, unwrapping NonNull and List types.
2831
+ */
2832
+ function getNamedTypeName(typeNode) {
2833
+ if (typeNode.kind === Kind.NAMED_TYPE) return typeNode.name.value;
2834
+ if (typeNode.kind === Kind.NON_NULL_TYPE || typeNode.kind === Kind.LIST_TYPE) return getNamedTypeName(typeNode.type);
2835
+ return null;
2836
+ }
2837
+ /**
2838
+ * Checks if a type is recursive (references itself directly or indirectly through required fields).
2839
+ */
2840
+ function isRecursiveType(typeName, typeDefByName, visitedTypes) {
2841
+ if (visitedTypes.has(typeName)) return true;
2842
+ const typeDef = typeDefByName.get(typeName);
2843
+ if (!typeDef || typeDef.kind !== Kind.OBJECT_TYPE_DEFINITION) return false;
2844
+ visitedTypes.add(typeName);
2845
+ for (const field of typeDef.fields ?? []) {
2846
+ if (field.type.kind !== Kind.NON_NULL_TYPE) continue;
2847
+ const innerType = field.type.type;
2848
+ let fieldTypeName = null;
2849
+ if (innerType.kind === Kind.NAMED_TYPE) fieldTypeName = innerType.name.value;
2850
+ else if (innerType.kind === Kind.LIST_TYPE) fieldTypeName = getNamedTypeName(innerType);
2851
+ if (fieldTypeName && isRecursiveType(fieldTypeName, typeDefByName, visitedTypes)) return true;
2852
+ }
2853
+ visitedTypes.delete(typeName);
2854
+ return false;
2855
+ }
2856
+ /**
2857
+ * Converts a TypeNode to its string representation (e.g., "String", "Int!", "[String]!")
2858
+ */
2859
+ function typeNodeToString(typeNode) {
2860
+ switch (typeNode.kind) {
2861
+ case Kind.NAMED_TYPE: return typeNode.name.value;
2862
+ case Kind.NON_NULL_TYPE: return `${typeNodeToString(typeNode.type)}!`;
2863
+ case Kind.LIST_TYPE: return `[${typeNodeToString(typeNode.type)}]`;
2864
+ }
2865
+ }
2866
+ function indexObjectTypes(doc) {
2867
+ const map = /* @__PURE__ */ new Map();
2868
+ for (const def of doc.definitions) if (def.kind === Kind.OBJECT_TYPE_DEFINITION) map.set(def.name.value, def);
2869
+ return map;
2870
+ }
2871
+ function unwrapNamedType(typeNode) {
2872
+ if (typeNode.kind === Kind.NAMED_TYPE) return typeNode.name.value;
2873
+ if (typeNode.kind === Kind.NON_NULL_TYPE) return unwrapNamedType(typeNode.type);
2874
+ if (typeNode.kind === Kind.LIST_TYPE) return unwrapNamedType(typeNode.type);
2875
+ }
2876
+ //#endregion
2877
+ //#region editors/document-model-editor/utils/linting.ts
2878
+ function ensureDocumentContainsNodeWithNameAndType(doc, nodeName, nodeType) {
2879
+ const parsedDoc = safeParseSdl(doc);
2880
+ if (!parsedDoc) return true;
2881
+ return parsedDoc.definitions.some((def) => {
2882
+ return def.kind === Kind[nodeType] && "name" in def && def.name?.value === nodeName;
2883
+ });
2884
+ }
2885
+ function createNodeTypeAndNameDiagnostic(doc, errorMessage) {
2886
+ const parsedDoc = safeParseSdl(doc);
2887
+ if (!parsedDoc) return void 0;
2888
+ const firstNode = parsedDoc.definitions[0];
2889
+ const nameNode = "name" in firstNode ? firstNode.name : null;
2890
+ return {
2891
+ from: nameNode?.loc?.start ?? firstNode.loc?.start ?? 0,
2892
+ to: nameNode?.loc?.end ?? firstNode.loc?.end ?? 0,
2893
+ severity: "error",
2894
+ message: errorMessage
2895
+ };
2896
+ }
2897
+ function ensureValidStateSchemaName(doc, modelName, scope) {
2898
+ if (!safeParseSdl(doc)) return [];
2899
+ const requiredTypeName = makeStateSchemaNameForScope(modelName, scope);
2900
+ if (!ensureDocumentContainsNodeWithNameAndType(doc, requiredTypeName, "OBJECT_TYPE_DEFINITION")) return [createNodeTypeAndNameDiagnostic(doc, `${sentenceCase(scope)} state schema must be named ${requiredTypeName}`)].filter((d) => d !== void 0);
2901
+ return [];
2902
+ }
2903
+ function ensureValidOperationSchemaInputName(doc, operationName) {
2904
+ if (!doc || !safeParseSdl(doc)) return [];
2905
+ const requiredTypeName = `${pascalCase(operationName)}Input`;
2906
+ 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);
2907
+ return [];
2908
+ }
2909
+ //#endregion
2910
+ //#region editors/document-model-editor/components/button.tsx
2911
+ const Button = forwardRef((props, ref) => {
2912
+ const { className, ...rest } = props;
2913
+ return /* @__PURE__ */ jsx("button", {
2914
+ ref,
2915
+ ...rest,
2916
+ 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)
2917
+ });
2918
+ });
2919
+ //#endregion
1937
2920
  //#region editors/document-model-editor/components/divider.tsx
1938
2921
  function Divider({ className, size = "sm", margin = "md" }) {
1939
2922
  function getSize() {
@@ -1946,7 +2929,9 @@ function Divider({ className, size = "sm", margin = "md" }) {
1946
2929
  if (margin === "md") return "my-6";
1947
2930
  return "my-8";
1948
2931
  }
1949
- return /* @__PURE__ */ jsx("div", { className: twMerge("bg-secondary", getSize(), getMargin(), className) });
2932
+ const sizeClass = getSize();
2933
+ const marginClass = getMargin();
2934
+ return /* @__PURE__ */ jsx("div", { className: twMerge("bg-secondary", sizeClass, marginClass, className) });
1950
2935
  }
1951
2936
  //#endregion
1952
2937
  //#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
@@ -1955,12 +2940,14 @@ const r = (t, r, o) => {
1955
2940
  const s = get(o, r);
1956
2941
  t.setCustomValidity(s && s.message || ""), t.reportValidity();
1957
2942
  }
1958
- }, o = (e, t) => {
2943
+ };
2944
+ const o = (e, t) => {
1959
2945
  for (const o in t.fields) {
1960
2946
  const s = t.fields[o];
1961
2947
  s && s.ref && "reportValidity" in s.ref ? r(s.ref, o, e) : s && s.refs && s.refs.forEach((t) => r(t, o, e));
1962
2948
  }
1963
- }, s$1 = (r, s) => {
2949
+ };
2950
+ const s$1 = (r, s) => {
1964
2951
  s.shouldUseNativeValidation && o(r, s);
1965
2952
  const n = {};
1966
2953
  for (const o in r) {
@@ -1971,7 +2958,8 @@ const r = (t, r, o) => {
1971
2958
  } else set(n, o, c);
1972
2959
  }
1973
2960
  return n;
1974
- }, i$1 = (e, t) => {
2961
+ };
2962
+ const i$1 = (e, t) => {
1975
2963
  const r = n$1(t);
1976
2964
  return e.some((e) => n$1(e).match(`^${r}\\.\\d+`));
1977
2965
  };
@@ -2402,32 +3390,38 @@ function ModelMetadata(props) {
2402
3390
  }
2403
3391
  function ModelNameForm(props) {
2404
3392
  const { name, globalStateSchema, localStateSchema, setModelName, setStateSchema } = props;
3393
+ const onSubmit = useCallback((newName) => {
3394
+ if (name === newName) return;
3395
+ setModelName(newName);
3396
+ if (!!!globalStateSchema) {
3397
+ const initialSchemaDoc = makeInitialSchemaDoc(newName, "global");
3398
+ setStateSchema(initialSchemaDoc, "global");
3399
+ return;
3400
+ }
3401
+ const newSchema = renameSchemaType(globalStateSchema, name, newName, "global");
3402
+ setStateSchema(newSchema, "global");
3403
+ if (localStateSchema) {
3404
+ const newLocalStateSchema = renameSchemaType(localStateSchema, name, newName, "local");
3405
+ setStateSchema(newLocalStateSchema, "local");
3406
+ }
3407
+ handleModelNameChange({
3408
+ oldName: name,
3409
+ newName,
3410
+ globalStateSchema,
3411
+ localStateSchema,
3412
+ setStateSchema
3413
+ });
3414
+ }, [
3415
+ name,
3416
+ globalStateSchema,
3417
+ localStateSchema,
3418
+ setStateSchema,
3419
+ setModelName
3420
+ ]);
2405
3421
  return /* @__PURE__ */ jsx(TextField, {
2406
3422
  name: "name",
2407
3423
  value: name,
2408
- onSubmit: useCallback((newName) => {
2409
- if (name === newName) return;
2410
- setModelName(newName);
2411
- if (!!!globalStateSchema) {
2412
- setStateSchema(makeInitialSchemaDoc(newName, "global"), "global");
2413
- return;
2414
- }
2415
- setStateSchema(renameSchemaType(globalStateSchema, name, newName, "global"), "global");
2416
- if (localStateSchema) setStateSchema(renameSchemaType(localStateSchema, name, newName, "local"), "local");
2417
- handleModelNameChange({
2418
- oldName: name,
2419
- newName,
2420
- globalStateSchema,
2421
- localStateSchema,
2422
- setStateSchema
2423
- });
2424
- }, [
2425
- name,
2426
- globalStateSchema,
2427
- localStateSchema,
2428
- setStateSchema,
2429
- setModelName
2430
- ]),
3424
+ onSubmit,
2431
3425
  placeholder: "Model name",
2432
3426
  className: "border-none pl-0 text-xl font-bold text-foreground",
2433
3427
  required: true,
@@ -2628,7 +3622,7 @@ function OperationErrors({ operation, addOperationError, deleteOperationError, s
2628
3622
  }
2629
3623
  //#endregion
2630
3624
  //#region editors/document-model-editor/components/operation.tsx
2631
- const GraphqlEditor = lazy(() => import("./graphql-editor-DoXZvdNr.js"));
3625
+ const GraphqlEditor = lazy(() => import("./graphql-editor-Cgi5UOrF.js"));
2632
3626
  function Operation(props) {
2633
3627
  const { operation, module, allOperationNames, lastCreatedOperationId, onAddOperationAndInitialSchema, updateOperationName, deleteOperation, updateOperationSchema, setOperationDescription, addOperationError, deleteOperationError, setOperationErrorName, toggleNoInputRequired } = props;
2634
3628
  const noInputRequired = isEmptyOperationSchema(operation.schema);
@@ -3364,7 +4358,8 @@ function useVersionAdvisory(args) {
3364
4358
  }
3365
4359
  //#endregion
3366
4360
  //#region editors/document-model-editor/editor.tsx
3367
- const StateSchemas = lazy(() => import("./state-schemas-B47wHvDV.js"));
4361
+ var editor_exports = /* @__PURE__ */ __exportAll({ default: () => Editor });
4362
+ const StateSchemas = lazy(() => import("./state-schemas-B5Bk_l1s.js"));
3368
4363
  const noopSetStateSchema = () => void 0;
3369
4364
  const noopSetInitialState = () => void 0;
3370
4365
  function Editor() {
@@ -3388,10 +4383,11 @@ function Editor() {
3388
4383
  useEffect(() => {
3389
4384
  if (!shouldSetInitialName.current || !documentNodeName) return;
3390
4385
  const initialSchemaDoc = initializeModelSchema(documentNodeName);
3391
- dispatch([setModelName({ name: documentNodeName }), setStateSchema({
4386
+ const actions = [setModelName({ name: documentNodeName }), setStateSchema({
3392
4387
  schema: initialSchemaDoc,
3393
4388
  scope: "global"
3394
- })]);
4389
+ })];
4390
+ dispatch(actions);
3395
4391
  shouldSetInitialName.current = false;
3396
4392
  }, [documentNodeName, dispatch]);
3397
4393
  const { guardedDispatch, prompt, releaseFirst, keepEditing, cancelAdvisory, markVersionInDevelopment } = useVersionAdvisory({
@@ -3542,11 +4538,12 @@ function Editor() {
3542
4538
  return;
3543
4539
  }
3544
4540
  const id = generateId();
4541
+ const errorCode = pascalCase(errorName);
3545
4542
  guardedDispatch(addOperationError({
3546
4543
  id,
3547
4544
  operationId,
3548
4545
  errorName,
3549
- errorCode: pascalCase(errorName)
4546
+ errorCode
3550
4547
  }));
3551
4548
  resolve(id);
3552
4549
  } catch (error) {
@@ -3674,6 +4671,6 @@ function Editor() {
3674
4671
  });
3675
4672
  }
3676
4673
  //#endregion
3677
- export { Editor as default };
4674
+ export { makeInitialSchemaDoc as a, validateStateObject as c, Editor as default, StateValidationError as i, safeParseSdl as l, Button as n, makeMinimalObjectForStateType as o, ensureValidStateSchemaName as r, makeStateSchemaNameForScope as s, editor_exports as t, useSchemaContext as u };
3678
4675
 
3679
- //# sourceMappingURL=editor-CQ4wUFK5.js.map
4676
+ //# sourceMappingURL=editor-C7KBR_ar.js.map