@powerhousedao/powerhouse-vetra-packages 6.2.0-dev.3 → 6.2.0-dev.31

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 (69) hide show
  1. package/dist/browser/assets/{entry-Bzani6_n.js → entry-BzMQu_A8.js} +2 -2
  2. package/dist/browser/assets/{projection-entry-Bpu-8SnI.js → projection-entry-CQb9a2Bz.js} +2 -2
  3. package/dist/browser/{connect-ZnLjvmRt.js → connect-CdR7HnG_.js} +104 -104
  4. package/dist/browser/connect-CdR7HnG_.js.map +1 -0
  5. package/dist/browser/{dist-DLFI75Zd.js → dist-DXM8ccKa.js} +46 -7
  6. package/dist/browser/dist-DXM8ccKa.js.map +1 -0
  7. package/dist/browser/{dist-C1nRM9t2.js → dist-HgA907mh.js} +95 -61
  8. package/dist/browser/dist-HgA907mh.js.map +1 -0
  9. package/dist/browser/{document-drive-oqv68jDU.js → document-drive-sTKoi6L4.js} +314 -9
  10. package/dist/browser/document-drive-sTKoi6L4.js.map +1 -0
  11. package/dist/browser/document-models/index.js +1 -1
  12. package/dist/browser/{editor-DC3bigBu.js → editor-Bzkc8cBh.js} +5 -5
  13. package/dist/browser/{editor-DC3bigBu.js.map → editor-Bzkc8cBh.js.map} +1 -1
  14. package/dist/browser/{editor-CoTq6fqT.js → editor-CwLkXRMi.js} +21 -21
  15. package/dist/browser/editor-CwLkXRMi.js.map +1 -0
  16. package/dist/browser/editors/document-model-editor/module.js +1 -1
  17. package/dist/browser/editors/generic-drive-explorer/index.js +5 -5
  18. package/dist/browser/editors/generic-drive-explorer/index.js.map +1 -1
  19. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  20. package/dist/browser/{folder-view-DmYBf2pP.js → folder-view-SEF40UJw.js} +7 -7
  21. package/dist/browser/folder-view-SEF40UJw.js.map +1 -0
  22. package/dist/browser/{graphql-editor-CiGd_Li7.js → graphql-editor-DMG1SdS3.js} +3 -3
  23. package/dist/browser/{graphql-editor-CiGd_Li7.js.map → graphql-editor-DMG1SdS3.js.map} +1 -1
  24. package/dist/browser/index.js +2 -2
  25. package/dist/browser/{json-editor-sEqd5piI.js → json-editor-C9wagvps.js} +3 -3
  26. package/dist/browser/{json-editor-sEqd5piI.js.map → json-editor-C9wagvps.js.map} +1 -1
  27. package/dist/browser/{state-schemas-DJmzG_M8.js → state-schemas-CDE7-WSq.js} +12 -12
  28. package/dist/browser/state-schemas-CDE7-WSq.js.map +1 -0
  29. package/dist/node/{connect-BLC4PXD9.mjs → connect-C5Fwy1TV.mjs} +93 -93
  30. package/dist/node/connect-C5Fwy1TV.mjs.map +1 -0
  31. package/dist/node/{dist-Bm05eoTg.mjs → dist-BCpGdShB.mjs} +95 -61
  32. package/dist/node/dist-BCpGdShB.mjs.map +1 -0
  33. package/dist/node/{dist-Cn3iExnV.mjs → dist-C88eUERe.mjs} +46 -7
  34. package/dist/node/dist-C88eUERe.mjs.map +1 -0
  35. package/dist/node/{document-drive-sM33juXr.mjs → document-drive-DjL9iikf.mjs} +314 -9
  36. package/dist/node/document-drive-DjL9iikf.mjs.map +1 -0
  37. package/dist/node/document-models/index.mjs +1 -1
  38. package/dist/node/{editor-BrS98lEH.mjs → editor-CIR848q-.mjs} +5 -5
  39. package/dist/node/{editor-BrS98lEH.mjs.map → editor-CIR848q-.mjs.map} +1 -1
  40. package/dist/node/{editor-BFBa9nsO.mjs → editor-DmB3aE4K.mjs} +21 -21
  41. package/dist/node/editor-DmB3aE4K.mjs.map +1 -0
  42. package/dist/node/editors/document-model-editor/module.mjs +1 -1
  43. package/dist/node/editors/generic-drive-explorer/index.mjs +5 -5
  44. package/dist/node/editors/generic-drive-explorer/index.mjs.map +1 -1
  45. package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
  46. package/dist/node/{folder-view-DHph3Yuu.mjs → folder-view-OzKx5KyJ.mjs} +7 -7
  47. package/dist/node/folder-view-OzKx5KyJ.mjs.map +1 -0
  48. package/dist/node/{graphql-editor-CPq7oIbf.mjs → graphql-editor-CG9Wyp7N.mjs} +3 -3
  49. package/dist/node/{graphql-editor-CPq7oIbf.mjs.map → graphql-editor-CG9Wyp7N.mjs.map} +1 -1
  50. package/dist/node/index.mjs +2 -2
  51. package/dist/node/{json-editor-L32CP7TS.mjs → json-editor-CfA5q_6F.mjs} +3 -3
  52. package/dist/node/{json-editor-L32CP7TS.mjs.map → json-editor-CfA5q_6F.mjs.map} +1 -1
  53. package/dist/node/{state-schemas-XTTjQZOe.mjs → state-schemas-DVr0xm_W.mjs} +12 -12
  54. package/dist/node/state-schemas-DVr0xm_W.mjs.map +1 -0
  55. package/package.json +6 -6
  56. package/dist/browser/connect-ZnLjvmRt.js.map +0 -1
  57. package/dist/browser/dist-C1nRM9t2.js.map +0 -1
  58. package/dist/browser/dist-DLFI75Zd.js.map +0 -1
  59. package/dist/browser/document-drive-oqv68jDU.js.map +0 -1
  60. package/dist/browser/editor-CoTq6fqT.js.map +0 -1
  61. package/dist/browser/folder-view-DmYBf2pP.js.map +0 -1
  62. package/dist/browser/state-schemas-DJmzG_M8.js.map +0 -1
  63. package/dist/node/connect-BLC4PXD9.mjs.map +0 -1
  64. package/dist/node/dist-Bm05eoTg.mjs.map +0 -1
  65. package/dist/node/dist-Cn3iExnV.mjs.map +0 -1
  66. package/dist/node/document-drive-sM33juXr.mjs.map +0 -1
  67. package/dist/node/editor-BFBa9nsO.mjs.map +0 -1
  68. package/dist/node/folder-view-DHph3Yuu.mjs.map +0 -1
  69. package/dist/node/state-schemas-XTTjQZOe.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-CoTq6fqT.js","names":["use","React","React","r","e","s","i","t","o","r","e","n.parse","n.parseAsync","n.$ZodError","z.string","z\n .string","z\n .object","z\n .union","z.url","z.literal","Label","React","React","LabelPrimitive.Root","React","zodResolver","z.object","z.object","z.string"],"sources":["../../../../node_modules/.pnpm/@radix-ui+react-slot@1.2.4_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-slot/dist/index.mjs","../../../../node_modules/.pnpm/@radix-ui+react-primitive@2.1.4_@types+react-dom@19.2.3_@types+react@19.2.14__@types+re_c8c8fd2647f03197dbf56370d7498033/node_modules/@radix-ui/react-primitive/dist/index.mjs","../../../../node_modules/.pnpm/clsx@2.0.0/node_modules/clsx/dist/clsx.mjs","../../../../node_modules/.pnpm/class-variance-authority@0.7.0/node_modules/class-variance-authority/dist/index.mjs","../../editors/document-model-editor/components/divider.tsx","../../../../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","../../../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.71.2_react@19.2.6_/node_modules/@hookform/resolvers/zod/dist/zod.mjs","../../editors/document-model-editor/schemas/inputs.ts","../../editors/document-model-editor/context/form-context.ts","../../editors/document-model-editor/hooks/useFormField.ts","../../../../node_modules/.pnpm/@radix-ui+react-label@2.1.8_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react@_8d35ec453e0b59eefe06771bb1432577/node_modules/@radix-ui/react-label/dist/index.mjs","../../editors/document-model-editor/components/label.tsx","../../editors/document-model-editor/components/form.tsx","../../editors/document-model-editor/components/text-area.tsx","../../editors/document-model-editor/components/text-field.tsx","../../editors/document-model-editor/components/model-metadata-form.tsx","../../editors/document-model-editor/components/module-form.tsx","../../editors/document-model-editor/components/operation-form.tsx","../../editors/document-model-editor/components/operation-description-form.tsx","../../editors/document-model-editor/components/operation-error-form.tsx","../../editors/document-model-editor/components/operation-errors.tsx","../../editors/document-model-editor/components/operation.tsx","../../editors/document-model-editor/components/operations.tsx","../../editors/document-model-editor/components/module.tsx","../../editors/document-model-editor/components/modules.tsx","../../editors/document-model-editor/config.ts","../../editors/document-model-editor/hooks/useDocumentModelDocument.ts","../../editors/document-model-editor/editor.tsx"],"sourcesContent":["// src/slot.tsx\nimport * as React from \"react\";\nimport { composeRefs } from \"@radix-ui/react-compose-refs\";\nimport { Fragment as Fragment2, jsx } from \"react/jsx-runtime\";\nvar REACT_LAZY_TYPE = Symbol.for(\"react.lazy\");\nvar use = React[\" use \".trim().toString()];\nfunction isPromiseLike(value) {\n return typeof value === \"object\" && value !== null && \"then\" in value;\n}\nfunction isLazyComponent(element) {\n return element != null && typeof element === \"object\" && \"$$typeof\" in element && element.$$typeof === REACT_LAZY_TYPE && \"_payload\" in element && isPromiseLike(element._payload);\n}\n// @__NO_SIDE_EFFECTS__\nfunction createSlot(ownerName) {\n const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);\n const Slot2 = React.forwardRef((props, forwardedRef) => {\n let { children, ...slotProps } = props;\n if (isLazyComponent(children) && typeof use === \"function\") {\n children = use(children._payload);\n }\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n if (slottable) {\n const newElement = slottable.props.children;\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement) ? newElement.props.children : null;\n } else {\n return child;\n }\n });\n return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });\n }\n return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });\n });\n Slot2.displayName = `${ownerName}.Slot`;\n return Slot2;\n}\nvar Slot = /* @__PURE__ */ createSlot(\"Slot\");\n// @__NO_SIDE_EFFECTS__\nfunction createSlotClone(ownerName) {\n const SlotClone = React.forwardRef((props, forwardedRef) => {\n let { children, ...slotProps } = props;\n if (isLazyComponent(children) && typeof use === \"function\") {\n children = use(children._payload);\n }\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n const props2 = mergeProps(slotProps, children.props);\n if (children.type !== React.Fragment) {\n props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;\n }\n return React.cloneElement(children, props2);\n }\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n });\n SlotClone.displayName = `${ownerName}.SlotClone`;\n return SlotClone;\n}\nvar SLOTTABLE_IDENTIFIER = Symbol(\"radix.slottable\");\n// @__NO_SIDE_EFFECTS__\nfunction createSlottable(ownerName) {\n const Slottable2 = ({ children }) => {\n return /* @__PURE__ */ jsx(Fragment2, { children });\n };\n Slottable2.displayName = `${ownerName}.Slottable`;\n Slottable2.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable2;\n}\nvar Slottable = /* @__PURE__ */ createSlottable(\"Slottable\");\nfunction isSlottable(child) {\n return React.isValidElement(child) && typeof child.type === \"function\" && \"__radixId\" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;\n}\nfunction mergeProps(slotProps, childProps) {\n const overrideProps = { ...childProps };\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n } else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n } else if (propName === \"style\") {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === \"className\") {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(\" \");\n }\n }\n return { ...slotProps, ...overrideProps };\n}\nfunction getElementRef(element) {\n let getter = Object.getOwnPropertyDescriptor(element.props, \"ref\")?.get;\n let mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n if (mayWarn) {\n return element.ref;\n }\n getter = Object.getOwnPropertyDescriptor(element, \"ref\")?.get;\n mayWarn = getter && \"isReactWarning\" in getter && getter.isReactWarning;\n if (mayWarn) {\n return element.props.ref;\n }\n return element.props.ref || element.ref;\n}\nexport {\n Slot as Root,\n Slot,\n Slottable,\n createSlot,\n createSlottable\n};\n//# sourceMappingURL=index.mjs.map\n","// src/primitive.tsx\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { createSlot } from \"@radix-ui/react-slot\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NODES = [\n \"a\",\n \"button\",\n \"div\",\n \"form\",\n \"h2\",\n \"h3\",\n \"img\",\n \"input\",\n \"label\",\n \"li\",\n \"nav\",\n \"ol\",\n \"p\",\n \"select\",\n \"span\",\n \"svg\",\n \"ul\"\n];\nvar Primitive = NODES.reduce((primitive, node) => {\n const Slot = createSlot(`Primitive.${node}`);\n const Node = React.forwardRef((props, forwardedRef) => {\n const { asChild, ...primitiveProps } = props;\n const Comp = asChild ? Slot : node;\n if (typeof window !== \"undefined\") {\n window[Symbol.for(\"radix-ui\")] = true;\n }\n return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });\n });\n Node.displayName = `Primitive.${node}`;\n return { ...primitive, [node]: Node };\n}, {});\nfunction dispatchDiscreteCustomEvent(target, event) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));\n}\nvar Root = Primitive;\nexport {\n Primitive,\n Root,\n dispatchDiscreteCustomEvent\n};\n//# sourceMappingURL=index.mjs.map\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f);else for(t in e)e[t]&&(n&&(n+=\" \"),n+=t);return n}export function clsx(){for(var e,t,f=0,n=\"\";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { clsx } from \"clsx\";\nconst falsyToString = (value)=>typeof value === \"boolean\" ? \"\".concat(value) : value === 0 ? \"0\" : value;\nexport const cx = clsx;\nexport const cva = (base, config)=>{\n return (props)=>{\n var ref;\n if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n const { variants , defaultVariants } = config;\n const getVariantClassNames = Object.keys(variants).map((variant)=>{\n const variantProp = props === null || props === void 0 ? void 0 : props[variant];\n const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];\n if (variantProp === null) return null;\n const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);\n return variants[variant][variantKey];\n });\n const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param)=>{\n let [key, value] = param;\n if (value === undefined) {\n return acc;\n }\n acc[key] = value;\n return acc;\n }, {});\n const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (ref = config.compoundVariants) === null || ref === void 0 ? void 0 : ref.reduce((acc, param1)=>{\n let { class: cvClass , className: cvClassName , ...compoundVariantOptions } = param1;\n return Object.entries(compoundVariantOptions).every((param)=>{\n let [key, value] = param;\n return Array.isArray(value) ? value.includes({\n ...defaultVariants,\n ...propsWithoutUndefined\n }[key]) : ({\n ...defaultVariants,\n ...propsWithoutUndefined\n })[key] === value;\n }) ? [\n ...acc,\n cvClass,\n cvClassName\n ] : acc;\n }, []);\n return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n };\n};\n\n\n//# sourceMappingURL=index.mjs.map","import { twMerge } from \"tailwind-merge\";\n\ntype Props = {\n className?: string;\n size?: \"sm\" | \"md\" | \"lg\";\n margin?: \"sm\" | \"md\" | \"lg\";\n};\nexport function Divider({ className, size = \"sm\", margin = \"md\" }: Props) {\n function getSize() {\n if (size === \"sm\") return \"h-px\";\n if (size === \"md\") return \"h-1\";\n return \"h-1.5\";\n }\n\n function getMargin() {\n if (margin === \"sm\") return \"my-4\";\n if (margin === \"md\") return \"my-6\";\n return \"my-8\";\n }\n\n const sizeClass = getSize();\n const marginClass = getMargin();\n return (\n <div\n className={twMerge(\n \"bg-gray-200 dark:bg-slate-600 dark:text-slate-100\",\n sizeClass,\n marginClass,\n className,\n )}\n />\n );\n}\n","import{get as e,set as t}from\"react-hook-form\";const r=(t,r,o)=>{if(t&&\"reportValidity\"in t){const s=e(o,r);t.setCustomValidity(s&&s.message||\"\"),t.reportValidity()}},o=(e,t)=>{for(const o in t.fields){const s=t.fields[o];s&&s.ref&&\"reportValidity\"in s.ref?r(s.ref,o,e):s&&s.refs&&s.refs.forEach(t=>r(t,o,e))}},s=(r,s)=>{s.shouldUseNativeValidation&&o(r,s);const n={};for(const o in r){const f=e(s.fields,o),c=Object.assign(r[o]||{},{ref:f&&f.ref});if(i(s.names||Object.keys(r),o)){const r=Object.assign({},e(n,o));t(r,\"root\",c),t(n,o,r)}else t(n,o,c)}return n},i=(e,t)=>{const r=n(t);return e.some(e=>n(e).match(`^${r}\\\\.\\\\d+`))};function n(e){return e.replace(/\\]|\\[/g,\"\")}export{s as toNestErrors,o as validateFieldsNatively};\n//# sourceMappingURL=resolvers.mjs.map\n","import{validateFieldsNatively as r,toNestErrors as e}from\"@hookform/resolvers\";import{appendErrors as o}from\"react-hook-form\";import*as n from\"zod/v4/core\";function t(r,e){try{var o=r()}catch(r){return e(r)}return o&&o.then?o.then(void 0,e):o}function s(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(\".\");if(!n[a])if(\"unionErrors\"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if(\"unionErrors\"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n}function i(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(\".\");if(!n[a])if(\"invalid_union\"===t.code&&t.errors.length>0){var u=t.errors[0][0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if(\"invalid_union\"===t.code&&t.errors.forEach(function(e){return e.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n}function a(o,a,u){if(void 0===u&&(u={}),function(r){return\"_def\"in r&&\"object\"==typeof r._def&&\"typeName\"in r._def}(o))return function(n,i,c){try{return Promise.resolve(t(function(){return Promise.resolve(o[\"sync\"===u.mode?\"parse\":\"parseAsync\"](n,a)).then(function(e){return c.shouldUseNativeValidation&&r({},c),{errors:{},values:u.raw?Object.assign({},n):e}})},function(r){if(function(r){return Array.isArray(null==r?void 0:r.issues)}(r))return{values:{},errors:e(s(r.errors,!c.shouldUseNativeValidation&&\"all\"===c.criteriaMode),c)};throw r}))}catch(r){return Promise.reject(r)}};if(function(r){return\"_zod\"in r&&\"object\"==typeof r._zod}(o))return function(s,c,f){try{return Promise.resolve(t(function(){return Promise.resolve((\"sync\"===u.mode?n.parse:n.parseAsync)(o,s,a)).then(function(e){return f.shouldUseNativeValidation&&r({},f),{errors:{},values:u.raw?Object.assign({},s):e}})},function(r){if(function(r){return r instanceof n.$ZodError}(r))return{values:{},errors:e(i(r.issues,!f.shouldUseNativeValidation&&\"all\"===f.criteriaMode),f)};throw r}))}catch(r){return Promise.reject(r)}};throw new Error(\"Invalid input: not a Zod schema\")}export{a as zodResolver};\n//# sourceMappingURL=zod.module.js.map\n","import { z } from \"zod\";\nimport { snakeCase, constantCase } from \"change-case\";\n\nconst isUppercase = (value: string) => !/\\p{Ll}/u.test(value);\nconst isLowercase = (value: string) => !/\\p{Lu}/u.test(value);\n\nconst whitespaceRegex = /\\s+/g;\n\nexport function containsSpaces(s: string) {\n return whitespaceRegex.test(s);\n}\n\nexport function replaceSpaces(s: string) {\n return s.replace(whitespaceRegex, \"_\");\n}\n\ntype SchemaOptions = {\n required?: boolean;\n allowEmpty?: boolean;\n unique?: string[];\n};\n\nexport function createNameSchema(options: SchemaOptions = {}) {\n const { required = false, allowEmpty = false, unique = [] } = options;\n\n const baseSchema = allowEmpty ? z.string() : z.string().min(1);\n\n const uniqueRefinement = baseSchema.refine(\n (value) => {\n if (!value && allowEmpty) return true;\n return !unique\n .map((n) => n.toLowerCase())\n .includes(value.replace(/^\\s+|\\s+$/g, \"_\").toLowerCase());\n },\n { message: \"Item with this name already exists\" },\n );\n\n if (!required) {\n return unique.length > 0\n ? z\n .string()\n .optional()\n .refine(\n (value) => {\n if (value === undefined) return true;\n if (!value && allowEmpty) return true;\n return !unique\n .map((n) => n.toLowerCase())\n .includes(value.replace(/^\\s+|\\s+$/g, \"_\").toLowerCase());\n },\n { message: \"Item with this name already exists\" },\n )\n : z.string().optional();\n }\n\n return unique.length > 0 ? uniqueRefinement : baseSchema;\n}\n\nexport function createConstantCaseSchema(options: SchemaOptions = {}) {\n return createNameSchema(options)\n .transform((value) => (value ? value.toUpperCase() : value))\n .refine((value) => !value || isUppercase(value), {\n message: \"Must be uppercase\",\n });\n}\n\nexport function createLowercaseSnakeCaseSchema(options: SchemaOptions = {}) {\n return createNameSchema(options)\n .transform((value) => (value ? value.toLowerCase() : value))\n .refine((value) => !value || isLowercase(value), {\n message: \"Must be lowercase\",\n });\n}\n\nexport function toLowercaseSnakeCase(\n value: string,\n options: SchemaOptions = {},\n) {\n return createLowercaseSnakeCaseSchema(options).parse(\n snakeCase(value),\n ) as LowercaseSnakeCase;\n}\n\nexport function toConstantCase(value: string, options: SchemaOptions = {}) {\n return createConstantCaseSchema(options).parse(\n constantCase(value),\n ) as ConstantCase;\n}\n\nexport type SnakeCase = `${string}_${string}`;\nexport type LowercaseSnakeCase = Lowercase<SnakeCase>;\nexport type ConstantCase = Uppercase<SnakeCase>;\nexport type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport const AuthorSchema = z\n .object({\n name: createNameSchema({ allowEmpty: true }),\n website: z\n .union([z.url(), z.literal(\"\")])\n .optional()\n .default(\"\"),\n })\n .default({\n name: \"\",\n website: \"\",\n });\n","import React from \"react\";\nimport type { FieldValues, FieldPath } from \"react-hook-form\";\n\nexport type FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nexport const FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nexport type FormItemContextValue = {\n id: string;\n};\n\nexport const FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n","import React from \"react\";\nimport { useFormContext } from \"react-hook-form\";\nimport { FormFieldContext, FormItemContext } from \"../context/form-context.js\";\n\nexport const useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState, formState } = useFormContext();\n\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n","\"use client\";\n\n// src/label.tsx\nimport * as React from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NAME = \"Label\";\nvar Label = React.forwardRef((props, forwardedRef) => {\n return /* @__PURE__ */ jsx(\n Primitive.label,\n {\n ...props,\n ref: forwardedRef,\n onMouseDown: (event) => {\n const target = event.target;\n if (target.closest(\"button, input, select, textarea\")) return;\n props.onMouseDown?.(event);\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault();\n }\n }\n );\n});\nLabel.displayName = NAME;\nvar Root = Label;\nexport {\n Label,\n Root\n};\n//# sourceMappingURL=index.mjs.map\n","import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport { cva } from \"class-variance-authority\";\nimport { twMerge } from \"tailwind-merge\";\n\nconst labelVariants = cva(\n \"text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n);\n\nconst Label = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &\n VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root\n ref={ref}\n className={twMerge(labelVariants(), className)}\n {...props}\n />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n","import * as React from \"react\";\nimport type * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport type { ControllerProps, FieldPath, FieldValues } from \"react-hook-form\";\nimport { Controller, FormProvider } from \"react-hook-form\";\nimport { FormFieldContext, FormItemContext } from \"../context/form-context.js\";\nimport { useFormField } from \"../hooks/useFormField.js\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Label } from \"./label.js\";\n\nconst Form = FormProvider;\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst FormItem = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={className} {...props} />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = \"FormItem\";\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n ref={ref}\n className={twMerge(error && \"text-red-900 dark:text-red-400\", className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n});\nFormLabel.displayName = \"FormLabel\";\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={\n !error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\nFormControl.displayName = \"FormControl\";\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={twMerge(\n \"text-sm text-gray-700 dark:text-slate-200\",\n className,\n )}\n {...props}\n />\n );\n});\nFormDescription.displayName = \"FormDescription\";\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error.message) : children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={twMerge(\n \"text-sm font-medium text-red-800 dark:text-red-100\",\n className,\n )}\n {...props}\n >\n {body}\n </p>\n );\n});\nFormMessage.displayName = \"FormMessage\";\n\nexport {\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n","import * as React from \"react\";\nimport { forwardRef, useImperativeHandle, useRef, useCallback } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}\n\nexport interface TextareaHandle {\n focus: () => void;\n element: HTMLTextAreaElement | null;\n}\n\nexport const Textarea = forwardRef<TextareaHandle, TextareaProps>(\n ({ className, ...props }, ref) => {\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const adjustHeight = useCallback((textarea: HTMLTextAreaElement) => {\n textarea.style.height = \"auto\";\n const newHeight = Math.max(textarea.scrollHeight, textarea.offsetHeight);\n textarea.style.height = `${newHeight}px`;\n }, []);\n\n const handleInput = useCallback(\n (e: React.FormEvent<HTMLTextAreaElement>) => {\n adjustHeight(e.currentTarget);\n },\n [adjustHeight],\n );\n\n React.useEffect(() => {\n if (textareaRef.current) {\n adjustHeight(textareaRef.current);\n }\n }, [adjustHeight]);\n\n useImperativeHandle(ref, () => ({\n focus: () => textareaRef.current?.focus(),\n element: textareaRef.current,\n }));\n\n return (\n <textarea\n {...props}\n className={twMerge(\n \"min-h-10 w-full resize-none rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-900 placeholder:text-gray-600 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-500 dark:bg-slate-600 dark:text-slate-100 dark:placeholder:text-slate-300\",\n className,\n )}\n ref={textareaRef}\n onInput={handleInput}\n />\n );\n },\n);\nTextarea.displayName = \"Textarea\";\n","import { zodResolver } from \"@hookform/resolvers/zod\";\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport type { FieldValues, Resolver } from \"react-hook-form\";\nimport { useForm } from \"react-hook-form\";\nimport { z } from \"zod\";\nimport { createNameSchema } from \"../schemas/inputs.js\";\nimport { compareStringsWithoutWhitespace } from \"../utils/helpers.js\";\nimport {\n Form,\n FormControl,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from \"./form.js\";\nimport type { TextareaHandle } from \"./text-area.js\";\nimport { Textarea } from \"./text-area.js\";\n\ntype TextFieldProps = {\n name: string;\n value: string | null | undefined;\n onSubmit: (value: string) => void;\n label?: string;\n placeholder?: string;\n className?: string;\n rows?: number;\n focusOnMount?: boolean;\n required?: boolean;\n allowEmpty?: boolean;\n unique?: string[];\n shouldReset?: boolean;\n onChange?: (value: string) => void;\n};\n\ntype TextFieldHandle = {\n focus: () => void;\n};\n\nexport const TextField = forwardRef<TextFieldHandle, TextFieldProps>(\n (\n {\n name,\n value,\n onSubmit,\n label,\n placeholder,\n unique,\n className = \"\",\n rows = 1,\n focusOnMount = false,\n required = false,\n allowEmpty = false,\n shouldReset = false,\n onChange,\n },\n ref,\n ) => {\n const textareaRef = useRef<TextareaHandle | null>(null);\n const id = useId();\n useEffect(() => {\n if (focusOnMount && textareaRef.current) {\n textareaRef.current.focus();\n }\n }, [focusOnMount]);\n\n const fieldSchema = z.object({\n [name]: createNameSchema({ required, allowEmpty, unique }),\n });\n\n const form = useForm({\n resolver: zodResolver(\n fieldSchema as unknown as Parameters<typeof zodResolver>[0],\n ) as Resolver<FieldValues>,\n defaultValues: {\n [name]: value ?? \"\",\n },\n });\n\n const handleSubmit = useCallback(\n (values: FieldValues) => {\n const newValue = values[name] as string | undefined;\n if (newValue === undefined || value === newValue) return;\n onSubmit(newValue);\n if (shouldReset) form.reset({ [name]: \"\" });\n },\n [name, value, onSubmit, form, shouldReset],\n );\n\n const handleBlur = useCallback(async () => {\n const currentValue = (form.getValues()[name] as string | undefined) ?? \"\";\n\n if (value === null || value === undefined) {\n if (!currentValue || currentValue.trim() === \"\") return;\n }\n\n if (compareStringsWithoutWhitespace(currentValue, value ?? \"\")) return;\n\n try {\n await form.trigger(); // Trigger validation\n if (form.formState.isValid) {\n await form.handleSubmit(handleSubmit)();\n }\n } catch (_e) {\n // Allow blur to proceed even if validation fails\n }\n }, [form, handleSubmit, name, value]);\n\n const onEnterKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n (e.target as HTMLTextAreaElement).blur();\n }\n },\n [],\n );\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value;\n onChange?.(newValue);\n },\n [onChange],\n );\n\n useImperativeHandle(ref, () => ({\n focus: () => textareaRef.current?.focus(),\n }));\n\n useEffect(() => {\n form.reset({ [name]: value ?? \"\" });\n }, [form, name, value]);\n\n return (\n <Form {...form}>\n <FormField\n control={form.control}\n name={name}\n render={({ field }) => (\n <FormItem className=\"grid h-full grid-rows-[auto,1fr] gap-2 overflow-visible\">\n {!!label && (\n <FormLabel\n htmlFor={name}\n className=\"text-sm font-medium text-gray-700 dark:text-slate-200\"\n >\n {label}\n </FormLabel>\n )}\n <FormControl>\n <Textarea\n {...field}\n id={id}\n name={name}\n ref={(node) => {\n if (node) {\n field.ref(node.element);\n textareaRef.current = node;\n }\n }}\n placeholder={placeholder}\n onBlur={() => void handleBlur()}\n onChange={(e) => {\n field.onChange(e);\n handleChange(e);\n }}\n onKeyDown={onEnterKeyDown}\n rows={rows}\n className={className}\n />\n </FormControl>\n <FormMessage />\n </FormItem>\n )}\n />\n </Form>\n );\n },\n);\n\nTextField.displayName = \"TextField\";\n","import { useCallback } from \"react\";\nimport { z } from \"zod\";\nimport type { Scope } from \"../types/documents.js\";\nimport {\n handleModelNameChange,\n makeInitialSchemaDoc,\n renameSchemaType,\n} from \"../utils/helpers.js\";\nimport { TextField } from \"./text-field.js\";\n\nexport const MetadataFormSchema = z.object({\n name: z.string(),\n documentType: z.string(),\n extension: z.string().optional().default(\"\"),\n description: z.string(),\n authorName: z.string(),\n authorWebsite: z.string(),\n});\n\nexport type MetadataFormValues = z.infer<typeof MetadataFormSchema>;\n\ntype Props = MetadataFormValues & {\n globalStateSchema: string;\n localStateSchema: string;\n setModelName: (name: string) => void;\n setModelId: (id: string) => void;\n setModelExtension: (extension: string) => void;\n setModelDescription: (description: string) => void;\n setAuthorName: (authorName: string) => void;\n setAuthorWebsite: (authorWebsite: string) => void;\n setStateSchema: (schema: string, scope: Scope) => void;\n};\n\nexport default function ModelMetadata(props: Props) {\n return (\n <div>\n <ModelNameForm {...props} />\n <div className=\"flex h-full flex-col gap-4\">\n <div className=\"grid flex-1 grid-cols-3 items-start gap-4\">\n <div className=\"col-span-2 flex h-full flex-col gap-4\">\n <div className=\"shrink-0\">\n <DocumentTypeForm {...props} />\n </div>\n <div className=\"min-h-0 flex-1\">\n <DescriptionForm {...props} />\n </div>\n </div>\n <div className=\"col-span-1 flex flex-col gap-4\">\n <AuthorNameForm {...props} />\n <AuthorWebsiteForm {...props} />\n <ModelExtensionForm {...props} />\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nexport function ModelNameForm(props: Props) {\n const {\n name,\n globalStateSchema,\n localStateSchema,\n setModelName,\n setStateSchema,\n } = props;\n\n const onSubmit = useCallback(\n (newName: string) => {\n if (name === newName) {\n return;\n }\n setModelName(newName);\n\n const hasExistingSchema = !!globalStateSchema;\n\n if (!hasExistingSchema) {\n const initialSchemaDoc = makeInitialSchemaDoc(newName, \"global\");\n setStateSchema(initialSchemaDoc, \"global\");\n return;\n }\n const newSchema = renameSchemaType(\n globalStateSchema,\n name,\n newName,\n \"global\",\n );\n setStateSchema(newSchema, \"global\");\n\n if (localStateSchema) {\n const newLocalStateSchema = renameSchemaType(\n localStateSchema,\n name,\n newName,\n \"local\",\n );\n setStateSchema(newLocalStateSchema, \"local\");\n }\n handleModelNameChange({\n oldName: name,\n newName,\n globalStateSchema,\n localStateSchema,\n setStateSchema,\n });\n },\n [name, globalStateSchema, localStateSchema, setStateSchema, setModelName],\n );\n\n return (\n <TextField\n name=\"name\"\n value={name}\n onSubmit={onSubmit}\n placeholder=\"Model name\"\n className=\"border-none pl-0 text-xl font-bold text-gray-900 dark:text-slate-50\"\n required\n focusOnMount\n />\n );\n}\n\nexport function DocumentTypeForm(props: Props) {\n const { documentType, setModelId } = props;\n\n return (\n <TextField\n label=\"Document Type *\"\n name=\"powerhouse/document-model\"\n value={documentType}\n onSubmit={setModelId}\n placeholder=\"Document Type\"\n required\n />\n );\n}\n\nexport function ModelExtensionForm(props: Props) {\n const { extension, setModelExtension } = props;\n\n return (\n <TextField\n name=\"extension\"\n value={extension}\n onSubmit={setModelExtension}\n label=\"Model Extension\"\n placeholder=\"Example .phdm\"\n allowEmpty\n />\n );\n}\n\nexport function DescriptionForm(props: Props) {\n const { description, setModelDescription } = props;\n\n return (\n <TextField\n name=\"description\"\n label=\"Model Description\"\n value={description}\n onSubmit={setModelDescription}\n placeholder=\"Describe your document to others\"\n allowEmpty\n className=\"h-full\"\n />\n );\n}\n\nexport function AuthorNameForm(props: Props) {\n const { authorName, setAuthorName } = props;\n\n return (\n <TextField\n name=\"authorName\"\n value={authorName}\n onSubmit={setAuthorName}\n label=\"Author Name\"\n placeholder=\"Username or organisation\"\n allowEmpty\n />\n );\n}\n\nexport function AuthorWebsiteForm(props: Props) {\n const { authorWebsite, setAuthorWebsite } = props;\n\n return (\n <TextField\n name=\"authorWebsite\"\n value={authorWebsite}\n label=\"Website URL\"\n onSubmit={(newAuthorWebsite) => {\n if (!!authorWebsite && !newAuthorWebsite) return;\n setAuthorWebsite(newAuthorWebsite);\n }}\n placeholder=\"https://www.powerhouse.inc/\"\n allowEmpty\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { toLowercaseSnakeCase } from \"../schemas/inputs.js\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n modules?: ModuleSpecification[];\n module?: ModuleSpecification;\n onAddModule: (name: string) => Promise<string | undefined>;\n updateModuleName: (id: string, name: string) => void;\n};\n\nexport function ModuleForm({\n module,\n onAddModule,\n updateModuleName,\n modules = [],\n}: Props) {\n const isEdit = !!module;\n const moduleNames = modules.map((m) => m.name);\n\n const handleSubmit = async (name: string) => {\n const formattedName = toLowercaseSnakeCase(name);\n if (!formattedName.length) return;\n\n if (isEdit) {\n if (formattedName !== module.name) {\n updateModuleName(module.id, formattedName);\n }\n } else {\n await onAddModule(formattedName);\n }\n };\n\n return (\n <TextField\n key={module?.id ?? \"new\"}\n name=\"name\"\n label={isEdit ? \"Module name *\" : \"Add module *\"}\n value={module?.name}\n onSubmit={(name) => void handleSubmit(name)}\n placeholder=\"Add module\"\n unique={moduleNames}\n shouldReset={!isEdit}\n required\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { toConstantCase } from \"../schemas/inputs.js\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n module: ModuleSpecification;\n operation?: ModuleSpecification[\"operations\"][number];\n focusOnMount?: boolean;\n allOperationNames: string[];\n onAddOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n};\n\nexport function OperationForm({\n operation,\n module,\n focusOnMount,\n allOperationNames,\n onAddOperationAndInitialSchema,\n updateOperationName,\n deleteOperation,\n}: Props) {\n const isEdit = !!operation;\n\n const handleSubmit = async (name: string) => {\n if (isEdit && name === \"\") {\n deleteOperation(operation.id);\n return;\n }\n\n const formattedName = toConstantCase(name);\n\n if (isEdit) {\n if (formattedName !== operation.name) {\n updateOperationName(operation.id, formattedName);\n }\n } else {\n await onAddOperationAndInitialSchema(module.id, formattedName);\n }\n };\n\n const handleChange = (value: string) => {\n if (isEdit && value === \"\") {\n deleteOperation(operation.id);\n }\n };\n\n return (\n <TextField\n name=\"name\"\n value={operation?.name}\n label={isEdit ? \"Operation name *\" : \"Add operation *\"}\n onSubmit={(name) => void handleSubmit(name)}\n onChange={handleChange}\n placeholder=\"Add operation\"\n required={!isEdit}\n allowEmpty={!isEdit}\n shouldReset={!isEdit}\n focusOnMount={focusOnMount}\n unique={allOperationNames}\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useEffect, useRef } from \"react\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n operation: ModuleSpecification[\"operations\"][number];\n focusOnMount?: boolean;\n setOperationDescription: (id: string, description: string) => void;\n};\n\nexport function OperationDescriptionForm({\n operation,\n focusOnMount,\n setOperationDescription,\n}: Props) {\n const textFieldRef = useRef<{ focus: () => void } | null>(null);\n\n useEffect(() => {\n if (focusOnMount && textFieldRef.current) {\n textFieldRef.current.focus();\n }\n }, [focusOnMount]);\n\n return (\n <TextField\n ref={textFieldRef}\n name=\"description\"\n value={operation.description}\n onSubmit={(newDescription) =>\n setOperationDescription(operation.id, newDescription)\n }\n label=\"Operation description\"\n allowEmpty\n placeholder=\"Operation Description\"\n />\n );\n}\n","import type {\n ModuleSpecification,\n OperationErrorSpecification,\n} from \"@powerhousedao/shared/document-model\";\nimport { pascalCase } from \"change-case\";\nimport { useRef } from \"react\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n operation: ModuleSpecification[\"operations\"][number];\n error?: OperationErrorSpecification;\n focusOnMount?: boolean;\n onSubmit?: () => void;\n onAddOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n};\n\nexport function OperationErrorForm({\n operation,\n error,\n focusOnMount,\n onSubmit,\n onAddOperationError,\n deleteOperationError,\n setOperationErrorName,\n}: Props) {\n const textFieldRef = useRef<{ focus: () => void } | null>(null);\n const isEdit = !!error;\n const allOperationErrorNames = operation.errors\n .map((o) => o.name)\n .filter((n) => n !== null);\n\n const handleSubmit = (name: string) => {\n if (isEdit && name === \"\") {\n deleteOperationError(error.id);\n return;\n }\n\n const formattedName = pascalCase(name);\n\n if (isEdit) {\n setOperationErrorName(operation.id, error.id, formattedName);\n } else {\n void onAddOperationError(operation.id, formattedName);\n }\n onSubmit?.();\n };\n\n const handleChange = (value: string) => {\n if (isEdit && value === \"\") {\n deleteOperationError(error.id);\n }\n };\n\n return (\n <TextField\n ref={textFieldRef}\n name=\"name\"\n value={error?.name}\n onSubmit={handleSubmit}\n onChange={handleChange}\n placeholder=\"Add exception\"\n required={!isEdit}\n allowEmpty={!isEdit}\n shouldReset={!isEdit}\n unique={allOperationErrorNames}\n focusOnMount={focusOnMount}\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useCallback, useId, useState } from \"react\";\nimport { OperationErrorForm } from \"./operation-error-form.js\";\n\ntype Props = {\n operation: ModuleSpecification[\"operations\"][number];\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n};\n\nexport function OperationErrors({\n operation,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n}: Props) {\n const addErrorFormId = useId();\n const [shouldFocusAddForm, setShouldFocusAddForm] = useState(false);\n\n const onAddOperationError = useCallback(\n async (operationId: string, error: string) => {\n const errorId = await addOperationError(operationId, error);\n if (errorId) {\n setShouldFocusAddForm(true);\n }\n return errorId;\n },\n [addOperationError, setShouldFocusAddForm],\n );\n\n const onAddOperationErrorSubmit = useCallback(\n () => setShouldFocusAddForm(false),\n [setShouldFocusAddForm],\n );\n\n return (\n <ul className=\"ml-4 list-disc\">\n {operation.errors.map((error) => (\n <li key={error.id}>\n <OperationErrorForm\n error={error}\n operation={operation}\n onAddOperationError={onAddOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n />\n </li>\n ))}\n <li>\n <OperationErrorForm\n operation={operation}\n onAddOperationError={onAddOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n key={`${addErrorFormId}-${shouldFocusAddForm}`}\n focusOnMount={shouldFocusAddForm}\n onSubmit={onAddOperationErrorSubmit}\n />\n </li>\n </ul>\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { lazy, Suspense, useCallback } from \"react\";\nimport type { DocumentActionHandlers } from \"../types/documents.js\";\nimport { isEmptyOperationSchema } from \"../utils/helpers.js\";\nimport { ensureValidOperationSchemaInputName } from \"../utils/linting.js\";\nimport { OperationDescriptionForm } from \"./operation-description-form.js\";\nimport { OperationErrors } from \"./operation-errors.js\";\nimport { OperationForm } from \"./operation-form.js\";\nconst GraphqlEditor = lazy(() => import(\"./code-editors/graphql-editor.js\"));\nexport type WrappedHandlers = DocumentActionHandlers & {\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n};\ntype Props = {\n lastCreatedOperationId: string | null;\n operation: ModuleSpecification[\"operations\"][number];\n module: ModuleSpecification;\n allOperationNames: string[];\n onAddOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport function Operation(props: Props) {\n const {\n operation,\n module,\n allOperationNames,\n lastCreatedOperationId,\n onAddOperationAndInitialSchema,\n updateOperationName,\n deleteOperation,\n updateOperationSchema,\n setOperationDescription,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n toggleNoInputRequired,\n } = props;\n\n const noInputRequired = isEmptyOperationSchema(operation.schema);\n\n const handleToggleNoInput = useCallback(\n (checked: boolean) => toggleNoInputRequired(operation.id, checked),\n [operation.id, toggleNoInputRequired],\n );\n\n const handleUpdateDocument = useCallback(\n (newDoc: string) => updateOperationSchema(operation.id, newDoc),\n [operation.id, updateOperationSchema],\n );\n\n const customLinter = useCallback(\n (doc: string) =>\n operation.name\n ? ensureValidOperationSchemaInputName(doc, operation.name)\n : [],\n [operation.name],\n );\n\n return (\n <div\n className=\"mt-4 grid grid-cols-2 gap-x-12\"\n style={{\n gridTemplateAreas: `\n \"left editor\"\n \"errors editor\"\n `,\n gridTemplateRows: \"auto 1fr\",\n }}\n >\n <div className=\"flex flex-col gap-2\" style={{ gridArea: \"left\" }}>\n <OperationForm\n operation={operation}\n onAddOperationAndInitialSchema={onAddOperationAndInitialSchema}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n module={module}\n allOperationNames={allOperationNames}\n />\n <OperationDescriptionForm\n operation={operation}\n focusOnMount={operation.id === lastCreatedOperationId}\n setOperationDescription={setOperationDescription}\n />\n </div>\n\n <div className=\"relative top-8\" style={{ gridArea: \"editor\" }}>\n <label className=\"mb-2 flex cursor-pointer items-center gap-2\">\n <input\n type=\"checkbox\"\n checked={noInputRequired}\n onChange={(e) => handleToggleNoInput(e.target.checked)}\n className=\"size-4 rounded-sm border-gray-300 dark:border-slate-500 dark:bg-slate-600 dark:text-slate-100\"\n />\n <span className=\"text-sm text-gray-700 dark:text-slate-200\">\n Operation with no inputs\n </span>\n </label>\n {!noInputRequired && (\n <Suspense>\n <GraphqlEditor\n doc={operation.schema ?? \"\"}\n updateDocumentInModel={handleUpdateDocument}\n customLinter={customLinter}\n />\n </Suspense>\n )}\n </div>\n\n <div style={{ gridArea: \"errors\" }}>\n <h3 className=\"my-2 text-sm font-medium text-gray-700 dark:text-slate-200\">\n Reducer Exceptions\n </h3>\n <OperationErrors\n operation={operation}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n />\n </div>\n </div>\n );\n}\n","import { OperationForm } from \"./operation-form.js\";\nimport type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useCallback, useId, useState } from \"react\";\nimport { Operation } from \"./operation.js\";\n\ntype Props = {\n module: ModuleSpecification;\n allOperations: ModuleSpecification[\"operations\"];\n shouldFocusNewOperation: boolean;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport function Operations({\n module,\n allOperations,\n shouldFocusNewOperation,\n updateOperationName,\n deleteOperation,\n addOperationAndInitialSchema,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n updateOperationSchema,\n setOperationDescription,\n toggleNoInputRequired,\n}: Props) {\n const [lastCreatedOperationId, setLastCreatedOperationId] = useState<\n string | null\n >(null);\n const addOperationFormId = useId();\n const allOperationNames = allOperations\n .map((o) => o.name)\n .filter((n) => n !== null);\n\n const onAddOperationAndInitialSchema = useCallback(\n async (moduleId: string, name: string) => {\n const operationId = await addOperationAndInitialSchema(moduleId, name);\n if (operationId) {\n setLastCreatedOperationId(operationId);\n }\n return operationId;\n },\n [addOperationAndInitialSchema, setLastCreatedOperationId],\n );\n\n return (\n <div>\n {module.operations.map((operation) => (\n <div key={operation.id}>\n <Operation\n operation={operation}\n module={module}\n lastCreatedOperationId={lastCreatedOperationId}\n allOperationNames={allOperationNames}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n onAddOperationAndInitialSchema={onAddOperationAndInitialSchema}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n </div>\n ))}\n <div className=\"mt-6 w-1/2 pr-6\">\n <OperationForm\n key={addOperationFormId}\n onAddOperationAndInitialSchema={onAddOperationAndInitialSchema}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n module={module}\n allOperationNames={allOperationNames}\n focusOnMount={shouldFocusNewOperation}\n />\n </div>\n </div>\n );\n}\n","import type { ModuleSpecification as TModule } from \"@powerhousedao/shared/document-model\";\nimport { ModuleForm } from \"./module-form.js\";\nimport { Operations } from \"./operations.js\";\ntype Props = {\n module?: TModule;\n modules?: TModule[];\n allOperations: TModule[\"operations\"];\n lastCreatedModuleId: string | null;\n onAddModule: (name: string) => Promise<string | undefined>;\n updateModuleName: (id: string, name: string) => void;\n deleteModule: (id: string) => void;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport function Module(props: Props) {\n const {\n module,\n modules,\n allOperations,\n lastCreatedModuleId,\n onAddModule,\n updateModuleName,\n deleteModule,\n updateOperationName,\n deleteOperation,\n addOperationAndInitialSchema,\n updateOperationSchema,\n setOperationDescription,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n toggleNoInputRequired,\n } = props;\n return (\n <div className=\"relative rounded-3xl bg-gray-100 p-6 dark:bg-slate-700\">\n <div className=\"mb-2 w-1/2 pr-6\">\n <ModuleForm\n modules={modules}\n module={module}\n onAddModule={onAddModule}\n updateModuleName={updateModuleName}\n />\n {!!module && (\n <button\n aria-label=\"Delete module\"\n tabIndex={-1}\n className=\"absolute top-1 right-1 p-2 text-gray-900 transition-colors hover:text-gray-500 dark:text-slate-100 dark:hover:text-slate-400\"\n onClick={() => {\n deleteModule(module.id);\n }}\n >\n <svg className=\"size-6\" viewBox=\"0 0 24 24\" fill=\"currentcolor\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M16.9993 8.51506L15.4844 7L11.9994 10.4852L8.51497 7.00057L7 8.51562L10.4844 12.0003L7.00056 15.4843L8.51552 16.9994L11.9994 13.5153L15.4838 17L16.9988 15.4849L13.5144 12.0003L16.9993 8.51506Z\"\n />\n </svg>\n </button>\n )}\n </div>\n {!!module && (\n <Operations\n module={module}\n allOperations={allOperations}\n shouldFocusNewOperation={module.id === lastCreatedModuleId}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n )}\n </div>\n );\n}\n","import type { ModuleSpecification as TModule } from \"@powerhousedao/shared/document-model\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { Module } from \"./module.js\";\n\ntype Props = {\n modules: TModule[];\n allOperations: TModule[\"operations\"];\n addModule: (name: string) => Promise<string | undefined>;\n updateModuleName: (id: string, name: string) => void;\n deleteModule: (id: string) => void;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport default function Modules({\n modules,\n allOperations,\n addModule,\n updateModuleName,\n deleteModule,\n updateOperationName,\n deleteOperation,\n addOperationAndInitialSchema,\n updateOperationSchema,\n setOperationDescription,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n toggleNoInputRequired,\n}: Props) {\n const [lastCreatedModuleId, setLastCreatedModuleId] = useState<string | null>(\n null,\n );\n const focusTrapRef = useRef<HTMLDivElement>(null);\n\n const onAddModule = useCallback(\n async (name: string) => {\n const moduleId = await addModule(name);\n if (moduleId) {\n setLastCreatedModuleId(moduleId);\n focusTrapRef.current?.focus();\n }\n return moduleId;\n },\n [addModule, setLastCreatedModuleId],\n );\n\n return (\n <div className=\"flex flex-col gap-2\">\n {modules.map((module) => (\n <Module\n key={module.id}\n module={module}\n modules={modules}\n allOperations={allOperations}\n lastCreatedModuleId={lastCreatedModuleId}\n onAddModule={onAddModule}\n updateModuleName={updateModuleName}\n deleteModule={deleteModule}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n ))}\n <Module\n key=\"add-module\"\n modules={modules}\n allOperations={allOperations}\n lastCreatedModuleId={lastCreatedModuleId}\n onAddModule={onAddModule}\n updateModuleName={updateModuleName}\n deleteModule={deleteModule}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n {/* Focus trap to prevent tabbing out of the editor */}\n <div\n ref={focusTrapRef}\n tabIndex={0}\n className=\"size-0 overflow-hidden\"\n aria-hidden=\"true\"\n />\n </div>\n );\n}\n","import type { PHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\n\nexport const editorConfig: PHDocumentEditorConfig = {\n isExternalControlsEnabled: false,\n};\n","import {\n useDocumentOfType,\n useSelectedDocumentOfType,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n DocumentModelAction,\n DocumentModelDocument,\n} from \"@powerhousedao/shared/document-model\";\n\nexport function useDocumentModelDocument(\n documentId: string | undefined | null,\n): ReturnType<\n typeof useDocumentOfType<DocumentModelDocument, DocumentModelAction>\n> {\n return useDocumentOfType<DocumentModelDocument, DocumentModelAction>(\n documentId,\n \"powerhouse/document-model\",\n );\n}\n\nexport function useSelectedDocumentModelDocument(): ReturnType<\n typeof useSelectedDocumentOfType<DocumentModelDocument, DocumentModelAction>\n> {\n return useSelectedDocumentOfType<DocumentModelDocument, DocumentModelAction>(\n \"powerhouse/document-model\",\n );\n}\n","import { DocumentToolbar } from \"@powerhousedao/design-system/connect\";\nimport {\n usePHToast,\n useSetPHDocumentEditorConfig,\n} from \"@powerhousedao/reactor-browser\";\nimport { pascalCase } from \"change-case\";\nimport { generateId } from \"@powerhousedao/shared/document-model\";\nimport {\n addModule,\n addOperation,\n addOperationError,\n deleteModule,\n deleteOperation,\n deleteOperationError,\n setAuthorName,\n setAuthorWebsite,\n setInitialState,\n setModelDescription,\n setModelExtension,\n setModelId,\n setModelName,\n setModuleName,\n setOperationDescription,\n setOperationErrorName,\n setOperationName,\n setOperationSchema,\n setStateSchema,\n} from \"@powerhousedao/shared/document-model\";\nimport { lazy, Suspense, useEffect, useRef, useState } from \"react\";\nimport { Divider } from \"./components/divider.js\";\nimport ModelMetadata from \"./components/model-metadata-form.js\";\nimport Modules from \"./components/modules.js\";\nimport { editorConfig } from \"./config.js\";\nimport { SchemaContextProvider } from \"./context/schema-context.js\";\nimport { useSelectedDocumentModelDocument } from \"./hooks/useDocumentModelDocument.js\";\nimport type { Scope } from \"./types/documents.js\";\nimport {\n compareStringsWithoutWhitespace,\n initializeModelSchema,\n makeEmptyOperationSchema,\n makeOperationInitialDoc,\n} from \"./utils/helpers.js\";\nconst StateSchemas = lazy(() => import(\"./components/state-schemas.js\"));\n\nexport default function Editor() {\n useSetPHDocumentEditorConfig(editorConfig);\n const toast = usePHToast();\n const [document, dispatch] = useSelectedDocumentModelDocument();\n const [scope, setScope] = useState<Scope>(\"global\");\n const documentNodeName = document.header.name;\n const {\n name: modelName,\n id: documentType,\n extension,\n description,\n author: { name: authorName, website: authorWebsite },\n } = document.state.global;\n const {\n state: {\n global: {\n schema: globalStateSchema,\n initialValue: globalStateInitialValue,\n },\n local: { schema: localStateSchema, initialValue: localStateInitialValue },\n },\n modules,\n } = document.state.global.specifications[0];\n const operations = modules.flatMap((module) => module.operations);\n const shouldSetInitialName = useRef(\n !modelName && !!documentNodeName && operations.length === 0,\n );\n\n useEffect(() => {\n if (!shouldSetInitialName.current || !documentNodeName) return;\n\n const initialSchemaDoc = initializeModelSchema(documentNodeName);\n const actions = [\n setModelName({ name: documentNodeName }),\n setStateSchema({ schema: initialSchemaDoc, scope: \"global\" }),\n ];\n dispatch(actions);\n shouldSetInitialName.current = false;\n }, [documentNodeName, dispatch]);\n\n const operationSchemasSdl = operations\n .flatMap((operation) => operation.schema ?? [])\n .join(\"\\n\");\n\n const handleSetModelId = (id: string) => {\n if (compareStringsWithoutWhitespace(id, documentType)) return;\n dispatch([setModelId({ id })]);\n };\n\n const handleSetModelDescription = (newDescription: string) => {\n if (compareStringsWithoutWhitespace(newDescription, description)) return;\n dispatch(setModelDescription({ description: newDescription }));\n };\n\n const handleSetModelExtension = (newExtension: string) => {\n if (compareStringsWithoutWhitespace(newExtension, extension)) return;\n dispatch(setModelExtension({ extension: newExtension }));\n };\n\n const handleSetModelName = (newName: string) => {\n if (compareStringsWithoutWhitespace(newName, modelName)) return;\n dispatch(setModelName({ name: newName }));\n };\n\n const handleSetAuthorName = (newAuthorName: string) => {\n if (compareStringsWithoutWhitespace(newAuthorName, authorName)) return;\n dispatch(setAuthorName({ authorName: newAuthorName }));\n };\n\n const handleSetAuthorWebsite = (newAuthorWebsite: string) => {\n if (compareStringsWithoutWhitespace(newAuthorWebsite, authorWebsite ?? \"\"))\n return;\n dispatch(setAuthorWebsite({ authorWebsite: newAuthorWebsite }));\n };\n\n const handleSetStateSchema = (newSchema: string, scope: Scope) => {\n const oldSchema = scope === \"global\" ? globalStateSchema : localStateSchema;\n if (compareStringsWithoutWhitespace(newSchema, oldSchema)) return;\n dispatch(setStateSchema({ schema: newSchema, scope }));\n };\n\n const handleSetInitialState = (newInitialValue: string, scope: Scope) => {\n const oldInitialValue =\n scope === \"global\" ? globalStateInitialValue : localStateInitialValue;\n if (compareStringsWithoutWhitespace(newInitialValue, oldInitialValue))\n return;\n dispatch(setInitialState({ initialValue: newInitialValue, scope }));\n };\n\n const handleAddModule = (name: string): Promise<string | undefined> => {\n return new Promise((resolve) => {\n try {\n if (\n modules.some((module) =>\n compareStringsWithoutWhitespace(module.name, name),\n )\n ) {\n resolve(undefined);\n return;\n }\n const id = generateId();\n dispatch(addModule({ id, name }));\n resolve(id);\n } catch (error) {\n console.error(\"Failed to add module:\", error);\n resolve(undefined);\n }\n });\n };\n\n const handleSetModuleName = (id: string, name: string) => {\n if (\n modules.some((module) =>\n compareStringsWithoutWhitespace(module.name, name),\n )\n )\n return;\n dispatch(setModuleName({ id, name }));\n };\n\n const handleDeleteModule = (id: string) => {\n dispatch(deleteModule({ id }));\n };\n\n const handleAddOperation = (\n moduleId: string,\n name: string,\n ): Promise<string | undefined> => {\n return new Promise((resolve) => {\n const id = generateId();\n dispatch(\n addOperation({ id, moduleId, name, scope }),\n (errors) => {\n if (errors.length > 0) {\n if (toast) {\n toast(errors[0].message, { type: \"connect-warning\" });\n }\n resolve(undefined);\n } else {\n resolve(id);\n }\n },\n () => resolve(id),\n );\n });\n };\n\n const handleSetOperationName = (id: string, name: string) => {\n dispatch(setOperationName({ id, name }), (errors) => {\n if (errors.length > 0 && toast) {\n toast(errors[0].message, { type: \"connect-warning\" });\n }\n });\n };\n\n const handleSetOperationSchema = (id: string, newSchema: string) => {\n const operation = operations.find((operation) => operation.id === id);\n if (\n operation?.schema &&\n compareStringsWithoutWhitespace(newSchema, operation.schema)\n )\n return;\n dispatch(setOperationSchema({ id, schema: newSchema }));\n };\n\n const handleToggleNoInputRequired = (\n id: string,\n noInputRequired: boolean,\n ) => {\n const operation = operations.find((op) => op.id === id);\n if (!operation?.name) return;\n\n if (noInputRequired) {\n dispatch(\n setOperationSchema({\n id,\n schema: makeEmptyOperationSchema(operation.name),\n }),\n );\n } else {\n dispatch(\n setOperationSchema({\n id,\n schema: makeOperationInitialDoc(operation.name),\n }),\n );\n }\n };\n\n const handleSetOperationDescription = (\n id: string,\n newDescription: string,\n ) => {\n const operationDescription =\n operations.find((operation) => operation.id === id)?.description ?? \"\";\n if (compareStringsWithoutWhitespace(operationDescription, newDescription))\n return;\n dispatch(setOperationDescription({ id, description: newDescription }));\n };\n\n const handleDeleteOperation = (id: string) => {\n dispatch(deleteOperation({ id }));\n };\n\n const handleAddOperationError = (\n operationId: string,\n errorName: string,\n ): Promise<string | undefined> => {\n return new Promise((resolve) => {\n try {\n const operation = operations.find(\n (operation) => operation.id === operationId,\n );\n const operationErrorNames =\n operation?.errors.map((error) => error.name).filter(Boolean) ?? [];\n if (\n operationErrorNames.some((name) =>\n compareStringsWithoutWhitespace(name, errorName),\n )\n ) {\n resolve(undefined);\n return;\n }\n const id = generateId();\n const errorCode = pascalCase(errorName);\n dispatch(addOperationError({ id, operationId, errorName, errorCode }));\n resolve(id);\n } catch (error) {\n console.error(\"Failed to add operation error:\", error);\n resolve(undefined);\n }\n });\n };\n\n const handleDeleteOperationError = (id: string) => {\n dispatch(deleteOperationError({ id }));\n };\n\n const handleSetOperationErrorName = (\n operationId: string,\n errorId: string,\n errorName: string,\n ) => {\n const operation = operations.find(\n (operation) => operation.id === operationId,\n );\n const operationErrorNames =\n operation?.errors.map((error) => error.name).filter(Boolean) ?? [];\n if (\n operationErrorNames.some((name) =>\n compareStringsWithoutWhitespace(name, errorName),\n )\n )\n return;\n dispatch(setOperationErrorName({ id: errorId, errorName }));\n };\n\n const addOperationAndInitialSchema = async (\n moduleId: string,\n name: string,\n ): Promise<string | undefined> => {\n try {\n const id = await handleAddOperation(moduleId, name);\n if (!id) return undefined;\n try {\n handleSetOperationSchema(id, makeOperationInitialDoc(name));\n return id;\n } catch (error) {\n console.error(\"Failed to update operation schema:\", error);\n return undefined;\n }\n } catch (error) {\n console.error(\"Failed to add operation and schema:\", error);\n return undefined;\n }\n };\n\n return (\n <main className=\"min-h-dvh bg-gray-50 p-6 dark:bg-slate-800\">\n <DocumentToolbar />\n <SchemaContextProvider\n globalStateSchemaSdl={globalStateSchema}\n localStateSchemaSdl={localStateSchema}\n operationSchemasSdl={operationSchemasSdl}\n >\n <div className=\"mx-auto max-w-6xl px-4 pt-8\">\n <ModelMetadata\n name={modelName}\n documentType={documentType}\n extension={extension}\n description={description}\n authorName={authorName}\n authorWebsite={authorWebsite ?? \"\"}\n globalStateSchema={globalStateSchema}\n localStateSchema={localStateSchema}\n setModelId={handleSetModelId}\n setModelDescription={handleSetModelDescription}\n setModelExtension={handleSetModelExtension}\n setModelName={handleSetModelName}\n setAuthorName={handleSetAuthorName}\n setAuthorWebsite={handleSetAuthorWebsite}\n setStateSchema={handleSetStateSchema}\n />\n <Divider />\n <div>\n <Suspense>\n <StateSchemas\n modelName={modelName}\n globalStateSchema={globalStateSchema}\n globalStateInitialValue={globalStateInitialValue}\n localStateSchema={localStateSchema}\n localStateInitialValue={localStateInitialValue}\n setStateSchema={handleSetStateSchema}\n setInitialState={handleSetInitialState}\n currentScope={scope}\n onScopeChange={setScope}\n />\n </Suspense>\n <Divider />\n <h3 className=\"mb-6 text-lg text-gray-900 capitalize dark:text-slate-100\">\n {scope} Operations\n </h3>\n <Modules\n modules={modules.map((module) => ({\n ...module,\n operations: module.operations.filter(\n (op) => op.scope === scope,\n ),\n }))}\n allOperations={operations}\n addModule={handleAddModule}\n updateModuleName={handleSetModuleName}\n deleteModule={handleDeleteModule}\n updateOperationName={handleSetOperationName}\n updateOperationSchema={handleSetOperationSchema}\n setOperationDescription={handleSetOperationDescription}\n deleteOperation={handleDeleteOperation}\n addOperationError={handleAddOperationError}\n deleteOperationError={handleDeleteOperationError}\n setOperationErrorName={handleSetOperationErrorName}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n toggleNoInputRequired={handleToggleNoInputRequired}\n />\n </div>\n </div>\n </SchemaContextProvider>\n </main>\n );\n}\n"],"x_google_ignoreList":[0,1,2,3,5,6,10],"mappings":";;;;;;;;;;;;AAIA,IAAI,kBAAkB,OAAO,IAAI,aAAa;AAC9C,IAAIA,QAAMC,QAAM,QAAQ,MAAM,CAAC,UAAU;AACzC,SAAS,cAAc,OAAO;AAC5B,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;;AAElE,SAA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EAAW,CAAA;MACX,qBAAC,MAAD;OAAI,WAAU;iBAAd,CACG,OAAM,cACJ;;MACL,oBAAC,SAAD;OACE,SAAS,QAAQ,KAAK,YAAY;QAChC,GAAG;QACH,YAAY,OAAO,WAAW,QAC3B,OAAO,GAAG,UAAU,MACtB;QACF,EAAE;OACH,eAAe;OACf,WAAW;OACX,kBAAkB;OAClB,cAAc;OACd,qBAAqB;OACrB,uBAAuB;OACvB,yBAAyB;OACzB,iBAAiB;OACjB,mBAAmB;OACnB,sBAAsB;OACtB,uBAAuB;OACO;OAC9B,uBAAuB;OACvB,CAAA;MACE,EAAA,CAAA;KACF;;GACgB,CAAA,CACnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"folder-view-DmYBf2pP.js","names":[],"sources":["../../editors/generic-drive-explorer/components/create-document.tsx","../../editors/generic-drive-explorer/components/file-content-view.tsx","../../editors/generic-drive-explorer/components/layout.tsx","../../editors/generic-drive-explorer/components/folder-view.tsx"],"sourcesContent":["import { PowerhouseButton } from \"@powerhousedao/design-system\";\nimport {\n showCreateDocumentModal,\n useDocumentModelModules,\n useUserPermissions,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n DocumentModelGlobalState,\n DocumentModelModule,\n} from \"@powerhousedao/shared/document-model\";\n\nfunction getDocumentSpec(doc: DocumentModelModule): DocumentModelGlobalState {\n return doc.documentModel.global;\n}\n\nexport function CreateDocument() {\n const { isAllowedToCreateDocuments } = useUserPermissions();\n const documentModelModules = useDocumentModelModules();\n const nonDriveDocumentModelModules = documentModelModules?.filter(\n (module) => module.documentModel.global.id !== \"powerhouse/document-drive\",\n );\n if (!isAllowedToCreateDocuments) return null;\n return (\n <div className=\"px-6 py-4\">\n <h3 className=\"mb-3 text-xl font-bold text-gray-700 dark:text-slate-200\">\n New document\n </h3>\n <div className=\"flex w-full flex-wrap gap-4\">\n {nonDriveDocumentModelModules?.map((doc) => {\n const spec = getDocumentSpec(doc);\n const versionLabel = doc.version ? ` v${doc.version}` : \"\";\n return (\n <PowerhouseButton\n key={`${spec.id}-v${doc.version ?? 1}`}\n color=\"light\"\n title={`${spec.name}${versionLabel}`}\n aria-description={spec.description}\n onClick={() => showCreateDocumentModal(spec.id)}\n >\n <span className=\"text-sm\">\n {spec.name}\n {versionLabel}\n </span>\n </PowerhouseButton>\n );\n })}\n </div>\n </div>\n );\n}\n","import { useWindowSize } from \"@powerhousedao/design-system\";\nimport { FileItem } from \"@powerhousedao/design-system/connect\";\nimport {\n isFileNodeKind,\n useNodesInSelectedDriveOrFolder,\n} from \"@powerhousedao/reactor-browser\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport type { FileNode } from \"@powerhousedao/shared/document-drive\";\nimport React, { useRef } from \"react\";\n\nconst GAP = 8;\nconst ITEM_WIDTH = 256;\nconst ITEM_HEIGHT = 48;\n\nconst USED_SPACE = 420;\n\nexport function FileContentView() {\n const parentRef = useRef(null);\n const windowSize = useWindowSize();\n const availableWidth = windowSize.innerWidth - USED_SPACE;\n const nodes = useNodesInSelectedDriveOrFolder();\n const fileNodes = nodes.filter((n) => isFileNodeKind(n));\n const columnCount = Math.floor(availableWidth / (ITEM_WIDTH + GAP)) || 1;\n const rowCount = Math.ceil(fileNodes.length / columnCount);\n\n const rowVirtualizer = useVirtualizer({\n count: rowCount,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n if (index > 0) {\n return ITEM_HEIGHT + GAP;\n }\n return ITEM_HEIGHT;\n },\n overscan: 5,\n });\n\n const columnVirtualizer = useVirtualizer({\n horizontal: true,\n count: columnCount,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n if (index > 0) {\n return ITEM_WIDTH + GAP;\n }\n return ITEM_WIDTH;\n },\n overscan: 5,\n });\n\n const getItemIndex = (rowIndex: number, columnIndex: number) =>\n rowIndex * columnCount + columnIndex;\n\n const getItem = (rowIndex: number, columnIndex: number): FileNode | null => {\n const index = getItemIndex(rowIndex, columnIndex);\n return fileNodes[index] || null;\n };\n\n if (fileNodes.length === 0) {\n return (\n <div className=\"mb-8 text-sm text-gray-400 dark:text-slate-200\">\n No documents or files 📄\n </div>\n );\n }\n\n const renderItem = (rowIndex: number, columnIndex: number) => {\n const fileNode = getItem(rowIndex, columnIndex);\n\n if (!fileNode) {\n return null;\n }\n\n return (\n <div\n style={{\n marginLeft: columnIndex === 0 ? 0 : GAP,\n }}\n >\n <FileItem key={fileNode.id} fileNode={fileNode} />\n </div>\n );\n };\n\n return (\n <div\n ref={parentRef}\n style={{\n width: `100%`,\n overflow: \"auto\",\n }}\n >\n <div\n style={{\n height: `${rowVirtualizer.getTotalSize()}px`,\n width: `${columnVirtualizer.getTotalSize()}px`,\n position: \"relative\",\n }}\n >\n {rowVirtualizer.getVirtualItems().map((virtualRow) => (\n <React.Fragment key={virtualRow.key}>\n {columnVirtualizer.getVirtualItems().map((virtualColumn) => (\n <div\n key={virtualColumn.key}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n marginTop: virtualRow.index === 0 ? 0 : GAP,\n width: `${virtualColumn.size}px`,\n height: `${ITEM_HEIGHT}px`,\n overflow: \"hidden\",\n transform: `translateX(${virtualColumn.start}px) translateY(${virtualRow.start}px)`,\n }}\n >\n {renderItem(virtualRow.index, virtualColumn.index)}\n </div>\n ))}\n </React.Fragment>\n ))}\n </div>\n </div>\n );\n}\n","import { twMerge } from \"tailwind-merge\";\nimport type { BaseProps } from \"../utils/types.js\";\n\nexport function DriveLayout({ children, className, ...props }: BaseProps) {\n return (\n <DriveLayout.Container className={className} {...props}>\n {children}\n </DriveLayout.Container>\n );\n}\n\nDriveLayout.Container = function DriveLayoutContainer({\n children,\n className,\n containerProps,\n ...props\n}: BaseProps) {\n return (\n <div\n className={twMerge(\"flex grow flex-col overflow-auto\", className)}\n {...containerProps}\n {...props}\n >\n {children}\n </div>\n );\n};\n\nDriveLayout.Header = function DriveLayoutHeader({\n children,\n className,\n containerProps,\n ...props\n}: BaseProps) {\n return (\n <div\n className={twMerge(\"flex-0\", className)}\n {...containerProps}\n {...props}\n >\n {children}\n </div>\n );\n};\n\nDriveLayout.Content = function DriveLayoutContent({\n children,\n className,\n containerProps,\n ...props\n}: BaseProps) {\n return (\n <div\n className={twMerge(\"mb-5 flex-1 px-4\", className)}\n {...containerProps}\n {...props}\n >\n {children}\n </div>\n );\n};\n\nDriveLayout.ContentSection = function DriveLayoutContentSection({\n title,\n children,\n className,\n containerProps,\n ...props\n}: BaseProps & { title?: string }) {\n return (\n <div className={twMerge(className)} {...containerProps} {...props}>\n {title && (\n <div className=\"mb-4 text-base font-semibold text-gray-700 dark:text-slate-200\">\n {title}\n </div>\n )}\n <div className=\"flex flex-wrap gap-2\">{children}</div>\n </div>\n );\n};\n\nDriveLayout.Footer = function DriveLayoutFooter({\n children,\n className,\n containerProps,\n ...props\n}: BaseProps) {\n return (\n <div\n className={twMerge(\"flex-0\", className)}\n {...containerProps}\n {...props}\n >\n {children}\n </div>\n );\n};\n","import { FolderItem } from \"@powerhousedao/design-system/connect\";\nimport {\n isFolderNodeKind,\n useNodesInSelectedDriveOrFolder,\n} from \"@powerhousedao/reactor-browser\";\nimport { twMerge } from \"tailwind-merge\";\nimport { FileContentView } from \"./file-content-view.js\";\nimport { DriveLayout } from \"./layout.js\";\n\nexport function FolderView(props: { className?: string }) {\n const { className } = props;\n const nodes = useNodesInSelectedDriveOrFolder();\n const folderNodes = nodes.filter((n) => isFolderNodeKind(n));\n return (\n <div\n className={twMerge(\n \"rounded-md border-2 border-transparent p-2\",\n className,\n )}\n >\n <DriveLayout.ContentSection title=\"Folders\" className=\"mb-4\">\n {folderNodes.length > 0 ? (\n folderNodes.map((folderNode) => (\n <FolderItem key={folderNode.id} folderNode={folderNode} />\n ))\n ) : (\n <div className=\"mb-8 text-sm text-gray-400 dark:text-slate-200\">\n No documents or files 📄\n </div>\n )}\n </DriveLayout.ContentSection>\n <DriveLayout.ContentSection title=\"Documents and files\">\n <div className=\"w-full\">\n <FileContentView />\n </div>\n </DriveLayout.ContentSection>\n </div>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BAAC,YAAY,gBAAb;GAA4B,OAAM;GAAU,WAAU;aACnD,YAAY,SAAS,IACpB,YAAY,KAAK,eACf,oBAAC,YAAD,EAA4C,YAAc,EAAzC,WAAW,GAA8B,CAC1D,GAEF,oBAAC,OAAD;IAAK,WAAU;cAAiD;IAE1D,CAAA;GAEmB,CAAA,EAC7B,oBAAC,YAAY,gBAAb;GAA4B,OAAM;aAChC,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,iBAAD,EAAmB,CAAA;IACf,CAAA;GACqB,CAAA,CACzB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"state-schemas-DJmzG_M8.js","names":["TabsPrimitive.Root","React","TabsPrimitive.List","TabsPrimitive.Trigger","TabsPrimitive.Content"],"sources":["../../editors/document-model-editor/components/button.tsx","../../editors/document-model-editor/components/state-error.tsx","../../editors/document-model-editor/components/tabs.tsx","../../editors/document-model-editor/components/state-schemas.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from \"react\";\nimport { forwardRef } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\n\ntype Props = ComponentPropsWithRef<\"button\">;\n\nexport const Button = forwardRef<HTMLButtonElement, Props>((props, ref) => {\n const { className, ...rest } = props;\n return (\n <button\n ref={ref}\n {...rest}\n className={twMerge(\n \"h-10 rounded-md border border-gray-200 bg-gray-50 px-4 py-2 text-sm font-medium whitespace-nowrap text-gray-900 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 dark:border-slate-500 dark:bg-slate-600 dark:text-slate-100 dark:hover:bg-slate-700 dark:hover:text-slate-50\",\n className,\n )}\n />\n );\n});\n","import type { StateValidationError } from \"../utils/helpers.js\";\n\nexport function StateValidationErrorMessage({\n error,\n}: {\n error: StateValidationError;\n}) {\n const { payload } = error;\n\n switch (payload.kind) {\n case \"MISSING\":\n return (\n <span>\n Field <strong>{payload.field}</strong> is missing.\n </span>\n );\n\n case \"MISSING_OPTIONAL\":\n return (\n <span>\n Optional field <strong>{payload.field}</strong> is not defined.\n </span>\n );\n\n case \"UNKNOWN_FIELD\":\n return (\n <span>\n Field <strong>{payload.field}</strong> is not a known field.\n </span>\n );\n\n case \"NON_NULL\":\n return (\n <span>\n Field <strong>{payload.field}</strong> cannot be null.\n </span>\n );\n\n case \"TYPE\":\n return (\n <span>\n Field <strong>{payload.field}</strong>\n {payload.expectedType ? (\n <>\n {\" \"}\n must be a{\" \"}\n <strong>{payload.expectedType.replace(/!/g, \"\")}</strong>.\n </>\n ) : (\n <> has an invalid value.</>\n )}\n </span>\n );\n\n case \"RECURSIVE_TYPE\":\n return (\n <span>\n Field <strong>{payload.typeName}</strong> has a recursive type. It\n must be optional.\n </span>\n );\n\n default:\n return <span>Invalid value.</span>;\n }\n}\n","import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport * as React from \"react\";\nimport { twMerge } from \"tailwind-merge\";\n\nconst Tabs = TabsPrimitive.Root;\n\nconst TabsList = React.forwardRef<\n React.ElementRef<typeof TabsPrimitive.List>,\n React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.List\n ref={ref}\n className={twMerge(\n \"flex items-center justify-center rounded-xl bg-gray-50 p-1 shadow-inner dark:bg-slate-800\",\n className,\n )}\n {...props}\n />\n));\nTabsList.displayName = TabsPrimitive.List.displayName;\n\nconst TabsTrigger = React.forwardRef<\n React.ElementRef<typeof TabsPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.Trigger\n ref={ref}\n className={twMerge(\n \"flex w-full items-center justify-center rounded-lg p-1 text-sm whitespace-nowrap text-gray-500 transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-gray-50 data-[state=active]:text-gray-800 data-[state=active]:shadow-tab dark:text-slate-400\",\n className,\n )}\n {...props}\n />\n));\nTabsTrigger.displayName = TabsPrimitive.Trigger.displayName;\n\nconst TabsContent = React.forwardRef<\n React.ElementRef<typeof TabsPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.Content ref={ref} className={className} {...props} />\n));\nTabsContent.displayName = TabsPrimitive.Content.displayName;\n\nexport { Tabs, TabsContent, TabsList, TabsTrigger };\n","import { twMerge } from \"tailwind-merge\";\nimport { Checkbox } from \"@powerhousedao/design-system/ui\";\nimport { Kind } from \"graphql\";\nimport {\n lazy,\n Suspense,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { typeDefsDoc } from \"../constants/documents.js\";\nimport { safeParseSdl, useSchemaContext } from \"../context/schema-context.js\";\nimport type { Scope } from \"../types/documents.js\";\nimport {\n makeInitialSchemaDoc,\n makeMinimalObjectForStateType,\n makeStateSchemaNameForScope,\n StateValidationError,\n validateStateObject,\n} from \"../utils/helpers.js\";\nimport { ensureValidStateSchemaName } from \"../utils/linting.js\";\nimport { Button } from \"./button.js\";\nimport { StateValidationErrorMessage } from \"./state-error.js\";\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from \"./tabs.js\";\nconst GraphqlEditor = lazy(() => import(\"./code-editors/graphql-editor.js\"));\nconst JSONEditor = lazy(() => import(\"./code-editors/json-editor.js\"));\ntype Props = {\n modelName: string;\n globalStateSchema: string;\n localStateSchema: string;\n globalStateInitialValue: string;\n localStateInitialValue: string;\n setStateSchema: (doc: string, scope: Scope) => void;\n setInitialState: (doc: string, scope: Scope) => void;\n currentScope: Scope;\n onScopeChange: (scope: Scope) => void;\n};\n\ntype StateEditorProps = {\n modelName: string;\n stateSchema: string;\n initialValue: string;\n setStateSchema: (doc: string, scope: Scope) => void;\n setInitialState: (doc: string, scope: Scope) => void;\n scope: Scope;\n};\n\nfunction StateEditor({\n modelName,\n stateSchema,\n initialValue,\n setStateSchema,\n setInitialState,\n scope,\n}: StateEditorProps) {\n const { sharedSchema: sharedSchemaSdl, error: sharedSchemaError } =\n useSchemaContext();\n const [showStandardLib, setShowStandardLib] = useState(false);\n const [syncWithSchema, setSyncWithSchema] = useState(true);\n\n const customLinter = useCallback(\n (doc: string) => ensureValidStateSchemaName(doc, modelName, scope),\n [modelName, scope],\n );\n\n const schemaErrors = useMemo(() => {\n const errors = ensureValidStateSchemaName(stateSchema, modelName, scope);\n if (sharedSchemaError) {\n return [...errors, sharedSchemaError];\n }\n return errors;\n }, [stateSchema, modelName, scope, sharedSchemaError]);\n\n const handleToggleStandardLib = useCallback(() => {\n setShowStandardLib((prev) => !prev);\n }, []);\n\n const handleSchemaUpdate = useCallback(\n (newDoc: string) => setStateSchema(newDoc, scope),\n [setStateSchema, scope],\n );\n\n const handleInitialStateUpdate = useCallback(\n (newDoc: string) => setInitialState(newDoc, scope),\n [setInitialState, scope],\n );\n\n // Track if we've already synced to prevent double-calls in StrictMode\n const hasSyncedRef = useRef(false);\n\n const { initialValueErrors, fixedState } = useMemo(() => {\n const existingValue = initialValue || \"{}\";\n const sharedSchemaDocumentNode = safeParseSdl(sharedSchemaSdl);\n if (!sharedSchemaDocumentNode)\n return { initialValueErrors: [], fixedState: null };\n const stateTypeName = makeStateSchemaNameForScope(modelName, scope);\n if (!stateTypeName) return { initialValueErrors: [], fixedState: null };\n const stateTypeDefinitionNode = sharedSchemaDocumentNode.definitions.find(\n (def) =>\n def.kind === Kind.OBJECT_TYPE_DEFINITION &&\n def.name.value === stateTypeName,\n );\n if (\n !stateTypeDefinitionNode ||\n stateTypeDefinitionNode.kind !== Kind.OBJECT_TYPE_DEFINITION\n )\n return { initialValueErrors: [], fixedState: null };\n\n const errors = validateStateObject(\n sharedSchemaDocumentNode,\n stateTypeDefinitionNode,\n existingValue,\n );\n\n if (errors.length && syncWithSchema) {\n const computedFixedState = makeMinimalObjectForStateType({\n sharedSchemaDocumentNode,\n stateTypeDefinitionNode,\n existingValue,\n });\n if (initialValue !== computedFixedState) {\n return { initialValueErrors: [], fixedState: computedFixedState };\n }\n }\n return { initialValueErrors: errors, fixedState: null };\n }, [sharedSchemaSdl, initialValue, syncWithSchema, scope, modelName]);\n\n // Handle the side effect of syncing initial state separately\n useEffect(() => {\n if (fixedState && !hasSyncedRef.current) {\n hasSyncedRef.current = true;\n setInitialState(fixedState, scope);\n } else if (!fixedState) {\n // Reset the ref when there's no fix needed\n hasSyncedRef.current = false;\n }\n }, [fixedState, setInitialState, scope]);\n\n return (\n <div className=\"grid grid-cols-2 gap-4\">\n <div>\n <h3 className=\"mb-2 text-lg text-gray-900 capitalize dark:text-slate-100\">\n {scope} state schema *\n </h3>\n <Button\n onClick={handleToggleStandardLib}\n className=\"mb-2 flex w-fit items-center gap-2\"\n >\n {showStandardLib ? \"Hide\" : \"Show\"} standard library\n <svg\n className={twMerge(\n \"inline-block transition-transform\",\n showStandardLib ? \"rotate-180\" : \"rotate-0\",\n )}\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n >\n <path\n d=\"M11.9883 6.01172C11.4363 6.01172 10.9883 6.45972 10.9883 7.01172V13.0117H6.98828L11.9883 18.0117L16.9883 13.0117H12.9883V7.01172C12.9883 6.45972 12.5403 6.01172 11.9883 6.01172Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Button>\n <Suspense>\n {showStandardLib && <GraphqlEditor doc={typeDefsDoc} readonly />}\n <GraphqlEditor\n doc={stateSchema}\n updateDocumentInModel={handleSchemaUpdate}\n customLinter={customLinter}\n />\n {schemaErrors.length > 0 && (\n <p className=\"mt-2 text-sm text-red-600 dark:text-red-100\">\n {schemaErrors[0].message}\n </p>\n )}\n </Suspense>\n </div>\n <div>\n <div className=\"flex flex-col items-end\">\n <h3 className=\"mb-2 text-right text-lg text-gray-900 capitalize dark:text-slate-100\">\n {scope} state initial value *\n </h3>\n <label className=\"mb-2 flex w-fit items-center gap-2 rounded-md border border-gray-200 bg-gray-50 p-2 text-sm font-medium whitespace-nowrap text-gray-900 transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none dark:border-slate-500 dark:bg-slate-600 dark:text-slate-100 dark:hover:bg-slate-500 dark:hover:text-slate-50\">\n <input\n type=\"checkbox\"\n className=\"\"\n value={syncWithSchema.toString()}\n onChange={(e) => {\n setSyncWithSchema(\n e.currentTarget.value === \"true\" ? true : false,\n );\n }}\n />\n Sync with schema{\" \"}\n <svg\n className=\"inline-block\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n >\n <path\n d=\"M8.00521 1.99219C6.63588 1.99219 5.32788 2.45152 4.27588 3.28419C3.98721 3.51219 3.94321 3.93285 4.17188 4.22151C4.40054 4.51018 4.82055 4.55418 5.10921 4.32552C5.92721 3.67819 6.93921 3.32552 8.00521 3.32552C10.5825 3.32552 12.6719 5.41485 12.6719 7.99218H11.3385L13.3385 10.6588L15.3385 7.99218H14.0052C14.0052 4.67818 11.3192 1.99219 8.00521 1.99219ZM2.67188 5.32552L0.671875 7.99218H2.00521C2.00521 11.3062 4.69121 13.9922 8.00521 13.9922C9.37521 13.9922 10.6825 13.5335 11.7345 12.7002C12.0232 12.4722 12.0672 12.0515 11.8385 11.7628C11.6099 11.4742 11.1899 11.4302 10.9012 11.6588C10.0825 12.3068 9.07188 12.6588 8.00521 12.6588C5.42788 12.6588 3.33854 10.5695 3.33854 7.99218H4.67188L2.67188 5.32552Z\"\n fill=\"currentColor\"\n />\n </svg>\n </label>\n </div>\n <Suspense>\n <JSONEditor\n doc={initialValue}\n updateDocumentInModel={handleInitialStateUpdate}\n />\n {initialValueErrors.map((error, index) => (\n <p\n key={index}\n className=\"mt-2 text-sm text-red-600 dark:text-red-100\"\n >\n {error instanceof StateValidationError ? (\n <StateValidationErrorMessage error={error} />\n ) : (\n error.message\n )}\n </p>\n ))}\n </Suspense>\n </div>\n </div>\n );\n}\n\nexport default function StateSchemas({\n modelName,\n globalStateSchema,\n localStateSchema,\n globalStateInitialValue,\n localStateInitialValue,\n setStateSchema,\n setInitialState,\n currentScope,\n onScopeChange,\n}: Props) {\n const handleAddLocalState = useCallback(() => {\n const initialDoc = makeInitialSchemaDoc(modelName, \"local\");\n setStateSchema(initialDoc, \"local\");\n setInitialState(\"\", \"local\");\n }, [modelName, setStateSchema, setInitialState]);\n\n return (\n <Tabs\n className=\"pb-8\"\n activationMode=\"manual\"\n value={currentScope}\n onValueChange={(value) => onScopeChange(value as Scope)}\n >\n <div className=\"my-6\">\n <TabsList className=\"mx-auto flex max-w-sm\">\n <TabsTrigger value=\"global\">Global</TabsTrigger>\n <TabsTrigger value=\"local\">Local</TabsTrigger>\n </TabsList>\n </div>\n\n <TabsContent value=\"global\" tabIndex={-1}>\n <StateEditor\n modelName={modelName}\n stateSchema={globalStateSchema}\n initialValue={globalStateInitialValue}\n setStateSchema={setStateSchema}\n setInitialState={setInitialState}\n scope=\"global\"\n />\n </TabsContent>\n\n <TabsContent value=\"local\" tabIndex={-1}>\n {!localStateSchema ? (\n <div className=\"\">\n <h3 className=\"mb-2 text-lg text-gray-900 capitalize dark:text-slate-100\">\n local state schema *\n </h3>\n <Button onClick={handleAddLocalState}>Add local state</Button>\n </div>\n ) : (\n <StateEditor\n modelName={modelName}\n stateSchema={localStateSchema}\n initialValue={localStateInitialValue}\n setStateSchema={setStateSchema}\n setInitialState={setInitialState}\n scope=\"local\"\n />\n )}\n </TabsContent>\n </Tabs>\n );\n}\n"],"mappings":";;;;;;;;;AAMA,MAAa,SAAS,YAAsC,OAAO,QAAQ;CACzE,MAAM,EAAE,WAAW,GAAG,SAAS;AAC/B,QACE,oBAAC,UAAD;EACO;EACL,GAAI;EACJ,WAAW,QACT,qZACA,UACD;EACD,CAAA;EAEJ;;;AChBF,SAAgB,4BAA4B,EAC1C,SAGC;CACD,MAAM,EAAE,YAAY;AAEpB,SAAQ,QAAQ,MAAhB;EACE,KAAK,UACH,QACE,qBA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