document-model 1.0.9 → 1.0.11

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 (55) hide show
  1. package/dist/browser/document/index.d.ts +1 -0
  2. package/dist/browser/document/object.d.ts +10 -4
  3. package/dist/browser/document/reducer.d.ts +2 -1
  4. package/dist/browser/document/signal.d.ts +15 -0
  5. package/dist/browser/document/types.d.ts +12 -3
  6. package/dist/browser/document/utils/base.d.ts +2 -2
  7. package/dist/browser/document-model/gen/object.d.ts +2 -2
  8. package/dist/browser/document-model/gen/operation/actions.d.ts +3 -2
  9. package/dist/browser/document-model/gen/operation/creators.d.ts +3 -2
  10. package/dist/browser/document-model/gen/operation/object.d.ts +2 -1
  11. package/dist/browser/document-model/gen/operation/operations.d.ts +2 -1
  12. package/dist/browser/document-model/gen/schema/types.d.ts +8 -0
  13. package/dist/browser/document-model/gen/schema/zod.d.ts +5 -1
  14. package/dist/browser/document-model/index.d.ts +1 -0
  15. package/dist/browser/document-model.cjs +1 -1
  16. package/dist/browser/document-model.js +2 -2
  17. package/dist/browser/document.cjs +1 -1
  18. package/dist/browser/document.js +2 -2
  19. package/dist/browser/index.cjs +1 -1
  20. package/dist/browser/index.js +3 -3
  21. package/dist/browser/internal/index-ac329925.js +22 -0
  22. package/dist/{node/internal/index-5b0ca13a.js → browser/internal/index-c9e4dc9e.js} +1 -1
  23. package/dist/{node/internal/index-6a7277fe.js → browser/internal/index-cf51e575.js} +1 -1
  24. package/dist/browser/internal/{index-48f140bc.js → index-df1f6a1b.js} +442 -374
  25. package/dist/browser/internal/{object-ceb8f869.js → object-113c73e2.js} +2 -2
  26. package/dist/browser/internal/{object-98a2cff6.js → object-13eaec2b.js} +219 -218
  27. package/dist/node/document/index.d.ts +1 -0
  28. package/dist/node/document/object.d.ts +10 -4
  29. package/dist/node/document/reducer.d.ts +2 -1
  30. package/dist/node/document/signal.d.ts +15 -0
  31. package/dist/node/document/types.d.ts +12 -3
  32. package/dist/node/document/utils/base.d.ts +2 -2
  33. package/dist/node/document-model/gen/object.d.ts +2 -2
  34. package/dist/node/document-model/gen/operation/actions.d.ts +3 -2
  35. package/dist/node/document-model/gen/operation/creators.d.ts +3 -2
  36. package/dist/node/document-model/gen/operation/object.d.ts +2 -1
  37. package/dist/node/document-model/gen/operation/operations.d.ts +2 -1
  38. package/dist/node/document-model/gen/schema/types.d.ts +8 -0
  39. package/dist/node/document-model/gen/schema/zod.d.ts +5 -1
  40. package/dist/node/document-model/index.d.ts +1 -0
  41. package/dist/node/document-model.cjs +1 -1
  42. package/dist/node/document-model.js +2 -2
  43. package/dist/node/document.cjs +1 -1
  44. package/dist/node/document.js +2 -2
  45. package/dist/node/index.cjs +1 -1
  46. package/dist/node/index.js +3 -3
  47. package/dist/node/internal/{index-dfaca09a.js → index-0abc9251.js} +442 -374
  48. package/dist/{browser/internal/index-9922a4fc.js → node/internal/index-150bbba4.js} +1 -1
  49. package/dist/node/internal/index-2cd26a65.js +22 -0
  50. package/dist/{browser/internal/index-ff22a5bb.js → node/internal/index-a74d15aa.js} +1 -1
  51. package/dist/node/internal/{object-10abe15d.js → object-073dccc4.js} +1 -1
  52. package/dist/node/internal/{object-6f942fcb.js → object-baf4e3d5.js} +79 -78
  53. package/package.json +1 -1
  54. package/dist/browser/internal/index-7d7d05c8.js +0 -22
  55. package/dist/node/internal/index-2e487f63.js +0 -22
@@ -1,22 +0,0 @@
1
- "use strict";var ct=Object.defineProperty;var lt=(t,e,o)=>e in t?ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var de=(t,e,o)=>(lt(t,typeof e!="symbol"?e+"":e,o),o);const s=require("./object-10abe15d.js");require("json-stringify-deterministic");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const r=require("zod"),dt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),_={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""}],state:{schema:"",initialValue:`{
2
- "id": "",
3
- "name": "",
4
- "extension": "",
5
- "description": "",
6
- "author": {
7
- "name": "",
8
- "website": ""
9
- },
10
- "specifications": [
11
- {
12
- "version": 1,
13
- "changeLog": [],
14
- "state": {
15
- "schema": "",
16
- "initialValue": "",
17
- "examples": []
18
- },
19
- "modules": []
20
- }
21
- ]
22
- }`,examples:[]}}]},ue=t=>t!=null,ut=r.z.any().refine(t=>ue(t));function f(){return r.z.object({__typename:r.z.literal("AddChangeLogItemInput").optional(),content:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullable()})}function A(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),name:r.z.string()})}function z(){return r.z.object({errorCode:r.z.string().nullish(),errorDescription:r.z.string().nullish(),errorName:r.z.string().nullish(),errorTemplate:r.z.string().nullish(),id:r.z.string(),operationId:r.z.string()})}function I(){return r.z.object({example:r.z.string(),id:r.z.string(),operationId:r.z.string()})}function T(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),moduleId:r.z.string(),name:r.z.string(),reducer:r.z.string().nullish(),schema:r.z.string().nullish(),template:r.z.string().nullish()})}function R(){return r.z.object({example:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullish()})}function me(){return r.z.object({__typename:r.z.literal("Author").optional(),name:r.z.string(),website:r.z.string().nullable()})}function D(){return r.z.object({__typename:r.z.literal("CodeExample").optional(),id:r.z.string(),value:r.z.string()})}function M(){return r.z.object({__typename:r.z.literal("DeleteChangeLogItemInput").optional(),id:r.z.string()})}function x(){return r.z.object({id:r.z.string()})}function b(){return r.z.object({id:r.z.string()})}function N(){return r.z.object({id:r.z.string()})}function L(){return r.z.object({id:r.z.string()})}function P(){return r.z.object({id:r.z.string()})}function mt(){return r.z.union([f(),A(),z(),I(),T(),R(),M(),x(),b(),N(),L(),P(),j(),C(),k(),y(),w(),U(),v(),F(),H(),V(),X(),G(),B(),W(),$(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),ne(),oe(),ie(),se(),ae()])}function Et(){return r.z.object({__typename:r.z.literal("DocumentModelState").optional(),author:me(),description:r.z.string(),extension:r.z.string(),id:r.z.string(),name:r.z.string(),specifications:r.z.array(Ee())})}function Ee(){return r.z.object({__typename:r.z.literal("DocumentSpecification").optional(),changeLog:r.z.array(r.z.string()),modules:r.z.array(he()),state:ge(),version:r.z.number()})}function he(){return r.z.object({__typename:r.z.literal("Module").optional(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string(),operations:r.z.array(Oe())})}function j(){return r.z.object({newModuleId:r.z.string(),operationId:r.z.string()})}function Oe(){return r.z.object({__typename:r.z.literal("Operation").optional(),description:r.z.string().nullable(),errors:r.z.array(Se()),examples:r.z.array(D()),id:r.z.string(),name:r.z.string().nullable(),reducer:r.z.string().nullable(),schema:r.z.string().nullable(),template:r.z.string().nullable()})}function Se(){return r.z.object({__typename:r.z.literal("OperationError").optional(),code:r.z.string().nullable(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string().nullable(),template:r.z.string().nullable()})}function C(){return r.z.object({__typename:r.z.literal("ReorderChangeLogItemsInput").optional(),order:r.z.array(r.z.string())})}function k(){return r.z.object({moduleId:r.z.string(),order:r.z.array(r.z.string())})}function y(){return r.z.object({order:r.z.array(r.z.string())})}function w(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function U(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function v(){return r.z.object({order:r.z.array(r.z.string())})}function F(){return r.z.object({authorName:r.z.string()})}function H(){return r.z.object({authorWebsite:r.z.string()})}function V(){return r.z.object({initialValue:r.z.string()})}function X(){return r.z.object({description:r.z.string()})}function G(){return r.z.object({extension:r.z.string()})}function B(){return r.z.object({id:r.z.string()})}function W(){return r.z.object({name:r.z.string()})}function $(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function q(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function J(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function K(){return r.z.object({errorCode:r.z.string().nullish(),id:r.z.string()})}function Q(){return r.z.object({errorDescription:r.z.string().nullish(),id:r.z.string()})}function Y(){return r.z.object({errorName:r.z.string().nullish(),id:r.z.string()})}function Z(){return r.z.object({errorTemplate:r.z.string().nullish(),id:r.z.string()})}function ee(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function te(){return r.z.object({id:r.z.string(),reducer:r.z.string().nullish()})}function re(){return r.z.object({id:r.z.string(),schema:r.z.string().nullish()})}function ne(){return r.z.object({id:r.z.string(),template:r.z.string().nullish()})}function oe(){return r.z.object({schema:r.z.string()})}function ge(){return r.z.object({__typename:r.z.literal("State").optional(),examples:r.z.array(D()),initialValue:r.z.string(),schema:r.z.string()})}function ie(){return r.z.object({__typename:r.z.literal("UpdateChangeLogItemInput").optional(),id:r.z.string(),newContent:r.z.string()})}function se(){return r.z.object({example:r.z.string(),id:r.z.string()})}function ae(){return r.z.object({id:r.z.string(),newExample:r.z.string()})}const _e=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:f,AddModuleInputSchema:A,AddOperationErrorInputSchema:z,AddOperationExampleInputSchema:I,AddOperationInputSchema:T,AddStateExampleInputSchema:R,AuthorSchema:me,CodeExampleSchema:D,DeleteChangeLogItemInputSchema:M,DeleteModuleInputSchema:x,DeleteOperationErrorInputSchema:b,DeleteOperationExampleInputSchema:N,DeleteOperationInputSchema:L,DeleteStateExampleInputSchema:P,DocumentModelInputSchema:mt,DocumentModelStateSchema:Et,DocumentSpecificationSchema:Ee,ModuleSchema:he,MoveOperationInputSchema:j,OperationErrorSchema:Se,OperationSchema:Oe,ReorderChangeLogItemsInputSchema:C,ReorderModuleOperationsInputSchema:k,ReorderModulesInputSchema:y,ReorderOperationErrorsInputSchema:w,ReorderOperationExamplesInputSchema:U,ReorderStateExamplesInputSchema:v,SetAuthorNameInputSchema:F,SetAuthorWebsiteInputSchema:H,SetInitialStateInputSchema:V,SetModelDescriptionInputSchema:X,SetModelExtensionInputSchema:G,SetModelIdInputSchema:B,SetModelNameInputSchema:W,SetModuleDescriptionInputSchema:$,SetModuleNameInputSchema:q,SetOperationDescriptionInputSchema:J,SetOperationErrorCodeInputSchema:K,SetOperationErrorDescriptionInputSchema:Q,SetOperationErrorNameInputSchema:Y,SetOperationErrorTemplateInputSchema:Z,SetOperationNameInputSchema:ee,SetOperationReducerInputSchema:te,SetOperationSchemaInputSchema:re,SetOperationTemplateInputSchema:ne,SetStateSchemaInputSchema:oe,StateSchema:ge,UpdateChangeLogItemInputSchema:ie,UpdateOperationExampleInputSchema:se,UpdateStateExampleInputSchema:ae,definedNonNullAnySchema:ut,isDefinedNonNullAny:ue},Symbol.toStringTag,{value:"Module"})),l={setModelNameOperation(t,e){t.name=e.input.name},setModelIdOperation(t,e){t.id=e.input.id},setModelExtensionOperation(t,e){t.extension=e.input.extension},setModelDescriptionOperation(t,e){t.description=e.input.description},setAuthorNameOperation(t,e){t.author=t.author||{name:"",website:null},t.author.name=e.input.authorName},setAuthorWebsiteOperation(t,e){t.author=t.author||{name:"",website:null},t.author.website=e.input.authorWebsite}},E={addChangeLogItemOperation(t,e){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(t,e){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(t,e){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(t,e){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(t,e){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},ht=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},h={addModuleOperation(t,e){t.specifications[t.specifications.length-1].modules.push({id:e.input.id,name:e.input.name,description:e.input.description||"",operations:[]})},setModuleNameOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].id===e.input.id&&(o.modules[n].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].id===e.input.id&&(o.modules[n].description=e.input.description||"")},deleteModuleOperation(t,e){const o=t.specifications[t.specifications.length-1];o.modules=o.modules.filter(n=>n.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(ht(e.input.order))}},Ot=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},c={addOperationErrorOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.operationId&&o.modules[n].operations[i].errors.push({id:e.input.id,name:e.input.errorName||"",code:e.input.errorCode||"",description:e.input.errorDescription||"",template:e.input.errorTemplate||""})},setOperationErrorCodeOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].errors.length;a++)o.modules[n].operations[i].errors[a].id==e.input.id&&(o.modules[n].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].errors.length;a++)o.modules[n].operations[i].errors[a].id==e.input.id&&(o.modules[n].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].errors.length;a++)o.modules[n].operations[i].errors[a].id==e.input.id&&(o.modules[n].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].errors.length;a++)o.modules[n].operations[i].errors[a].id==e.input.id&&(o.modules[n].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].errors=o.modules[n].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.operationId&&o.modules[n].operations[i].errors.sort(Ot(e.input.order))}},St=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},S={addOperationExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.operationId&&o.modules[n].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].examples.length;a++)o.modules[n].operations[i].examples[a].id==e.input.id&&(o.modules[n].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].examples=o.modules[n].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.operationId&&o.modules[n].operations[i].examples.sort(St(e.input.order))}},gt=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},p={addOperationOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].id==e.input.moduleId&&o.modules[n].operations.push({id:e.input.id,name:e.input.name,description:e.input.description||"",schema:e.input.schema||"",template:e.input.template||e.input.description||"",reducer:e.input.reducer||"",errors:[],examples:[]})},setOperationNameOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].name=e.input.name||"")},setOperationSchemaOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const o=[],n=t.specifications[t.specifications.length-1];for(let i=0;i<n.modules.length;i++)n.modules[i].operations=n.modules[i].operations.filter(a=>a.id==e.input.operationId?(o.push(a),!1):!0);for(let i=0;i<n.modules.length;i++)n.modules[i].id==e.input.newModuleId&&n.modules[i].operations.push(...o)},deleteOperationOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].operations=o.modules[n].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].id==e.input.moduleId&&o.modules[n].operations.sort(gt(e.input.order))}},_t=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},d={setStateSchemaOperation(t,e){const o=t.specifications[t.specifications.length-1];o.state.schema=e.input.schema},setInitialStateOperation(t,e){const o=t.specifications[t.specifications.length-1];o.state.initialValue=e.input.initialValue},addStateExampleOperation(t,e){t.specifications[t.specifications.length-1].state.examples.push({id:e.input.id,value:e.input.example})},updateStateExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.state.examples.length;n++)o.state.examples[n].id==e.input.id&&(o.state.examples[n].value=e.input.newExample)},deleteStateExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];o.state.examples=o.state.examples.filter(n=>n.id!=e.input.id)},reorderStateExamplesOperation(t,e){t.specifications[t.specifications.length-1].state.examples.sort(_t(e.input.order))}},ft=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":W().parse(e.input),l.setModelNameOperation(t,e);break;case"SET_MODEL_ID":B().parse(e.input),l.setModelIdOperation(t,e);break;case"SET_MODEL_EXTENSION":G().parse(e.input),l.setModelExtensionOperation(t,e);break;case"SET_MODEL_DESCRIPTION":X().parse(e.input),l.setModelDescriptionOperation(t,e);break;case"SET_AUTHOR_NAME":F().parse(e.input),l.setAuthorNameOperation(t,e);break;case"SET_AUTHOR_WEBSITE":H().parse(e.input),l.setAuthorWebsiteOperation(t,e);break;case"ADD_CHANGE_LOG_ITEM":f().parse(e.input),E.addChangeLogItemOperation(t,e);break;case"UPDATE_CHANGE_LOG_ITEM":ie().parse(e.input),E.updateChangeLogItemOperation(t,e);break;case"DELETE_CHANGE_LOG_ITEM":M().parse(e.input),E.deleteChangeLogItemOperation(t,e);break;case"REORDER_CHANGE_LOG_ITEMS":C().parse(e.input),E.reorderChangeLogItemsOperation(t,e);break;case"RELEASE_NEW_VERSION":if(Object.keys(e.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");E.releaseNewVersionOperation(t,e);break;case"ADD_MODULE":A().parse(e.input),h.addModuleOperation(t,e);break;case"SET_MODULE_NAME":q().parse(e.input),h.setModuleNameOperation(t,e);break;case"SET_MODULE_DESCRIPTION":$().parse(e.input),h.setModuleDescriptionOperation(t,e);break;case"DELETE_MODULE":x().parse(e.input),h.deleteModuleOperation(t,e);break;case"REORDER_MODULES":y().parse(e.input),h.reorderModulesOperation(t,e);break;case"ADD_OPERATION_ERROR":z().parse(e.input),c.addOperationErrorOperation(t,e);break;case"SET_OPERATION_ERROR_CODE":K().parse(e.input),c.setOperationErrorCodeOperation(t,e);break;case"SET_OPERATION_ERROR_NAME":Y().parse(e.input),c.setOperationErrorNameOperation(t,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Q().parse(e.input),c.setOperationErrorDescriptionOperation(t,e);break;case"SET_OPERATION_ERROR_TEMPLATE":Z().parse(e.input),c.setOperationErrorTemplateOperation(t,e);break;case"DELETE_OPERATION_ERROR":b().parse(e.input),c.deleteOperationErrorOperation(t,e);break;case"REORDER_OPERATION_ERRORS":w().parse(e.input),c.reorderOperationErrorsOperation(t,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),S.addOperationExampleOperation(t,e);break;case"UPDATE_OPERATION_EXAMPLE":se().parse(e.input),S.updateOperationExampleOperation(t,e);break;case"DELETE_OPERATION_EXAMPLE":N().parse(e.input),S.deleteOperationExampleOperation(t,e);break;case"REORDER_OPERATION_EXAMPLES":U().parse(e.input),S.reorderOperationExamplesOperation(t,e);break;case"ADD_OPERATION":T().parse(e.input),p.addOperationOperation(t,e);break;case"SET_OPERATION_NAME":ee().parse(e.input),p.setOperationNameOperation(t,e);break;case"SET_OPERATION_SCHEMA":re().parse(e.input),p.setOperationSchemaOperation(t,e);break;case"SET_OPERATION_DESCRIPTION":J().parse(e.input),p.setOperationDescriptionOperation(t,e);break;case"SET_OPERATION_TEMPLATE":ne().parse(e.input),p.setOperationTemplateOperation(t,e);break;case"SET_OPERATION_REDUCER":te().parse(e.input),p.setOperationReducerOperation(t,e);break;case"MOVE_OPERATION":j().parse(e.input),p.moveOperationOperation(t,e);break;case"DELETE_OPERATION":L().parse(e.input),p.deleteOperationOperation(t,e);break;case"REORDER_MODULE_OPERATIONS":k().parse(e.input),p.reorderModuleOperationsOperation(t,e);break;case"SET_STATE_SCHEMA":oe().parse(e.input),d.setStateSchemaOperation(t,e);break;case"SET_INITIAL_STATE":V().parse(e.input),d.setInitialStateOperation(t,e);break;case"ADD_STATE_EXAMPLE":R().parse(e.input),d.addStateExampleOperation(t,e);break;case"UPDATE_STATE_EXAMPLE":ae().parse(e.input),d.updateStateExampleOperation(t,e);break;case"DELETE_STATE_EXAMPLE":P().parse(e.input),d.deleteStateExampleOperation(t,e);break;case"REORDER_STATE_EXAMPLES":v().parse(e.input),d.reorderStateExamplesOperation(t,e);break;default:return t}},m=s.createReducer(ft),At={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{schema:"",initialValue:"",examples:[]},modules:[]}]},O={fileExtension:"phdm",createState(t){return{...At,...t}},createExtendedState(t){return s.createExtendedState({...t,documentType:"powerhouse/document-model"},O.createState)},createDocument(t){return s.createDocument(O.createExtendedState(t),O.createState)},saveToFile(t,e,o){return s.saveToFile(t,e,"phdm",o)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,m)},loadFromInput(t){return s.loadFromInput(t,m)}},fe=t=>s.createAction("SET_MODEL_NAME",{...t}),Ae=t=>s.createAction("SET_MODEL_ID",{...t}),ze=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Ie=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),Te=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Re=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class zt extends s.BaseDocument{setModelName(e){return this.dispatch(fe(e))}setModelId(e){return this.dispatch(Ae(e))}setModelExtension(e){return this.dispatch(ze(e))}setModelDescription(e){return this.dispatch(Ie(e))}setAuthorName(e){return this.dispatch(Te(e))}setAuthorWebsite(e){return this.dispatch(Re(e))}}const De=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),Me=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),xe=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),be=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),Ne=()=>s.createAction("RELEASE_NEW_VERSION");class It extends s.BaseDocument{addChangeLogItem(e){return this.dispatch(De(e))}updateChangeLogItem(e){return this.dispatch(Me(e))}deleteChangeLogItem(e){return this.dispatch(xe(e))}reorderChangeLogItems(e){return this.dispatch(be(e))}releaseNewVersion(){return this.dispatch(Ne())}}const Le=t=>s.createAction("ADD_MODULE",{...t}),Pe=t=>s.createAction("SET_MODULE_NAME",{...t}),je=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),Ce=t=>s.createAction("DELETE_MODULE",{...t}),ke=t=>s.createAction("REORDER_MODULES",{...t});class Tt extends s.BaseDocument{addModule(e){return this.dispatch(Le(e))}setModuleName(e){return this.dispatch(Pe(e))}setModuleDescription(e){return this.dispatch(je(e))}deleteModule(e){return this.dispatch(Ce(e))}reorderModules(e){return this.dispatch(ke(e))}}const ye=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),we=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),Ue=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),ve=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),Fe=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),He=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Ve=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Rt extends s.BaseDocument{addOperationError(e){return this.dispatch(ye(e))}setOperationErrorCode(e){return this.dispatch(we(e))}setOperationErrorName(e){return this.dispatch(Ue(e))}setOperationErrorDescription(e){return this.dispatch(ve(e))}setOperationErrorTemplate(e){return this.dispatch(Fe(e))}deleteOperationError(e){return this.dispatch(He(e))}reorderOperationErrors(e){return this.dispatch(Ve(e))}}const Xe=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),Ge=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),Be=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),We=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Dt extends s.BaseDocument{addOperationExample(e){return this.dispatch(Xe(e))}updateOperationExample(e){return this.dispatch(Ge(e))}deleteOperationExample(e){return this.dispatch(Be(e))}reorderOperationExamples(e){return this.dispatch(We(e))}}const $e=t=>s.createAction("ADD_OPERATION",{...t}),qe=t=>s.createAction("SET_OPERATION_NAME",{...t}),Je=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),Ke=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),Qe=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),Ye=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),Ze=t=>s.createAction("MOVE_OPERATION",{...t}),et=t=>s.createAction("DELETE_OPERATION",{...t}),tt=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class Mt extends s.BaseDocument{addOperation(e){return this.dispatch($e(e))}setOperationName(e){return this.dispatch(qe(e))}setOperationSchema(e){return this.dispatch(Je(e))}setOperationDescription(e){return this.dispatch(Ke(e))}setOperationTemplate(e){return this.dispatch(Qe(e))}setOperationReducer(e){return this.dispatch(Ye(e))}moveOperation(e){return this.dispatch(Ze(e))}deleteOperation(e){return this.dispatch(et(e))}reorderModuleOperations(e){return this.dispatch(tt(e))}}const rt=t=>s.createAction("SET_STATE_SCHEMA",{...t}),nt=t=>s.createAction("SET_INITIAL_STATE",{...t}),ot=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),it=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),st=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),at=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class xt extends s.BaseDocument{setStateSchema(e){return this.dispatch(rt(e))}setInitialState(e){return this.dispatch(nt(e))}addStateExample(e){return this.dispatch(ot(e))}updateStateExample(e){return this.dispatch(it(e))}deleteStateExample(e){return this.dispatch(st(e))}reorderStateExamples(e){return this.dispatch(at(e))}}var u;let g=(u=class extends s.BaseDocument{constructor(e){super(m,O.createDocument(e))}saveToFile(e,o){return super.saveToFile(e,u.fileExtension,o)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const o=new this;return await o.loadFromFile(e),o}},de(u,"fileExtension","phdm"),u);s.applyMixins(g,[zt,It,Tt,Rt,Dt,Mt,xt]);const bt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:De,addModule:Le,addOperation:$e,addOperationError:ye,addOperationExample:Xe,addStateExample:ot,deleteChangeLogItem:xe,deleteModule:Ce,deleteOperation:et,deleteOperationError:He,deleteOperationExample:Be,deleteStateExample:st,moveOperation:Ze,releaseNewVersion:Ne,reorderChangeLogItems:be,reorderModuleOperations:tt,reorderModules:ke,reorderOperationErrors:Ve,reorderOperationExamples:We,reorderStateExamples:at,setAuthorName:Te,setAuthorWebsite:Re,setInitialState:nt,setModelDescription:Ie,setModelExtension:ze,setModelId:Ae,setModelName:fe,setModuleDescription:je,setModuleName:Pe,setOperationDescription:Ke,setOperationErrorCode:we,setOperationErrorDescription:ve,setOperationErrorName:Ue,setOperationErrorTemplate:Fe,setOperationName:qe,setOperationReducer:Ye,setOperationSchema:Je,setOperationTemplate:Qe,setStateSchema:rt,updateChangeLogItem:Me,updateOperationExample:Ge,updateStateExample:it},Symbol.toStringTag,{value:"Module"})),pe=g,ce={...O,...dt},le={...s.BaseActions,...bt},pt={Document:pe,reducer:m,actions:le,utils:ce,documentModel:_},Nt=Object.freeze(Object.defineProperty({__proto__:null,Document:pe,DocumentModel:g,actions:le,documentModel:_,module:pt,reducer:m,utils:ce,z:_e},Symbol.toStringTag,{value:"Module"}));exports.Document=pe;exports.DocumentModel=Nt;exports.DocumentModel$1=g;exports.actions=le;exports.documentModel=_;exports.module=pt;exports.reducer=m;exports.utils=ce;exports.zod=_e;