document-model 1.0.19 → 1.0.20
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.
- package/dist/browser/document/actions/creators.d.ts +4 -4
- package/dist/browser/document/actions/index.d.ts +4 -4
- package/dist/browser/document/object.d.ts +119 -13
- package/dist/browser/document/schema/types.d.ts +5 -4
- package/dist/browser/document/schema/zod.d.ts +14 -12
- package/dist/browser/document/types.d.ts +2 -5
- package/dist/browser/document-model/gen/schema/zod.d.ts +5 -3
- package/dist/browser/document-model/index.d.ts +3 -3
- package/dist/browser/document-model.cjs +1 -1
- package/dist/browser/document-model.js +2 -2
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +2 -2
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +3 -3
- package/dist/browser/internal/{index-46b68530.js → index-22f88bf2.js} +361 -357
- package/dist/{node/internal/index-f235f9be.js → browser/internal/index-3607fd07.js} +1 -1
- package/dist/{node/internal/index-6477ee0a.js → browser/internal/index-79fde5f3.js} +1 -1
- package/dist/browser/internal/index-dda5d688.js +22 -0
- package/dist/browser/internal/object-32802eed.js +6 -0
- package/dist/browser/internal/{object-d50f7d2f.js → object-d03c84c9.js} +857 -819
- package/dist/node/document/actions/creators.d.ts +4 -4
- package/dist/node/document/actions/index.d.ts +4 -4
- package/dist/node/document/object.d.ts +119 -13
- package/dist/node/document/schema/types.d.ts +5 -4
- package/dist/node/document/schema/zod.d.ts +14 -12
- package/dist/node/document/types.d.ts +2 -5
- package/dist/node/document-model/gen/schema/zod.d.ts +5 -3
- package/dist/node/document-model/index.d.ts +3 -3
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +2 -2
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +2 -2
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +3 -3
- package/dist/node/internal/{index-8d582c48.js → index-14279b3a.js} +361 -357
- package/dist/{browser/internal/index-869c5d0d.js → node/internal/index-4b25c8a5.js} +1 -1
- package/dist/node/internal/index-bfc402ef.js +22 -0
- package/dist/{browser/internal/index-2551382e.js → node/internal/index-e02d7854.js} +1 -1
- package/dist/node/internal/object-ac706c4a.js +1 -0
- package/dist/node/internal/{object-773231ca.js → object-b97efc1b.js} +399 -361
- package/package.json +1 -1
- package/dist/browser/internal/index-1ad32a2e.js +0 -22
- package/dist/browser/internal/object-1fdba77d.js +0 -6
- package/dist/node/internal/index-631ba7bf.js +0 -22
- package/dist/node/internal/object-08bd169a.js +0 -1
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";var ut=Object.defineProperty;var mt=(t,e,o)=>e in t?ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var ue=(t,e,o)=>(mt(t,typeof e!="symbol"?e+"":e,o),o);const s=require("./object-1fdba77d.js");require("json-stringify-deterministic");require("immer");require("jszip");const r=require("zod"),Et=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),f={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:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{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:[]},local:{schema:"",initialValue:"{}",examples:[]}}}]},me=t=>t!=null,ht=r.z.any().refine(t=>me(t));function _(){return r.z.object({__typename:r.z.literal("AddChangeLogItemInput").optional(),content:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullable()})}function z(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),name:r.z.string()})}function A(){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(),scope:r.z.literal("local").or(r.z.literal("global")).nullish()})}function R(){return r.z.object({scope:r.z.string(),example:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullish()})}function Ee(){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 N(){return r.z.object({id:r.z.string()})}function L(){return r.z.object({id:r.z.string()})}function j(){return r.z.object({id:r.z.string()})}function P(){return r.z.object({scope:r.z.string(),id:r.z.string()})}function Ot(){return r.z.union([_(),z(),A(),I(),T(),R(),M(),x(),N(),L(),j(),P(),C(),k(),y(),w(),v(),U(),V(),F(),H(),$(),X(),G(),B(),W(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae(),pe()])}function gt(){return r.z.object({__typename:r.z.literal("DocumentModelState").optional(),author:Ee(),description:r.z.string(),extension:r.z.string(),id:r.z.string(),name:r.z.string(),specifications:r.z.array(he())})}function he(){return r.z.object({__typename:r.z.literal("DocumentSpecification").optional(),changeLog:r.z.array(r.z.string()),modules:r.z.array(Oe()),state:fe(),version:r.z.number()})}function Oe(){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(ge())})}function C(){return r.z.object({newModuleId:r.z.string(),operationId:r.z.string()})}function ge(){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(),scope:r.z.literal("local").or(r.z.literal("global"))})}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 k(){return r.z.object({__typename:r.z.literal("ReorderChangeLogItemsInput").optional(),order:r.z.array(r.z.string())})}function y(){return r.z.object({moduleId:r.z.string(),order:r.z.array(r.z.string())})}function w(){return r.z.object({order:r.z.array(r.z.string())})}function v(){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({scope:r.z.string(),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 $(){return r.z.object({scope:r.z.string(),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 q(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function J(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function K(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function Q(){return r.z.object({errorCode:r.z.string().nullish(),id:r.z.string()})}function Y(){return r.z.object({errorDescription:r.z.string().nullish(),id:r.z.string()})}function Z(){return r.z.object({errorName:r.z.string().nullish(),id:r.z.string()})}function ee(){return r.z.object({errorTemplate:r.z.string().nullish(),id:r.z.string()})}function te(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function be(){return r.z.object({id:r.z.string(),scope:r.z.literal("global").or(r.z.literal("local"))})}function re(){return r.z.object({id:r.z.string(),reducer:r.z.string().nullish()})}function oe(){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 ie(){return r.z.object({scope:r.z.string(),schema:r.z.string()})}function b(){return r.z.object({__typename:r.z.literal("State").optional(),examples:r.z.array(D()),initialValue:r.z.string(),schema:r.z.string()})}function fe(){return r.z.object({global:b(),local:b()})}function se(){return r.z.object({__typename:r.z.literal("UpdateChangeLogItemInput").optional(),id:r.z.string(),newContent:r.z.string()})}function ae(){return r.z.object({example:r.z.string(),id:r.z.string()})}function pe(){return r.z.object({scope:r.z.string(),id:r.z.string(),newExample:r.z.string()})}const _e=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:_,AddModuleInputSchema:z,AddOperationErrorInputSchema:A,AddOperationExampleInputSchema:I,AddOperationInputSchema:T,AddStateExampleInputSchema:R,AuthorSchema:Ee,CodeExampleSchema:D,DeleteChangeLogItemInputSchema:M,DeleteModuleInputSchema:x,DeleteOperationErrorInputSchema:N,DeleteOperationExampleInputSchema:L,DeleteOperationInputSchema:j,DeleteStateExampleInputSchema:P,DocumentModelInputSchema:Ot,DocumentModelStateSchema:gt,DocumentSpecificationSchema:he,ModuleSchema:Oe,MoveOperationInputSchema:C,OperationErrorSchema:Se,OperationSchema:ge,ReorderChangeLogItemsInputSchema:k,ReorderModuleOperationsInputSchema:y,ReorderModulesInputSchema:w,ReorderOperationErrorsInputSchema:v,ReorderOperationExamplesInputSchema:U,ReorderStateExamplesInputSchema:V,ScopeStateSchema:fe,SetAuthorNameInputSchema:F,SetAuthorWebsiteInputSchema:H,SetInitialStateInputSchema:$,SetModelDescriptionInputSchema:X,SetModelExtensionInputSchema:G,SetModelIdInputSchema:B,SetModelNameInputSchema:W,SetModuleDescriptionInputSchema:q,SetModuleNameInputSchema:J,SetOperationDescriptionInputSchema:K,SetOperationErrorCodeInputSchema:Q,SetOperationErrorDescriptionInputSchema:Y,SetOperationErrorNameInputSchema:Z,SetOperationErrorTemplateInputSchema:ee,SetOperationNameInputSchema:te,SetOperationReducerInputSchema:re,SetOperationSchemaInputSchema:oe,SetOperationScopeInputSchema:be,SetOperationTemplateInputSchema:ne,SetStateSchemaInputSchema:ie,StateSchema:b,UpdateChangeLogItemInputSchema:se,UpdateOperationExampleInputSchema:ae,UpdateStateExampleInputSchema:pe,definedNonNullAnySchema:ht,isDefinedNonNullAny:me},Symbol.toStringTag,{value:"Module"})),c={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')}},St=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(St(e.input.order))}},bt=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},l={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(bt(e.input.order))}},ft=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},g={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(ft(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)},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:[],scope:e.input.scope||"global"})},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||"")},setOperationScopeOperation(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].scope=e.input.scope||"global")},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(_t(e.input.order))}},zt=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];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].schema=e.input.schema;else throw new Error(`Invalid scope: ${e.input.scope}`)},setInitialStateOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].initialValue=e.input.initialValue;else throw new Error(`Invalid scope: ${e.input.scope}`)},addStateExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].examples.push({id:e.input.id,value:e.input.example});else throw new Error(`Invalid scope: ${e.input.scope}`)},updateStateExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];if(!Object.keys(o.state).includes(e.input.scope))throw new Error(`Invalid scope: ${e.input.scope}`);const n=o.state[e.input.scope].examples;for(let i=0;i<n.length;i++)n[i].id==e.input.id&&(n[i].value=e.input.newExample)},deleteStateExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].examples=o.state[e.input.scope].examples.filter(n=>n.id!=e.input.id);else throw new Error(`Invalid scope: ${e.input.scope}`)},reorderStateExamplesOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].examples.sort(zt(e.input.order));else throw new Error(`Invalid scope: ${e.input.scope}`)}},At=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":W().parse(e.input),c.setModelNameOperation(t.global,e);break;case"SET_MODEL_ID":B().parse(e.input),c.setModelIdOperation(t.global,e);break;case"SET_MODEL_EXTENSION":G().parse(e.input),c.setModelExtensionOperation(t.global,e);break;case"SET_MODEL_DESCRIPTION":X().parse(e.input),c.setModelDescriptionOperation(t.global,e);break;case"SET_AUTHOR_NAME":F().parse(e.input),c.setAuthorNameOperation(t.global,e);break;case"SET_AUTHOR_WEBSITE":H().parse(e.input),c.setAuthorWebsiteOperation(t.global,e);break;case"ADD_CHANGE_LOG_ITEM":_().parse(e.input),E.addChangeLogItemOperation(t.global,e);break;case"UPDATE_CHANGE_LOG_ITEM":se().parse(e.input),E.updateChangeLogItemOperation(t.global,e);break;case"DELETE_CHANGE_LOG_ITEM":M().parse(e.input),E.deleteChangeLogItemOperation(t.global,e);break;case"REORDER_CHANGE_LOG_ITEMS":k().parse(e.input),E.reorderChangeLogItemsOperation(t.global,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.global,e);break;case"ADD_MODULE":z().parse(e.input),h.addModuleOperation(t.global,e);break;case"SET_MODULE_NAME":J().parse(e.input),h.setModuleNameOperation(t.global,e);break;case"SET_MODULE_DESCRIPTION":q().parse(e.input),h.setModuleDescriptionOperation(t.global,e);break;case"DELETE_MODULE":x().parse(e.input),h.deleteModuleOperation(t.global,e);break;case"REORDER_MODULES":w().parse(e.input),h.reorderModulesOperation(t.global,e);break;case"ADD_OPERATION_ERROR":A().parse(e.input),l.addOperationErrorOperation(t.global,e);break;case"SET_OPERATION_ERROR_CODE":Q().parse(e.input),l.setOperationErrorCodeOperation(t.global,e);break;case"SET_OPERATION_ERROR_NAME":Z().parse(e.input),l.setOperationErrorNameOperation(t.global,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Y().parse(e.input),l.setOperationErrorDescriptionOperation(t.global,e);break;case"SET_OPERATION_ERROR_TEMPLATE":ee().parse(e.input),l.setOperationErrorTemplateOperation(t.global,e);break;case"DELETE_OPERATION_ERROR":N().parse(e.input),l.deleteOperationErrorOperation(t.global,e);break;case"REORDER_OPERATION_ERRORS":v().parse(e.input),l.reorderOperationErrorsOperation(t.global,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),g.addOperationExampleOperation(t.global,e);break;case"UPDATE_OPERATION_EXAMPLE":ae().parse(e.input),g.updateOperationExampleOperation(t.global,e);break;case"DELETE_OPERATION_EXAMPLE":L().parse(e.input),g.deleteOperationExampleOperation(t.global,e);break;case"REORDER_OPERATION_EXAMPLES":U().parse(e.input),g.reorderOperationExamplesOperation(t.global,e);break;case"ADD_OPERATION":T().parse(e.input),p.addOperationOperation(t.global,e);break;case"SET_OPERATION_NAME":te().parse(e.input),p.setOperationNameOperation(t.global,e);break;case"SET_OPERATION_SCOPE":be().parse(e.input),p.setOperationScopeOperation(t.global,e);break;case"SET_OPERATION_SCHEMA":oe().parse(e.input),p.setOperationSchemaOperation(t.global,e);break;case"SET_OPERATION_DESCRIPTION":K().parse(e.input),p.setOperationDescriptionOperation(t.global,e);break;case"SET_OPERATION_TEMPLATE":ne().parse(e.input),p.setOperationTemplateOperation(t.global,e);break;case"SET_OPERATION_REDUCER":re().parse(e.input),p.setOperationReducerOperation(t.global,e);break;case"MOVE_OPERATION":C().parse(e.input),p.moveOperationOperation(t.global,e);break;case"DELETE_OPERATION":j().parse(e.input),p.deleteOperationOperation(t.global,e);break;case"REORDER_MODULE_OPERATIONS":y().parse(e.input),p.reorderModuleOperationsOperation(t.global,e);break;case"SET_STATE_SCHEMA":ie().parse(e.input),d.setStateSchemaOperation(t.global,e);break;case"SET_INITIAL_STATE":$().parse(e.input),d.setInitialStateOperation(t.global,e);break;case"ADD_STATE_EXAMPLE":R().parse(e.input),d.addStateExampleOperation(t.global,e);break;case"UPDATE_STATE_EXAMPLE":pe().parse(e.input),d.updateStateExampleOperation(t.global,e);break;case"DELETE_STATE_EXAMPLE":P().parse(e.input),d.deleteStateExampleOperation(t.global,e);break;case"REORDER_STATE_EXAMPLES":V().parse(e.input),d.reorderStateExamplesOperation(t.global,e);break;default:return t}},m=s.createReducer(At),It={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},Tt={},O={fileExtension:"phdm",createState(t){return{global:{...It,...t==null?void 0:t.global},local:{...Tt,...t==null?void 0:t.local}}},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)}},ze=t=>s.createAction("SET_MODEL_NAME",{...t}),Ae=t=>s.createAction("SET_MODEL_ID",{...t}),Ie=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Te=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),Re=t=>s.createAction("SET_AUTHOR_NAME",{...t}),De=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Rt extends s.BaseDocument{setModelName(e){return this.dispatch(ze(e))}setModelId(e){return this.dispatch(Ae(e))}setModelExtension(e){return this.dispatch(Ie(e))}setModelDescription(e){return this.dispatch(Te(e))}setAuthorName(e){return this.dispatch(Re(e))}setAuthorWebsite(e){return this.dispatch(De(e))}}const Me=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),xe=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Le=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),je=()=>s.createAction("RELEASE_NEW_VERSION");class Dt extends s.BaseDocument{addChangeLogItem(e){return this.dispatch(Me(e))}updateChangeLogItem(e){return this.dispatch(xe(e))}deleteChangeLogItem(e){return this.dispatch(Ne(e))}reorderChangeLogItems(e){return this.dispatch(Le(e))}releaseNewVersion(){return this.dispatch(je())}}const Pe=t=>s.createAction("ADD_MODULE",{...t}),Ce=t=>s.createAction("SET_MODULE_NAME",{...t}),ke=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),ye=t=>s.createAction("DELETE_MODULE",{...t}),we=t=>s.createAction("REORDER_MODULES",{...t});class Mt extends s.BaseDocument{addModule(e){return this.dispatch(Pe(e))}setModuleName(e){return this.dispatch(Ce(e))}setModuleDescription(e){return this.dispatch(ke(e))}deleteModule(e){return this.dispatch(ye(e))}reorderModules(e){return this.dispatch(we(e))}}const ve=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),Ue=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),Ve=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),Fe=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),He=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),$e=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Xe=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class xt extends s.BaseDocument{addOperationError(e){return this.dispatch(ve(e))}setOperationErrorCode(e){return this.dispatch(Ue(e))}setOperationErrorName(e){return this.dispatch(Ve(e))}setOperationErrorDescription(e){return this.dispatch(Fe(e))}setOperationErrorTemplate(e){return this.dispatch(He(e))}deleteOperationError(e){return this.dispatch($e(e))}reorderOperationErrors(e){return this.dispatch(Xe(e))}}const Ge=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),Be=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),We=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),qe=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Nt extends s.BaseDocument{addOperationExample(e){return this.dispatch(Ge(e))}updateOperationExample(e){return this.dispatch(Be(e))}deleteOperationExample(e){return this.dispatch(We(e))}reorderOperationExamples(e){return this.dispatch(qe(e))}}const Je=t=>s.createAction("ADD_OPERATION",{...t}),Ke=t=>s.createAction("SET_OPERATION_NAME",{...t}),Qe=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Ye=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),Ze=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),et=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),tt=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),rt=t=>s.createAction("MOVE_OPERATION",{...t}),ot=t=>s.createAction("DELETE_OPERATION",{...t}),nt=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class Lt extends s.BaseDocument{addOperation(e){return this.dispatch(Je(e))}setOperationName(e){return this.dispatch(Ke(e))}setOperationScope(e){return this.dispatch(Qe(e))}setOperationSchema(e){return this.dispatch(Ye(e))}setOperationDescription(e){return this.dispatch(Ze(e))}setOperationTemplate(e){return this.dispatch(et(e))}setOperationReducer(e){return this.dispatch(tt(e))}moveOperation(e){return this.dispatch(rt(e))}deleteOperation(e){return this.dispatch(ot(e))}reorderModuleOperations(e){return this.dispatch(nt(e))}}const it=t=>s.createAction("SET_STATE_SCHEMA",{...t}),st=t=>s.createAction("SET_INITIAL_STATE",{...t}),at=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),pt=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),ct=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class jt extends s.BaseDocument{setStateSchema(e){return this.dispatch(it(e))}setInitialState(e){return this.dispatch(st(e))}addStateExample(e){return this.dispatch(at(e))}updateStateExample(e){return this.dispatch(pt(e))}deleteStateExample(e){return this.dispatch(lt(e))}reorderStateExamples(e){return this.dispatch(ct(e))}}var u;let S=(u=class extends s.BaseDocument{constructor(e,o){super(m,O.createDocument(e),o)}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}},ue(u,"fileExtension","phdm"),u);s.applyMixins(S,[Rt,Dt,Mt,xt,Nt,Lt,jt]);const Pt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:Me,addModule:Pe,addOperation:Je,addOperationError:ve,addOperationExample:Ge,addStateExample:at,deleteChangeLogItem:Ne,deleteModule:ye,deleteOperation:ot,deleteOperationError:$e,deleteOperationExample:We,deleteStateExample:lt,moveOperation:rt,releaseNewVersion:je,reorderChangeLogItems:Le,reorderModuleOperations:nt,reorderModules:we,reorderOperationErrors:Xe,reorderOperationExamples:qe,reorderStateExamples:ct,setAuthorName:Re,setAuthorWebsite:De,setInitialState:st,setModelDescription:Te,setModelExtension:Ie,setModelId:Ae,setModelName:ze,setModuleDescription:ke,setModuleName:Ce,setOperationDescription:Ze,setOperationErrorCode:Ue,setOperationErrorDescription:Fe,setOperationErrorName:Ve,setOperationErrorTemplate:He,setOperationName:Ke,setOperationReducer:tt,setOperationSchema:Ye,setOperationScope:Qe,setOperationTemplate:et,setStateSchema:it,updateChangeLogItem:xe,updateOperationExample:Be,updateStateExample:pt},Symbol.toStringTag,{value:"Module"})),le=S,ce={...O,...Et},de={...s.BaseActions,...Pt},dt={Document:le,reducer:m,actions:de,utils:ce,documentModel:f},Ct=Object.freeze(Object.defineProperty({__proto__:null,Document:le,DocumentModel:S,actions:de,documentModel:f,module:dt,reducer:m,utils:ce,z:_e},Symbol.toStringTag,{value:"Module"}));exports.Document=le;exports.DocumentModel=Ct;exports.DocumentModel$1=S;exports.actions=de;exports.documentModel=f;exports.module=dt;exports.reducer=m;exports.utils=ce;exports.zod=_e;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";var Br=Object.defineProperty;var jr=(i,a,p)=>a in i?Br(i,a,{enumerable:!0,configurable:!0,writable:!0,value:p}):i[a]=p;var H=(i,a,p)=>(jr(i,typeof a!="symbol"?a+"":a,p),p);const Ir=require("json-stringify-deterministic"),R=require("immer"),g=require("zod"),jt=require("jszip"),It=i=>i!=null,Ur=g.z.any().refine(i=>It(i)),Ut=g.z.enum(["LOAD_STATE"]),Tt=g.z.enum(["PRUNE"]),zt=g.z.enum(["REDO"]),kt=g.z.enum(["SET_NAME"]),Dt=g.z.enum(["UNDO"]);function Tr(){return g.z.object({__typename:g.z.literal("Action").optional(),type:g.z.string()})}function Ot(){return g.z.union([Nt(),Rt(),Ct(),Lt(),qt()])}function zr(){return g.z.object({__typename:g.z.literal("DocumentFile").optional(),data:g.z.string(),extension:g.z.string().nullable(),fileName:g.z.string().nullable(),mimeType:g.z.string()})}function Nt(){return g.z.object({input:g.z.lazy(()=>at()),type:Ut,scope:g.z.literal("global")})}function at(){return g.z.object({operations:g.z.number(),state:g.z.lazy(()=>Mt())})}function Mt(){return g.z.object({data:g.z.unknown().nullish(),name:g.z.string()})}function kr(){return g.z.object({__typename:g.z.literal("Operation").optional(),hash:g.z.string(),index:g.z.number(),timestamp:g.z.string().datetime(),type:g.z.string()})}function Rt(){return g.z.object({input:g.z.lazy(()=>ot()),type:Tt,scope:g.z.literal("global")})}function ot(){return g.z.object({end:g.z.number().nullish(),start:g.z.number().nullish()})}const pt=g.z.number;function Ct(){return g.z.object({input:pt(),type:zt,scope:g.z.literal("global")})}const st=g.z.string;function Lt(){return g.z.object({input:st(),type:kt,scope:g.z.literal("global")})}function Dr(){return g.z.object({__typename:g.z.literal("SetNameOperation").optional(),hash:g.z.string(),index:g.z.number(),input:g.z.string(),timestamp:g.z.string().datetime(),type:g.z.string()})}const lt=g.z.number;function qt(){return g.z.object({input:lt(),type:Dt,scope:g.z.literal("global")})}const Or=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Tr,BaseActionSchema:Ot,DocumentFileSchema:zr,LoadStateActionInputSchema:at,LoadStateActionSchema:Nt,LoadStateActionStateInputSchema:Mt,Load_StateSchema:Ut,OperationSchema:kr,PruneActionInputSchema:ot,PruneActionSchema:Rt,PruneSchema:Tt,RedoActionInputSchema:pt,RedoActionSchema:Ct,RedoSchema:zt,SetNameActionInputSchema:st,SetNameActionSchema:Lt,SetNameOperationSchema:Dr,Set_NameSchema:kt,UndoActionInputSchema:lt,UndoActionSchema:qt,UndoSchema:Dt,definedNonNullAnySchema:Ur,isDefinedNonNullAny:It},Symbol.toStringTag,{value:"Module"}));function Nr(i,a){return{...i,name:a}}function Mr(i,a,p){const l=Math.min(a,i.revision),c=i.operations.global.slice(0,i.revision-l);return{...C(i.initialState,{global:c,local:i.operations.local},p),operations:i.operations,revision:i.revision-l}}function Rr(i,a,p){const l=i.operations.global.length-i.revision;if(!l)throw new Error("There is no UNDO operation to REDO");const c=a<l?a:l,h=i.operations.global.slice(0,i.revision+c);return{...C(i.initialState,{global:h,local:i.operations.local},p),operations:i.operations,revision:i.revision+c}}function Cr(i,a,p,l){a=a||0,p=p||i.operations.global.length;const c=i.operations.global.slice(a,p),h=i.operations.global.slice(0,a),u=i.operations.global.slice(p),o=C(i.initialState,{global:h.concat(c),local:i.operations.local},l),{name:x,state:d}=o,w=h.length,b=h.length?h[h.length-1].timestamp:u.length?u[0].timestamp:new Date().toISOString();return C(i.initialState,{global:[...h,{...gt({name:x,state:d},c.length),timestamp:b,index:w,hash:mt({state:d},"global")},...u.map((j,_)=>({...j,index:w+_+1}))],local:i.operations.local},l)}function Lr(i,a){return{...i,name:a.name,state:a.state??{global:{},local:{}}}}const $t="SET_NAME",L="UNDO",q="REDO",$="PRUNE",Jt="LOAD_STATE";function Pt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Z(){this._types=Object.create(null),this._extensions=Object.create(null);for(let i=0;i<arguments.length;i++)this.define(arguments[i]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}Z.prototype.define=function(i,a){for(let p in i){let l=i[p].map(function(c){return c.toLowerCase()});p=p.toLowerCase();for(let c=0;c<l.length;c++){const h=l[c];if(h[0]!=="*"){if(!a&&h in this._types)throw new Error('Attempt to change mapping for "'+h+'" extension from "'+this._types[h]+'" to "'+p+'". Pass `force=true` to allow this, otherwise remove "'+h+'" from the list of extensions for "'+p+'".');this._types[h]=p}}if(a||!this._extensions[p]){const c=l[0];this._extensions[p]=c[0]!=="*"?c:c.substr(1)}}};Z.prototype.getType=function(i){i=String(i);let a=i.replace(/^.*[/\\]/,"").toLowerCase(),p=a.replace(/^.*\./,"").toLowerCase(),l=a.length<i.length;return(p.length<a.length-1||!l)&&this._types[p]||null};Z.prototype.getExtension=function(i){return i=/^\s*([^;\s]*)/.test(i)&&RegExp.$1,i&&this._extensions[i.toLowerCase()]||null};var qr=Z,$r={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};let Jr=qr;var Pr=new Jr($r);const Wr=Pt(Pr);var rt={exports:{}};typeof Object.create=="function"?rt.exports=function(a,p){p&&(a.super_=p,a.prototype=Object.create(p.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:rt.exports=function(a,p){if(p){a.super_=p;var l=function(){};l.prototype=p.prototype,a.prototype=new l,a.prototype.constructor=a}};var Hr=rt.exports,et={exports:{}},Wt={},K={};K.byteLength=Yr;K.toByteArray=Gr;K.fromByteArray=te;var T=[],I=[],Zr=typeof Uint8Array<"u"?Uint8Array:Array,tt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var D=0,Kr=tt.length;D<Kr;++D)T[D]=tt[D],I[tt.charCodeAt(D)]=D;I["-".charCodeAt(0)]=62;I["_".charCodeAt(0)]=63;function Ht(i){var a=i.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var p=i.indexOf("=");p===-1&&(p=a);var l=p===a?0:4-p%4;return[p,l]}function Yr(i){var a=Ht(i),p=a[0],l=a[1];return(p+l)*3/4-l}function Xr(i,a,p){return(a+p)*3/4-p}function Gr(i){var a,p=Ht(i),l=p[0],c=p[1],h=new Zr(Xr(i,l,c)),u=0,o=c>0?l-4:l,x;for(x=0;x<o;x+=4)a=I[i.charCodeAt(x)]<<18|I[i.charCodeAt(x+1)]<<12|I[i.charCodeAt(x+2)]<<6|I[i.charCodeAt(x+3)],h[u++]=a>>16&255,h[u++]=a>>8&255,h[u++]=a&255;return c===2&&(a=I[i.charCodeAt(x)]<<2|I[i.charCodeAt(x+1)]>>4,h[u++]=a&255),c===1&&(a=I[i.charCodeAt(x)]<<10|I[i.charCodeAt(x+1)]<<4|I[i.charCodeAt(x+2)]>>2,h[u++]=a>>8&255,h[u++]=a&255),h}function Vr(i){return T[i>>18&63]+T[i>>12&63]+T[i>>6&63]+T[i&63]}function Qr(i,a,p){for(var l,c=[],h=a;h<p;h+=3)l=(i[h]<<16&16711680)+(i[h+1]<<8&65280)+(i[h+2]&255),c.push(Vr(l));return c.join("")}function te(i){for(var a,p=i.length,l=p%3,c=[],h=16383,u=0,o=p-l;u<o;u+=h)c.push(Qr(i,u,u+h>o?o:u+h));return l===1?(a=i[p-1],c.push(T[a>>2]+T[a<<4&63]+"==")):l===2&&(a=(i[p-2]<<8)+i[p-1],c.push(T[a>>10]+T[a>>4&63]+T[a<<2&63]+"=")),c.join("")}var ct={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ct.read=function(i,a,p,l,c){var h,u,o=c*8-l-1,x=(1<<o)-1,d=x>>1,w=-7,b=p?c-1:0,j=p?-1:1,_=i[a+b];for(b+=j,h=_&(1<<-w)-1,_>>=-w,w+=o;w>0;h=h*256+i[a+b],b+=j,w-=8);for(u=h&(1<<-w)-1,h>>=-w,w+=l;w>0;u=u*256+i[a+b],b+=j,w-=8);if(h===0)h=1-d;else{if(h===x)return u?NaN:(_?-1:1)*(1/0);u=u+Math.pow(2,l),h=h-d}return(_?-1:1)*u*Math.pow(2,h-l)};ct.write=function(i,a,p,l,c,h){var u,o,x,d=h*8-c-1,w=(1<<d)-1,b=w>>1,j=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=l?0:h-1,z=l?1:-1,N=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(o=isNaN(a)?1:0,u=w):(u=Math.floor(Math.log(a)/Math.LN2),a*(x=Math.pow(2,-u))<1&&(u--,x*=2),u+b>=1?a+=j/x:a+=j*Math.pow(2,1-b),a*x>=2&&(u++,x/=2),u+b>=w?(o=0,u=w):u+b>=1?(o=(a*x-1)*Math.pow(2,c),u=u+b):(o=a*Math.pow(2,b-1)*Math.pow(2,c),u=0));c>=8;i[p+_]=o&255,_+=z,o/=256,c-=8);for(u=u<<c|o,d+=c;d>0;i[p+_]=u&255,_+=z,u/=256,d-=8);i[p+_-z]|=N*128};/*!
|
|
2
|
-
* The buffer module from node.js, for the browser.
|
|
3
|
-
*
|
|
4
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
-
* @license MIT
|
|
6
|
-
*/(function(i){var a=K,p=ct,l=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=o,i.SlowBuffer=lr,i.INSPECT_MAX_BYTES=50;var c=2147483647;i.kMaxLength=c,o.TYPED_ARRAY_SUPPORT=h(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function u(e){if(e>c)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(e)}return x(e,t,r)}o.poolSize=8192;function x(e,t,r){if(typeof e=="string")return j(e,t);if(ArrayBuffer.isView(e))return z(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(U(e,SharedArrayBuffer)||e&&U(e.buffer,SharedArrayBuffer)))return N(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return o.from(n,t,r);var s=sr(e);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return o.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}o.from=function(e,t,r){return x(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function d(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function w(e,t,r){return d(e),e<=0?u(e):t!==void 0?typeof r=="string"?u(e).fill(t,r):u(e).fill(t):u(e)}o.alloc=function(e,t,r){return w(e,t,r)};function b(e){return d(e),u(e<0?0:G(e)|0)}o.allocUnsafe=function(e){return b(e)},o.allocUnsafeSlow=function(e){return b(e)};function j(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=dt(e,t)|0,n=u(r),s=n.write(e,t);return s!==r&&(n=n.slice(0,s)),n}function _(e){for(var t=e.length<0?0:G(e.length)|0,r=u(t),n=0;n<t;n+=1)r[n]=e[n]&255;return r}function z(e){if(U(e,Uint8Array)){var t=new Uint8Array(e);return N(t.buffer,t.byteOffset,t.byteLength)}return _(e)}function N(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,o.prototype),n}function sr(e){if(o.isBuffer(e)){var t=G(e.length)|0,r=u(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Q(e.length)?u(0):_(e);if(e.type==="Buffer"&&Array.isArray(e.data))return _(e.data)}function G(e){if(e>=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return e|0}function lr(e){return+e!=e&&(e=0),o.alloc(+e)}o.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==o.prototype},o.compare=function(t,r){if(U(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),U(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(t)||!o.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;for(var n=t.length,s=r.length,f=0,m=Math.min(n,s);f<m;++f)if(t[f]!==r[f]){n=t[f],s=r[f];break}return n<s?-1:s<n?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return o.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var s=o.allocUnsafe(r),f=0;for(n=0;n<t.length;++n){var m=t[n];if(U(m,Uint8Array))f+m.length>s.length?o.from(m).copy(s,f):Uint8Array.prototype.set.call(s,m,f);else if(o.isBuffer(m))m.copy(s,f);else throw new TypeError('"list" argument must be an Array of Buffers');f+=m.length}return s};function dt(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return At(e).length;default:if(s)return n?-1:V(e).length;t=(""+t).toLowerCase(),s=!0}}o.byteLength=dt;function cr(e,t,r){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return vr(this,t,r);case"utf8":case"utf-8":return vt(this,t,r);case"ascii":return yr(this,t,r);case"latin1":case"binary":return wr(this,t,r);case"base64":return gr(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return br(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}o.prototype._isBuffer=!0;function k(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}o.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)k(this,r,r+1);return this},o.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)k(this,r,r+3),k(this,r+1,r+2);return this},o.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)k(this,r,r+7),k(this,r+1,r+6),k(this,r+2,r+5),k(this,r+3,r+4);return this},o.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?vt(this,0,t):cr.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:o.compare(this,t)===0},o.prototype.inspect=function(){var t="",r=i.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},l&&(o.prototype[l]=o.prototype.inspect),o.prototype.compare=function(t,r,n,s,f){if(U(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),s===void 0&&(s=0),f===void 0&&(f=this.length),r<0||n>t.length||s<0||f>this.length)throw new RangeError("out of range index");if(s>=f&&r>=n)return 0;if(s>=f)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,s>>>=0,f>>>=0,this===t)return 0;for(var m=f-s,y=n-r,v=Math.min(m,y),E=this.slice(s,f),S=t.slice(r,n),F=0;F<v;++F)if(E[F]!==S[F]){m=E[F],y=S[F];break}return m<y?-1:y<m?1:0};function yt(e,t,r,n,s){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Q(r)&&(r=s?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(s)return-1;r=e.length-1}else if(r<0)if(s)r=0;else return-1;if(typeof t=="string"&&(t=o.from(t,n)),o.isBuffer(t))return t.length===0?-1:wt(e,t,r,n,s);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):wt(e,[t],r,n,s);throw new TypeError("val must be string, number or Buffer")}function wt(e,t,r,n,s){var f=1,m=e.length,y=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;f=2,m/=2,y/=2,r/=2}function v(St,Bt){return f===1?St[Bt]:St.readUInt16BE(Bt*f)}var E;if(s){var S=-1;for(E=r;E<m;E++)if(v(e,E)===v(t,S===-1?0:E-S)){if(S===-1&&(S=E),E-S+1===y)return S*f}else S!==-1&&(E-=E-S),S=-1}else for(r+y>m&&(r=m-y),E=r;E>=0;E--){for(var F=!0,W=0;W<y;W++)if(v(e,E+W)!==v(t,W)){F=!1;break}if(F)return E}return-1}o.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1},o.prototype.indexOf=function(t,r,n){return yt(this,t,r,n,!0)},o.prototype.lastIndexOf=function(t,r,n){return yt(this,t,r,n,!1)};function ur(e,t,r,n){r=Number(r)||0;var s=e.length-r;n?(n=Number(n),n>s&&(n=s)):n=s;var f=t.length;n>f/2&&(n=f/2);for(var m=0;m<n;++m){var y=parseInt(t.substr(m*2,2),16);if(Q(y))return m;e[r+m]=y}return m}function fr(e,t,r,n){return P(V(t,e.length-r),e,r,n)}function hr(e,t,r,n){return P(_r(t),e,r,n)}function mr(e,t,r,n){return P(At(t),e,r,n)}function xr(e,t,r,n){return P(Ar(t,e.length-r),e,r,n)}o.prototype.write=function(t,r,n,s){if(r===void 0)s="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")s=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,s===void 0&&(s="utf8")):(s=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var f=this.length-r;if((n===void 0||n>f)&&(n=f),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var m=!1;;)switch(s){case"hex":return ur(this,t,r,n);case"utf8":case"utf-8":return fr(this,t,r,n);case"ascii":case"latin1":case"binary":return hr(this,t,r,n);case"base64":return mr(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xr(this,t,r,n);default:if(m)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),m=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function gr(e,t,r){return t===0&&r===e.length?a.fromByteArray(e):a.fromByteArray(e.slice(t,r))}function vt(e,t,r){r=Math.min(e.length,r);for(var n=[],s=t;s<r;){var f=e[s],m=null,y=f>239?4:f>223?3:f>191?2:1;if(s+y<=r){var v,E,S,F;switch(y){case 1:f<128&&(m=f);break;case 2:v=e[s+1],(v&192)===128&&(F=(f&31)<<6|v&63,F>127&&(m=F));break;case 3:v=e[s+1],E=e[s+2],(v&192)===128&&(E&192)===128&&(F=(f&15)<<12|(v&63)<<6|E&63,F>2047&&(F<55296||F>57343)&&(m=F));break;case 4:v=e[s+1],E=e[s+2],S=e[s+3],(v&192)===128&&(E&192)===128&&(S&192)===128&&(F=(f&15)<<18|(v&63)<<12|(E&63)<<6|S&63,F>65535&&F<1114112&&(m=F))}}m===null?(m=65533,y=1):m>65535&&(m-=65536,n.push(m>>>10&1023|55296),m=56320|m&1023),n.push(m),s+=y}return dr(n)}var bt=4096;function dr(e){var t=e.length;if(t<=bt)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=bt));return r}function yr(e,t,r){var n="";r=Math.min(e.length,r);for(var s=t;s<r;++s)n+=String.fromCharCode(e[s]&127);return n}function wr(e,t,r){var n="";r=Math.min(e.length,r);for(var s=t;s<r;++s)n+=String.fromCharCode(e[s]);return n}function vr(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var s="",f=t;f<r;++f)s+=Sr[e[f]];return s}function br(e,t,r){for(var n=e.slice(t,r),s="",f=0;f<n.length-1;f+=2)s+=String.fromCharCode(n[f]+n[f+1]*256);return s}o.prototype.slice=function(t,r){var n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);var s=this.subarray(t,r);return Object.setPrototypeOf(s,o.prototype),s};function A(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||A(t,r,this.length);for(var s=this[t],f=1,m=0;++m<r&&(f*=256);)s+=this[t+m]*f;return s},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||A(t,r,this.length);for(var s=this[t+--r],f=1;r>0&&(f*=256);)s+=this[t+--r]*f;return s},o.prototype.readUint8=o.prototype.readUInt8=function(t,r){return t=t>>>0,r||A(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||A(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||A(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||A(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||A(t,r,this.length);for(var s=this[t],f=1,m=0;++m<r&&(f*=256);)s+=this[t+m]*f;return f*=128,s>=f&&(s-=Math.pow(2,8*r)),s},o.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||A(t,r,this.length);for(var s=r,f=1,m=this[t+--s];s>0&&(f*=256);)m+=this[t+--s]*f;return f*=128,m>=f&&(m-=Math.pow(2,8*r)),m},o.prototype.readInt8=function(t,r){return t=t>>>0,r||A(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,r){t=t>>>0,r||A(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},o.prototype.readInt16BE=function(t,r){t=t>>>0,r||A(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},o.prototype.readInt32LE=function(t,r){return t=t>>>0,r||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,r){return t=t>>>0,r||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,r){return t=t>>>0,r||A(t,4,this.length),p.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,r){return t=t>>>0,r||A(t,4,this.length),p.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||A(t,8,this.length),p.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||A(t,8,this.length),p.read(this,t,!1,52,8)};function B(e,t,r,n,s,f){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<f)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,r,n,s){if(t=+t,r=r>>>0,n=n>>>0,!s){var f=Math.pow(2,8*n)-1;B(this,t,r,n,f,0)}var m=1,y=0;for(this[r]=t&255;++y<n&&(m*=256);)this[r+y]=t/m&255;return r+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,r,n,s){if(t=+t,r=r>>>0,n=n>>>0,!s){var f=Math.pow(2,8*n)-1;B(this,t,r,n,f,0)}var m=n-1,y=1;for(this[r+m]=t&255;--m>=0&&(y*=256);)this[r+m]=t/y&255;return r+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,1,255,0),this[r]=t&255,r+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4},o.prototype.writeIntLE=function(t,r,n,s){if(t=+t,r=r>>>0,!s){var f=Math.pow(2,8*n-1);B(this,t,r,n,f-1,-f)}var m=0,y=1,v=0;for(this[r]=t&255;++m<n&&(y*=256);)t<0&&v===0&&this[r+m-1]!==0&&(v=1),this[r+m]=(t/y>>0)-v&255;return r+n},o.prototype.writeIntBE=function(t,r,n,s){if(t=+t,r=r>>>0,!s){var f=Math.pow(2,8*n-1);B(this,t,r,n,f-1,-f)}var m=n-1,y=1,v=0;for(this[r+m]=t&255;--m>=0&&(y*=256);)t<0&&v===0&&this[r+m+1]!==0&&(v=1),this[r+m]=(t/y>>0)-v&255;return r+n},o.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1},o.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2},o.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2},o.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},o.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||B(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function Et(e,t,r,n,s,f){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ft(e,t,r,n,s){return t=+t,r=r>>>0,s||Et(e,t,r,4),p.write(e,t,r,n,23,4),r+4}o.prototype.writeFloatLE=function(t,r,n){return Ft(this,t,r,!0,n)},o.prototype.writeFloatBE=function(t,r,n){return Ft(this,t,r,!1,n)};function _t(e,t,r,n,s){return t=+t,r=r>>>0,s||Et(e,t,r,8),p.write(e,t,r,n,52,8),r+8}o.prototype.writeDoubleLE=function(t,r,n){return _t(this,t,r,!0,n)},o.prototype.writeDoubleBE=function(t,r,n){return _t(this,t,r,!1,n)},o.prototype.copy=function(t,r,n,s){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!s&&s!==0&&(s=this.length),r>=t.length&&(r=t.length),r||(r=0),s>0&&s<n&&(s=n),s===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-r<s-n&&(s=t.length-r+n);var f=s-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,s):Uint8Array.prototype.set.call(t,this.subarray(n,s),r),f},o.prototype.fill=function(t,r,n,s){if(typeof t=="string"){if(typeof r=="string"?(s=r,r=0,n=this.length):typeof n=="string"&&(s=n,n=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!o.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(t.length===1){var f=t.charCodeAt(0);(s==="utf8"&&f<128||s==="latin1")&&(t=f)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var m;if(typeof t=="number")for(m=r;m<n;++m)this[m]=t;else{var y=o.isBuffer(t)?t:o.from(t,s),v=y.length;if(v===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(m=0;m<n-r;++m)this[m+r]=y[m%v]}return this};var Er=/[^+/0-9A-Za-z-_]/g;function Fr(e){if(e=e.split("=")[0],e=e.trim().replace(Er,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function V(e,t){t=t||1/0;for(var r,n=e.length,s=null,f=[],m=0;m<n;++m){if(r=e.charCodeAt(m),r>55295&&r<57344){if(!s){if(r>56319){(t-=3)>-1&&f.push(239,191,189);continue}else if(m+1===n){(t-=3)>-1&&f.push(239,191,189);continue}s=r;continue}if(r<56320){(t-=3)>-1&&f.push(239,191,189),s=r;continue}r=(s-55296<<10|r-56320)+65536}else s&&(t-=3)>-1&&f.push(239,191,189);if(s=null,r<128){if((t-=1)<0)break;f.push(r)}else if(r<2048){if((t-=2)<0)break;f.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;f.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;f.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return f}function _r(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Ar(e,t){for(var r,n,s,f=[],m=0;m<e.length&&!((t-=2)<0);++m)r=e.charCodeAt(m),n=r>>8,s=r%256,f.push(s),f.push(n);return f}function At(e){return a.toByteArray(Fr(e))}function P(e,t,r,n){for(var s=0;s<n&&!(s+r>=t.length||s>=e.length);++s)t[s+r]=e[s];return s}function U(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Q(e){return e!==e}var Sr=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var n=r*16,s=0;s<16;++s)t[n+s]=e[r]+e[s];return t}()})(Wt);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(i,a){var p=Wt,l=p.Buffer;function c(u,o){for(var x in u)o[x]=u[x]}l.from&&l.alloc&&l.allocUnsafe&&l.allocUnsafeSlow?i.exports=p:(c(p,a),a.Buffer=h);function h(u,o,x){return l(u,o,x)}h.prototype=Object.create(l.prototype),c(l,h),h.from=function(u,o,x){if(typeof u=="number")throw new TypeError("Argument must not be a number");return l(u,o,x)},h.alloc=function(u,o,x){if(typeof u!="number")throw new TypeError("Argument must be a number");var d=l(u);return o!==void 0?typeof x=="string"?d.fill(o,x):d.fill(o):d.fill(0),d},h.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return l(u)},h.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return p.SlowBuffer(u)}})(et,et.exports);var Zt=et.exports,Kt=Zt.Buffer;function Y(i,a){this._block=Kt.alloc(i),this._finalSize=a,this._blockSize=i,this._len=0}Y.prototype.update=function(i,a){typeof i=="string"&&(a=a||"utf8",i=Kt.from(i,a));for(var p=this._block,l=this._blockSize,c=i.length,h=this._len,u=0;u<c;){for(var o=h%l,x=Math.min(c-u,l-o),d=0;d<x;d++)p[o+d]=i[u+d];h+=x,u+=x,h%l===0&&this._update(p)}return this._len+=c,this};Y.prototype.digest=function(i){var a=this._len%this._blockSize;this._block[a]=128,this._block.fill(0,a+1),a>=this._finalSize&&(this._update(this._block),this._block.fill(0));var p=this._len*8;if(p<=4294967295)this._block.writeUInt32BE(p,this._blockSize-4);else{var l=(p&4294967295)>>>0,c=(p-l)/4294967296;this._block.writeUInt32BE(c,this._blockSize-8),this._block.writeUInt32BE(l,this._blockSize-4)}this._update(this._block);var h=this._hash();return i?h.toString(i):h};Y.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var re=Y,ee=Hr,Yt=re,ie=Zt.Buffer,ne=[1518500249,1859775393,-1894007588,-899497514],ae=new Array(80);function J(){this.init(),this._w=ae,Yt.call(this,64,56)}ee(J,Yt);J.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function oe(i){return i<<1|i>>>31}function pe(i){return i<<5|i>>>27}function se(i){return i<<30|i>>>2}function le(i,a,p,l){return i===0?a&p|~a&l:i===2?a&p|a&l|p&l:a^p^l}J.prototype._update=function(i){for(var a=this._w,p=this._a|0,l=this._b|0,c=this._c|0,h=this._d|0,u=this._e|0,o=0;o<16;++o)a[o]=i.readInt32BE(o*4);for(;o<80;++o)a[o]=oe(a[o-3]^a[o-8]^a[o-14]^a[o-16]);for(var x=0;x<80;++x){var d=~~(x/20),w=pe(p)+le(d,l,c,h)+u+a[x]+ne[d]|0;u=h,h=c,c=se(l),l=p,p=w}this._a=p+this._a|0,this._b=l+this._b|0,this._c=c+this._c|0,this._d=h+this._d|0,this._e=u+this._e|0};J.prototype._hash=function(){var i=ie.allocUnsafe(20);return i.writeInt32BE(this._a|0,0),i.writeInt32BE(this._b|0,4),i.writeInt32BE(this._c|0,8),i.writeInt32BE(this._d|0,12),i.writeInt32BE(this._e|0,16),i};var ce=J;const ue=Pt(ce),ut=new Error("File system not available.");function fe(i,a,p){throw ut}function Xt(i){throw ut}function he(i){throw ut}const me=async i=>Xt();function xe(i){let a="";for(let p=0;p<i.length;p+=2)a+=String.fromCharCode(parseInt(i.substr(p,2),16));return btoa(a)}const X=(i,a="sha1")=>{if(a!=="sha1")throw new Error("Only sha1 algorithm is available.");const p=new ue;return xe(p.update(i).digest("hex"))},ft=async i=>{const a=new jt,{name:p,revision:l,documentType:c,created:h,lastModified:u}=i,o={name:p,revision:l,documentType:c,created:h,lastModified:u};return a.file("header.json",JSON.stringify(o,null,2)),a.file("state.json",JSON.stringify(i.initialState||{},null,2)),a.file("operations.json",JSON.stringify(i.operations,null,2)),Object.keys(i.attachments).forEach(d=>{const{data:w,...b}=i.attachments[d];a.file(d,w,{base64:!0,createFolders:!0,comment:JSON.stringify(b)})}),a},Gt=async(i,a,p,l)=>{await(await ft(i)).generateAsync({type:"uint8array",streamFiles:!0});const h=l??i.name,u=`.${p}.zip`;return fe(a,h.endsWith(u)?h:`${h}${u}`)},ge=async(i,a)=>{const l=await(await ft(i)).generateAsync({type:"blob"}),c=await a.createWritable();await c.write(l),await c.close()},it=async(i,a)=>{const p=Xt();return Vt(p,a)},Vt=async(i,a)=>{const p=new jt;return await p.loadAsync(i),de(p,a)};async function de(i,a){const p=i.file("state.json");if(!p)throw new Error("Initial state not found");const l=await p.async("string"),c=JSON.parse(l),h=i.file("header.json");let u;h&&(u=JSON.parse(await h.async("string")));const o=i.file("operations.json");if(!o)throw new Error("Operations history not found");const x=JSON.parse(await o.async("string"));let d=xt(c,x,a,void 0,u);return u&&(d={...d,...u}),d}function Qt(i){const a=i.replace(/^.*\./,"")||void 0,p=i.replace(/^.*[/\\]/,"")||void 0;return{extension:a,fileName:p}}async function ye(i){const{buffer:a,mimeType:p="application/octet-stream"}=await he(),l=Qt(i),c=a.toString("base64");return{data:c,hash:X(c),mimeType:p,...l}}async function we(i){const a=await me(),p=Wr.getType(i)||"application/octet-stream",l=Qt(i),c=a.toString("base64");return{data:c,hash:X(c),mimeType:p,...l}}function ve(i,a){return[L,q,$].includes(a.type)?i.revision:i.revision+1}function be(i,a){return{...i,revision:ve(i,a),lastModified:new Date().toISOString()}}function Ee(i,a){if([L,q,$].includes(a.type))return i;const p=i.operations.global.slice(0,i.revision),l=a.scope||"global",c=l==="global"?p:i.operations[l];return c.push({...a,index:c.length,timestamp:new Date().toISOString(),hash:"",scope:l}),{...i,operations:{...i.operations,[l]:c}}}function Fe(i,a){let p=Ee(i,a);return(!a.scope||a.scope==="global")&&(p=be(p,a)),p}function _e(i,a,p){switch(Ot().parse(a),a.type){case $t:return Nr(i,a.input);case L:return Mr(i,a.input,p);case q:return Rr(i,a.input,p);case $:return Cr(i,a.input.start,a.input.end,p);case Jt:return Lr(i,a.input.state);default:return i}}function ht(i,a,p,l){let c=i;return nt(a)&&(c=_e(c,a,p)),c=Fe(c,a),c=R.produce(c,h=>{const u=p(h.state,a,l);if(u)return R.castDraft({...c,state:u})}),R.produce(c,h=>{if([L,q,$].includes(a.type))return h;const u=a.scope||"global";h.operations[u][h.operations[u].length-1].hash=mt(h,u),!nt(a)&&a.attachments&&a.attachments.forEach(o=>{const{hash:x,...d}=o;h.attachments[x]={...d}})})}function nt(i){return[$t,L,q,$,Jt].includes(i.type)}function O(i,a,p,l,c="global"){if(!i)throw new Error("Empty action type");if(typeof i!="string")throw new Error(`Invalid action type: ${i}`);const h={type:i,input:a,scope:c};p&&(h.attachments=p);try{l==null||l().parse(h.input)}catch(u){throw new Error(`Invalid action input: ${u}`)}return h}function tr(i,a=ht){return(p,l,c)=>a(p,l,i,c)}const rr=(i,a)=>({name:"",documentType:"",revision:0,created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...i,state:(a==null?void 0:a(i==null?void 0:i.state))??(i==null?void 0:i.state)??{global:{},local:{}}}),er=(i,a)=>{const p=rr(i,a);return{...p,initialState:p,operations:{global:[],local:[]}}},mt=(i,a="global")=>X(Ir(i.state[a])),Ae=(i,a=1e3)=>{const p=Math.random()*a;return X(`${(i??new Date).toISOString()}${p}`)};function M(i){return R.castImmutable(R.freeze(i,!0))}function ir(i){return Object.values(i).flatMap(a=>a).sort((a,p)=>new Date(a.timestamp).getTime()-new Date(p.timestamp).getTime())}function C(i,a,p,l,c,h=ht){const u=tr(p,h);return xt(i,a,u,l,c)}function xt(i,a,p,l,c){const h=er(i),u={...a,global:a.global.slice(0,c==null?void 0:c.revision)},o=ir(u).reduce((d,w)=>p(d,w,l),h),x=Object.keys(o.operations).reduce((d,w)=>{const b=w,j=b==="global"&&c&&c.revision<a.global.length?a.global.slice(c==null?void 0:c.revision):[];return{...d,[b]:[...o.operations[b].map((_,z)=>({..._,timestamp:a[b][z].timestamp})),...j]}},{global:[],local:[]});return{...o,operations:x}}const nr=i=>O("SET_NAME",i,void 0,st),ar=(i=1)=>O("UNDO",i,void 0,lt),or=(i=1)=>O("REDO",i,void 0,pt),pr=(i,a)=>O("PRUNE",{start:i,end:a},void 0,ot),gt=(i,a)=>O("LOAD_STATE",{state:i,operations:a},void 0,at),Se=Object.freeze(Object.defineProperty({__proto__:null,loadState:gt,prune:pr,redo:or,setName:nr,undo:ar},Symbol.toStringTag,{value:"Module"}));class Be{constructor(a,p,l){H(this,"_document");H(this,"_reducer");H(this,"_signalDispatch");this._reducer=a,this._document=p,this._signalDispatch=l}dispatch(a){return this._document=this._reducer(this._document,a,this._signalDispatch),this}saveToFile(a,p,l){return Gt(this._document,a,p,l)}async loadFromFile(a){this._document=await it(a,this._reducer)}static async stateFromFile(a,p){return await it(a,p)}get state(){return M(this._document.state)}get operations(){return M(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision}get initialState(){return M(this._document.initialState)}toDocument(){return M(this._document)}getAttachment(a){return this._document.attachments[a]}setName(a){return this.dispatch(nr(a)),this}undo(a){return this.dispatch(ar(a)),this}redo(a){return this.dispatch(or(a)),this}prune(a,p){return this.dispatch(pr(a,p)),this}loadState(a,p){return this.dispatch(gt(a,p)),this}}function je(i,a){a.forEach(p=>{Object.getOwnPropertyNames(p.prototype).forEach(l=>{Object.defineProperty(i.prototype,l,Object.getOwnPropertyDescriptor(p.prototype,l)||Object.create(null))})})}exports.BaseActions=Se;exports.BaseDocument=Be;exports.applyMixins=je;exports.baseReducer=ht;exports.createAction=O;exports.createDocument=er;exports.createExtendedState=rr;exports.createReducer=tr;exports.createZip=ft;exports.getLocalFile=we;exports.getRemoteFile=ye;exports.hashDocument=mt;exports.hashKey=Ae;exports.isBaseAction=nt;exports.loadFromFile=it;exports.loadFromInput=Vt;exports.readOnly=M;exports.replayDocument=xt;exports.replayOperations=C;exports.saveToFile=Gt;exports.saveToFileHandle=ge;exports.sortOperations=ir;exports.zod=Or;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";var ut=Object.defineProperty;var mt=(t,e,o)=>e in t?ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var ue=(t,e,o)=>(mt(t,typeof e!="symbol"?e+"":e,o),o);const s=require("./object-08bd169a.js");require("json-stringify-deterministic");require("immer");require("jszip");require("crypto");require("fs");require("https");require("path");const r=require("zod"),Et=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),f={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:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{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:[]},local:{schema:"",initialValue:"{}",examples:[]}}}]},me=t=>t!=null,ht=r.z.any().refine(t=>me(t));function _(){return r.z.object({__typename:r.z.literal("AddChangeLogItemInput").optional(),content:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullable()})}function z(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),name:r.z.string()})}function A(){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(),scope:r.z.literal("local").or(r.z.literal("global")).nullish()})}function R(){return r.z.object({scope:r.z.string(),example:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullish()})}function Ee(){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 N(){return r.z.object({id:r.z.string()})}function L(){return r.z.object({id:r.z.string()})}function j(){return r.z.object({id:r.z.string()})}function P(){return r.z.object({scope:r.z.string(),id:r.z.string()})}function Ot(){return r.z.union([_(),z(),A(),I(),T(),R(),M(),x(),N(),L(),j(),P(),C(),k(),y(),w(),v(),U(),V(),F(),H(),$(),X(),G(),B(),W(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae(),pe()])}function gt(){return r.z.object({__typename:r.z.literal("DocumentModelState").optional(),author:Ee(),description:r.z.string(),extension:r.z.string(),id:r.z.string(),name:r.z.string(),specifications:r.z.array(he())})}function he(){return r.z.object({__typename:r.z.literal("DocumentSpecification").optional(),changeLog:r.z.array(r.z.string()),modules:r.z.array(Oe()),state:fe(),version:r.z.number()})}function Oe(){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(ge())})}function C(){return r.z.object({newModuleId:r.z.string(),operationId:r.z.string()})}function ge(){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(),scope:r.z.literal("local").or(r.z.literal("global"))})}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 k(){return r.z.object({__typename:r.z.literal("ReorderChangeLogItemsInput").optional(),order:r.z.array(r.z.string())})}function y(){return r.z.object({moduleId:r.z.string(),order:r.z.array(r.z.string())})}function w(){return r.z.object({order:r.z.array(r.z.string())})}function v(){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({scope:r.z.string(),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 $(){return r.z.object({scope:r.z.string(),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 q(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function J(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function K(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function Q(){return r.z.object({errorCode:r.z.string().nullish(),id:r.z.string()})}function Y(){return r.z.object({errorDescription:r.z.string().nullish(),id:r.z.string()})}function Z(){return r.z.object({errorName:r.z.string().nullish(),id:r.z.string()})}function ee(){return r.z.object({errorTemplate:r.z.string().nullish(),id:r.z.string()})}function te(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function be(){return r.z.object({id:r.z.string(),scope:r.z.literal("global").or(r.z.literal("local"))})}function re(){return r.z.object({id:r.z.string(),reducer:r.z.string().nullish()})}function oe(){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 ie(){return r.z.object({scope:r.z.string(),schema:r.z.string()})}function b(){return r.z.object({__typename:r.z.literal("State").optional(),examples:r.z.array(D()),initialValue:r.z.string(),schema:r.z.string()})}function fe(){return r.z.object({global:b(),local:b()})}function se(){return r.z.object({__typename:r.z.literal("UpdateChangeLogItemInput").optional(),id:r.z.string(),newContent:r.z.string()})}function ae(){return r.z.object({example:r.z.string(),id:r.z.string()})}function pe(){return r.z.object({scope:r.z.string(),id:r.z.string(),newExample:r.z.string()})}const _e=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:_,AddModuleInputSchema:z,AddOperationErrorInputSchema:A,AddOperationExampleInputSchema:I,AddOperationInputSchema:T,AddStateExampleInputSchema:R,AuthorSchema:Ee,CodeExampleSchema:D,DeleteChangeLogItemInputSchema:M,DeleteModuleInputSchema:x,DeleteOperationErrorInputSchema:N,DeleteOperationExampleInputSchema:L,DeleteOperationInputSchema:j,DeleteStateExampleInputSchema:P,DocumentModelInputSchema:Ot,DocumentModelStateSchema:gt,DocumentSpecificationSchema:he,ModuleSchema:Oe,MoveOperationInputSchema:C,OperationErrorSchema:Se,OperationSchema:ge,ReorderChangeLogItemsInputSchema:k,ReorderModuleOperationsInputSchema:y,ReorderModulesInputSchema:w,ReorderOperationErrorsInputSchema:v,ReorderOperationExamplesInputSchema:U,ReorderStateExamplesInputSchema:V,ScopeStateSchema:fe,SetAuthorNameInputSchema:F,SetAuthorWebsiteInputSchema:H,SetInitialStateInputSchema:$,SetModelDescriptionInputSchema:X,SetModelExtensionInputSchema:G,SetModelIdInputSchema:B,SetModelNameInputSchema:W,SetModuleDescriptionInputSchema:q,SetModuleNameInputSchema:J,SetOperationDescriptionInputSchema:K,SetOperationErrorCodeInputSchema:Q,SetOperationErrorDescriptionInputSchema:Y,SetOperationErrorNameInputSchema:Z,SetOperationErrorTemplateInputSchema:ee,SetOperationNameInputSchema:te,SetOperationReducerInputSchema:re,SetOperationSchemaInputSchema:oe,SetOperationScopeInputSchema:be,SetOperationTemplateInputSchema:ne,SetStateSchemaInputSchema:ie,StateSchema:b,UpdateChangeLogItemInputSchema:se,UpdateOperationExampleInputSchema:ae,UpdateStateExampleInputSchema:pe,definedNonNullAnySchema:ht,isDefinedNonNullAny:me},Symbol.toStringTag,{value:"Module"})),c={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')}},St=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(St(e.input.order))}},bt=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},l={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(bt(e.input.order))}},ft=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},g={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(ft(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)},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:[],scope:e.input.scope||"global"})},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||"")},setOperationScopeOperation(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].scope=e.input.scope||"global")},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(_t(e.input.order))}},zt=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];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].schema=e.input.schema;else throw new Error(`Invalid scope: ${e.input.scope}`)},setInitialStateOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].initialValue=e.input.initialValue;else throw new Error(`Invalid scope: ${e.input.scope}`)},addStateExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].examples.push({id:e.input.id,value:e.input.example});else throw new Error(`Invalid scope: ${e.input.scope}`)},updateStateExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];if(!Object.keys(o.state).includes(e.input.scope))throw new Error(`Invalid scope: ${e.input.scope}`);const n=o.state[e.input.scope].examples;for(let i=0;i<n.length;i++)n[i].id==e.input.id&&(n[i].value=e.input.newExample)},deleteStateExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].examples=o.state[e.input.scope].examples.filter(n=>n.id!=e.input.id);else throw new Error(`Invalid scope: ${e.input.scope}`)},reorderStateExamplesOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].examples.sort(zt(e.input.order));else throw new Error(`Invalid scope: ${e.input.scope}`)}},At=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":W().parse(e.input),c.setModelNameOperation(t.global,e);break;case"SET_MODEL_ID":B().parse(e.input),c.setModelIdOperation(t.global,e);break;case"SET_MODEL_EXTENSION":G().parse(e.input),c.setModelExtensionOperation(t.global,e);break;case"SET_MODEL_DESCRIPTION":X().parse(e.input),c.setModelDescriptionOperation(t.global,e);break;case"SET_AUTHOR_NAME":F().parse(e.input),c.setAuthorNameOperation(t.global,e);break;case"SET_AUTHOR_WEBSITE":H().parse(e.input),c.setAuthorWebsiteOperation(t.global,e);break;case"ADD_CHANGE_LOG_ITEM":_().parse(e.input),E.addChangeLogItemOperation(t.global,e);break;case"UPDATE_CHANGE_LOG_ITEM":se().parse(e.input),E.updateChangeLogItemOperation(t.global,e);break;case"DELETE_CHANGE_LOG_ITEM":M().parse(e.input),E.deleteChangeLogItemOperation(t.global,e);break;case"REORDER_CHANGE_LOG_ITEMS":k().parse(e.input),E.reorderChangeLogItemsOperation(t.global,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.global,e);break;case"ADD_MODULE":z().parse(e.input),h.addModuleOperation(t.global,e);break;case"SET_MODULE_NAME":J().parse(e.input),h.setModuleNameOperation(t.global,e);break;case"SET_MODULE_DESCRIPTION":q().parse(e.input),h.setModuleDescriptionOperation(t.global,e);break;case"DELETE_MODULE":x().parse(e.input),h.deleteModuleOperation(t.global,e);break;case"REORDER_MODULES":w().parse(e.input),h.reorderModulesOperation(t.global,e);break;case"ADD_OPERATION_ERROR":A().parse(e.input),l.addOperationErrorOperation(t.global,e);break;case"SET_OPERATION_ERROR_CODE":Q().parse(e.input),l.setOperationErrorCodeOperation(t.global,e);break;case"SET_OPERATION_ERROR_NAME":Z().parse(e.input),l.setOperationErrorNameOperation(t.global,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Y().parse(e.input),l.setOperationErrorDescriptionOperation(t.global,e);break;case"SET_OPERATION_ERROR_TEMPLATE":ee().parse(e.input),l.setOperationErrorTemplateOperation(t.global,e);break;case"DELETE_OPERATION_ERROR":N().parse(e.input),l.deleteOperationErrorOperation(t.global,e);break;case"REORDER_OPERATION_ERRORS":v().parse(e.input),l.reorderOperationErrorsOperation(t.global,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),g.addOperationExampleOperation(t.global,e);break;case"UPDATE_OPERATION_EXAMPLE":ae().parse(e.input),g.updateOperationExampleOperation(t.global,e);break;case"DELETE_OPERATION_EXAMPLE":L().parse(e.input),g.deleteOperationExampleOperation(t.global,e);break;case"REORDER_OPERATION_EXAMPLES":U().parse(e.input),g.reorderOperationExamplesOperation(t.global,e);break;case"ADD_OPERATION":T().parse(e.input),p.addOperationOperation(t.global,e);break;case"SET_OPERATION_NAME":te().parse(e.input),p.setOperationNameOperation(t.global,e);break;case"SET_OPERATION_SCOPE":be().parse(e.input),p.setOperationScopeOperation(t.global,e);break;case"SET_OPERATION_SCHEMA":oe().parse(e.input),p.setOperationSchemaOperation(t.global,e);break;case"SET_OPERATION_DESCRIPTION":K().parse(e.input),p.setOperationDescriptionOperation(t.global,e);break;case"SET_OPERATION_TEMPLATE":ne().parse(e.input),p.setOperationTemplateOperation(t.global,e);break;case"SET_OPERATION_REDUCER":re().parse(e.input),p.setOperationReducerOperation(t.global,e);break;case"MOVE_OPERATION":C().parse(e.input),p.moveOperationOperation(t.global,e);break;case"DELETE_OPERATION":j().parse(e.input),p.deleteOperationOperation(t.global,e);break;case"REORDER_MODULE_OPERATIONS":y().parse(e.input),p.reorderModuleOperationsOperation(t.global,e);break;case"SET_STATE_SCHEMA":ie().parse(e.input),d.setStateSchemaOperation(t.global,e);break;case"SET_INITIAL_STATE":$().parse(e.input),d.setInitialStateOperation(t.global,e);break;case"ADD_STATE_EXAMPLE":R().parse(e.input),d.addStateExampleOperation(t.global,e);break;case"UPDATE_STATE_EXAMPLE":pe().parse(e.input),d.updateStateExampleOperation(t.global,e);break;case"DELETE_STATE_EXAMPLE":P().parse(e.input),d.deleteStateExampleOperation(t.global,e);break;case"REORDER_STATE_EXAMPLES":V().parse(e.input),d.reorderStateExamplesOperation(t.global,e);break;default:return t}},m=s.createReducer(At),It={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},Tt={},O={fileExtension:"phdm",createState(t){return{global:{...It,...t==null?void 0:t.global},local:{...Tt,...t==null?void 0:t.local}}},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)}},ze=t=>s.createAction("SET_MODEL_NAME",{...t}),Ae=t=>s.createAction("SET_MODEL_ID",{...t}),Ie=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Te=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),Re=t=>s.createAction("SET_AUTHOR_NAME",{...t}),De=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Rt extends s.BaseDocument{setModelName(e){return this.dispatch(ze(e))}setModelId(e){return this.dispatch(Ae(e))}setModelExtension(e){return this.dispatch(Ie(e))}setModelDescription(e){return this.dispatch(Te(e))}setAuthorName(e){return this.dispatch(Re(e))}setAuthorWebsite(e){return this.dispatch(De(e))}}const Me=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),xe=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Le=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),je=()=>s.createAction("RELEASE_NEW_VERSION");class Dt extends s.BaseDocument{addChangeLogItem(e){return this.dispatch(Me(e))}updateChangeLogItem(e){return this.dispatch(xe(e))}deleteChangeLogItem(e){return this.dispatch(Ne(e))}reorderChangeLogItems(e){return this.dispatch(Le(e))}releaseNewVersion(){return this.dispatch(je())}}const Pe=t=>s.createAction("ADD_MODULE",{...t}),Ce=t=>s.createAction("SET_MODULE_NAME",{...t}),ke=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),ye=t=>s.createAction("DELETE_MODULE",{...t}),we=t=>s.createAction("REORDER_MODULES",{...t});class Mt extends s.BaseDocument{addModule(e){return this.dispatch(Pe(e))}setModuleName(e){return this.dispatch(Ce(e))}setModuleDescription(e){return this.dispatch(ke(e))}deleteModule(e){return this.dispatch(ye(e))}reorderModules(e){return this.dispatch(we(e))}}const ve=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),Ue=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),Ve=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),Fe=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),He=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),$e=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Xe=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class xt extends s.BaseDocument{addOperationError(e){return this.dispatch(ve(e))}setOperationErrorCode(e){return this.dispatch(Ue(e))}setOperationErrorName(e){return this.dispatch(Ve(e))}setOperationErrorDescription(e){return this.dispatch(Fe(e))}setOperationErrorTemplate(e){return this.dispatch(He(e))}deleteOperationError(e){return this.dispatch($e(e))}reorderOperationErrors(e){return this.dispatch(Xe(e))}}const Ge=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),Be=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),We=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),qe=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Nt extends s.BaseDocument{addOperationExample(e){return this.dispatch(Ge(e))}updateOperationExample(e){return this.dispatch(Be(e))}deleteOperationExample(e){return this.dispatch(We(e))}reorderOperationExamples(e){return this.dispatch(qe(e))}}const Je=t=>s.createAction("ADD_OPERATION",{...t}),Ke=t=>s.createAction("SET_OPERATION_NAME",{...t}),Qe=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Ye=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),Ze=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),et=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),tt=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),rt=t=>s.createAction("MOVE_OPERATION",{...t}),ot=t=>s.createAction("DELETE_OPERATION",{...t}),nt=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class Lt extends s.BaseDocument{addOperation(e){return this.dispatch(Je(e))}setOperationName(e){return this.dispatch(Ke(e))}setOperationScope(e){return this.dispatch(Qe(e))}setOperationSchema(e){return this.dispatch(Ye(e))}setOperationDescription(e){return this.dispatch(Ze(e))}setOperationTemplate(e){return this.dispatch(et(e))}setOperationReducer(e){return this.dispatch(tt(e))}moveOperation(e){return this.dispatch(rt(e))}deleteOperation(e){return this.dispatch(ot(e))}reorderModuleOperations(e){return this.dispatch(nt(e))}}const it=t=>s.createAction("SET_STATE_SCHEMA",{...t}),st=t=>s.createAction("SET_INITIAL_STATE",{...t}),at=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),pt=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),ct=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class jt extends s.BaseDocument{setStateSchema(e){return this.dispatch(it(e))}setInitialState(e){return this.dispatch(st(e))}addStateExample(e){return this.dispatch(at(e))}updateStateExample(e){return this.dispatch(pt(e))}deleteStateExample(e){return this.dispatch(lt(e))}reorderStateExamples(e){return this.dispatch(ct(e))}}var u;let S=(u=class extends s.BaseDocument{constructor(e,o){super(m,O.createDocument(e),o)}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}},ue(u,"fileExtension","phdm"),u);s.applyMixins(S,[Rt,Dt,Mt,xt,Nt,Lt,jt]);const Pt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:Me,addModule:Pe,addOperation:Je,addOperationError:ve,addOperationExample:Ge,addStateExample:at,deleteChangeLogItem:Ne,deleteModule:ye,deleteOperation:ot,deleteOperationError:$e,deleteOperationExample:We,deleteStateExample:lt,moveOperation:rt,releaseNewVersion:je,reorderChangeLogItems:Le,reorderModuleOperations:nt,reorderModules:we,reorderOperationErrors:Xe,reorderOperationExamples:qe,reorderStateExamples:ct,setAuthorName:Re,setAuthorWebsite:De,setInitialState:st,setModelDescription:Te,setModelExtension:Ie,setModelId:Ae,setModelName:ze,setModuleDescription:ke,setModuleName:Ce,setOperationDescription:Ze,setOperationErrorCode:Ue,setOperationErrorDescription:Fe,setOperationErrorName:Ve,setOperationErrorTemplate:He,setOperationName:Ke,setOperationReducer:tt,setOperationSchema:Ye,setOperationScope:Qe,setOperationTemplate:et,setStateSchema:it,updateChangeLogItem:xe,updateOperationExample:Be,updateStateExample:pt},Symbol.toStringTag,{value:"Module"})),le=S,ce={...O,...Et},de={...s.BaseActions,...Pt},dt={Document:le,reducer:m,actions:de,utils:ce,documentModel:f},Ct=Object.freeze(Object.defineProperty({__proto__:null,Document:le,DocumentModel:S,actions:de,documentModel:f,module:dt,reducer:m,utils:ce,z:_e},Symbol.toStringTag,{value:"Module"}));exports.Document=le;exports.DocumentModel=Ct;exports.DocumentModel$1=S;exports.actions=de;exports.documentModel=f;exports.module=dt;exports.reducer=m;exports.utils=ce;exports.zod=_e;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var dt=Object.defineProperty;var xt=(t,e,i)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var y=(t,e,i)=>(xt(t,typeof e!="symbol"?e+"":e,i),i);const gt=require("json-stringify-deterministic"),g=require("immer"),o=require("zod"),R=require("jszip"),ft=require("crypto"),O=require("fs"),ht=require("https"),bt=require("path"),L=t=>t!=null,vt=o.z.any().refine(t=>L(t)),U=o.z.enum(["LOAD_STATE"]),J=o.z.enum(["PRUNE"]),$=o.z.enum(["REDO"]),B=o.z.enum(["SET_NAME"]),C=o.z.enum(["UNDO"]);function yt(){return o.z.object({__typename:o.z.literal("Action").optional(),type:o.z.string()})}function Z(){return o.z.union([H(),W(),G(),Q(),V()])}function jt(){return o.z.object({__typename:o.z.literal("DocumentFile").optional(),data:o.z.string(),extension:o.z.string().nullable(),fileName:o.z.string().nullable(),mimeType:o.z.string()})}function H(){return o.z.object({input:o.z.lazy(()=>k()),type:U,scope:o.z.literal("global")})}function k(){return o.z.object({operations:o.z.number(),state:o.z.lazy(()=>K())})}function K(){return o.z.object({data:o.z.unknown().nullish(),name:o.z.string()})}function wt(){return o.z.object({__typename:o.z.literal("Operation").optional(),hash:o.z.string(),index:o.z.number(),timestamp:o.z.string().datetime(),type:o.z.string()})}function W(){return o.z.object({input:o.z.lazy(()=>E()),type:J,scope:o.z.literal("global")})}function E(){return o.z.object({end:o.z.number().nullish(),start:o.z.number().nullish()})}const A=o.z.number;function G(){return o.z.object({input:A(),type:$,scope:o.z.literal("global")})}const N=o.z.string;function Q(){return o.z.object({input:N(),type:B,scope:o.z.literal("global")})}function zt(){return o.z.object({__typename:o.z.literal("SetNameOperation").optional(),hash:o.z.string(),index:o.z.number(),input:o.z.string(),timestamp:o.z.string().datetime(),type:o.z.string()})}const T=o.z.number;function V(){return o.z.object({input:T(),type:C,scope:o.z.literal("global")})}const St=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:yt,BaseActionSchema:Z,DocumentFileSchema:jt,LoadStateActionInputSchema:k,LoadStateActionSchema:H,LoadStateActionStateInputSchema:K,Load_StateSchema:U,OperationSchema:wt,PruneActionInputSchema:E,PruneActionSchema:W,PruneSchema:J,RedoActionInputSchema:A,RedoActionSchema:G,RedoSchema:$,SetNameActionInputSchema:N,SetNameActionSchema:Q,SetNameOperationSchema:zt,Set_NameSchema:B,UndoActionInputSchema:T,UndoActionSchema:V,UndoSchema:C,definedNonNullAnySchema:vt,isDefinedNonNullAny:L},Symbol.toStringTag,{value:"Module"}));function Ot(t,e){return{...t,name:e}}function _t(t,e,i){const n=Math.min(e,t.revision),a=t.operations.global.slice(0,t.revision-n);return{...f(t.initialState,{global:a,local:t.operations.local},i),operations:t.operations,revision:t.revision-n}}function Dt(t,e,i){const n=t.operations.global.length-t.revision;if(!n)throw new Error("There is no UNDO operation to REDO");const a=e<n?e:n,s=t.operations.global.slice(0,t.revision+a);return{...f(t.initialState,{global:s,local:t.operations.local},i),operations:t.operations,revision:t.revision+a}}function kt(t,e,i,n){e=e||0,i=i||t.operations.global.length;const a=t.operations.global.slice(e,i),s=t.operations.global.slice(0,e),p=t.operations.global.slice(i),l=f(t.initialState,{global:s.concat(a),local:t.operations.local},n),{name:r,state:c}=l,m=s.length,u=s.length?s[s.length-1].timestamp:p.length?p[0].timestamp:new Date().toISOString();return f(t.initialState,{global:[...s,{...P({name:r,state:c},a.length),timestamp:u,index:m,hash:I({state:c},"global")},...p.map((z,S)=>({...z,index:m+S+1}))],local:t.operations.local},n)}function Et(t,e){return{...t,name:e.name,state:e.state??{global:{},local:{}}}}const X="SET_NAME",h="UNDO",b="REDO",v="PRUNE",Y="LOAD_STATE";function At(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function j(){this._types=Object.create(null),this._extensions=Object.create(null);for(let t=0;t<arguments.length;t++)this.define(arguments[t]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}j.prototype.define=function(t,e){for(let i in t){let n=t[i].map(function(a){return a.toLowerCase()});i=i.toLowerCase();for(let a=0;a<n.length;a++){const s=n[a];if(s[0]!=="*"){if(!e&&s in this._types)throw new Error('Attempt to change mapping for "'+s+'" extension from "'+this._types[s]+'" to "'+i+'". Pass `force=true` to allow this, otherwise remove "'+s+'" from the list of extensions for "'+i+'".');this._types[s]=i}}if(e||!this._extensions[i]){const a=n[0];this._extensions[i]=a[0]!=="*"?a:a.substr(1)}}};j.prototype.getType=function(t){t=String(t);let e=t.replace(/^.*[/\\]/,"").toLowerCase(),i=e.replace(/^.*\./,"").toLowerCase(),n=e.length<t.length;return(i.length<e.length-1||!n)&&this._types[i]||null};j.prototype.getExtension=function(t){return t=/^\s*([^;\s]*)/.test(t)&&RegExp.$1,t&&this._extensions[t.toLowerCase()]||null};var Nt=j,Tt={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};let Ft=Nt;var qt=new Ft(Tt);const It=At(qt);function Mt(t,e,i){const n=bt.join(t,e);return O.mkdirSync(t,{recursive:!0}),new Promise((a,s)=>{try{O.writeFile(n,i,{},p=>{p?s(p):a(n)})}catch(p){s(p)}})}function tt(t){return O.readFileSync(t)}function Pt(t){return new Promise((e,i)=>{ht.get(t,n=>{const a=[],s=n.headers["content-type"];n.on("data",p=>{a.push(p)}),n.on("end",()=>{e({buffer:Buffer.concat(a),mimeType:s})})}).on("error",n=>{i(n)})})}const Rt=async t=>tt(t),w=(t,e="sha1")=>ft.createHash(e).update(t).digest("base64"),F=async t=>{const e=new R,{name:i,revision:n,documentType:a,created:s,lastModified:p}=t,l={name:i,revision:n,documentType:a,created:s,lastModified:p};return e.file("header.json",JSON.stringify(l,null,2)),e.file("state.json",JSON.stringify(t.initialState||{},null,2)),e.file("operations.json",JSON.stringify(t.operations,null,2)),Object.keys(t.attachments).forEach(c=>{const{data:m,...u}=t.attachments[c];e.file(c,m,{base64:!0,createFolders:!0,comment:JSON.stringify(u)})}),e},et=async(t,e,i,n)=>{const s=await(await F(t)).generateAsync({type:"uint8array",streamFiles:!0}),p=n??t.name,l=`.${i}.zip`;return Mt(e,p.endsWith(l)?p:`${p}${l}`,s)},Lt=async(t,e)=>{const n=await(await F(t)).generateAsync({type:"blob"}),a=await e.createWritable();await a.write(n),await a.close()},_=async(t,e)=>{const i=tt(t);return it(i,e)},it=async(t,e)=>{const i=new R;return await i.loadAsync(t),Ut(i,e)};async function Ut(t,e){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const n=await i.async("string"),a=JSON.parse(n),s=t.file("header.json");let p;s&&(p=JSON.parse(await s.async("string")));const l=t.file("operations.json");if(!l)throw new Error("Operations history not found");const r=JSON.parse(await l.async("string"));let c=M(a,r,e,void 0,p);return p&&(c={...c,...p}),c}function at(t){const e=t.replace(/^.*\./,"")||void 0,i=t.replace(/^.*[/\\]/,"")||void 0;return{extension:e,fileName:i}}async function Jt(t){const{buffer:e,mimeType:i="application/octet-stream"}=await Pt(t),n=at(t),a=e.toString("base64");return{data:a,hash:w(a),mimeType:i,...n}}async function $t(t){const e=await Rt(t),i=It.getType(t)||"application/octet-stream",n=at(t),a=e.toString("base64");return{data:a,hash:w(a),mimeType:i,...n}}function Bt(t,e){return[h,b,v].includes(e.type)?t.revision:t.revision+1}function Ct(t,e){return{...t,revision:Bt(t,e),lastModified:new Date().toISOString()}}function Zt(t,e){if([h,b,v].includes(e.type))return t;const i=t.operations.global.slice(0,t.revision),n=e.scope||"global",a=n==="global"?i:t.operations[n];return a.push({...e,index:a.length,timestamp:new Date().toISOString(),hash:"",scope:n}),{...t,operations:{...t.operations,[n]:a}}}function Ht(t,e){let i=Zt(t,e);return(!e.scope||e.scope==="global")&&(i=Ct(i,e)),i}function Kt(t,e,i){switch(Z().parse(e),e.type){case X:return Ot(t,e.input);case h:return _t(t,e.input,i);case b:return Dt(t,e.input,i);case v:return kt(t,e.input.start,e.input.end,i);case Y:return Et(t,e.input.state);default:return t}}function q(t,e,i,n){let a=t;return D(e)&&(a=Kt(a,e,i)),a=Ht(a,e),a=g.produce(a,s=>{const p=i(s.state,e,n);if(p)return g.castDraft({...a,state:p})}),g.produce(a,s=>{if([h,b,v].includes(e.type))return s;const p=e.scope||"global";s.operations[p][s.operations[p].length-1].hash=I(s,p),!D(e)&&e.attachments&&e.attachments.forEach(l=>{const{hash:r,...c}=l;s.attachments[r]={...c}})})}function D(t){return[X,h,b,v,Y].includes(t.type)}function d(t,e,i,n,a="global"){if(!t)throw new Error("Empty action type");if(typeof t!="string")throw new Error(`Invalid action type: ${t}`);const s={type:t,input:e,scope:a};i&&(s.attachments=i);try{n==null||n().parse(s.input)}catch(p){throw new Error(`Invalid action input: ${p}`)}return s}function nt(t,e=q){return(i,n,a)=>e(i,n,t,a)}const ot=(t,e)=>({name:"",documentType:"",revision:0,created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...t,state:(e==null?void 0:e(t==null?void 0:t.state))??(t==null?void 0:t.state)??{global:{},local:{}}}),st=(t,e)=>{const i=ot(t,e);return{...i,initialState:i,operations:{global:[],local:[]}}},I=(t,e="global")=>w(gt(t.state[e])),Wt=(t,e=1e3)=>{const i=Math.random()*e;return w(`${(t??new Date).toISOString()}${i}`)};function x(t){return g.castImmutable(g.freeze(t,!0))}function pt(t){return Object.values(t).flatMap(e=>e).sort((e,i)=>new Date(e.timestamp).getTime()-new Date(i.timestamp).getTime())}function f(t,e,i,n,a,s=q){const p=nt(i,s);return M(t,e,p,n,a)}function M(t,e,i,n,a){const s=st(t),p={...e,global:e.global.slice(0,a==null?void 0:a.revision)},l=pt(p).reduce((c,m)=>i(c,m,n),s),r=Object.keys(l.operations).reduce((c,m)=>{const u=m,z=u==="global"&&a&&a.revision<e.global.length?e.global.slice(a==null?void 0:a.revision):[];return{...c,[u]:[...l.operations[u].map((S,ut)=>({...S,timestamp:e[u][ut].timestamp})),...z]}},{global:[],local:[]});return{...l,operations:r}}const lt=t=>d("SET_NAME",t,void 0,N),ct=(t=1)=>d("UNDO",t,void 0,T),rt=(t=1)=>d("REDO",t,void 0,A),mt=(t,e)=>d("PRUNE",{start:t,end:e},void 0,E),P=(t,e)=>d("LOAD_STATE",{state:t,operations:e},void 0,k),Gt=Object.freeze(Object.defineProperty({__proto__:null,loadState:P,prune:mt,redo:rt,setName:lt,undo:ct},Symbol.toStringTag,{value:"Module"}));class Qt{constructor(e,i,n){y(this,"_document");y(this,"_reducer");y(this,"_signalDispatch");this._reducer=e,this._document=i,this._signalDispatch=n}dispatch(e){return this._document=this._reducer(this._document,e,this._signalDispatch),this}saveToFile(e,i,n){return et(this._document,e,i,n)}async loadFromFile(e){this._document=await _(e,this._reducer)}static async stateFromFile(e,i){return await _(e,i)}get state(){return x(this._document.state)}get operations(){return x(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision}get initialState(){return x(this._document.initialState)}toDocument(){return x(this._document)}getAttachment(e){return this._document.attachments[e]}setName(e){return this.dispatch(lt(e)),this}undo(e){return this.dispatch(ct(e)),this}redo(e){return this.dispatch(rt(e)),this}prune(e,i){return this.dispatch(mt(e,i)),this}loadState(e,i){return this.dispatch(P(e,i)),this}}function Vt(t,e){e.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{Object.defineProperty(t.prototype,n,Object.getOwnPropertyDescriptor(i.prototype,n)||Object.create(null))})})}exports.BaseActions=Gt;exports.BaseDocument=Qt;exports.applyMixins=Vt;exports.baseReducer=q;exports.createAction=d;exports.createDocument=st;exports.createExtendedState=ot;exports.createReducer=nt;exports.createZip=F;exports.getLocalFile=$t;exports.getRemoteFile=Jt;exports.hashDocument=I;exports.hashKey=Wt;exports.isBaseAction=D;exports.loadFromFile=_;exports.loadFromInput=it;exports.readOnly=x;exports.replayDocument=M;exports.replayOperations=f;exports.saveToFile=et;exports.saveToFileHandle=Lt;exports.sortOperations=pt;exports.zod=St;
|