document-model 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/browser/document/actions/creators.d.ts +1 -1
  2. package/dist/browser/document/actions/index.d.ts +8 -8
  3. package/dist/browser/document/object.d.ts +123 -99
  4. package/dist/browser/document/reducer.d.ts +1 -1
  5. package/dist/browser/document/schema/types.d.ts +5 -0
  6. package/dist/browser/document/schema/zod.d.ts +39 -0
  7. package/dist/browser/document/types.d.ts +41 -31
  8. package/dist/browser/document/utils/base.d.ts +6 -6
  9. package/dist/browser/document/utils/file.d.ts +2 -2
  10. package/dist/browser/document-model/gen/object.d.ts +1 -1
  11. package/dist/browser/document-model/gen/reducer.d.ts +1 -1
  12. package/dist/browser/document-model/gen/schema/types.d.ts +13 -3
  13. package/dist/browser/document-model/gen/schema/zod.d.ts +20 -1
  14. package/dist/browser/document-model/index.d.ts +9 -9
  15. package/dist/browser/document-model.cjs +1 -1
  16. package/dist/browser/document-model.js +2 -2
  17. package/dist/browser/document.cjs +1 -1
  18. package/dist/browser/document.js +2 -2
  19. package/dist/browser/index.cjs +1 -1
  20. package/dist/browser/index.js +3 -3
  21. package/dist/browser/internal/index-01030c3f.js +22 -0
  22. package/dist/{node/internal/index-c9d178be.js → browser/internal/index-2aee8ea9.js} +1 -1
  23. package/dist/browser/internal/{index-8142b58e.js → index-5f1909ad.js} +513 -435
  24. package/dist/{node/internal/index-0b0cb8c2.js → browser/internal/index-a1282d5c.js} +1 -1
  25. package/dist/browser/internal/object-24df9d92.js +6 -0
  26. package/dist/browser/internal/{object-4ec03a36.js → object-7e8eaff4.js} +777 -731
  27. package/dist/node/document/actions/creators.d.ts +1 -1
  28. package/dist/node/document/actions/index.d.ts +8 -8
  29. package/dist/node/document/object.d.ts +123 -99
  30. package/dist/node/document/reducer.d.ts +1 -1
  31. package/dist/node/document/schema/types.d.ts +5 -0
  32. package/dist/node/document/schema/zod.d.ts +39 -0
  33. package/dist/node/document/types.d.ts +41 -31
  34. package/dist/node/document/utils/base.d.ts +6 -6
  35. package/dist/node/document/utils/file.d.ts +2 -2
  36. package/dist/node/document-model/gen/object.d.ts +1 -1
  37. package/dist/node/document-model/gen/reducer.d.ts +1 -1
  38. package/dist/node/document-model/gen/schema/types.d.ts +13 -3
  39. package/dist/node/document-model/gen/schema/zod.d.ts +20 -1
  40. package/dist/node/document-model/index.d.ts +9 -9
  41. package/dist/node/document-model.cjs +1 -1
  42. package/dist/node/document-model.js +2 -2
  43. package/dist/node/document.cjs +1 -1
  44. package/dist/node/document.js +2 -2
  45. package/dist/node/index.cjs +1 -1
  46. package/dist/node/index.js +3 -3
  47. package/dist/node/internal/{index-0c87fbed.js → index-0db636da.js} +513 -435
  48. package/dist/{browser/internal/index-cb990484.js → node/internal/index-2d4783d9.js} +1 -1
  49. package/dist/{browser/internal/index-9f1cf811.js → node/internal/index-5ef0c6b0.js} +1 -1
  50. package/dist/node/internal/index-cddc9dfd.js +22 -0
  51. package/dist/node/internal/object-21f3d2ee.js +1 -0
  52. package/dist/node/internal/{object-89d9b82f.js → object-c32ea0a0.js} +400 -356
  53. package/package.json +3 -3
  54. package/dist/browser/internal/index-cbe39f72.js +0 -22
  55. package/dist/browser/internal/object-5f03095e.js +0 -6
  56. package/dist/node/internal/index-63db4708.js +0 -22
  57. package/dist/node/internal/object-397a9b23.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-model",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "license": "AGPL-3.0-only",
5
5
  "private": false,
6
6
  "files": [
@@ -67,9 +67,9 @@
67
67
  "sha.js": "^2.4.11",
68
68
  "ts-jest": "^29.1.1",
69
69
  "ts-node": "^10.9.1",
70
- "typescript": "^5.2.2",
70
+ "typescript": "^5.3.3",
71
71
  "vite": "^4.4.9",
72
- "vite-plugin-dts": "^3.5.3",
72
+ "vite-plugin-dts": "^3.6.4",
73
73
  "vite-plugin-node-polyfills": "^0.11.3"
74
74
  },
75
75
  "dependencies": {
@@ -1,22 +0,0 @@
1
- "use strict";var dt=Object.defineProperty;var ut=(t,e,n)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var de=(t,e,n)=>(ut(t,typeof e!="symbol"?e+"":e,n),n);const s=require("./object-5f03095e.js");require("json-stringify-deterministic");require("immer");require("jszip");const r=require("zod"),mt=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:{schema:"",initialValue:`{
2
- "id": "",
3
- "name": "",
4
- "extension": "",
5
- "description": "",
6
- "author": {
7
- "name": "",
8
- "website": ""
9
- },
10
- "specifications": [
11
- {
12
- "version": 1,
13
- "changeLog": [],
14
- "state": {
15
- "schema": "",
16
- "initialValue": "",
17
- "examples": []
18
- },
19
- "modules": []
20
- }
21
- ]
22
- }`,examples:[]}}]},ue=t=>t!=null,Et=r.z.any().refine(t=>ue(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 A(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),name:r.z.string()})}function z(){return r.z.object({errorCode:r.z.string().nullish(),errorDescription:r.z.string().nullish(),errorName:r.z.string().nullish(),errorTemplate:r.z.string().nullish(),id:r.z.string(),operationId:r.z.string()})}function I(){return r.z.object({example:r.z.string(),id:r.z.string(),operationId:r.z.string()})}function T(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),moduleId:r.z.string(),name:r.z.string(),reducer:r.z.string().nullish(),schema:r.z.string().nullish(),template:r.z.string().nullish(),scope:r.z.literal("local").or(r.z.literal("global")).nullish()})}function b(){return r.z.object({example:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullish()})}function me(){return r.z.object({__typename:r.z.literal("Author").optional(),name:r.z.string(),website:r.z.string().nullable()})}function R(){return r.z.object({__typename:r.z.literal("CodeExample").optional(),id:r.z.string(),value:r.z.string()})}function D(){return r.z.object({__typename:r.z.literal("DeleteChangeLogItemInput").optional(),id:r.z.string()})}function M(){return r.z.object({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 P(){return r.z.object({id:r.z.string()})}function ht(){return r.z.union([_(),A(),z(),I(),T(),b(),D(),M(),x(),N(),L(),P(),j(),C(),k(),y(),w(),U(),v(),F(),H(),V(),X(),G(),B(),W(),$(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae()])}function Ot(){return r.z.object({__typename:r.z.literal("DocumentModelState").optional(),author:me(),description:r.z.string(),extension:r.z.string(),id:r.z.string(),name:r.z.string(),specifications:r.z.array(Ee())})}function Ee(){return r.z.object({__typename:r.z.literal("DocumentSpecification").optional(),changeLog:r.z.array(r.z.string()),modules:r.z.array(he()),state:fe(),version:r.z.number()})}function he(){return r.z.object({__typename:r.z.literal("Module").optional(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string(),operations:r.z.array(Oe())})}function j(){return r.z.object({newModuleId:r.z.string(),operationId:r.z.string()})}function Oe(){return r.z.object({__typename:r.z.literal("Operation").optional(),description:r.z.string().nullable(),errors:r.z.array(ge()),examples:r.z.array(R()),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 ge(){return r.z.object({__typename:r.z.literal("OperationError").optional(),code:r.z.string().nullable(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string().nullable(),template:r.z.string().nullable()})}function C(){return r.z.object({__typename:r.z.literal("ReorderChangeLogItemsInput").optional(),order:r.z.array(r.z.string())})}function k(){return r.z.object({moduleId:r.z.string(),order:r.z.array(r.z.string())})}function y(){return r.z.object({order:r.z.array(r.z.string())})}function w(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function U(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function v(){return r.z.object({order:r.z.array(r.z.string())})}function F(){return r.z.object({authorName:r.z.string()})}function H(){return r.z.object({authorWebsite:r.z.string()})}function V(){return r.z.object({initialValue:r.z.string()})}function X(){return r.z.object({description:r.z.string()})}function G(){return r.z.object({extension:r.z.string()})}function B(){return r.z.object({id:r.z.string()})}function W(){return r.z.object({name:r.z.string()})}function $(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function q(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function J(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function K(){return r.z.object({errorCode:r.z.string().nullish(),id:r.z.string()})}function Q(){return r.z.object({errorDescription:r.z.string().nullish(),id:r.z.string()})}function Y(){return r.z.object({errorName:r.z.string().nullish(),id:r.z.string()})}function Z(){return r.z.object({errorTemplate:r.z.string().nullish(),id:r.z.string()})}function ee(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function Se(){return r.z.object({id:r.z.string(),scope:r.z.literal("global").or(r.z.literal("local"))})}function te(){return r.z.object({id:r.z.string(),reducer:r.z.string().nullish()})}function re(){return r.z.object({id:r.z.string(),schema:r.z.string().nullish()})}function oe(){return r.z.object({id:r.z.string(),template:r.z.string().nullish()})}function ne(){return r.z.object({schema:r.z.string()})}function fe(){return r.z.object({__typename:r.z.literal("State").optional(),examples:r.z.array(R()),initialValue:r.z.string(),schema:r.z.string()})}function ie(){return r.z.object({__typename:r.z.literal("UpdateChangeLogItemInput").optional(),id:r.z.string(),newContent:r.z.string()})}function se(){return r.z.object({example:r.z.string(),id:r.z.string()})}function ae(){return r.z.object({id:r.z.string(),newExample:r.z.string()})}const _e=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:_,AddModuleInputSchema:A,AddOperationErrorInputSchema:z,AddOperationExampleInputSchema:I,AddOperationInputSchema:T,AddStateExampleInputSchema:b,AuthorSchema:me,CodeExampleSchema:R,DeleteChangeLogItemInputSchema:D,DeleteModuleInputSchema:M,DeleteOperationErrorInputSchema:x,DeleteOperationExampleInputSchema:N,DeleteOperationInputSchema:L,DeleteStateExampleInputSchema:P,DocumentModelInputSchema:ht,DocumentModelStateSchema:Ot,DocumentSpecificationSchema:Ee,ModuleSchema:he,MoveOperationInputSchema:j,OperationErrorSchema:ge,OperationSchema:Oe,ReorderChangeLogItemsInputSchema:C,ReorderModuleOperationsInputSchema:k,ReorderModulesInputSchema:y,ReorderOperationErrorsInputSchema:w,ReorderOperationExamplesInputSchema:U,ReorderStateExamplesInputSchema:v,SetAuthorNameInputSchema:F,SetAuthorWebsiteInputSchema:H,SetInitialStateInputSchema:V,SetModelDescriptionInputSchema:X,SetModelExtensionInputSchema:G,SetModelIdInputSchema:B,SetModelNameInputSchema:W,SetModuleDescriptionInputSchema:$,SetModuleNameInputSchema:q,SetOperationDescriptionInputSchema:J,SetOperationErrorCodeInputSchema:K,SetOperationErrorDescriptionInputSchema:Q,SetOperationErrorNameInputSchema:Y,SetOperationErrorTemplateInputSchema:Z,SetOperationNameInputSchema:ee,SetOperationReducerInputSchema:te,SetOperationSchemaInputSchema:re,SetOperationScopeInputSchema:Se,SetOperationTemplateInputSchema:oe,SetStateSchemaInputSchema:ne,StateSchema:fe,UpdateChangeLogItemInputSchema:ie,UpdateOperationExampleInputSchema:se,UpdateStateExampleInputSchema:ae,definedNonNullAnySchema:Et,isDefinedNonNullAny:ue},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')}},gt=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.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 n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].description=e.input.description||"")},deleteModuleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.modules=n.modules.filter(o=>o.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(gt(e.input.order))}},St=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},l={addOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].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 n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].errors=n.modules[o].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].errors.sort(St(e.input.order))}},ft=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},g={addOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].examples.length;a++)n.modules[o].operations[i].examples[a].id==e.input.id&&(n.modules[o].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].examples=n.modules[o].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.sort(ft(e.input.order))}},_t=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},p={addOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.modules[o].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 n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const n=[],o=t.specifications[t.specifications.length-1];for(let i=0;i<o.modules.length;i++)o.modules[i].operations=o.modules[i].operations.filter(a=>a.id==e.input.operationId?(n.push(a),!1):!0);for(let i=0;i<o.modules.length;i++)o.modules[i].id==e.input.newModuleId&&o.modules[i].operations.push(...n)},deleteOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].operations=n.modules[o].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.modules[o].operations.sort(_t(e.input.order))}},At=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},d={setStateSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.schema=e.input.schema},setInitialStateOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.initialValue=e.input.initialValue},addStateExampleOperation(t,e){t.specifications[t.specifications.length-1].state.examples.push({id:e.input.id,value:e.input.example})},updateStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.state.examples.length;o++)n.state.examples[o].id==e.input.id&&(n.state.examples[o].value=e.input.newExample)},deleteStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.examples=n.state.examples.filter(o=>o.id!=e.input.id)},reorderStateExamplesOperation(t,e){t.specifications[t.specifications.length-1].state.examples.sort(At(e.input.order))}},zt=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":W().parse(e.input),c.setModelNameOperation(t,e);break;case"SET_MODEL_ID":B().parse(e.input),c.setModelIdOperation(t,e);break;case"SET_MODEL_EXTENSION":G().parse(e.input),c.setModelExtensionOperation(t,e);break;case"SET_MODEL_DESCRIPTION":X().parse(e.input),c.setModelDescriptionOperation(t,e);break;case"SET_AUTHOR_NAME":F().parse(e.input),c.setAuthorNameOperation(t,e);break;case"SET_AUTHOR_WEBSITE":H().parse(e.input),c.setAuthorWebsiteOperation(t,e);break;case"ADD_CHANGE_LOG_ITEM":_().parse(e.input),E.addChangeLogItemOperation(t,e);break;case"UPDATE_CHANGE_LOG_ITEM":ie().parse(e.input),E.updateChangeLogItemOperation(t,e);break;case"DELETE_CHANGE_LOG_ITEM":D().parse(e.input),E.deleteChangeLogItemOperation(t,e);break;case"REORDER_CHANGE_LOG_ITEMS":C().parse(e.input),E.reorderChangeLogItemsOperation(t,e);break;case"RELEASE_NEW_VERSION":if(Object.keys(e.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");E.releaseNewVersionOperation(t,e);break;case"ADD_MODULE":A().parse(e.input),h.addModuleOperation(t,e);break;case"SET_MODULE_NAME":q().parse(e.input),h.setModuleNameOperation(t,e);break;case"SET_MODULE_DESCRIPTION":$().parse(e.input),h.setModuleDescriptionOperation(t,e);break;case"DELETE_MODULE":M().parse(e.input),h.deleteModuleOperation(t,e);break;case"REORDER_MODULES":y().parse(e.input),h.reorderModulesOperation(t,e);break;case"ADD_OPERATION_ERROR":z().parse(e.input),l.addOperationErrorOperation(t,e);break;case"SET_OPERATION_ERROR_CODE":K().parse(e.input),l.setOperationErrorCodeOperation(t,e);break;case"SET_OPERATION_ERROR_NAME":Y().parse(e.input),l.setOperationErrorNameOperation(t,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Q().parse(e.input),l.setOperationErrorDescriptionOperation(t,e);break;case"SET_OPERATION_ERROR_TEMPLATE":Z().parse(e.input),l.setOperationErrorTemplateOperation(t,e);break;case"DELETE_OPERATION_ERROR":x().parse(e.input),l.deleteOperationErrorOperation(t,e);break;case"REORDER_OPERATION_ERRORS":w().parse(e.input),l.reorderOperationErrorsOperation(t,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),g.addOperationExampleOperation(t,e);break;case"UPDATE_OPERATION_EXAMPLE":se().parse(e.input),g.updateOperationExampleOperation(t,e);break;case"DELETE_OPERATION_EXAMPLE":N().parse(e.input),g.deleteOperationExampleOperation(t,e);break;case"REORDER_OPERATION_EXAMPLES":U().parse(e.input),g.reorderOperationExamplesOperation(t,e);break;case"ADD_OPERATION":T().parse(e.input),p.addOperationOperation(t,e);break;case"SET_OPERATION_NAME":ee().parse(e.input),p.setOperationNameOperation(t,e);break;case"SET_OPERATION_SCOPE":Se().parse(e.input),p.setOperationScopeOperation(t,e);break;case"SET_OPERATION_SCHEMA":re().parse(e.input),p.setOperationSchemaOperation(t,e);break;case"SET_OPERATION_DESCRIPTION":J().parse(e.input),p.setOperationDescriptionOperation(t,e);break;case"SET_OPERATION_TEMPLATE":oe().parse(e.input),p.setOperationTemplateOperation(t,e);break;case"SET_OPERATION_REDUCER":te().parse(e.input),p.setOperationReducerOperation(t,e);break;case"MOVE_OPERATION":j().parse(e.input),p.moveOperationOperation(t,e);break;case"DELETE_OPERATION":L().parse(e.input),p.deleteOperationOperation(t,e);break;case"REORDER_MODULE_OPERATIONS":k().parse(e.input),p.reorderModuleOperationsOperation(t,e);break;case"SET_STATE_SCHEMA":ne().parse(e.input),d.setStateSchemaOperation(t,e);break;case"SET_INITIAL_STATE":V().parse(e.input),d.setInitialStateOperation(t,e);break;case"ADD_STATE_EXAMPLE":b().parse(e.input),d.addStateExampleOperation(t,e);break;case"UPDATE_STATE_EXAMPLE":ae().parse(e.input),d.updateStateExampleOperation(t,e);break;case"DELETE_STATE_EXAMPLE":P().parse(e.input),d.deleteStateExampleOperation(t,e);break;case"REORDER_STATE_EXAMPLES":v().parse(e.input),d.reorderStateExamplesOperation(t,e);break;default:return t}},m=s.createReducer(zt),It={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{schema:"",initialValue:"",examples:[]},modules:[]}]},O={fileExtension:"phdm",createState(t){return{...It,...t}},createExtendedState(t){return s.createExtendedState({...t,documentType:"powerhouse/document-model"},O.createState)},createDocument(t){return s.createDocument(O.createExtendedState(t),O.createState)},saveToFile(t,e,n){return s.saveToFile(t,e,"phdm",n)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,m)},loadFromInput(t){return s.loadFromInput(t,m)}},Ae=t=>s.createAction("SET_MODEL_NAME",{...t}),ze=t=>s.createAction("SET_MODEL_ID",{...t}),Ie=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Te=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),be=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Re=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Tt extends s.BaseDocument{setModelName(e){return this.dispatch(Ae(e))}setModelId(e){return this.dispatch(ze(e))}setModelExtension(e){return this.dispatch(Ie(e))}setModelDescription(e){return this.dispatch(Te(e))}setAuthorName(e){return this.dispatch(be(e))}setAuthorWebsite(e){return this.dispatch(Re(e))}}const De=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),Me=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),xe=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),Le=()=>s.createAction("RELEASE_NEW_VERSION");class bt extends s.BaseDocument{addChangeLogItem(e){return this.dispatch(De(e))}updateChangeLogItem(e){return this.dispatch(Me(e))}deleteChangeLogItem(e){return this.dispatch(xe(e))}reorderChangeLogItems(e){return this.dispatch(Ne(e))}releaseNewVersion(){return this.dispatch(Le())}}const Pe=t=>s.createAction("ADD_MODULE",{...t}),je=t=>s.createAction("SET_MODULE_NAME",{...t}),Ce=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),ke=t=>s.createAction("DELETE_MODULE",{...t}),ye=t=>s.createAction("REORDER_MODULES",{...t});class Rt extends s.BaseDocument{addModule(e){return this.dispatch(Pe(e))}setModuleName(e){return this.dispatch(je(e))}setModuleDescription(e){return this.dispatch(Ce(e))}deleteModule(e){return this.dispatch(ke(e))}reorderModules(e){return this.dispatch(ye(e))}}const we=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}),Ve=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Xe=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Dt extends s.BaseDocument{addOperationError(e){return this.dispatch(we(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(Ve(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}),$e=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Mt 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($e(e))}}const qe=t=>s.createAction("ADD_OPERATION",{...t}),Je=t=>s.createAction("SET_OPERATION_NAME",{...t}),Ke=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Qe=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),Ye=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),Ze=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),et=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),tt=t=>s.createAction("MOVE_OPERATION",{...t}),rt=t=>s.createAction("DELETE_OPERATION",{...t}),ot=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class xt extends s.BaseDocument{addOperation(e){return this.dispatch(qe(e))}setOperationName(e){return this.dispatch(Je(e))}setOperationScope(e){return this.dispatch(Ke(e))}setOperationSchema(e){return this.dispatch(Qe(e))}setOperationDescription(e){return this.dispatch(Ye(e))}setOperationTemplate(e){return this.dispatch(Ze(e))}setOperationReducer(e){return this.dispatch(et(e))}moveOperation(e){return this.dispatch(tt(e))}deleteOperation(e){return this.dispatch(rt(e))}reorderModuleOperations(e){return this.dispatch(ot(e))}}const nt=t=>s.createAction("SET_STATE_SCHEMA",{...t}),it=t=>s.createAction("SET_INITIAL_STATE",{...t}),st=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),at=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),pt=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class Nt extends s.BaseDocument{setStateSchema(e){return this.dispatch(nt(e))}setInitialState(e){return this.dispatch(it(e))}addStateExample(e){return this.dispatch(st(e))}updateStateExample(e){return this.dispatch(at(e))}deleteStateExample(e){return this.dispatch(pt(e))}reorderStateExamples(e){return this.dispatch(lt(e))}}var u;let S=(u=class extends s.BaseDocument{constructor(e,n){super(m,O.createDocument(e),n)}saveToFile(e,n){return super.saveToFile(e,u.fileExtension,n)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const n=new this;return await n.loadFromFile(e),n}},de(u,"fileExtension","phdm"),u);s.applyMixins(S,[Tt,bt,Rt,Dt,Mt,xt,Nt]);const Lt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:De,addModule:Pe,addOperation:qe,addOperationError:we,addOperationExample:Ge,addStateExample:st,deleteChangeLogItem:xe,deleteModule:ke,deleteOperation:rt,deleteOperationError:Ve,deleteOperationExample:We,deleteStateExample:pt,moveOperation:tt,releaseNewVersion:Le,reorderChangeLogItems:Ne,reorderModuleOperations:ot,reorderModules:ye,reorderOperationErrors:Xe,reorderOperationExamples:$e,reorderStateExamples:lt,setAuthorName:be,setAuthorWebsite:Re,setInitialState:it,setModelDescription:Te,setModelExtension:Ie,setModelId:ze,setModelName:Ae,setModuleDescription:Ce,setModuleName:je,setOperationDescription:Ye,setOperationErrorCode:Ue,setOperationErrorDescription:Fe,setOperationErrorName:ve,setOperationErrorTemplate:He,setOperationName:Je,setOperationReducer:et,setOperationSchema:Qe,setOperationScope:Ke,setOperationTemplate:Ze,setStateSchema:nt,updateChangeLogItem:Me,updateOperationExample:Be,updateStateExample:at},Symbol.toStringTag,{value:"Module"})),pe=S,le={...O,...mt},ce={...s.BaseActions,...Lt},ct={Document:pe,reducer:m,actions:ce,utils:le,documentModel:f},Pt=Object.freeze(Object.defineProperty({__proto__:null,Document:pe,DocumentModel:S,actions:ce,documentModel:f,module:ct,reducer:m,utils:le,z:_e},Symbol.toStringTag,{value:"Module"}));exports.Document=pe;exports.DocumentModel=Pt;exports.DocumentModel$1=S;exports.actions=ce;exports.documentModel=f;exports.module=ct;exports.reducer=m;exports.utils=le;exports.zod=_e;
@@ -1,6 +0,0 @@
1
- "use strict";var br=Object.defineProperty;var Fr=(n,a,s)=>a in n?br(n,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[a]=s;var J=(n,a,s)=>(Fr(n,typeof a!="symbol"?a+"":a,s),s);const _r=require("json-stringify-deterministic"),R=require("immer"),At=require("jszip"),d=require("zod"),Bt=n=>n!=null,Ar=d.z.any().refine(n=>Bt(n)),St=d.z.enum(["LOAD_STATE"]),jt=d.z.enum(["PRUNE"]),Ut=d.z.enum(["REDO"]),It=d.z.enum(["SET_NAME"]),Tt=d.z.enum(["UNDO"]);function Br(){return d.z.object({__typename:d.z.literal("Action").optional(),type:d.z.string()})}function kt(){return d.z.union([at(),ot(),pt(),st(),ct()])}function Sr(){return d.z.object({__typename:d.z.literal("DocumentFile").optional(),data:d.z.string(),extension:d.z.string().nullable(),fileName:d.z.string().nullable(),mimeType:d.z.string()})}function at(){return d.z.object({input:d.z.lazy(()=>zt()),type:St})}function zt(){return d.z.object({operations:d.z.number(),state:d.z.lazy(()=>Dt())})}function Dt(){return d.z.object({data:d.z.unknown().nullish(),name:d.z.string()})}function jr(){return d.z.object({__typename:d.z.literal("Operation").optional(),hash:d.z.string(),index:d.z.number(),timestamp:d.z.string().datetime(),type:d.z.string()})}function ot(){return d.z.object({input:d.z.lazy(()=>Ot()),type:jt})}function Ot(){return d.z.object({end:d.z.number().nullish(),start:d.z.number().nullish()})}function pt(){return d.z.object({input:d.z.number(),type:Ut})}function st(){return d.z.object({input:d.z.string(),type:It})}function Ur(){return d.z.object({__typename:d.z.literal("SetNameOperation").optional(),hash:d.z.string(),index:d.z.number(),input:d.z.string(),timestamp:d.z.string().datetime(),type:d.z.string()})}function ct(){return d.z.object({input:d.z.number(),type:Tt})}const Ir=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Br,BaseActionSchema:kt,DocumentFileSchema:Sr,LoadStateActionInputSchema:zt,LoadStateActionSchema:at,LoadStateActionStateInputSchema:Dt,Load_StateSchema:St,OperationSchema:jr,PruneActionInputSchema:Ot,PruneActionSchema:ot,PruneSchema:jt,RedoActionSchema:pt,RedoSchema:Ut,SetNameActionSchema:st,SetNameOperationSchema:Ur,Set_NameSchema:It,UndoActionSchema:ct,UndoSchema:Tt,definedNonNullAnySchema:Ar,isDefinedNonNullAny:Bt},Symbol.toStringTag,{value:"Module"}));function Nt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function W(){this._types=Object.create(null),this._extensions=Object.create(null);for(let n=0;n<arguments.length;n++)this.define(arguments[n]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}W.prototype.define=function(n,a){for(let s in n){let c=n[s].map(function(f){return f.toLowerCase()});s=s.toLowerCase();for(let f=0;f<c.length;f++){const h=c[f];if(h[0]!=="*"){if(!a&&h in this._types)throw new Error('Attempt to change mapping for "'+h+'" extension from "'+this._types[h]+'" to "'+s+'". Pass `force=true` to allow this, otherwise remove "'+h+'" from the list of extensions for "'+s+'".');this._types[h]=s}}if(a||!this._extensions[s]){const f=c[0];this._extensions[s]=f[0]!=="*"?f:f.substr(1)}}};W.prototype.getType=function(n){n=String(n);let a=n.replace(/^.*[/\\]/,"").toLowerCase(),s=a.replace(/^.*\./,"").toLowerCase(),c=a.length<n.length;return(s.length<a.length-1||!c)&&this._types[s]||null};W.prototype.getExtension=function(n){return n=/^\s*([^;\s]*)/.test(n)&&RegExp.$1,n&&this._extensions[n.toLowerCase()]||null};var Tr=W,kr={"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 zr=Tr;var Dr=new zr(kr);const Or=Nt(Dr);var rt={exports:{}};typeof Object.create=="function"?rt.exports=function(a,s){s&&(a.super_=s,a.prototype=Object.create(s.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:rt.exports=function(a,s){if(s){a.super_=s;var c=function(){};c.prototype=s.prototype,a.prototype=new c,a.prototype.constructor=a}};var Nr=rt.exports,it={exports:{}},Mt={},H={};H.byteLength=Cr;H.toByteArray=qr;H.fromByteArray=Pr;var T=[],j=[],Mr=typeof Uint8Array<"u"?Uint8Array:Array,tt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var z=0,Rr=tt.length;z<Rr;++z)T[z]=tt[z],j[tt.charCodeAt(z)]=z;j["-".charCodeAt(0)]=62;j["_".charCodeAt(0)]=63;function Rt(n){var a=n.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=n.indexOf("=");s===-1&&(s=a);var c=s===a?0:4-s%4;return[s,c]}function Cr(n){var a=Rt(n),s=a[0],c=a[1];return(s+c)*3/4-c}function Lr(n,a,s){return(a+s)*3/4-s}function qr(n){var a,s=Rt(n),c=s[0],f=s[1],h=new Mr(Lr(n,c,f)),u=0,o=f>0?c-4:c,x;for(x=0;x<o;x+=4)a=j[n.charCodeAt(x)]<<18|j[n.charCodeAt(x+1)]<<12|j[n.charCodeAt(x+2)]<<6|j[n.charCodeAt(x+3)],h[u++]=a>>16&255,h[u++]=a>>8&255,h[u++]=a&255;return f===2&&(a=j[n.charCodeAt(x)]<<2|j[n.charCodeAt(x+1)]>>4,h[u++]=a&255),f===1&&(a=j[n.charCodeAt(x)]<<10|j[n.charCodeAt(x+1)]<<4|j[n.charCodeAt(x+2)]>>2,h[u++]=a>>8&255,h[u++]=a&255),h}function $r(n){return T[n>>18&63]+T[n>>12&63]+T[n>>6&63]+T[n&63]}function Jr(n,a,s){for(var c,f=[],h=a;h<s;h+=3)c=(n[h]<<16&16711680)+(n[h+1]<<8&65280)+(n[h+2]&255),f.push($r(c));return f.join("")}function Pr(n){for(var a,s=n.length,c=s%3,f=[],h=16383,u=0,o=s-c;u<o;u+=h)f.push(Jr(n,u,u+h>o?o:u+h));return c===1?(a=n[s-1],f.push(T[a>>2]+T[a<<4&63]+"==")):c===2&&(a=(n[s-2]<<8)+n[s-1],f.push(T[a>>10]+T[a>>4&63]+T[a<<2&63]+"=")),f.join("")}var lt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */lt.read=function(n,a,s,c,f){var h,u,o=f*8-c-1,x=(1<<o)-1,w=x>>1,v=-7,F=s?f-1:0,U=s?-1:1,B=n[a+F];for(F+=U,h=B&(1<<-v)-1,B>>=-v,v+=o;v>0;h=h*256+n[a+F],F+=U,v-=8);for(u=h&(1<<-v)-1,h>>=-v,v+=c;v>0;u=u*256+n[a+F],F+=U,v-=8);if(h===0)h=1-w;else{if(h===x)return u?NaN:(B?-1:1)*(1/0);u=u+Math.pow(2,c),h=h-w}return(B?-1:1)*u*Math.pow(2,h-c)};lt.write=function(n,a,s,c,f,h){var u,o,x,w=h*8-f-1,v=(1<<w)-1,F=v>>1,U=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=c?0:h-1,O=c?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=v):(u=Math.floor(Math.log(a)/Math.LN2),a*(x=Math.pow(2,-u))<1&&(u--,x*=2),u+F>=1?a+=U/x:a+=U*Math.pow(2,1-F),a*x>=2&&(u++,x/=2),u+F>=v?(o=0,u=v):u+F>=1?(o=(a*x-1)*Math.pow(2,f),u=u+F):(o=a*Math.pow(2,F-1)*Math.pow(2,f),u=0));f>=8;n[s+B]=o&255,B+=O,o/=256,f-=8);for(u=u<<f|o,w+=f;w>0;n[s+B]=u&255,B+=O,u/=256,w-=8);n[s+B-O]|=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(n){var a=H,s=lt,c=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=o,n.SlowBuffer=nr,n.INSPECT_MAX_BYTES=50;var f=2147483647;n.kMaxLength=f,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 i=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(i,t),i.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(i){if(i>f)throw new RangeError('The value "'+i+'" is invalid for option "size"');var t=new Uint8Array(i);return Object.setPrototypeOf(t,o.prototype),t}function o(i,t,r){if(typeof i=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return F(i)}return x(i,t,r)}o.poolSize=8192;function x(i,t,r){if(typeof i=="string")return U(i,t);if(ArrayBuffer.isView(i))return O(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(I(i,ArrayBuffer)||i&&I(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(I(i,SharedArrayBuffer)||i&&I(i.buffer,SharedArrayBuffer)))return N(i,t,r);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var e=i.valueOf&&i.valueOf();if(e!=null&&e!==i)return o.from(e,t,r);var p=er(i);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return o.from(i[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 i)}o.from=function(i,t,r){return x(i,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function w(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function v(i,t,r){return w(i),i<=0?u(i):t!==void 0?typeof r=="string"?u(i).fill(t,r):u(i).fill(t):u(i)}o.alloc=function(i,t,r){return v(i,t,r)};function F(i){return w(i),u(i<0?0:G(i)|0)}o.allocUnsafe=function(i){return F(i)},o.allocUnsafeSlow=function(i){return F(i)};function U(i,t){if((typeof t!="string"||t==="")&&(t="utf8"),!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=mt(i,t)|0,e=u(r),p=e.write(i,t);return p!==r&&(e=e.slice(0,p)),e}function B(i){for(var t=i.length<0?0:G(i.length)|0,r=u(t),e=0;e<t;e+=1)r[e]=i[e]&255;return r}function O(i){if(I(i,Uint8Array)){var t=new Uint8Array(i);return N(t.buffer,t.byteOffset,t.byteLength)}return B(i)}function N(i,t,r){if(t<0||i.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var e;return t===void 0&&r===void 0?e=new Uint8Array(i):r===void 0?e=new Uint8Array(i,t):e=new Uint8Array(i,t,r),Object.setPrototypeOf(e,o.prototype),e}function er(i){if(o.isBuffer(i)){var t=G(i.length)|0,r=u(t);return r.length===0||i.copy(r,0,0,t),r}if(i.length!==void 0)return typeof i.length!="number"||Q(i.length)?u(0):B(i);if(i.type==="Buffer"&&Array.isArray(i.data))return B(i.data)}function G(i){if(i>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return i|0}function nr(i){return+i!=i&&(i=0),o.alloc(+i)}o.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==o.prototype},o.compare=function(t,r){if(I(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),I(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 e=t.length,p=r.length,l=0,m=Math.min(e,p);l<m;++l)if(t[l]!==r[l]){e=t[l],p=r[l];break}return e<p?-1:p<e?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 e;if(r===void 0)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var p=o.allocUnsafe(r),l=0;for(e=0;e<t.length;++e){var m=t[e];if(I(m,Uint8Array))l+m.length>p.length?o.from(m).copy(p,l):Uint8Array.prototype.set.call(p,m,l);else if(o.isBuffer(m))m.copy(p,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=m.length}return p};function mt(i,t){if(o.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||I(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);var r=i.length,e=arguments.length>2&&arguments[2]===!0;if(!e&&r===0)return 0;for(var p=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return bt(i).length;default:if(p)return e?-1:V(i).length;t=(""+t).toLowerCase(),p=!0}}o.byteLength=mt;function ar(i,t,r){var e=!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(i||(i="utf8");;)switch(i){case"hex":return xr(this,t,r);case"utf8":case"utf-8":return yt(this,t,r);case"ascii":return hr(this,t,r);case"latin1":case"binary":return mr(this,t,r);case"base64":return ur(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return dr(this,t,r);default:if(e)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),e=!0}}o.prototype._isBuffer=!0;function k(i,t,r){var e=i[t];i[t]=i[r],i[r]=e}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?yt(this,0,t):ar.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=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},c&&(o.prototype[c]=o.prototype.inspect),o.prototype.compare=function(t,r,e,p,l){if(I(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),e===void 0&&(e=t?t.length:0),p===void 0&&(p=0),l===void 0&&(l=this.length),r<0||e>t.length||p<0||l>this.length)throw new RangeError("out of range index");if(p>=l&&r>=e)return 0;if(p>=l)return-1;if(r>=e)return 1;if(r>>>=0,e>>>=0,p>>>=0,l>>>=0,this===t)return 0;for(var m=l-p,y=e-r,g=Math.min(m,y),E=this.slice(p,l),A=t.slice(r,e),b=0;b<g;++b)if(E[b]!==A[b]){m=E[b],y=A[b];break}return m<y?-1:y<m?1:0};function xt(i,t,r,e,p){if(i.length===0)return-1;if(typeof r=="string"?(e=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Q(r)&&(r=p?0:i.length-1),r<0&&(r=i.length+r),r>=i.length){if(p)return-1;r=i.length-1}else if(r<0)if(p)r=0;else return-1;if(typeof t=="string"&&(t=o.from(t,e)),o.isBuffer(t))return t.length===0?-1:dt(i,t,r,e,p);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(i,t,r):Uint8Array.prototype.lastIndexOf.call(i,t,r):dt(i,[t],r,e,p);throw new TypeError("val must be string, number or Buffer")}function dt(i,t,r,e,p){var l=1,m=i.length,y=t.length;if(e!==void 0&&(e=String(e).toLowerCase(),e==="ucs2"||e==="ucs-2"||e==="utf16le"||e==="utf-16le")){if(i.length<2||t.length<2)return-1;l=2,m/=2,y/=2,r/=2}function g(Ft,_t){return l===1?Ft[_t]:Ft.readUInt16BE(_t*l)}var E;if(p){var A=-1;for(E=r;E<m;E++)if(g(i,E)===g(t,A===-1?0:E-A)){if(A===-1&&(A=E),E-A+1===y)return A*l}else A!==-1&&(E-=E-A),A=-1}else for(r+y>m&&(r=m-y),E=r;E>=0;E--){for(var b=!0,$=0;$<y;$++)if(g(i,E+$)!==g(t,$)){b=!1;break}if(b)return E}return-1}o.prototype.includes=function(t,r,e){return this.indexOf(t,r,e)!==-1},o.prototype.indexOf=function(t,r,e){return xt(this,t,r,e,!0)},o.prototype.lastIndexOf=function(t,r,e){return xt(this,t,r,e,!1)};function or(i,t,r,e){r=Number(r)||0;var p=i.length-r;e?(e=Number(e),e>p&&(e=p)):e=p;var l=t.length;e>l/2&&(e=l/2);for(var m=0;m<e;++m){var y=parseInt(t.substr(m*2,2),16);if(Q(y))return m;i[r+m]=y}return m}function pr(i,t,r,e){return q(V(t,i.length-r),i,r,e)}function sr(i,t,r,e){return q(gr(t),i,r,e)}function cr(i,t,r,e){return q(bt(t),i,r,e)}function lr(i,t,r,e){return q(vr(t,i.length-r),i,r,e)}o.prototype.write=function(t,r,e,p){if(r===void 0)p="utf8",e=this.length,r=0;else if(e===void 0&&typeof r=="string")p=r,e=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(e)?(e=e>>>0,p===void 0&&(p="utf8")):(p=e,e=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var l=this.length-r;if((e===void 0||e>l)&&(e=l),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");for(var m=!1;;)switch(p){case"hex":return or(this,t,r,e);case"utf8":case"utf-8":return pr(this,t,r,e);case"ascii":case"latin1":case"binary":return sr(this,t,r,e);case"base64":return cr(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return lr(this,t,r,e);default:if(m)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),m=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ur(i,t,r){return t===0&&r===i.length?a.fromByteArray(i):a.fromByteArray(i.slice(t,r))}function yt(i,t,r){r=Math.min(i.length,r);for(var e=[],p=t;p<r;){var l=i[p],m=null,y=l>239?4:l>223?3:l>191?2:1;if(p+y<=r){var g,E,A,b;switch(y){case 1:l<128&&(m=l);break;case 2:g=i[p+1],(g&192)===128&&(b=(l&31)<<6|g&63,b>127&&(m=b));break;case 3:g=i[p+1],E=i[p+2],(g&192)===128&&(E&192)===128&&(b=(l&15)<<12|(g&63)<<6|E&63,b>2047&&(b<55296||b>57343)&&(m=b));break;case 4:g=i[p+1],E=i[p+2],A=i[p+3],(g&192)===128&&(E&192)===128&&(A&192)===128&&(b=(l&15)<<18|(g&63)<<12|(E&63)<<6|A&63,b>65535&&b<1114112&&(m=b))}}m===null?(m=65533,y=1):m>65535&&(m-=65536,e.push(m>>>10&1023|55296),m=56320|m&1023),e.push(m),p+=y}return fr(e)}var wt=4096;function fr(i){var t=i.length;if(t<=wt)return String.fromCharCode.apply(String,i);for(var r="",e=0;e<t;)r+=String.fromCharCode.apply(String,i.slice(e,e+=wt));return r}function hr(i,t,r){var e="";r=Math.min(i.length,r);for(var p=t;p<r;++p)e+=String.fromCharCode(i[p]&127);return e}function mr(i,t,r){var e="";r=Math.min(i.length,r);for(var p=t;p<r;++p)e+=String.fromCharCode(i[p]);return e}function xr(i,t,r){var e=i.length;(!t||t<0)&&(t=0),(!r||r<0||r>e)&&(r=e);for(var p="",l=t;l<r;++l)p+=Er[i[l]];return p}function dr(i,t,r){for(var e=i.slice(t,r),p="",l=0;l<e.length-1;l+=2)p+=String.fromCharCode(e[l]+e[l+1]*256);return p}o.prototype.slice=function(t,r){var e=this.length;t=~~t,r=r===void 0?e:~~r,t<0?(t+=e,t<0&&(t=0)):t>e&&(t=e),r<0?(r+=e,r<0&&(r=0)):r>e&&(r=e),r<t&&(r=t);var p=this.subarray(t,r);return Object.setPrototypeOf(p,o.prototype),p};function _(i,t,r){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+t>r)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(t,r,e){t=t>>>0,r=r>>>0,e||_(t,r,this.length);for(var p=this[t],l=1,m=0;++m<r&&(l*=256);)p+=this[t+m]*l;return p},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,r,e){t=t>>>0,r=r>>>0,e||_(t,r,this.length);for(var p=this[t+--r],l=1;r>0&&(l*=256);)p+=this[t+--r]*l;return p},o.prototype.readUint8=o.prototype.readUInt8=function(t,r){return t=t>>>0,r||_(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||_(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||_(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||_(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||_(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,r,e){t=t>>>0,r=r>>>0,e||_(t,r,this.length);for(var p=this[t],l=1,m=0;++m<r&&(l*=256);)p+=this[t+m]*l;return l*=128,p>=l&&(p-=Math.pow(2,8*r)),p},o.prototype.readIntBE=function(t,r,e){t=t>>>0,r=r>>>0,e||_(t,r,this.length);for(var p=r,l=1,m=this[t+--p];p>0&&(l*=256);)m+=this[t+--p]*l;return l*=128,m>=l&&(m-=Math.pow(2,8*r)),m},o.prototype.readInt8=function(t,r){return t=t>>>0,r||_(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,r){t=t>>>0,r||_(t,2,this.length);var e=this[t]|this[t+1]<<8;return e&32768?e|4294901760:e},o.prototype.readInt16BE=function(t,r){t=t>>>0,r||_(t,2,this.length);var e=this[t+1]|this[t]<<8;return e&32768?e|4294901760:e},o.prototype.readInt32LE=function(t,r){return t=t>>>0,r||_(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||_(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||_(t,4,this.length),s.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,r){return t=t>>>0,r||_(t,4,this.length),s.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||_(t,8,this.length),s.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||_(t,8,this.length),s.read(this,t,!1,52,8)};function S(i,t,r,e,p,l){if(!o.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>p||t<l)throw new RangeError('"value" argument is out of bounds');if(r+e>i.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,r,e,p){if(t=+t,r=r>>>0,e=e>>>0,!p){var l=Math.pow(2,8*e)-1;S(this,t,r,e,l,0)}var m=1,y=0;for(this[r]=t&255;++y<e&&(m*=256);)this[r+y]=t/m&255;return r+e},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,r,e,p){if(t=+t,r=r>>>0,e=e>>>0,!p){var l=Math.pow(2,8*e)-1;S(this,t,r,e,l,0)}var m=e-1,y=1;for(this[r+m]=t&255;--m>=0&&(y*=256);)this[r+m]=t/y&255;return r+e},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,1,255,0),this[r]=t&255,r+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,r,e){return t=+t,r=r>>>0,e||S(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,e){return t=+t,r=r>>>0,e||S(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,e){return t=+t,r=r>>>0,e||S(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,e){return t=+t,r=r>>>0,e||S(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,e,p){if(t=+t,r=r>>>0,!p){var l=Math.pow(2,8*e-1);S(this,t,r,e,l-1,-l)}var m=0,y=1,g=0;for(this[r]=t&255;++m<e&&(y*=256);)t<0&&g===0&&this[r+m-1]!==0&&(g=1),this[r+m]=(t/y>>0)-g&255;return r+e},o.prototype.writeIntBE=function(t,r,e,p){if(t=+t,r=r>>>0,!p){var l=Math.pow(2,8*e-1);S(this,t,r,e,l-1,-l)}var m=e-1,y=1,g=0;for(this[r+m]=t&255;--m>=0&&(y*=256);)t<0&&g===0&&this[r+m+1]!==0&&(g=1),this[r+m]=(t/y>>0)-g&255;return r+e},o.prototype.writeInt8=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1},o.prototype.writeInt16LE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2},o.prototype.writeInt16BE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2},o.prototype.writeInt32LE=function(t,r,e){return t=+t,r=r>>>0,e||S(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,e){return t=+t,r=r>>>0,e||S(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 gt(i,t,r,e,p,l){if(r+e>i.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function vt(i,t,r,e,p){return t=+t,r=r>>>0,p||gt(i,t,r,4),s.write(i,t,r,e,23,4),r+4}o.prototype.writeFloatLE=function(t,r,e){return vt(this,t,r,!0,e)},o.prototype.writeFloatBE=function(t,r,e){return vt(this,t,r,!1,e)};function Et(i,t,r,e,p){return t=+t,r=r>>>0,p||gt(i,t,r,8),s.write(i,t,r,e,52,8),r+8}o.prototype.writeDoubleLE=function(t,r,e){return Et(this,t,r,!0,e)},o.prototype.writeDoubleBE=function(t,r,e){return Et(this,t,r,!1,e)},o.prototype.copy=function(t,r,e,p){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),!p&&p!==0&&(p=this.length),r>=t.length&&(r=t.length),r||(r=0),p>0&&p<e&&(p=e),p===e||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),t.length-r<p-e&&(p=t.length-r+e);var l=p-e;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,e,p):Uint8Array.prototype.set.call(t,this.subarray(e,p),r),l},o.prototype.fill=function(t,r,e,p){if(typeof t=="string"){if(typeof r=="string"?(p=r,r=0,e=this.length):typeof e=="string"&&(p=e,e=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!o.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(t.length===1){var l=t.charCodeAt(0);(p==="utf8"&&l<128||p==="latin1")&&(t=l)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<e)throw new RangeError("Out of range index");if(e<=r)return this;r=r>>>0,e=e===void 0?this.length:e>>>0,t||(t=0);var m;if(typeof t=="number")for(m=r;m<e;++m)this[m]=t;else{var y=o.isBuffer(t)?t:o.from(t,p),g=y.length;if(g===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(m=0;m<e-r;++m)this[m+r]=y[m%g]}return this};var yr=/[^+/0-9A-Za-z-_]/g;function wr(i){if(i=i.split("=")[0],i=i.trim().replace(yr,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function V(i,t){t=t||1/0;for(var r,e=i.length,p=null,l=[],m=0;m<e;++m){if(r=i.charCodeAt(m),r>55295&&r<57344){if(!p){if(r>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(m+1===e){(t-=3)>-1&&l.push(239,191,189);continue}p=r;continue}if(r<56320){(t-=3)>-1&&l.push(239,191,189),p=r;continue}r=(p-55296<<10|r-56320)+65536}else p&&(t-=3)>-1&&l.push(239,191,189);if(p=null,r<128){if((t-=1)<0)break;l.push(r)}else if(r<2048){if((t-=2)<0)break;l.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;l.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;l.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return l}function gr(i){for(var t=[],r=0;r<i.length;++r)t.push(i.charCodeAt(r)&255);return t}function vr(i,t){for(var r,e,p,l=[],m=0;m<i.length&&!((t-=2)<0);++m)r=i.charCodeAt(m),e=r>>8,p=r%256,l.push(p),l.push(e);return l}function bt(i){return a.toByteArray(wr(i))}function q(i,t,r,e){for(var p=0;p<e&&!(p+r>=t.length||p>=i.length);++p)t[p+r]=i[p];return p}function I(i,t){return i instanceof t||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===t.name}function Q(i){return i!==i}var Er=function(){for(var i="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var e=r*16,p=0;p<16;++p)t[e+p]=i[r]+i[p];return t}()})(Mt);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,a){var s=Mt,c=s.Buffer;function f(u,o){for(var x in u)o[x]=u[x]}c.from&&c.alloc&&c.allocUnsafe&&c.allocUnsafeSlow?n.exports=s:(f(s,a),a.Buffer=h);function h(u,o,x){return c(u,o,x)}h.prototype=Object.create(c.prototype),f(c,h),h.from=function(u,o,x){if(typeof u=="number")throw new TypeError("Argument must not be a number");return c(u,o,x)},h.alloc=function(u,o,x){if(typeof u!="number")throw new TypeError("Argument must be a number");var w=c(u);return o!==void 0?typeof x=="string"?w.fill(o,x):w.fill(o):w.fill(0),w},h.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return c(u)},h.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return s.SlowBuffer(u)}})(it,it.exports);var Ct=it.exports,Lt=Ct.Buffer;function Z(n,a){this._block=Lt.alloc(n),this._finalSize=a,this._blockSize=n,this._len=0}Z.prototype.update=function(n,a){typeof n=="string"&&(a=a||"utf8",n=Lt.from(n,a));for(var s=this._block,c=this._blockSize,f=n.length,h=this._len,u=0;u<f;){for(var o=h%c,x=Math.min(f-u,c-o),w=0;w<x;w++)s[o+w]=n[u+w];h+=x,u+=x,h%c===0&&this._update(s)}return this._len+=f,this};Z.prototype.digest=function(n){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 s=this._len*8;if(s<=4294967295)this._block.writeUInt32BE(s,this._blockSize-4);else{var c=(s&4294967295)>>>0,f=(s-c)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(c,this._blockSize-4)}this._update(this._block);var h=this._hash();return n?h.toString(n):h};Z.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Wr=Z,Hr=Nr,qt=Wr,Zr=Ct.Buffer,Kr=[1518500249,1859775393,-1894007588,-899497514],Yr=new Array(80);function L(){this.init(),this._w=Yr,qt.call(this,64,56)}Hr(L,qt);L.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Xr(n){return n<<1|n>>>31}function Gr(n){return n<<5|n>>>27}function Vr(n){return n<<30|n>>>2}function Qr(n,a,s,c){return n===0?a&s|~a&c:n===2?a&s|a&c|s&c:a^s^c}L.prototype._update=function(n){for(var a=this._w,s=this._a|0,c=this._b|0,f=this._c|0,h=this._d|0,u=this._e|0,o=0;o<16;++o)a[o]=n.readInt32BE(o*4);for(;o<80;++o)a[o]=Xr(a[o-3]^a[o-8]^a[o-14]^a[o-16]);for(var x=0;x<80;++x){var w=~~(x/20),v=Gr(s)+Qr(w,c,f,h)+u+a[x]+Kr[w]|0;u=h,h=f,f=Vr(c),c=s,s=v}this._a=s+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=h+this._d|0,this._e=u+this._e|0};L.prototype._hash=function(){var n=Zr.allocUnsafe(20);return n.writeInt32BE(this._a|0,0),n.writeInt32BE(this._b|0,4),n.writeInt32BE(this._c|0,8),n.writeInt32BE(this._d|0,12),n.writeInt32BE(this._e|0,16),n};var ti=L;const ri=Nt(ti),ut=new Error("File system not available.");function ii(n,a,s){throw ut}function $t(n){throw ut}function ei(n){throw ut}const ni=async n=>$t();function ai(n){let a="";for(let s=0;s<n.length;s+=2)a+=String.fromCharCode(parseInt(n.substr(s,2),16));return btoa(a)}const K=(n,a="sha1")=>{if(a!=="sha1")throw new Error("Only sha1 algorithm is available.");const s=new ri;return ai(s.update(n).digest("hex"))},ft=async n=>{const a=new At,{name:s,revision:c,documentType:f,created:h,lastModified:u}=n,o={name:s,revision:c,documentType:f,created:h,lastModified:u};return a.file("header.json",JSON.stringify(o,null,2)),a.file("state.json",JSON.stringify(n.initialState||{},null,2)),a.file("operations.json",JSON.stringify(n.operations,null,2)),Object.keys(n.attachments).forEach(w=>{const{data:v,...F}=n.attachments[w];a.file(w,v,{base64:!0,createFolders:!0,comment:JSON.stringify(F)})}),a},Jt=async(n,a,s,c)=>{await(await ft(n)).generateAsync({type:"uint8array",streamFiles:!0});const h=c??n.name,u=`.${s}.zip`;return ii(a,h.endsWith(u)?h:`${h}${u}`)},oi=async(n,a)=>{const c=await(await ft(n)).generateAsync({type:"blob"}),f=await a.createWritable();await f.write(c),await f.close()},et=async(n,a)=>{const s=$t();return Pt(s,a)},Pt=async(n,a)=>{const s=new At;return await s.loadAsync(n),pi(s,a)};async function pi(n,a){const s=n.file("state.json");if(!s)throw new Error("Initial state not found");const c=await s.async("string"),f=JSON.parse(c),h=n.file("header.json");let u=null;h&&(u=JSON.parse(await h.async("string")));const o=n.file("operations.json");if(!o)throw new Error("Operations history not found");const x=JSON.parse(await o.async("string")),w={...f,...u,initialState:f,operations:[],attachments:{...f.attachments}};let v=x.slice(0,u==null?void 0:u.revision).reduce((F,U)=>a(F,U),w);return u&&(v={...v,...u,operations:[...v.operations,...x.slice(u.revision)]}),v}function Wt(n){const a=n.replace(/^.*\./,"")||void 0,s=n.replace(/^.*[/\\]/,"")||void 0;return{extension:a,fileName:s}}async function si(n){const{buffer:a,mimeType:s="application/octet-stream"}=await ei(),c=Wt(n),f=a.toString("base64");return{data:f,hash:K(f),mimeType:s,...c}}async function ci(n){const a=await ni(),s=Or.getType(n)||"application/octet-stream",c=Wt(n),f=a.toString("base64");return{data:f,hash:K(f),mimeType:s,...c}}function P(n,a,s,c){const f=Gt(n),h=Yt(s);return a.reduce((u,o)=>h(u,o,c),f)}function li(n,a){return{...n,name:a}}function ui(n,a,s){const c=Math.min(a,n.revision),f=n.operations.slice(0,n.revision-c);return{...P(n.initialState,f,s),operations:n.operations,revision:n.revision-c}}function fi(n,a,s){const c=n.operations.length-n.revision;if(!c)throw new Error("There is no UNDO operation to REDO");const f=a<c?a:c,h=n.operations.slice(0,n.revision+f);return{...P(n.initialState,h,s),operations:n.operations,revision:n.revision+f}}function hi(n,a,s,c){a=a||0,s=s||n.operations.length;const f=n.operations.slice(a,s),h=n.operations.slice(0,a),u=n.operations.slice(s),o=P(n.initialState,h.concat(f),c),{name:x,state:w}=o;return P(n.initialState,[...h,ht({name:x,state:w},f.length),...u],c)}function mi(n,a){return{...n,name:a.name,state:a.state??{}}}const Ht="SET_NAME",Y="UNDO",X="REDO",C="PRUNE",Zt="LOAD_STATE";function xi(n,a){return[Y,X,C].includes(a.type)?n.revision:n.revision+1}function di(n,a){return{...n,revision:xi(n,a),lastModified:new Date().toISOString()}}function yi(n,a){if([Y,X,C,C].includes(a.type))return n;const s=n.operations.slice(0,n.revision);return{...n,operations:[...s,{...a,index:s.length,timestamp:new Date().toISOString(),hash:""}]}}function wi(n,a){let s=yi(n,a);return s=di(s,a),s}function gi(n,a,s){switch(kt().parse(a),a.type){case Ht:return li(n,a.input);case Y:return ui(n,a.input,s);case X:return fi(n,a.input,s);case C:return hi(n,a.input.start,a.input.end,s);case Zt:return mi(n,a.input.state);default:return n}}function Kt(n,a,s,c){let f=n;return nt(a)&&(f=gi(f,a,s)),f=wi(f,a),f=R.produce(f,h=>{const u=s(h.state,a,c);if(u)return R.castDraft({...f,state:u})}),R.produce(f,h=>{h.operations[h.operations.length-1].hash=Vt(h),!nt(a)&&a.attachments&&a.attachments.forEach(u=>{const{hash:o,...x}=u;h.attachments[o]={...x}})})}function nt(n){return[Ht,Y,X,C,Zt].includes(n.type)}function D(n,a,s,c,f="global"){if(!n)throw new Error("Empty action type");if(typeof n!="string")throw new Error(`Invalid action type: ${n}`);const h={type:n,input:a,scope:f};return s&&(h.attachments=s),c==null||c().parse(h),h}function Yt(n,a=Kt){return(s,c,f)=>a(s,c,n,f)}const Xt=(n,a)=>({name:"",documentType:"",revision:0,created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...n,state:(a==null?void 0:a(n==null?void 0:n.state))??(n==null?void 0:n.state)??{}}),Gt=(n,a)=>{const s=Xt(n,a);return{...s,initialState:s,operations:[]}},Vt=n=>K(_r(n.state)),vi=(n,a=1e3)=>{const s=Math.random()*a;return K(`${(n??new Date).toISOString()}${s}`)};function M(n){return R.castImmutable(R.freeze(n,!0))}const Qt=n=>D("SET_NAME",n,void 0,st),tr=(n=1)=>D("UNDO",n,void 0,ct),rr=(n=1)=>D("REDO",n,void 0,pt),ir=(n,a)=>D("PRUNE",{start:n,end:a},void 0,ot),ht=(n,a)=>D("LOAD_STATE",{state:n,operations:a},void 0,at),Ei=Object.freeze(Object.defineProperty({__proto__:null,loadState:ht,prune:ir,redo:rr,setName:Qt,undo:tr},Symbol.toStringTag,{value:"Module"}));class bi{constructor(a,s,c){J(this,"_document");J(this,"_reducer");J(this,"_signalDispatch");this._reducer=a,this._document=s,this._signalDispatch=c}dispatch(a){return this._document=this._reducer(this._document,a,this._signalDispatch),this}saveToFile(a,s,c){return Jt(this._document,a,s,c)}async loadFromFile(a){this._document=await et(a,this._reducer)}static async stateFromFile(a,s){return await et(a,s)}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(Qt(a)),this}undo(a){return this.dispatch(tr(a)),this}redo(a){return this.dispatch(rr(a)),this}prune(a,s){return this.dispatch(ir(a,s)),this}loadState(a,s){return this.dispatch(ht(a,s)),this}}function Fi(n,a){a.forEach(s=>{Object.getOwnPropertyNames(s.prototype).forEach(c=>{Object.defineProperty(n.prototype,c,Object.getOwnPropertyDescriptor(s.prototype,c)||Object.create(null))})})}exports.BaseActions=Ei;exports.BaseDocument=bi;exports.applyMixins=Fi;exports.baseReducer=Kt;exports.createAction=D;exports.createDocument=Gt;exports.createExtendedState=Xt;exports.createReducer=Yt;exports.createZip=ft;exports.getLocalFile=ci;exports.getRemoteFile=si;exports.hashDocument=Vt;exports.hashKey=vi;exports.isBaseAction=nt;exports.loadFromFile=et;exports.loadFromInput=Pt;exports.readOnly=M;exports.saveToFile=Jt;exports.saveToFileHandle=oi;exports.zod=Ir;
@@ -1,22 +0,0 @@
1
- "use strict";var dt=Object.defineProperty;var ut=(t,e,n)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var de=(t,e,n)=>(ut(t,typeof e!="symbol"?e+"":e,n),n);const s=require("./object-397a9b23.js");require("json-stringify-deterministic");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const r=require("zod"),mt=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:{schema:"",initialValue:`{
2
- "id": "",
3
- "name": "",
4
- "extension": "",
5
- "description": "",
6
- "author": {
7
- "name": "",
8
- "website": ""
9
- },
10
- "specifications": [
11
- {
12
- "version": 1,
13
- "changeLog": [],
14
- "state": {
15
- "schema": "",
16
- "initialValue": "",
17
- "examples": []
18
- },
19
- "modules": []
20
- }
21
- ]
22
- }`,examples:[]}}]},ue=t=>t!=null,Et=r.z.any().refine(t=>ue(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 A(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),name:r.z.string()})}function z(){return r.z.object({errorCode:r.z.string().nullish(),errorDescription:r.z.string().nullish(),errorName:r.z.string().nullish(),errorTemplate:r.z.string().nullish(),id:r.z.string(),operationId:r.z.string()})}function I(){return r.z.object({example:r.z.string(),id:r.z.string(),operationId:r.z.string()})}function T(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),moduleId:r.z.string(),name:r.z.string(),reducer:r.z.string().nullish(),schema:r.z.string().nullish(),template:r.z.string().nullish(),scope:r.z.literal("local").or(r.z.literal("global")).nullish()})}function b(){return r.z.object({example:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullish()})}function me(){return r.z.object({__typename:r.z.literal("Author").optional(),name:r.z.string(),website:r.z.string().nullable()})}function R(){return r.z.object({__typename:r.z.literal("CodeExample").optional(),id:r.z.string(),value:r.z.string()})}function D(){return r.z.object({__typename:r.z.literal("DeleteChangeLogItemInput").optional(),id:r.z.string()})}function M(){return r.z.object({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 P(){return r.z.object({id:r.z.string()})}function ht(){return r.z.union([_(),A(),z(),I(),T(),b(),D(),M(),x(),N(),L(),P(),j(),C(),k(),y(),w(),U(),v(),F(),H(),V(),X(),G(),B(),W(),$(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae()])}function Ot(){return r.z.object({__typename:r.z.literal("DocumentModelState").optional(),author:me(),description:r.z.string(),extension:r.z.string(),id:r.z.string(),name:r.z.string(),specifications:r.z.array(Ee())})}function Ee(){return r.z.object({__typename:r.z.literal("DocumentSpecification").optional(),changeLog:r.z.array(r.z.string()),modules:r.z.array(he()),state:fe(),version:r.z.number()})}function he(){return r.z.object({__typename:r.z.literal("Module").optional(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string(),operations:r.z.array(Oe())})}function j(){return r.z.object({newModuleId:r.z.string(),operationId:r.z.string()})}function Oe(){return r.z.object({__typename:r.z.literal("Operation").optional(),description:r.z.string().nullable(),errors:r.z.array(ge()),examples:r.z.array(R()),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 ge(){return r.z.object({__typename:r.z.literal("OperationError").optional(),code:r.z.string().nullable(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string().nullable(),template:r.z.string().nullable()})}function C(){return r.z.object({__typename:r.z.literal("ReorderChangeLogItemsInput").optional(),order:r.z.array(r.z.string())})}function k(){return r.z.object({moduleId:r.z.string(),order:r.z.array(r.z.string())})}function y(){return r.z.object({order:r.z.array(r.z.string())})}function w(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function U(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function v(){return r.z.object({order:r.z.array(r.z.string())})}function F(){return r.z.object({authorName:r.z.string()})}function H(){return r.z.object({authorWebsite:r.z.string()})}function V(){return r.z.object({initialValue:r.z.string()})}function X(){return r.z.object({description:r.z.string()})}function G(){return r.z.object({extension:r.z.string()})}function B(){return r.z.object({id:r.z.string()})}function W(){return r.z.object({name:r.z.string()})}function $(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function q(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function J(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function K(){return r.z.object({errorCode:r.z.string().nullish(),id:r.z.string()})}function Q(){return r.z.object({errorDescription:r.z.string().nullish(),id:r.z.string()})}function Y(){return r.z.object({errorName:r.z.string().nullish(),id:r.z.string()})}function Z(){return r.z.object({errorTemplate:r.z.string().nullish(),id:r.z.string()})}function ee(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function Se(){return r.z.object({id:r.z.string(),scope:r.z.literal("global").or(r.z.literal("local"))})}function te(){return r.z.object({id:r.z.string(),reducer:r.z.string().nullish()})}function re(){return r.z.object({id:r.z.string(),schema:r.z.string().nullish()})}function oe(){return r.z.object({id:r.z.string(),template:r.z.string().nullish()})}function ne(){return r.z.object({schema:r.z.string()})}function fe(){return r.z.object({__typename:r.z.literal("State").optional(),examples:r.z.array(R()),initialValue:r.z.string(),schema:r.z.string()})}function ie(){return r.z.object({__typename:r.z.literal("UpdateChangeLogItemInput").optional(),id:r.z.string(),newContent:r.z.string()})}function se(){return r.z.object({example:r.z.string(),id:r.z.string()})}function ae(){return r.z.object({id:r.z.string(),newExample:r.z.string()})}const _e=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:_,AddModuleInputSchema:A,AddOperationErrorInputSchema:z,AddOperationExampleInputSchema:I,AddOperationInputSchema:T,AddStateExampleInputSchema:b,AuthorSchema:me,CodeExampleSchema:R,DeleteChangeLogItemInputSchema:D,DeleteModuleInputSchema:M,DeleteOperationErrorInputSchema:x,DeleteOperationExampleInputSchema:N,DeleteOperationInputSchema:L,DeleteStateExampleInputSchema:P,DocumentModelInputSchema:ht,DocumentModelStateSchema:Ot,DocumentSpecificationSchema:Ee,ModuleSchema:he,MoveOperationInputSchema:j,OperationErrorSchema:ge,OperationSchema:Oe,ReorderChangeLogItemsInputSchema:C,ReorderModuleOperationsInputSchema:k,ReorderModulesInputSchema:y,ReorderOperationErrorsInputSchema:w,ReorderOperationExamplesInputSchema:U,ReorderStateExamplesInputSchema:v,SetAuthorNameInputSchema:F,SetAuthorWebsiteInputSchema:H,SetInitialStateInputSchema:V,SetModelDescriptionInputSchema:X,SetModelExtensionInputSchema:G,SetModelIdInputSchema:B,SetModelNameInputSchema:W,SetModuleDescriptionInputSchema:$,SetModuleNameInputSchema:q,SetOperationDescriptionInputSchema:J,SetOperationErrorCodeInputSchema:K,SetOperationErrorDescriptionInputSchema:Q,SetOperationErrorNameInputSchema:Y,SetOperationErrorTemplateInputSchema:Z,SetOperationNameInputSchema:ee,SetOperationReducerInputSchema:te,SetOperationSchemaInputSchema:re,SetOperationScopeInputSchema:Se,SetOperationTemplateInputSchema:oe,SetStateSchemaInputSchema:ne,StateSchema:fe,UpdateChangeLogItemInputSchema:ie,UpdateOperationExampleInputSchema:se,UpdateStateExampleInputSchema:ae,definedNonNullAnySchema:Et,isDefinedNonNullAny:ue},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')}},gt=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.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 n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].description=e.input.description||"")},deleteModuleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.modules=n.modules.filter(o=>o.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(gt(e.input.order))}},St=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},l={addOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].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 n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].errors=n.modules[o].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].errors.sort(St(e.input.order))}},ft=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},g={addOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].examples.length;a++)n.modules[o].operations[i].examples[a].id==e.input.id&&(n.modules[o].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].examples=n.modules[o].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.sort(ft(e.input.order))}},_t=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},p={addOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.modules[o].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 n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const n=[],o=t.specifications[t.specifications.length-1];for(let i=0;i<o.modules.length;i++)o.modules[i].operations=o.modules[i].operations.filter(a=>a.id==e.input.operationId?(n.push(a),!1):!0);for(let i=0;i<o.modules.length;i++)o.modules[i].id==e.input.newModuleId&&o.modules[i].operations.push(...n)},deleteOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].operations=n.modules[o].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.modules[o].operations.sort(_t(e.input.order))}},At=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},d={setStateSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.schema=e.input.schema},setInitialStateOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.initialValue=e.input.initialValue},addStateExampleOperation(t,e){t.specifications[t.specifications.length-1].state.examples.push({id:e.input.id,value:e.input.example})},updateStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.state.examples.length;o++)n.state.examples[o].id==e.input.id&&(n.state.examples[o].value=e.input.newExample)},deleteStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.examples=n.state.examples.filter(o=>o.id!=e.input.id)},reorderStateExamplesOperation(t,e){t.specifications[t.specifications.length-1].state.examples.sort(At(e.input.order))}},zt=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":W().parse(e.input),c.setModelNameOperation(t,e);break;case"SET_MODEL_ID":B().parse(e.input),c.setModelIdOperation(t,e);break;case"SET_MODEL_EXTENSION":G().parse(e.input),c.setModelExtensionOperation(t,e);break;case"SET_MODEL_DESCRIPTION":X().parse(e.input),c.setModelDescriptionOperation(t,e);break;case"SET_AUTHOR_NAME":F().parse(e.input),c.setAuthorNameOperation(t,e);break;case"SET_AUTHOR_WEBSITE":H().parse(e.input),c.setAuthorWebsiteOperation(t,e);break;case"ADD_CHANGE_LOG_ITEM":_().parse(e.input),E.addChangeLogItemOperation(t,e);break;case"UPDATE_CHANGE_LOG_ITEM":ie().parse(e.input),E.updateChangeLogItemOperation(t,e);break;case"DELETE_CHANGE_LOG_ITEM":D().parse(e.input),E.deleteChangeLogItemOperation(t,e);break;case"REORDER_CHANGE_LOG_ITEMS":C().parse(e.input),E.reorderChangeLogItemsOperation(t,e);break;case"RELEASE_NEW_VERSION":if(Object.keys(e.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");E.releaseNewVersionOperation(t,e);break;case"ADD_MODULE":A().parse(e.input),h.addModuleOperation(t,e);break;case"SET_MODULE_NAME":q().parse(e.input),h.setModuleNameOperation(t,e);break;case"SET_MODULE_DESCRIPTION":$().parse(e.input),h.setModuleDescriptionOperation(t,e);break;case"DELETE_MODULE":M().parse(e.input),h.deleteModuleOperation(t,e);break;case"REORDER_MODULES":y().parse(e.input),h.reorderModulesOperation(t,e);break;case"ADD_OPERATION_ERROR":z().parse(e.input),l.addOperationErrorOperation(t,e);break;case"SET_OPERATION_ERROR_CODE":K().parse(e.input),l.setOperationErrorCodeOperation(t,e);break;case"SET_OPERATION_ERROR_NAME":Y().parse(e.input),l.setOperationErrorNameOperation(t,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Q().parse(e.input),l.setOperationErrorDescriptionOperation(t,e);break;case"SET_OPERATION_ERROR_TEMPLATE":Z().parse(e.input),l.setOperationErrorTemplateOperation(t,e);break;case"DELETE_OPERATION_ERROR":x().parse(e.input),l.deleteOperationErrorOperation(t,e);break;case"REORDER_OPERATION_ERRORS":w().parse(e.input),l.reorderOperationErrorsOperation(t,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),g.addOperationExampleOperation(t,e);break;case"UPDATE_OPERATION_EXAMPLE":se().parse(e.input),g.updateOperationExampleOperation(t,e);break;case"DELETE_OPERATION_EXAMPLE":N().parse(e.input),g.deleteOperationExampleOperation(t,e);break;case"REORDER_OPERATION_EXAMPLES":U().parse(e.input),g.reorderOperationExamplesOperation(t,e);break;case"ADD_OPERATION":T().parse(e.input),p.addOperationOperation(t,e);break;case"SET_OPERATION_NAME":ee().parse(e.input),p.setOperationNameOperation(t,e);break;case"SET_OPERATION_SCOPE":Se().parse(e.input),p.setOperationScopeOperation(t,e);break;case"SET_OPERATION_SCHEMA":re().parse(e.input),p.setOperationSchemaOperation(t,e);break;case"SET_OPERATION_DESCRIPTION":J().parse(e.input),p.setOperationDescriptionOperation(t,e);break;case"SET_OPERATION_TEMPLATE":oe().parse(e.input),p.setOperationTemplateOperation(t,e);break;case"SET_OPERATION_REDUCER":te().parse(e.input),p.setOperationReducerOperation(t,e);break;case"MOVE_OPERATION":j().parse(e.input),p.moveOperationOperation(t,e);break;case"DELETE_OPERATION":L().parse(e.input),p.deleteOperationOperation(t,e);break;case"REORDER_MODULE_OPERATIONS":k().parse(e.input),p.reorderModuleOperationsOperation(t,e);break;case"SET_STATE_SCHEMA":ne().parse(e.input),d.setStateSchemaOperation(t,e);break;case"SET_INITIAL_STATE":V().parse(e.input),d.setInitialStateOperation(t,e);break;case"ADD_STATE_EXAMPLE":b().parse(e.input),d.addStateExampleOperation(t,e);break;case"UPDATE_STATE_EXAMPLE":ae().parse(e.input),d.updateStateExampleOperation(t,e);break;case"DELETE_STATE_EXAMPLE":P().parse(e.input),d.deleteStateExampleOperation(t,e);break;case"REORDER_STATE_EXAMPLES":v().parse(e.input),d.reorderStateExamplesOperation(t,e);break;default:return t}},m=s.createReducer(zt),It={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{schema:"",initialValue:"",examples:[]},modules:[]}]},O={fileExtension:"phdm",createState(t){return{...It,...t}},createExtendedState(t){return s.createExtendedState({...t,documentType:"powerhouse/document-model"},O.createState)},createDocument(t){return s.createDocument(O.createExtendedState(t),O.createState)},saveToFile(t,e,n){return s.saveToFile(t,e,"phdm",n)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,m)},loadFromInput(t){return s.loadFromInput(t,m)}},Ae=t=>s.createAction("SET_MODEL_NAME",{...t}),ze=t=>s.createAction("SET_MODEL_ID",{...t}),Ie=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Te=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),be=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Re=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Tt extends s.BaseDocument{setModelName(e){return this.dispatch(Ae(e))}setModelId(e){return this.dispatch(ze(e))}setModelExtension(e){return this.dispatch(Ie(e))}setModelDescription(e){return this.dispatch(Te(e))}setAuthorName(e){return this.dispatch(be(e))}setAuthorWebsite(e){return this.dispatch(Re(e))}}const De=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),Me=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),xe=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),Le=()=>s.createAction("RELEASE_NEW_VERSION");class bt extends s.BaseDocument{addChangeLogItem(e){return this.dispatch(De(e))}updateChangeLogItem(e){return this.dispatch(Me(e))}deleteChangeLogItem(e){return this.dispatch(xe(e))}reorderChangeLogItems(e){return this.dispatch(Ne(e))}releaseNewVersion(){return this.dispatch(Le())}}const Pe=t=>s.createAction("ADD_MODULE",{...t}),je=t=>s.createAction("SET_MODULE_NAME",{...t}),Ce=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),ke=t=>s.createAction("DELETE_MODULE",{...t}),ye=t=>s.createAction("REORDER_MODULES",{...t});class Rt extends s.BaseDocument{addModule(e){return this.dispatch(Pe(e))}setModuleName(e){return this.dispatch(je(e))}setModuleDescription(e){return this.dispatch(Ce(e))}deleteModule(e){return this.dispatch(ke(e))}reorderModules(e){return this.dispatch(ye(e))}}const we=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}),Ve=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Xe=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Dt extends s.BaseDocument{addOperationError(e){return this.dispatch(we(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(Ve(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}),$e=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Mt 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($e(e))}}const qe=t=>s.createAction("ADD_OPERATION",{...t}),Je=t=>s.createAction("SET_OPERATION_NAME",{...t}),Ke=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Qe=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),Ye=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),Ze=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),et=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),tt=t=>s.createAction("MOVE_OPERATION",{...t}),rt=t=>s.createAction("DELETE_OPERATION",{...t}),ot=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class xt extends s.BaseDocument{addOperation(e){return this.dispatch(qe(e))}setOperationName(e){return this.dispatch(Je(e))}setOperationScope(e){return this.dispatch(Ke(e))}setOperationSchema(e){return this.dispatch(Qe(e))}setOperationDescription(e){return this.dispatch(Ye(e))}setOperationTemplate(e){return this.dispatch(Ze(e))}setOperationReducer(e){return this.dispatch(et(e))}moveOperation(e){return this.dispatch(tt(e))}deleteOperation(e){return this.dispatch(rt(e))}reorderModuleOperations(e){return this.dispatch(ot(e))}}const nt=t=>s.createAction("SET_STATE_SCHEMA",{...t}),it=t=>s.createAction("SET_INITIAL_STATE",{...t}),st=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),at=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),pt=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class Nt extends s.BaseDocument{setStateSchema(e){return this.dispatch(nt(e))}setInitialState(e){return this.dispatch(it(e))}addStateExample(e){return this.dispatch(st(e))}updateStateExample(e){return this.dispatch(at(e))}deleteStateExample(e){return this.dispatch(pt(e))}reorderStateExamples(e){return this.dispatch(lt(e))}}var u;let S=(u=class extends s.BaseDocument{constructor(e,n){super(m,O.createDocument(e),n)}saveToFile(e,n){return super.saveToFile(e,u.fileExtension,n)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const n=new this;return await n.loadFromFile(e),n}},de(u,"fileExtension","phdm"),u);s.applyMixins(S,[Tt,bt,Rt,Dt,Mt,xt,Nt]);const Lt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:De,addModule:Pe,addOperation:qe,addOperationError:we,addOperationExample:Ge,addStateExample:st,deleteChangeLogItem:xe,deleteModule:ke,deleteOperation:rt,deleteOperationError:Ve,deleteOperationExample:We,deleteStateExample:pt,moveOperation:tt,releaseNewVersion:Le,reorderChangeLogItems:Ne,reorderModuleOperations:ot,reorderModules:ye,reorderOperationErrors:Xe,reorderOperationExamples:$e,reorderStateExamples:lt,setAuthorName:be,setAuthorWebsite:Re,setInitialState:it,setModelDescription:Te,setModelExtension:Ie,setModelId:ze,setModelName:Ae,setModuleDescription:Ce,setModuleName:je,setOperationDescription:Ye,setOperationErrorCode:Ue,setOperationErrorDescription:Fe,setOperationErrorName:ve,setOperationErrorTemplate:He,setOperationName:Je,setOperationReducer:et,setOperationSchema:Qe,setOperationScope:Ke,setOperationTemplate:Ze,setStateSchema:nt,updateChangeLogItem:Me,updateOperationExample:Be,updateStateExample:at},Symbol.toStringTag,{value:"Module"})),pe=S,le={...O,...mt},ce={...s.BaseActions,...Lt},ct={Document:pe,reducer:m,actions:ce,utils:le,documentModel:f},Pt=Object.freeze(Object.defineProperty({__proto__:null,Document:pe,DocumentModel:S,actions:ce,documentModel:f,module:ct,reducer:m,utils:le,z:_e},Symbol.toStringTag,{value:"Module"}));exports.Document=pe;exports.DocumentModel=Pt;exports.DocumentModel$1=S;exports.actions=ce;exports.documentModel=f;exports.module=ct;exports.reducer=m;exports.utils=le;exports.zod=_e;
@@ -1 +0,0 @@
1
- "use strict";var st=Object.defineProperty;var pt=(t,e,i)=>e in t?st(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var g=(t,e,i)=>(pt(t,typeof e!="symbol"?e+"":e,i),i);const ct=require("json-stringify-deterministic"),x=require("immer"),F=require("jszip"),lt=require("crypto"),z=require("fs"),rt=require("https"),mt=require("path"),o=require("zod"),q=t=>t!=null,ut=o.z.any().refine(t=>q(t)),P=o.z.enum(["LOAD_STATE"]),M=o.z.enum(["PRUNE"]),R=o.z.enum(["REDO"]),L=o.z.enum(["SET_NAME"]),I=o.z.enum(["UNDO"]);function dt(){return o.z.object({__typename:o.z.literal("Action").optional(),type:o.z.string()})}function U(){return o.z.union([O(),D(),k(),E(),A()])}function xt(){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 O(){return o.z.object({input:o.z.lazy(()=>J()),type:P})}function J(){return o.z.object({operations:o.z.number(),state:o.z.lazy(()=>B())})}function B(){return o.z.object({data:o.z.unknown().nullish(),name:o.z.string()})}function ft(){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 D(){return o.z.object({input:o.z.lazy(()=>C()),type:M})}function C(){return o.z.object({end:o.z.number().nullish(),start:o.z.number().nullish()})}function k(){return o.z.object({input:o.z.number(),type:R})}function E(){return o.z.object({input:o.z.string(),type:L})}function gt(){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()})}function A(){return o.z.object({input:o.z.number(),type:I})}const ht=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:dt,BaseActionSchema:U,DocumentFileSchema:xt,LoadStateActionInputSchema:J,LoadStateActionSchema:O,LoadStateActionStateInputSchema:B,Load_StateSchema:P,OperationSchema:ft,PruneActionInputSchema:C,PruneActionSchema:D,PruneSchema:M,RedoActionSchema:k,RedoSchema:R,SetNameActionSchema:E,SetNameOperationSchema:gt,Set_NameSchema:L,UndoActionSchema:A,UndoSchema:I,definedNonNullAnySchema:ut,isDefinedNonNullAny:q},Symbol.toStringTag,{value:"Module"}));function vt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function v(){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)}v.prototype.define=function(t,e){for(let i in t){let a=t[i].map(function(n){return n.toLowerCase()});i=i.toLowerCase();for(let n=0;n<a.length;n++){const s=a[n];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 n=a[0];this._extensions[i]=n[0]!=="*"?n:n.substr(1)}}};v.prototype.getType=function(t){t=String(t);let e=t.replace(/^.*[/\\]/,"").toLowerCase(),i=e.replace(/^.*\./,"").toLowerCase(),a=e.length<t.length;return(i.length<e.length-1||!a)&&this._types[i]||null};v.prototype.getExtension=function(t){return t=/^\s*([^;\s]*)/.test(t)&&RegExp.$1,t&&this._extensions[t.toLowerCase()]||null};var yt=v,bt={"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 jt=yt;var wt=new jt(bt);const zt=vt(wt);function St(t,e,i){const a=mt.join(t,e);return z.mkdirSync(t,{recursive:!0}),new Promise((n,s)=>{try{z.writeFile(a,i,{},p=>{p?s(p):n(a)})}catch(p){s(p)}})}function $(t){return z.readFileSync(t)}function _t(t){return new Promise((e,i)=>{rt.get(t,a=>{const n=[],s=a.headers["content-type"];a.on("data",p=>{n.push(p)}),a.on("end",()=>{e({buffer:Buffer.concat(n),mimeType:s})})}).on("error",a=>{i(a)})})}const Ot=async t=>$(t),y=(t,e="sha1")=>lt.createHash(e).update(t).digest("base64"),N=async t=>{const e=new F,{name:i,revision:a,documentType:n,created:s,lastModified:p}=t,c={name:i,revision:a,documentType:n,created:s,lastModified:p};return e.file("header.json",JSON.stringify(c,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(r=>{const{data:m,...w}=t.attachments[r];e.file(r,m,{base64:!0,createFolders:!0,comment:JSON.stringify(w)})}),e},Z=async(t,e,i,a)=>{const s=await(await N(t)).generateAsync({type:"uint8array",streamFiles:!0}),p=a??t.name,c=`.${i}.zip`;return St(e,p.endsWith(c)?p:`${p}${c}`,s)},Dt=async(t,e)=>{const a=await(await N(t)).generateAsync({type:"blob"}),n=await e.createWritable();await n.write(a),await n.close()},S=async(t,e)=>{const i=$(t);return H(i,e)},H=async(t,e)=>{const i=new F;return await i.loadAsync(t),kt(i,e)};async function kt(t,e){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const a=await i.async("string"),n=JSON.parse(a),s=t.file("header.json");let p=null;s&&(p=JSON.parse(await s.async("string")));const c=t.file("operations.json");if(!c)throw new Error("Operations history not found");const l=JSON.parse(await c.async("string")),r={...n,...p,initialState:n,operations:[],attachments:{...n.attachments}};let m=l.slice(0,p==null?void 0:p.revision).reduce((w,ot)=>e(w,ot),r);return p&&(m={...m,...p,operations:[...m.operations,...l.slice(p.revision)]}),m}function K(t){const e=t.replace(/^.*\./,"")||void 0,i=t.replace(/^.*[/\\]/,"")||void 0;return{extension:e,fileName:i}}async function Et(t){const{buffer:e,mimeType:i="application/octet-stream"}=await _t(t),a=K(t),n=e.toString("base64");return{data:n,hash:y(n),mimeType:i,...a}}async function At(t){const e=await Ot(t),i=zt.getType(t)||"application/octet-stream",a=K(t),n=e.toString("base64");return{data:n,hash:y(n),mimeType:i,...a}}function h(t,e,i,a){const n=Y(t),s=V(i);return e.reduce((p,c)=>s(p,c,a),n)}function Nt(t,e){return{...t,name:e}}function Tt(t,e,i){const a=Math.min(e,t.revision),n=t.operations.slice(0,t.revision-a);return{...h(t.initialState,n,i),operations:t.operations,revision:t.revision-a}}function Ft(t,e,i){const a=t.operations.length-t.revision;if(!a)throw new Error("There is no UNDO operation to REDO");const n=e<a?e:a,s=t.operations.slice(0,t.revision+n);return{...h(t.initialState,s,i),operations:t.operations,revision:t.revision+n}}function qt(t,e,i,a){e=e||0,i=i||t.operations.length;const n=t.operations.slice(e,i),s=t.operations.slice(0,e),p=t.operations.slice(i),c=h(t.initialState,s.concat(n),a),{name:l,state:r}=c;return h(t.initialState,[...s,T({name:l,state:r},n.length),...p],a)}function Pt(t,e){return{...t,name:e.name,state:e.state??{}}}const W="SET_NAME",b="UNDO",j="REDO",f="PRUNE",G="LOAD_STATE";function Mt(t,e){return[b,j,f].includes(e.type)?t.revision:t.revision+1}function Rt(t,e){return{...t,revision:Mt(t,e),lastModified:new Date().toISOString()}}function Lt(t,e){if([b,j,f,f].includes(e.type))return t;const i=t.operations.slice(0,t.revision);return{...t,operations:[...i,{...e,index:i.length,timestamp:new Date().toISOString(),hash:""}]}}function It(t,e){let i=Lt(t,e);return i=Rt(i,e),i}function Ut(t,e,i){switch(U().parse(e),e.type){case W:return Nt(t,e.input);case b:return Tt(t,e.input,i);case j:return Ft(t,e.input,i);case f:return qt(t,e.input.start,e.input.end,i);case G:return Pt(t,e.input.state);default:return t}}function Q(t,e,i,a){let n=t;return _(e)&&(n=Ut(n,e,i)),n=It(n,e),n=x.produce(n,s=>{const p=i(s.state,e,a);if(p)return x.castDraft({...n,state:p})}),x.produce(n,s=>{s.operations[s.operations.length-1].hash=tt(s),!_(e)&&e.attachments&&e.attachments.forEach(p=>{const{hash:c,...l}=p;s.attachments[c]={...l}})})}function _(t){return[W,b,j,f,G].includes(t.type)}function u(t,e,i,a,n="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:n};return i&&(s.attachments=i),a==null||a().parse(s),s}function V(t,e=Q){return(i,a,n)=>e(i,a,t,n)}const X=(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)??{}}),Y=(t,e)=>{const i=X(t,e);return{...i,initialState:i,operations:[]}},tt=t=>y(ct(t.state)),Jt=(t,e=1e3)=>{const i=Math.random()*e;return y(`${(t??new Date).toISOString()}${i}`)};function d(t){return x.castImmutable(x.freeze(t,!0))}const et=t=>u("SET_NAME",t,void 0,E),it=(t=1)=>u("UNDO",t,void 0,A),at=(t=1)=>u("REDO",t,void 0,k),nt=(t,e)=>u("PRUNE",{start:t,end:e},void 0,D),T=(t,e)=>u("LOAD_STATE",{state:t,operations:e},void 0,O),Bt=Object.freeze(Object.defineProperty({__proto__:null,loadState:T,prune:nt,redo:at,setName:et,undo:it},Symbol.toStringTag,{value:"Module"}));class Ct{constructor(e,i,a){g(this,"_document");g(this,"_reducer");g(this,"_signalDispatch");this._reducer=e,this._document=i,this._signalDispatch=a}dispatch(e){return this._document=this._reducer(this._document,e,this._signalDispatch),this}saveToFile(e,i,a){return Z(this._document,e,i,a)}async loadFromFile(e){this._document=await S(e,this._reducer)}static async stateFromFile(e,i){return await S(e,i)}get state(){return d(this._document.state)}get operations(){return d(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 d(this._document.initialState)}toDocument(){return d(this._document)}getAttachment(e){return this._document.attachments[e]}setName(e){return this.dispatch(et(e)),this}undo(e){return this.dispatch(it(e)),this}redo(e){return this.dispatch(at(e)),this}prune(e,i){return this.dispatch(nt(e,i)),this}loadState(e,i){return this.dispatch(T(e,i)),this}}function $t(t,e){e.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(a=>{Object.defineProperty(t.prototype,a,Object.getOwnPropertyDescriptor(i.prototype,a)||Object.create(null))})})}exports.BaseActions=Bt;exports.BaseDocument=Ct;exports.applyMixins=$t;exports.baseReducer=Q;exports.createAction=u;exports.createDocument=Y;exports.createExtendedState=X;exports.createReducer=V;exports.createZip=N;exports.getLocalFile=At;exports.getRemoteFile=Et;exports.hashDocument=tt;exports.hashKey=Jt;exports.isBaseAction=_;exports.loadFromFile=S;exports.loadFromInput=H;exports.readOnly=d;exports.saveToFile=Z;exports.saveToFileHandle=Dt;exports.zod=ht;