document-model 1.1.0-debug.2 → 1.1.0-experimental.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/cjs/document-model.js +1 -21
- package/dist/browser/cjs/document.js +1 -15
- package/dist/browser/cjs/index.js +1 -18
- package/dist/browser/cjs/internal/index-DLodkpOq.js +22 -0
- package/dist/browser/cjs/internal/index-azT4DEce.js +1 -0
- package/dist/browser/cjs/internal/object-CMr-_AP8.js +25 -0
- package/dist/browser/es/document-model.js +15 -16
- package/dist/browser/es/document.js +9 -10
- package/dist/browser/es/index.js +11 -13
- package/dist/browser/es/internal/index-BzNpRs2a.js +44 -0
- package/dist/browser/es/internal/index-CL_1ivGq.js +2104 -0
- package/dist/browser/es/internal/object-FFc9n_3I.js +2789 -0
- package/dist/browser/src/document/object.d.ts +35 -0
- package/dist/browser/src/document/types.d.ts +6 -0
- package/dist/browser/src/document/utils/base.d.ts +5 -4
- package/dist/browser/src/document/utils/document-helpers.d.ts +1 -1
- package/dist/browser/src/document/utils/index.d.ts +1 -1
- package/dist/node/cjs/document-model.js +1 -25
- package/dist/node/cjs/document.js +1 -19
- package/dist/node/cjs/index.js +1 -22
- package/dist/node/cjs/internal/index-CPeTtUsk.js +22 -0
- package/dist/node/cjs/internal/index-CTavCc1t.js +1 -0
- package/dist/node/cjs/internal/object-DhI24-1e.js +20 -0
- package/dist/node/es/document-model.js +14 -15
- package/dist/node/es/document.js +9 -10
- package/dist/node/es/index.js +11 -13
- package/dist/node/es/internal/index-8lUz8qED.js +44 -0
- package/dist/node/es/internal/index-A880In4b.js +2108 -0
- package/dist/node/es/internal/object-C9n9Ijnt.js +1687 -0
- package/dist/node/src/document/object.d.ts +35 -0
- package/dist/node/src/document/types.d.ts +6 -0
- package/dist/node/src/document/utils/base.d.ts +5 -4
- package/dist/node/src/document/utils/document-helpers.d.ts +1 -1
- package/dist/node/src/document/utils/index.d.ts +1 -1
- package/package.json +1 -1
- package/CHANGELOG.md +0 -19
- package/dist/browser/cjs/document-model.js.map +0 -1
- package/dist/browser/cjs/document.js.map +0 -1
- package/dist/browser/cjs/index.js.map +0 -1
- package/dist/browser/cjs/internal/index-CaJbS06G.js +0 -2339
- package/dist/browser/cjs/internal/index-CaJbS06G.js.map +0 -1
- package/dist/browser/cjs/internal/index-kKIg6qNB.js +0 -44
- package/dist/browser/cjs/internal/index-kKIg6qNB.js.map +0 -1
- package/dist/browser/cjs/internal/object-B6dSDhtS.js +0 -4109
- package/dist/browser/cjs/internal/object-B6dSDhtS.js.map +0 -1
- package/dist/browser/es/document-model.js.map +0 -1
- package/dist/browser/es/document.js.map +0 -1
- package/dist/browser/es/index.js.map +0 -1
- package/dist/browser/es/internal/index-B1lQN59e.js +0 -2340
- package/dist/browser/es/internal/index-B1lQN59e.js.map +0 -1
- package/dist/browser/es/internal/index-Bu0CkmrW.js +0 -45
- package/dist/browser/es/internal/index-Bu0CkmrW.js.map +0 -1
- package/dist/browser/es/internal/object-9mR1JlXD.js +0 -4110
- package/dist/browser/es/internal/object-9mR1JlXD.js.map +0 -1
- package/dist/node/cjs/document-model.js.map +0 -1
- package/dist/node/cjs/document.js.map +0 -1
- package/dist/node/cjs/index.js.map +0 -1
- package/dist/node/cjs/internal/index-AqiVmL0w.js +0 -44
- package/dist/node/cjs/internal/index-AqiVmL0w.js.map +0 -1
- package/dist/node/cjs/internal/index-ajqhOWQ1.js +0 -2343
- package/dist/node/cjs/internal/index-ajqhOWQ1.js.map +0 -1
- package/dist/node/cjs/internal/object-D_9h7jBN.js +0 -2111
- package/dist/node/cjs/internal/object-D_9h7jBN.js.map +0 -1
- package/dist/node/es/document-model.js.map +0 -1
- package/dist/node/es/document.js.map +0 -1
- package/dist/node/es/index.js.map +0 -1
- package/dist/node/es/internal/index-Bh_09edy.js +0 -2344
- package/dist/node/es/internal/index-Bh_09edy.js.map +0 -1
- package/dist/node/es/internal/index-s6NFw7Kq.js +0 -45
- package/dist/node/es/internal/index-s6NFw7Kq.js.map +0 -1
- package/dist/node/es/internal/object-CbITi4iq.js +0 -2112
- package/dist/node/es/internal/object-CbITi4iq.js.map +0 -1
- package/dist/src/document/actions/creators.d.ts +0 -47
- package/dist/src/document/actions/index.d.ts +0 -14
- package/dist/src/document/actions/types.d.ts +0 -15
- package/dist/src/document/index.d.ts +0 -6
- package/dist/src/document/object.d.ts +0 -1175
- package/dist/src/document/reducer.d.ts +0 -43
- package/dist/src/document/schema/index.d.ts +0 -2
- package/dist/src/document/schema/types.d.ts +0 -176
- package/dist/src/document/schema/zod.d.ts +0 -113
- package/dist/src/document/signal.d.ts +0 -29
- package/dist/src/document/types.d.ts +0 -249
- package/dist/src/document/utils/base.d.ts +0 -85
- package/dist/src/document/utils/document-helpers.d.ts +0 -53
- package/dist/src/document/utils/file.d.ts +0 -48
- package/dist/src/document/utils/index.d.ts +0 -5
- package/dist/src/document/utils/node.d.ts +0 -9
- package/dist/src/document/utils/validation.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/header.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/module.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-error.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-example.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/state.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/versioning.d.ts +0 -7
- package/dist/src/document-model/custom/utils.d.ts +0 -7
- package/dist/src/document-model/gen/actions.d.ts +0 -15
- package/dist/src/document-model/gen/creators.d.ts +0 -7
- package/dist/src/document-model/gen/document-model.d.ts +0 -2
- package/dist/src/document-model/gen/header/actions.d.ts +0 -9
- package/dist/src/document-model/gen/header/creators.d.ts +0 -8
- package/dist/src/document-model/gen/header/object.d.ts +0 -12
- package/dist/src/document-model/gen/header/operations.d.ts +0 -10
- package/dist/src/document-model/gen/index.d.ts +0 -5
- package/dist/src/document-model/gen/module/actions.d.ts +0 -8
- package/dist/src/document-model/gen/module/creators.d.ts +0 -7
- package/dist/src/document-model/gen/module/object.d.ts +0 -11
- package/dist/src/document-model/gen/module/operations.d.ts +0 -9
- package/dist/src/document-model/gen/object.d.ts +0 -28
- package/dist/src/document-model/gen/operation/actions.d.ts +0 -13
- package/dist/src/document-model/gen/operation/creators.d.ts +0 -12
- package/dist/src/document-model/gen/operation/object.d.ts +0 -16
- package/dist/src/document-model/gen/operation/operations.d.ts +0 -14
- package/dist/src/document-model/gen/operation-error/actions.d.ts +0 -10
- package/dist/src/document-model/gen/operation-error/creators.d.ts +0 -9
- package/dist/src/document-model/gen/operation-error/object.d.ts +0 -13
- package/dist/src/document-model/gen/operation-error/operations.d.ts +0 -11
- package/dist/src/document-model/gen/operation-example/actions.d.ts +0 -7
- package/dist/src/document-model/gen/operation-example/creators.d.ts +0 -6
- package/dist/src/document-model/gen/operation-example/object.d.ts +0 -10
- package/dist/src/document-model/gen/operation-example/operations.d.ts +0 -8
- package/dist/src/document-model/gen/reducer.d.ts +0 -5
- package/dist/src/document-model/gen/schema/index.d.ts +0 -2
- package/dist/src/document-model/gen/schema/types.d.ts +0 -453
- package/dist/src/document-model/gen/schema/zod.d.ts +0 -453
- package/dist/src/document-model/gen/state/actions.d.ts +0 -9
- package/dist/src/document-model/gen/state/creators.d.ts +0 -8
- package/dist/src/document-model/gen/state/object.d.ts +0 -12
- package/dist/src/document-model/gen/state/operations.d.ts +0 -10
- package/dist/src/document-model/gen/types.d.ts +0 -8
- package/dist/src/document-model/gen/utils.d.ts +0 -6
- package/dist/src/document-model/gen/versioning/actions.d.ts +0 -8
- package/dist/src/document-model/gen/versioning/creators.d.ts +0 -7
- package/dist/src/document-model/gen/versioning/object.d.ts +0 -11
- package/dist/src/document-model/gen/versioning/operations.d.ts +0 -9
- package/dist/src/document-model/index.d.ts +0 -80
- package/dist/src/index.d.ts +0 -25
- package/dist/vite.config.d.ts +0 -2
- package/dist/vitest.config.d.ts +0 -2
|
@@ -1,21 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("./internal/object-B6dSDhtS.js");
|
|
4
|
-
require("immer");
|
|
5
|
-
require("jszip");
|
|
6
|
-
const documentModel = require("./internal/index-CaJbS06G.js");
|
|
7
|
-
require("zod");
|
|
8
|
-
exports.Document = documentModel.Document;
|
|
9
|
-
exports.DocumentModel = documentModel.DocumentModel$1;
|
|
10
|
-
exports.actions = documentModel.actions;
|
|
11
|
-
exports.documentModel = documentModel.documentModel;
|
|
12
|
-
exports.module = documentModel.module;
|
|
13
|
-
exports.reducer = documentModel.reducer;
|
|
14
|
-
exports.utils = documentModel.utils;
|
|
15
|
-
exports.validateInitialState = documentModel.validateInitialState;
|
|
16
|
-
exports.validateModule = documentModel.validateModule;
|
|
17
|
-
exports.validateModuleOperation = documentModel.validateModuleOperation;
|
|
18
|
-
exports.validateModules = documentModel.validateModules;
|
|
19
|
-
exports.validateStateSchemaName = documentModel.validateStateSchemaName;
|
|
20
|
-
exports.z = documentModel.zod;
|
|
21
|
-
//# sourceMappingURL=document-model.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-CMr-_AP8.js");require("immer");require("jszip");const e=require("./internal/index-DLodkpOq.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.validateInitialState=e.validateInitialState;exports.validateModule=e.validateModule;exports.validateModuleOperation=e.validateModuleOperation;exports.validateModules=e.validateModules;exports.validateStateSchemaName=e.validateStateSchemaName;exports.z=e.zod;
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const object = require("./internal/object-B6dSDhtS.js");
|
|
4
|
-
const document = require("./internal/index-kKIg6qNB.js");
|
|
5
|
-
require("immer");
|
|
6
|
-
require("zod");
|
|
7
|
-
require("jszip");
|
|
8
|
-
exports.BaseDocument = object.BaseDocument;
|
|
9
|
-
exports.actions = object.BaseActions;
|
|
10
|
-
exports.applyMixins = object.applyMixins;
|
|
11
|
-
exports.baseReducer = object.baseReducer;
|
|
12
|
-
exports.processUndoRedo = object.processUndoRedo;
|
|
13
|
-
exports.z = object.zod;
|
|
14
|
-
exports.utils = document.index;
|
|
15
|
-
//# sourceMappingURL=document.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-CMr-_AP8.js"),o=require("./internal/index-azT4DEce.js");require("immer");require("zod");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.z=e.zod;exports.utils=o.index;
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const document = require("./internal/index-kKIg6qNB.js");
|
|
4
|
-
const documentModel = require("./internal/index-CaJbS06G.js");
|
|
5
|
-
require("./internal/object-B6dSDhtS.js");
|
|
6
|
-
require("immer");
|
|
7
|
-
require("zod");
|
|
8
|
-
require("jszip");
|
|
9
|
-
const DocumentModels = {
|
|
10
|
-
"powerhouse/document": document.Document,
|
|
11
|
-
"powerhouse/document-model": documentModel.DocumentModel
|
|
12
|
-
};
|
|
13
|
-
const index = { Document: document.Document, DocumentModel: documentModel.DocumentModel };
|
|
14
|
-
exports.Document = document.Document;
|
|
15
|
-
exports.DocumentModel = documentModel.DocumentModel;
|
|
16
|
-
exports.DocumentModels = DocumentModels;
|
|
17
|
-
exports.default = index;
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-azT4DEce.js"),o=require("./internal/index-DLodkpOq.js");require("./internal/object-CMr-_AP8.js");require("immer");require("zod");require("jszip");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";var Tt=Object.defineProperty;var Rt=(t,e,r)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var be=(t,e,r)=>(Rt(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-CMr-_AP8.js");require("immer");require("jszip");const o=require("zod"),xt=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Mt=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Dt=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Nt=/[^\p{L}\d]+/giu,_e="$1\0$2",Ae="";function ze(t){let e=t.trim();e=e.replace(xt,_e).replace(Mt,_e),e=e.replace(Nt,"\0");let r=0,n=e.length;for(;e.charAt(r)==="\0";)r++;if(r===n)return[];for(;e.charAt(n-1)==="\0";)n--;return e.slice(r,n).split(/\0/g)}function Lt(t){const e=ze(t);for(let r=0;r<e.length;r++){const n=e[r],i=Dt.exec(n);if(i){const a=i.index+(i[1]??i[2]).length;e.splice(r,1,n.slice(0,a),n.slice(a))}}return e}function Ie(t,e){const[r,n,i]=wt(t,e),a=Pt(e==null?void 0:e.locale),l=jt(e==null?void 0:e.locale),d=e!=null&&e.mergeAmbiguousCharacters?Ct(a,l):yt(a,l);return r+n.map(d).join((e==null?void 0:e.delimiter)??"")+i}function Pt(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function jt(t){return t===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t)}function Ct(t,e){return r=>`${e(r[0])}${t(r.slice(1))}`}function yt(t,e){return(r,n)=>{const i=r[0];return(n>0&&i>="0"&&i<="9"?"_"+i:e(i))+t(r.slice(1))}}function wt(t,e={}){const r=e.split??(e.separateNumbers?Lt:ze),n=e.prefixCharacters??Ae,i=e.suffixCharacters??Ae;let a=0,l=t.length;for(;a<t.length;){const d=t.charAt(a);if(!n.includes(d))break;a++}for(;l>a;){const d=l-1,zt=t.charAt(d);if(!i.includes(zt))break;l=d}return[t.slice(0,a),r(t.slice(a,l)),t.slice(l)]}function T(t,e=!1){const r=[];if(e&&t==="")return r;try{const n=JSON.parse(t);!e&&!Object.keys(n).length&&r.push({message:"Initial state cannot be empty",details:{initialState:t}})}catch{r.push({message:"Invalid initial state",details:{initialState:t}})}return r}function R(t,e,r="",n=!0){const i=[];if(!n&&!t)return i.push({message:"State schema is required",details:{schema:t}}),i;if(n&&!t)return i;const a=`type ${Ie(e)}${Ie(r)}State`;return t.includes(a)||i.push({message:`Invalid state schema name. Expected ${a}`,details:{schema:t}}),i}function x(t){const e=[];t.length||e.push({message:"Modules are required",details:{modules:t}});const r=t.reduce((n,i)=>[...n,...b(i)],[]);return[...e,...r]}function b(t){const e=[];t.name||e.push({message:"Module name is required",details:{module:t}}),t.operations.length||e.push({message:"Module operations are required",details:{module:t}});const r=t.operations.reduce((n,i)=>[...n,..._(i)],[]);return[...e,...r]}function _(t){const e=[];return t.name||e.push({message:"Operation name is required",details:{operation:t}}),t.schema||e.push({message:"Operation schema is required",details:{operation:t}}),e}const kt=Object.freeze(Object.defineProperty({__proto__:null,validateInitialState:T,validateModule:b,validateModuleOperation:_,validateModules:x,validateStateSchemaName:R},Symbol.toStringTag,{value:"Module"})),M={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
|
|
2
|
+
"id": "",
|
|
3
|
+
"name": "",
|
|
4
|
+
"extension": "",
|
|
5
|
+
"description": "",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "",
|
|
8
|
+
"website": ""
|
|
9
|
+
},
|
|
10
|
+
"specifications": [
|
|
11
|
+
{
|
|
12
|
+
"version": 1,
|
|
13
|
+
"changeLog": [],
|
|
14
|
+
"state": {
|
|
15
|
+
"schema": "",
|
|
16
|
+
"initialValue": "",
|
|
17
|
+
"examples": []
|
|
18
|
+
},
|
|
19
|
+
"modules": []
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}`,examples:[]},local:{schema:"",initialValue:"{}",examples:[]}}}]},Te=t=>t!=null,vt=o.z.any().refine(t=>Te(t));function D(){return o.z.object({__typename:o.z.literal("AddChangeLogItemInput").optional(),content:o.z.string(),id:o.z.string(),insertBefore:o.z.string().nullable()})}function N(){return o.z.object({description:o.z.string().nullish(),id:o.z.string(),name:o.z.string()})}function L(){return o.z.object({errorCode:o.z.string().nullish(),errorDescription:o.z.string().nullish(),errorName:o.z.string().nullish(),errorTemplate:o.z.string().nullish(),id:o.z.string(),operationId:o.z.string()})}function P(){return o.z.object({example:o.z.string(),id:o.z.string(),operationId:o.z.string()})}function j(){return o.z.object({description:o.z.string().nullish(),id:o.z.string(),moduleId:o.z.string(),name:o.z.string(),reducer:o.z.string().nullish(),schema:o.z.string().nullish(),template:o.z.string().nullish(),scope:A().nullish()})}function C(){return o.z.object({scope:o.z.string(),example:o.z.string(),id:o.z.string(),insertBefore:o.z.string().nullish()})}function Re(){return o.z.object({__typename:o.z.literal("Author").optional(),name:o.z.string(),website:o.z.string().nullable()})}function y(){return o.z.object({__typename:o.z.literal("CodeExample").optional(),id:o.z.string(),value:o.z.string()})}function w(){return o.z.object({__typename:o.z.literal("DeleteChangeLogItemInput").optional(),id:o.z.string()})}function k(){return o.z.object({id:o.z.string()})}function v(){return o.z.object({id:o.z.string()})}function U(){return o.z.object({id:o.z.string()})}function F(){return o.z.object({id:o.z.string()})}function $(){return o.z.object({scope:o.z.string(),id:o.z.string()})}function A(){return o.z.literal("global").or(o.z.literal("local"))}function Ut(){return o.z.union([D(),N(),L(),P(),j(),C(),w(),k(),v(),U(),F(),$(),V(),X(),H(),G(),B(),W(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae(),pe(),le(),ce(),de(),ue(),me(),Ee(),he(),Oe()])}function Ft(){return o.z.object({__typename:o.z.literal("DocumentModelState").optional(),author:Re(),description:o.z.string(),extension:o.z.string(),id:o.z.string(),name:o.z.string(),specifications:o.z.array(xe())})}function xe(){return o.z.object({__typename:o.z.literal("DocumentSpecification").optional(),changeLog:o.z.array(o.z.string()),modules:o.z.array(Me()),state:Pe(),version:o.z.number()})}function Me(){return o.z.object({__typename:o.z.literal("Module").optional(),description:o.z.string().nullable(),id:o.z.string(),name:o.z.string(),operations:o.z.array(De())})}function V(){return o.z.object({newModuleId:o.z.string(),operationId:o.z.string()})}function De(){return o.z.object({__typename:o.z.literal("Operation").optional(),description:o.z.string().nullable(),errors:o.z.array(Ne()),examples:o.z.array(y()),id:o.z.string(),name:o.z.string().nullable(),reducer:o.z.string().nullable(),schema:o.z.string().nullable(),template:o.z.string().nullable(),scope:A()})}function Ne(){return o.z.object({__typename:o.z.literal("OperationError").optional(),code:o.z.string().nullable(),description:o.z.string().nullable(),id:o.z.string(),name:o.z.string().nullable(),template:o.z.string().nullable()})}function X(){return o.z.object({__typename:o.z.literal("ReorderChangeLogItemsInput").optional(),order:o.z.array(o.z.string())})}function H(){return o.z.object({moduleId:o.z.string(),order:o.z.array(o.z.string())})}function G(){return o.z.object({order:o.z.array(o.z.string())})}function B(){return o.z.object({operationId:o.z.string(),order:o.z.array(o.z.string())})}function W(){return o.z.object({operationId:o.z.string(),order:o.z.array(o.z.string())})}function q(){return o.z.object({scope:o.z.string(),order:o.z.array(o.z.string())})}function J(){return o.z.object({authorName:o.z.string()})}function K(){return o.z.object({authorWebsite:o.z.string()})}function Q(){return o.z.object({scope:o.z.string(),initialValue:o.z.string()})}function Y(){return o.z.object({description:o.z.string()})}function Z(){return o.z.object({extension:o.z.string()})}function ee(){return o.z.object({id:o.z.string()})}function te(){return o.z.object({name:o.z.string()})}function re(){return o.z.object({description:o.z.string().nullish(),id:o.z.string()})}function oe(){return o.z.object({id:o.z.string(),name:o.z.string().nullish()})}function ne(){return o.z.object({description:o.z.string().nullish(),id:o.z.string()})}function ie(){return o.z.object({errorCode:o.z.string().nullish(),id:o.z.string()})}function se(){return o.z.object({errorDescription:o.z.string().nullish(),id:o.z.string()})}function ae(){return o.z.object({errorName:o.z.string().nullish(),id:o.z.string()})}function pe(){return o.z.object({errorTemplate:o.z.string().nullish(),id:o.z.string()})}function le(){return o.z.object({id:o.z.string(),name:o.z.string().nullish()})}function Le(){return o.z.object({id:o.z.string(),scope:A()})}function ce(){return o.z.object({id:o.z.string(),reducer:o.z.string().nullish()})}function de(){return o.z.object({id:o.z.string(),schema:o.z.string().nullish()})}function ue(){return o.z.object({id:o.z.string(),template:o.z.string().nullish()})}function me(){return o.z.object({scope:o.z.string(),schema:o.z.string()})}function z(){return o.z.object({__typename:o.z.literal("State").optional(),examples:o.z.array(y()),initialValue:o.z.string(),schema:o.z.string()})}function Pe(){return o.z.object({global:z(),local:z()})}function Ee(){return o.z.object({__typename:o.z.literal("UpdateChangeLogItemInput").optional(),id:o.z.string(),newContent:o.z.string()})}function he(){return o.z.object({example:o.z.string(),id:o.z.string()})}function Oe(){return o.z.object({scope:o.z.string(),id:o.z.string(),newExample:o.z.string()})}const je=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:D,AddModuleInputSchema:N,AddOperationErrorInputSchema:L,AddOperationExampleInputSchema:P,AddOperationInputSchema:j,AddStateExampleInputSchema:C,AuthorSchema:Re,CodeExampleSchema:y,DeleteChangeLogItemInputSchema:w,DeleteModuleInputSchema:k,DeleteOperationErrorInputSchema:v,DeleteOperationExampleInputSchema:U,DeleteOperationInputSchema:F,DeleteStateExampleInputSchema:$,DocumentModelInputSchema:Ut,DocumentModelStateSchema:Ft,DocumentSpecificationSchema:xe,ModuleSchema:Me,MoveOperationInputSchema:V,OperationErrorSchema:Ne,OperationSchema:De,OperationScopeSchema:A,ReorderChangeLogItemsInputSchema:X,ReorderModuleOperationsInputSchema:H,ReorderModulesInputSchema:G,ReorderOperationErrorsInputSchema:B,ReorderOperationExamplesInputSchema:W,ReorderStateExamplesInputSchema:q,ScopeStateSchema:Pe,SetAuthorNameInputSchema:J,SetAuthorWebsiteInputSchema:K,SetInitialStateInputSchema:Q,SetModelDescriptionInputSchema:Y,SetModelExtensionInputSchema:Z,SetModelIdInputSchema:ee,SetModelNameInputSchema:te,SetModuleDescriptionInputSchema:re,SetModuleNameInputSchema:oe,SetOperationDescriptionInputSchema:ne,SetOperationErrorCodeInputSchema:ie,SetOperationErrorDescriptionInputSchema:se,SetOperationErrorNameInputSchema:ae,SetOperationErrorTemplateInputSchema:pe,SetOperationNameInputSchema:le,SetOperationReducerInputSchema:ce,SetOperationSchemaInputSchema:de,SetOperationScopeInputSchema:Le,SetOperationTemplateInputSchema:ue,SetStateSchemaInputSchema:me,StateSchema:z,UpdateChangeLogItemInputSchema:Ee,UpdateOperationExampleInputSchema:he,UpdateStateExampleInputSchema:Oe,definedNonNullAnySchema:vt,isDefinedNonNullAny:Te},Symbol.toStringTag,{value:"Module"})),u={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}},O={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')}},$t=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},g={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 r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id===e.input.id&&(r.modules[n].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id===e.input.id&&(r.modules[n].description=e.input.description||"")},deleteModuleOperation(t,e){const r=t.specifications[t.specifications.length-1];r.modules=r.modules.filter(n=>n.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort($t(e.input.order))}},Vt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},c={addOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].errors.push({id:e.input.id,name:e.input.errorName||"",code:e.input.errorCode||"",description:e.input.errorDescription||"",template:e.input.errorTemplate||""})},setOperationErrorCodeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].errors=r.modules[n].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].errors.sort(Vt(e.input.order))}},Xt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},f={addOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].examples.length;a++)r.modules[n].operations[i].examples[a].id==e.input.id&&(r.modules[n].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].examples=r.modules[n].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].examples.sort(Xt(e.input.order))}},Ht=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},p={addOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id==e.input.moduleId&&r.modules[n].operations.push({id:e.input.id,name:e.input.name,description:e.input.description||"",schema:e.input.schema||"",template:e.input.template||e.input.description||"",reducer:e.input.reducer||"",errors:[],examples:[],scope:e.input.scope||"global"})},setOperationNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const r=[],n=t.specifications[t.specifications.length-1];for(let i=0;i<n.modules.length;i++)n.modules[i].operations=n.modules[i].operations.filter(a=>a.id==e.input.operationId?(r.push(a),!1):!0);for(let i=0;i<n.modules.length;i++)n.modules[i].id==e.input.newModuleId&&n.modules[i].operations.push(...r)},deleteOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].operations=r.modules[n].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id==e.input.moduleId&&r.modules[n].operations.sort(Ht(e.input.order))}},Gt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},m={setStateSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].schema=e.input.schema;else throw new Error(`Invalid scope: ${e.input.scope}`)},setInitialStateOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].initialValue=e.input.initialValue;else throw new Error(`Invalid scope: ${e.input.scope}`)},addStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples.push({id:e.input.id,value:e.input.example});else throw new Error(`Invalid scope: ${e.input.scope}`)},updateStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(!Object.keys(r.state).includes(e.input.scope))throw new Error(`Invalid scope: ${e.input.scope}`);const n=r.state[e.input.scope].examples;for(let i=0;i<n.length;i++)n[i].id==e.input.id&&(n[i].value=e.input.newExample)},deleteStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples=r.state[e.input.scope].examples.filter(n=>n.id!=e.input.id);else throw new Error(`Invalid scope: ${e.input.scope}`)},reorderStateExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples.sort(Gt(e.input.order));else throw new Error(`Invalid scope: ${e.input.scope}`)}},Bt=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":te().parse(e.input),u.setModelNameOperation(t.global,e);break;case"SET_MODEL_ID":ee().parse(e.input),u.setModelIdOperation(t.global,e);break;case"SET_MODEL_EXTENSION":Z().parse(e.input),u.setModelExtensionOperation(t.global,e);break;case"SET_MODEL_DESCRIPTION":Y().parse(e.input),u.setModelDescriptionOperation(t.global,e);break;case"SET_AUTHOR_NAME":J().parse(e.input),u.setAuthorNameOperation(t.global,e);break;case"SET_AUTHOR_WEBSITE":K().parse(e.input),u.setAuthorWebsiteOperation(t.global,e);break;case"ADD_CHANGE_LOG_ITEM":D().parse(e.input),O.addChangeLogItemOperation(t.global,e);break;case"UPDATE_CHANGE_LOG_ITEM":Ee().parse(e.input),O.updateChangeLogItemOperation(t.global,e);break;case"DELETE_CHANGE_LOG_ITEM":w().parse(e.input),O.deleteChangeLogItemOperation(t.global,e);break;case"REORDER_CHANGE_LOG_ITEMS":X().parse(e.input),O.reorderChangeLogItemsOperation(t.global,e);break;case"RELEASE_NEW_VERSION":if(Object.keys(e.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");O.releaseNewVersionOperation(t.global,e);break;case"ADD_MODULE":N().parse(e.input),g.addModuleOperation(t.global,e);break;case"SET_MODULE_NAME":oe().parse(e.input),g.setModuleNameOperation(t.global,e);break;case"SET_MODULE_DESCRIPTION":re().parse(e.input),g.setModuleDescriptionOperation(t.global,e);break;case"DELETE_MODULE":k().parse(e.input),g.deleteModuleOperation(t.global,e);break;case"REORDER_MODULES":G().parse(e.input),g.reorderModulesOperation(t.global,e);break;case"ADD_OPERATION_ERROR":L().parse(e.input),c.addOperationErrorOperation(t.global,e);break;case"SET_OPERATION_ERROR_CODE":ie().parse(e.input),c.setOperationErrorCodeOperation(t.global,e);break;case"SET_OPERATION_ERROR_NAME":ae().parse(e.input),c.setOperationErrorNameOperation(t.global,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":se().parse(e.input),c.setOperationErrorDescriptionOperation(t.global,e);break;case"SET_OPERATION_ERROR_TEMPLATE":pe().parse(e.input),c.setOperationErrorTemplateOperation(t.global,e);break;case"DELETE_OPERATION_ERROR":v().parse(e.input),c.deleteOperationErrorOperation(t.global,e);break;case"REORDER_OPERATION_ERRORS":B().parse(e.input),c.reorderOperationErrorsOperation(t.global,e);break;case"ADD_OPERATION_EXAMPLE":P().parse(e.input),f.addOperationExampleOperation(t.global,e);break;case"UPDATE_OPERATION_EXAMPLE":he().parse(e.input),f.updateOperationExampleOperation(t.global,e);break;case"DELETE_OPERATION_EXAMPLE":U().parse(e.input),f.deleteOperationExampleOperation(t.global,e);break;case"REORDER_OPERATION_EXAMPLES":W().parse(e.input),f.reorderOperationExamplesOperation(t.global,e);break;case"ADD_OPERATION":j().parse(e.input),p.addOperationOperation(t.global,e);break;case"SET_OPERATION_NAME":le().parse(e.input),p.setOperationNameOperation(t.global,e);break;case"SET_OPERATION_SCOPE":Le().parse(e.input),p.setOperationScopeOperation(t.global,e);break;case"SET_OPERATION_SCHEMA":de().parse(e.input),p.setOperationSchemaOperation(t.global,e);break;case"SET_OPERATION_DESCRIPTION":ne().parse(e.input),p.setOperationDescriptionOperation(t.global,e);break;case"SET_OPERATION_TEMPLATE":ue().parse(e.input),p.setOperationTemplateOperation(t.global,e);break;case"SET_OPERATION_REDUCER":ce().parse(e.input),p.setOperationReducerOperation(t.global,e);break;case"MOVE_OPERATION":V().parse(e.input),p.moveOperationOperation(t.global,e);break;case"DELETE_OPERATION":F().parse(e.input),p.deleteOperationOperation(t.global,e);break;case"REORDER_MODULE_OPERATIONS":H().parse(e.input),p.reorderModuleOperationsOperation(t.global,e);break;case"SET_STATE_SCHEMA":me().parse(e.input),m.setStateSchemaOperation(t.global,e);break;case"SET_INITIAL_STATE":Q().parse(e.input),m.setInitialStateOperation(t.global,e);break;case"ADD_STATE_EXAMPLE":C().parse(e.input),m.addStateExampleOperation(t.global,e);break;case"UPDATE_STATE_EXAMPLE":Oe().parse(e.input),m.updateStateExampleOperation(t.global,e);break;case"DELETE_STATE_EXAMPLE":$().parse(e.input),m.deleteStateExampleOperation(t.global,e);break;case"REORDER_STATE_EXAMPLES":q().parse(e.input),m.reorderStateExamplesOperation(t.global,e);break;default:return t}},h=s.createReducer(Bt),Wt={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},qt={},S={fileExtension:"phdm",createState(t){return{global:{...Wt,...t==null?void 0:t.global},local:{...qt,...t==null?void 0:t.local}}},createExtendedState(t){return s.createExtendedState({...t,documentType:"powerhouse/document-model"},S.createState)},createDocument(t){return s.createDocument(S.createExtendedState(t),S.createState)},saveToFile(t,e,r){return s.saveToFile(t,e,"phdm",r)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,h)},loadFromInput(t){return s.loadFromInput(t,h)}},Ce=t=>s.createAction("SET_MODEL_NAME",{...t}),ye=t=>s.createAction("SET_MODEL_ID",{...t}),we=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),ke=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),ve=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Ue=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Jt extends s.BaseDocument{setModelName(e,r){return this.dispatch(Ce(e),r)}setModelId(e,r){return this.dispatch(ye(e),r)}setModelExtension(e,r){return this.dispatch(we(e),r)}setModelDescription(e,r){return this.dispatch(ke(e),r)}setAuthorName(e,r){return this.dispatch(ve(e),r)}setAuthorWebsite(e,r){return this.dispatch(Ue(e),r)}}const Fe=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),$e=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),Ve=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Xe=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),He=()=>s.createAction("RELEASE_NEW_VERSION");class Kt extends s.BaseDocument{addChangeLogItem(e,r){return this.dispatch(Fe(e),r)}updateChangeLogItem(e,r){return this.dispatch($e(e),r)}deleteChangeLogItem(e,r){return this.dispatch(Ve(e),r)}reorderChangeLogItems(e,r){return this.dispatch(Xe(e),r)}releaseNewVersion(e){return this.dispatch(He(),e)}}const Ge=t=>s.createAction("ADD_MODULE",{...t}),Be=t=>s.createAction("SET_MODULE_NAME",{...t}),We=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),qe=t=>s.createAction("DELETE_MODULE",{...t}),Je=t=>s.createAction("REORDER_MODULES",{...t});class Qt extends s.BaseDocument{addModule(e,r){return this.dispatch(Ge(e),r)}setModuleName(e,r){return this.dispatch(Be(e),r)}setModuleDescription(e,r){return this.dispatch(We(e),r)}deleteModule(e,r){return this.dispatch(qe(e),r)}reorderModules(e,r){return this.dispatch(Je(e),r)}}const Ke=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),Qe=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),Ye=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),Ze=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),et=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),tt=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),rt=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Yt extends s.BaseDocument{addOperationError(e,r){return this.dispatch(Ke(e),r)}setOperationErrorCode(e,r){return this.dispatch(Qe(e),r)}setOperationErrorName(e,r){return this.dispatch(Ye(e),r)}setOperationErrorDescription(e,r){return this.dispatch(Ze(e),r)}setOperationErrorTemplate(e,r){return this.dispatch(et(e),r)}deleteOperationError(e,r){return this.dispatch(tt(e),r)}reorderOperationErrors(e,r){return this.dispatch(rt(e),r)}}const ot=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),nt=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),it=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),st=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Zt extends s.BaseDocument{addOperationExample(e,r){return this.dispatch(ot(e),r)}updateOperationExample(e,r){return this.dispatch(nt(e),r)}deleteOperationExample(e,r){return this.dispatch(it(e),r)}reorderOperationExamples(e,r){return this.dispatch(st(e),r)}}const at=t=>s.createAction("ADD_OPERATION",{...t}),pt=t=>s.createAction("SET_OPERATION_NAME",{...t}),lt=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),ct=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),dt=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),ut=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),mt=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),Et=t=>s.createAction("MOVE_OPERATION",{...t}),ht=t=>s.createAction("DELETE_OPERATION",{...t}),Ot=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class er extends s.BaseDocument{addOperation(e,r){return this.dispatch(at(e),r)}setOperationName(e,r){return this.dispatch(pt(e),r)}setOperationScope(e,r){return this.dispatch(lt(e),r)}setOperationSchema(e,r){return this.dispatch(ct(e),r)}setOperationDescription(e,r){return this.dispatch(dt(e),r)}setOperationTemplate(e,r){return this.dispatch(ut(e),r)}setOperationReducer(e,r){return this.dispatch(mt(e),r)}moveOperation(e,r){return this.dispatch(Et(e),r)}deleteOperation(e,r){return this.dispatch(ht(e),r)}reorderModuleOperations(e,r){return this.dispatch(Ot(e),r)}}const gt=t=>s.createAction("SET_STATE_SCHEMA",{...t}),St=t=>s.createAction("SET_INITIAL_STATE",{...t}),ft=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),bt=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),_t=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),At=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class tr extends s.BaseDocument{setStateSchema(e,r){return this.dispatch(gt(e),r)}setInitialState(e,r){return this.dispatch(St(e),r)}addStateExample(e,r){return this.dispatch(ft(e),r)}updateStateExample(e,r){return this.dispatch(bt(e),r)}deleteStateExample(e,r){return this.dispatch(_t(e),r)}reorderStateExamples(e,r){return this.dispatch(At(e),r)}}var E;let I=(E=class extends s.BaseDocument{constructor(e,r){super(h,S.createDocument(e),r)}saveToFile(e,r){return super.saveToFile(e,E.fileExtension,r)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const r=new this;return await r.loadFromFile(e),r}},be(E,"fileExtension","phdm"),E);s.applyMixins(I,[Jt,Kt,Qt,Yt,Zt,er,tr]);const rr=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:Fe,addModule:Ge,addOperation:at,addOperationError:Ke,addOperationExample:ot,addStateExample:ft,deleteChangeLogItem:Ve,deleteModule:qe,deleteOperation:ht,deleteOperationError:tt,deleteOperationExample:it,deleteStateExample:_t,moveOperation:Et,releaseNewVersion:He,reorderChangeLogItems:Xe,reorderModuleOperations:Ot,reorderModules:Je,reorderOperationErrors:rt,reorderOperationExamples:st,reorderStateExamples:At,setAuthorName:ve,setAuthorWebsite:Ue,setInitialState:St,setModelDescription:ke,setModelExtension:we,setModelId:ye,setModelName:Ce,setModuleDescription:We,setModuleName:Be,setOperationDescription:dt,setOperationErrorCode:Qe,setOperationErrorDescription:Ze,setOperationErrorName:Ye,setOperationErrorTemplate:et,setOperationName:pt,setOperationReducer:mt,setOperationSchema:ct,setOperationScope:lt,setOperationTemplate:ut,setStateSchema:gt,updateChangeLogItem:$e,updateOperationExample:nt,updateStateExample:bt},Symbol.toStringTag,{value:"Module"})),ge=I,Se={...S,...kt},fe={...s.BaseActions,...rr},It={Document:ge,reducer:h,actions:fe,utils:Se,documentModel:M},or=Object.freeze(Object.defineProperty({__proto__:null,Document:ge,DocumentModel:I,actions:fe,documentModel:M,module:It,reducer:h,utils:Se,validateInitialState:T,validateModule:b,validateModuleOperation:_,validateModules:x,validateStateSchemaName:R,z:je},Symbol.toStringTag,{value:"Module"}));exports.Document=ge;exports.DocumentModel=or;exports.DocumentModel$1=I;exports.actions=fe;exports.documentModel=M;exports.module=It;exports.reducer=h;exports.utils=Se;exports.validateInitialState=T;exports.validateModule=b;exports.validateModuleOperation=_;exports.validateModules=x;exports.validateStateSchemaName=R;exports.zod=je;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("./object-CMr-_AP8.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,documentHelpers:e.documentHelpers,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,parseResultingState:e.parseResultingState,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";var Ye=Object.defineProperty;var Qe=(r,i,o)=>i in r?Ye(r,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[i]=o;var Ot=(r,i,o)=>(Qe(r,typeof i!="symbol"?i+"":i,o),o);const nt=require("immer"),_=require("zod"),pe=require("jszip"),ce=r=>r!=null,tr=_.z.any().refine(r=>ce(r)),le=_.z.enum(["LOAD_STATE"]),ue=_.z.enum(["PRUNE"]),fe=_.z.enum(["REDO"]),he=_.z.enum(["SET_NAME"]),me=_.z.enum(["UNDO"]);function er(){return _.z.object({__typename:_.z.literal("Action").optional(),type:_.z.string()})}function Et(){return _.z.literal("global").or(_.z.literal("local"))}function xe(){return _.z.union([de(),ye(),we(),Ee(),be()])}function rr(){return _.z.object({__typename:_.z.literal("DocumentFile").optional(),data:_.z.string(),extension:_.z.string().nullable(),fileName:_.z.string().nullable(),mimeType:_.z.string()})}function de(){return _.z.object({input:_.z.lazy(()=>Ht()),type:le,scope:Et()})}function Ht(){return _.z.object({operations:_.z.number(),state:_.z.lazy(()=>ge())})}function ge(){return _.z.object({data:_.z.unknown().nullish(),name:_.z.string()})}function ir(){return _.z.object({__typename:_.z.literal("Operation").optional(),hash:_.z.string(),index:_.z.number(),timestamp:_.z.string().datetime(),type:_.z.string()})}function ye(){return _.z.object({input:_.z.lazy(()=>Jt()),type:ue,scope:Et()})}function Jt(){return _.z.object({end:_.z.number().nullish(),start:_.z.number().nullish()})}const Wt=_.z.number;function we(){return _.z.object({input:Wt(),type:fe,scope:Et()})}const Xt=_.z.string;function Ee(){return _.z.object({input:Xt(),type:he,scope:_.z.literal("global")})}function nr(){return _.z.object({__typename:_.z.literal("SetNameOperation").optional(),hash:_.z.string(),index:_.z.number(),input:_.z.string(),timestamp:_.z.string().datetime(),type:_.z.string()})}const Vt=_.z.number;function be(){return _.z.object({input:Vt(),type:me,scope:Et()})}const or=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:er,BaseActionSchema:xe,DocumentFileSchema:rr,LoadStateActionInputSchema:Ht,LoadStateActionSchema:de,LoadStateActionStateInputSchema:ge,Load_StateSchema:le,OperationSchema:ir,OperationScopeSchema:Et,PruneActionInputSchema:Jt,PruneActionSchema:ye,PruneSchema:ue,RedoActionInputSchema:Wt,RedoActionSchema:we,RedoSchema:fe,SetNameActionInputSchema:Xt,SetNameActionSchema:Ee,SetNameOperationSchema:nr,Set_NameSchema:he,UndoActionInputSchema:Vt,UndoActionSchema:be,UndoSchema:me,definedNonNullAnySchema:tr,isDefinedNonNullAny:ce},Symbol.toStringTag,{value:"Module"}));function Kt(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var zt={exports:{}};(function(r,i){const{hasOwnProperty:o}=Object.prototype,p=Z();p.configure=Z,p.stringify=p,p.default=p,i.stringify=p,i.configure=Z,r.exports=p;const u=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function f(w){return w.length<5e3&&!u.test(w)?`"${w}"`:JSON.stringify(w)}function c(w){if(w.length>200)return w.sort();for(let E=1;E<w.length;E++){const S=w[E];let M=E;for(;M!==0&&w[M-1]>S;)w[M]=w[M-1],M--;w[M]=S}return w}const s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function h(w){return s.call(w)!==void 0&&w.length!==0}function g(w,E,S){w.length<S&&(S=w.length);const M=E===","?"":" ";let J=`"0":${M}${w[0]}`;for(let W=1;W<S;W++)J+=`${E}"${W}":${M}${w[W]}`;return J}function y(w){if(o.call(w,"circularValue")){const E=w.circularValue;if(typeof E=="string")return`"${E}"`;if(E==null)return E;if(E===Error||E===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function b(w,E){let S;if(o.call(w,E)&&(S=w[E],typeof S!="boolean"))throw new TypeError(`The "${E}" argument must be of type boolean`);return S===void 0?!0:S}function F(w,E){let S;if(o.call(w,E)){if(S=w[E],typeof S!="number")throw new TypeError(`The "${E}" argument must be of type number`);if(!Number.isInteger(S))throw new TypeError(`The "${E}" argument must be an integer`);if(S<1)throw new RangeError(`The "${E}" argument must be >= 1`)}return S===void 0?1/0:S}function j(w){return w===1?"1 item":`${w} items`}function $(w){const E=new Set;for(const S of w)(typeof S=="string"||typeof S=="number")&&E.add(String(S));return E}function q(w){if(o.call(w,"strict")){const E=w.strict;if(typeof E!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(E)return S=>{let M=`Object can not safely be stringified. Received type ${typeof S}`;throw typeof S!="function"&&(M+=` (${S.toString()})`),new Error(M)}}}function Z(w){w={...w};const E=q(w);E&&(w.bigint===void 0&&(w.bigint=!1),"circularValue"in w||(w.circularValue=Error));const S=y(w),M=b(w,"bigint"),J=b(w,"deterministic"),W=F(w,"maximumDepth"),z=F(w,"maximumBreadth");function ht(X,m,v,D,B,U){let A=m[X];switch(typeof A=="object"&&A!==null&&typeof A.toJSON=="function"&&(A=A.toJSON(X)),A=D.call(m,X,A),typeof A){case"string":return f(A);case"object":{if(A===null)return"null";if(v.indexOf(A)!==-1)return S;let T="",O=",";const I=U;if(Array.isArray(A)){if(A.length===0)return"[]";if(W<v.length+1)return'"[Array]"';v.push(A),B!==""&&(U+=B,T+=`
|
|
2
|
+
${U}`,O=`,
|
|
3
|
+
${U}`);const V=Math.min(A.length,z);let Q=0;for(;Q<V-1;Q++){const lt=ht(String(Q),A,v,D,B,U);T+=lt!==void 0?lt:"null",T+=O}const tt=ht(String(Q),A,v,D,B,U);if(T+=tt!==void 0?tt:"null",A.length-1>z){const lt=A.length-z-1;T+=`${O}"... ${j(lt)} not stringified"`}return B!==""&&(T+=`
|
|
4
|
+
${I}`),v.pop(),`[${T}]`}let R=Object.keys(A);const H=R.length;if(H===0)return"{}";if(W<v.length+1)return'"[Object]"';let C="",K="";B!==""&&(U+=B,O=`,
|
|
5
|
+
${U}`,C=" ");const Y=Math.min(H,z);J&&!h(A)&&(R=c(R)),v.push(A);for(let V=0;V<Y;V++){const Q=R[V],tt=ht(Q,A,v,D,B,U);tt!==void 0&&(T+=`${K}${f(Q)}:${C}${tt}`,K=O)}if(H>z){const V=H-z;T+=`${K}"...":${C}"${j(V)} not stringified"`,K=O}return B!==""&&K.length>1&&(T=`
|
|
6
|
+
${U}${T}
|
|
7
|
+
${I}`),v.pop(),`{${T}}`}case"number":return isFinite(A)?String(A):E?E(A):"null";case"boolean":return A===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(A);default:return E?E(A):void 0}}function mt(X,m,v,D,B,U){switch(typeof m=="object"&&m!==null&&typeof m.toJSON=="function"&&(m=m.toJSON(X)),typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(v.indexOf(m)!==-1)return S;const A=U;let T="",O=",";if(Array.isArray(m)){if(m.length===0)return"[]";if(W<v.length+1)return'"[Array]"';v.push(m),B!==""&&(U+=B,T+=`
|
|
8
|
+
${U}`,O=`,
|
|
9
|
+
${U}`);const H=Math.min(m.length,z);let C=0;for(;C<H-1;C++){const Y=mt(String(C),m[C],v,D,B,U);T+=Y!==void 0?Y:"null",T+=O}const K=mt(String(C),m[C],v,D,B,U);if(T+=K!==void 0?K:"null",m.length-1>z){const Y=m.length-z-1;T+=`${O}"... ${j(Y)} not stringified"`}return B!==""&&(T+=`
|
|
10
|
+
${A}`),v.pop(),`[${T}]`}v.push(m);let I="";B!==""&&(U+=B,O=`,
|
|
11
|
+
${U}`,I=" ");let R="";for(const H of D){const C=mt(H,m[H],v,D,B,U);C!==void 0&&(T+=`${R}${f(H)}:${I}${C}`,R=O)}return B!==""&&R.length>1&&(T=`
|
|
12
|
+
${U}${T}
|
|
13
|
+
${A}`),v.pop(),`{${T}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(m);default:return E?E(m):void 0}}function pt(X,m,v,D,B){switch(typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(X),typeof m!="object")return pt(X,m,v,D,B);if(m===null)return"null"}if(v.indexOf(m)!==-1)return S;const U=B;if(Array.isArray(m)){if(m.length===0)return"[]";if(W<v.length+1)return'"[Array]"';v.push(m),B+=D;let C=`
|
|
14
|
+
${B}`;const K=`,
|
|
15
|
+
${B}`,Y=Math.min(m.length,z);let V=0;for(;V<Y-1;V++){const tt=pt(String(V),m[V],v,D,B);C+=tt!==void 0?tt:"null",C+=K}const Q=pt(String(V),m[V],v,D,B);if(C+=Q!==void 0?Q:"null",m.length-1>z){const tt=m.length-z-1;C+=`${K}"... ${j(tt)} not stringified"`}return C+=`
|
|
16
|
+
${U}`,v.pop(),`[${C}]`}let A=Object.keys(m);const T=A.length;if(T===0)return"{}";if(W<v.length+1)return'"[Object]"';B+=D;const O=`,
|
|
17
|
+
${B}`;let I="",R="",H=Math.min(T,z);h(m)&&(I+=g(m,O,z),A=A.slice(m.length),H-=m.length,R=O),J&&(A=c(A)),v.push(m);for(let C=0;C<H;C++){const K=A[C],Y=pt(K,m[K],v,D,B);Y!==void 0&&(I+=`${R}${f(K)}: ${Y}`,R=O)}if(T>z){const C=T-z;I+=`${R}"...": "${j(C)} not stringified"`,R=O}return R!==""&&(I=`
|
|
18
|
+
${B}${I}
|
|
19
|
+
${U}`),v.pop(),`{${I}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(m);default:return E?E(m):void 0}}function ct(X,m,v){switch(typeof m){case"string":return f(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(X),typeof m!="object")return ct(X,m,v);if(m===null)return"null"}if(v.indexOf(m)!==-1)return S;let D="";if(Array.isArray(m)){if(m.length===0)return"[]";if(W<v.length+1)return'"[Array]"';v.push(m);const O=Math.min(m.length,z);let I=0;for(;I<O-1;I++){const H=ct(String(I),m[I],v);D+=H!==void 0?H:"null",D+=","}const R=ct(String(I),m[I],v);if(D+=R!==void 0?R:"null",m.length-1>z){const H=m.length-z-1;D+=`,"... ${j(H)} not stringified"`}return v.pop(),`[${D}]`}let B=Object.keys(m);const U=B.length;if(U===0)return"{}";if(W<v.length+1)return'"[Object]"';let A="",T=Math.min(U,z);h(m)&&(D+=g(m,",",z),B=B.slice(m.length),T-=m.length,A=","),J&&(B=c(B)),v.push(m);for(let O=0;O<T;O++){const I=B[O],R=ct(I,m[I],v);R!==void 0&&(D+=`${A}${f(I)}:${R}`,A=",")}if(U>z){const O=U-z;D+=`${A}"...":"${j(O)} not stringified"`}return v.pop(),`{${D}}`}case"number":return isFinite(m)?String(m):E?E(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(M)return String(m);default:return E?E(m):void 0}}function Ut(X,m,v){if(arguments.length>1){let D="";if(typeof v=="number"?D=" ".repeat(Math.min(v,10)):typeof v=="string"&&(D=v.slice(0,10)),m!=null){if(typeof m=="function")return ht("",{"":X},[],m,D,"");if(Array.isArray(m))return mt("",X,[],$(m),D,"")}if(D.length!==0)return pt("",X,[],D,"")}return ct("",X,[])}return Ut}})(zt,zt.exports);var ar=zt.exports;const gt=Kt(ar);gt.configure;function sr(r,i){return{...r,name:i}}function pr(r,i,o){const{scope:p,input:u}=i,f={document:r,action:i,skip:o};return nt.produce(f,c=>{if(c.document.operations[p].length<1)throw new Error(`Cannot undo: no operations in history for scope "${p}"`);if(u<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(c.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const s=c.document.operations[p].at(-1),h=s&&s.type==="NOOP"&&s.skip>0;if(c.skip+=u,h){c.skip+=s.skip;const F=c.document.operations[p][c.document.operations[p].length-2];F&&s.index-F.index===1&&c.document.operations[p].pop()}if(c.document.operations[p].length<c.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const g=c.document.operations[p].length-1;let y=u,b=h?g-s.skip:g;for(;y>0&&b>=0;){const F=c.document.operations[p][b];if(!F){y--,b--;continue}F.type==="NOOP"&&F.skip>0?(b=b-(F.skip+1),c.skip+=F.skip+1):(c.document.clipboard.push({...F}),y--,b--)}c.action=Ge(p)})}function cr(r,i,o){const{scope:p,input:u}=i,f={document:r,action:i,skip:o};return nt.produce(f,c=>{if(c.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(u>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(u<1)throw new Error("Invalid REDO action: invalid redo input value");if(c.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const s=c.document.clipboard.findLastIndex(g=>g.scope===p);if(s<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${p}"`);const h=c.document.clipboard.splice(s,1)[0];c.action=nt.castDraft({type:h.type,scope:h.scope,input:h.input})})}function lr(r,i,o){const{scope:p}=i,u=r.operations[p];let{input:{start:f,end:c}}=i;f=f||0,c=c||u.length;const s=u.slice(f,c),h=u.slice(0,f),g=u.slice(c),y=Bt(r.initialState,{...r.operations,[p]:h.concat(s)},o),{name:b,state:F}=y,j=h.length,$=h.length?h[h.length-1].timestamp:g.length?g[0].timestamp:new Date().toISOString();return Bt(r.initialState,{...r.operations,[p]:[...h,{...oe({name:b,state:F},s.length),timestamp:$,index:j,hash:kt({state:F},"global")},...g.map((q,Z)=>({...q,index:j+Z+1}))]},o)}function ur(r,i){return{...r,name:i.name,state:i.state??{global:{},local:{}}}}const Se="SET_NAME",bt="UNDO",St="REDO",It="PRUNE",ve="LOAD_STATE",fr="NOOP",_e={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"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/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"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/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"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"],"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/media-policy-dataset+xml":["mpf"],"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":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"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-keys":["asc"],"application/pgp-signature":["sig","*asc"],"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/sql":["sql"],"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/watcherinfo+xml":["wif"],"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/xfdf":["xfdf"],"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/aac":["adts","aac"],"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/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"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","jpgm"],"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/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"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/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"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/wgsl":["wgsl"],"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"]};Object.freeze(_e);var et=function(r,i,o,p){if(o==="a"&&!p)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?r!==i||!p:!i.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return o==="m"?p:o==="a"?p.call(r):p?p.value:i.get(r)},dt,yt,ut;class hr{constructor(...i){dt.set(this,new Map),yt.set(this,new Map),ut.set(this,new Map);for(const o of i)this.define(o)}define(i,o=!1){for(let[p,u]of Object.entries(i)){p=p.toLowerCase(),u=u.map(s=>s.toLowerCase()),et(this,ut,"f").has(p)||et(this,ut,"f").set(p,new Set);const f=et(this,ut,"f").get(p);let c=!0;for(let s of u){const h=s.startsWith("*");if(s=h?s.slice(1):s,f==null||f.add(s),c&&et(this,yt,"f").set(p,s),c=!1,h)continue;const g=et(this,dt,"f").get(s);if(g&&g!=p&&!o)throw new Error(`"${p} -> ${s}" conflicts with "${g} -> ${s}". Pass \`force=true\` to override this definition.`);et(this,dt,"f").set(s,p)}}return this}getType(i){if(typeof i!="string")return null;const o=i.replace(/^.*[/\\]/,"").toLowerCase(),p=o.replace(/^.*\./,"").toLowerCase(),u=o.length<i.length;return!(p.length<o.length-1)&&u?null:et(this,dt,"f").get(p)??null}getExtension(i){var o;return typeof i!="string"?null:(i=(o=i==null?void 0:i.split)==null?void 0:o.call(i,";")[0],(i&&et(this,yt,"f").get(i.trim().toLowerCase()))??null)}getAllExtensions(i){return typeof i!="string"?null:et(this,ut,"f").get(i.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const i of et(this,ut,"f").values())Object.freeze(i);return this}_getTestState(){return{types:et(this,dt,"f"),extensions:et(this,yt,"f")}}}dt=new WeakMap,yt=new WeakMap,ut=new WeakMap;const mr=new hr(_e)._freeze();var Mt={exports:{}};typeof Object.create=="function"?Mt.exports=function(i,o){o&&(i.super_=o,i.prototype=Object.create(o.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}))}:Mt.exports=function(i,o){if(o){i.super_=o;var p=function(){};p.prototype=o.prototype,i.prototype=new p,i.prototype.constructor=i}};var Ae=Mt.exports,Rt={exports:{}},Fe={},jt={};jt.byteLength=gr;jt.toByteArray=wr;jt.fromByteArray=Sr;var ot=[],rt=[],xr=typeof Uint8Array<"u"?Uint8Array:Array,$t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var xt=0,dr=$t.length;xt<dr;++xt)ot[xt]=$t[xt],rt[$t.charCodeAt(xt)]=xt;rt[45]=62;rt[95]=63;function Oe(r){var i=r.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=r.indexOf("=");o===-1&&(o=i);var p=o===i?0:4-o%4;return[o,p]}function gr(r){var i=Oe(r),o=i[0],p=i[1];return(o+p)*3/4-p}function yr(r,i,o){return(i+o)*3/4-o}function wr(r){var i,o=Oe(r),p=o[0],u=o[1],f=new xr(yr(r,p,u)),c=0,s=u>0?p-4:p,h;for(h=0;h<s;h+=4)i=rt[r.charCodeAt(h)]<<18|rt[r.charCodeAt(h+1)]<<12|rt[r.charCodeAt(h+2)]<<6|rt[r.charCodeAt(h+3)],f[c++]=i>>16&255,f[c++]=i>>8&255,f[c++]=i&255;return u===2&&(i=rt[r.charCodeAt(h)]<<2|rt[r.charCodeAt(h+1)]>>4,f[c++]=i&255),u===1&&(i=rt[r.charCodeAt(h)]<<10|rt[r.charCodeAt(h+1)]<<4|rt[r.charCodeAt(h+2)]>>2,f[c++]=i>>8&255,f[c++]=i&255),f}function Er(r){return ot[r>>18&63]+ot[r>>12&63]+ot[r>>6&63]+ot[r&63]}function br(r,i,o){for(var p,u=[],f=i;f<o;f+=3)p=(r[f]<<16&16711680)+(r[f+1]<<8&65280)+(r[f+2]&255),u.push(Er(p));return u.join("")}function Sr(r){for(var i,o=r.length,p=o%3,u=[],f=16383,c=0,s=o-p;c<s;c+=f)u.push(br(r,c,c+f>s?s:c+f));return p===1?(i=r[o-1],u.push(ot[i>>2]+ot[i<<4&63]+"==")):p===2&&(i=(r[o-2]<<8)+r[o-1],u.push(ot[i>>10]+ot[i>>4&63]+ot[i<<2&63]+"=")),u.join("")}var Gt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Gt.read=function(r,i,o,p,u){var f,c,s=u*8-p-1,h=(1<<s)-1,g=h>>1,y=-7,b=o?u-1:0,F=o?-1:1,j=r[i+b];for(b+=F,f=j&(1<<-y)-1,j>>=-y,y+=s;y>0;f=f*256+r[i+b],b+=F,y-=8);for(c=f&(1<<-y)-1,f>>=-y,y+=p;y>0;c=c*256+r[i+b],b+=F,y-=8);if(f===0)f=1-g;else{if(f===h)return c?NaN:(j?-1:1)*(1/0);c=c+Math.pow(2,p),f=f-g}return(j?-1:1)*c*Math.pow(2,f-p)};Gt.write=function(r,i,o,p,u,f){var c,s,h,g=f*8-u-1,y=(1<<g)-1,b=y>>1,F=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,j=p?0:f-1,$=p?1:-1,q=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(s=isNaN(i)?1:0,c=y):(c=Math.floor(Math.log(i)/Math.LN2),i*(h=Math.pow(2,-c))<1&&(c--,h*=2),c+b>=1?i+=F/h:i+=F*Math.pow(2,1-b),i*h>=2&&(c++,h/=2),c+b>=y?(s=0,c=y):c+b>=1?(s=(i*h-1)*Math.pow(2,u),c=c+b):(s=i*Math.pow(2,b-1)*Math.pow(2,u),c=0));u>=8;r[o+j]=s&255,j+=$,s/=256,u-=8);for(c=c<<u|s,g+=u;g>0;r[o+j]=c&255,j+=$,c/=256,g-=8);r[o+j-$]|=q*128};/*!
|
|
20
|
+
* The buffer module from node.js, for the browser.
|
|
21
|
+
*
|
|
22
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
23
|
+
* @license MIT
|
|
24
|
+
*/(function(r){var i=jt,o=Gt,p=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=s,r.SlowBuffer=E,r.INSPECT_MAX_BYTES=50;var u=2147483647;r.kMaxLength=u,s.TYPED_ARRAY_SUPPORT=f(),!s.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 f(){try{var n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function c(n){if(n>u)throw new RangeError('The value "'+n+'" is invalid for option "size"');var t=new Uint8Array(n);return Object.setPrototypeOf(t,s.prototype),t}function s(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(n)}return h(n,t,e)}s.poolSize=8192;function h(n,t,e){if(typeof n=="string")return F(n,t);if(ArrayBuffer.isView(n))return $(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(it(n,ArrayBuffer)||n&&it(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(it(n,SharedArrayBuffer)||n&&it(n.buffer,SharedArrayBuffer)))return q(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var a=n.valueOf&&n.valueOf();if(a!=null&&a!==n)return s.from(a,t,e);var l=Z(n);if(l)return l;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return s.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}s.from=function(n,t,e){return h(n,t,e)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function g(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function y(n,t,e){return g(n),n<=0?c(n):t!==void 0?typeof e=="string"?c(n).fill(t,e):c(n).fill(t):c(n)}s.alloc=function(n,t,e){return y(n,t,e)};function b(n){return g(n),c(n<0?0:w(n)|0)}s.allocUnsafe=function(n){return b(n)},s.allocUnsafeSlow=function(n){return b(n)};function F(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=S(n,t)|0,a=c(e),l=a.write(n,t);return l!==e&&(a=a.slice(0,l)),a}function j(n){for(var t=n.length<0?0:w(n.length)|0,e=c(t),a=0;a<t;a+=1)e[a]=n[a]&255;return e}function $(n){if(it(n,Uint8Array)){var t=new Uint8Array(n);return q(t.buffer,t.byteOffset,t.byteLength)}return j(n)}function q(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var a;return t===void 0&&e===void 0?a=new Uint8Array(n):e===void 0?a=new Uint8Array(n,t):a=new Uint8Array(n,t,e),Object.setPrototypeOf(a,s.prototype),a}function Z(n){if(s.isBuffer(n)){var t=w(n.length)|0,e=c(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Ct(n.length)?c(0):j(n);if(n.type==="Buffer"&&Array.isArray(n.data))return j(n.data)}function w(n){if(n>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return n|0}function E(n){return+n!=n&&(n=0),s.alloc(+n)}s.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==s.prototype},s.compare=function(t,e){if(it(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),it(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var a=t.length,l=e.length,x=0,d=Math.min(a,l);x<d;++x)if(t[x]!==e[x]){a=t[x],l=e[x];break}return a<l?-1:l<a?1:0},s.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}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return s.alloc(0);var a;if(e===void 0)for(e=0,a=0;a<t.length;++a)e+=t[a].length;var l=s.allocUnsafe(e),x=0;for(a=0;a<t.length;++a){var d=t[a];if(it(d,Uint8Array))x+d.length>l.length?s.from(d).copy(l,x):Uint8Array.prototype.set.call(l,d,x);else if(s.isBuffer(d))d.copy(l,x);else throw new TypeError('"list" argument must be an Array of Buffers');x+=d.length}return l};function S(n,t){if(s.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||it(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,a=arguments.length>2&&arguments[2]===!0;if(!a&&e===0)return 0;for(var l=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return V(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return lt(n).length;default:if(l)return a?-1:V(n).length;t=(""+t).toLowerCase(),l=!0}}s.byteLength=S;function M(n,t,e){var a=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return A(this,t,e);case"utf8":case"utf-8":return m(this,t,e);case"ascii":return B(this,t,e);case"latin1":case"binary":return U(this,t,e);case"base64":return X(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),a=!0}}s.prototype._isBuffer=!0;function J(n,t,e){var a=n[t];n[t]=n[e],n[e]=a}s.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 e=0;e<t;e+=2)J(this,e,e+1);return this},s.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 e=0;e<t;e+=4)J(this,e,e+3),J(this,e+1,e+2);return this},s.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 e=0;e<t;e+=8)J(this,e,e+7),J(this,e+1,e+6),J(this,e+2,e+5),J(this,e+3,e+4);return this},s.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?m(this,0,t):M.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:s.compare(this,t)===0},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},p&&(s.prototype[p]=s.prototype.inspect),s.prototype.compare=function(t,e,a,l,x){if(it(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),a===void 0&&(a=t?t.length:0),l===void 0&&(l=0),x===void 0&&(x=this.length),e<0||a>t.length||l<0||x>this.length)throw new RangeError("out of range index");if(l>=x&&e>=a)return 0;if(l>=x)return-1;if(e>=a)return 1;if(e>>>=0,a>>>=0,l>>>=0,x>>>=0,this===t)return 0;for(var d=x-l,k=a-e,N=Math.min(d,k),L=this.slice(l,x),G=t.slice(e,a),P=0;P<N;++P)if(L[P]!==G[P]){d=L[P],k=G[P];break}return d<k?-1:k<d?1:0};function W(n,t,e,a,l){if(n.length===0)return-1;if(typeof e=="string"?(a=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Ct(e)&&(e=l?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(l)return-1;e=n.length-1}else if(e<0)if(l)e=0;else return-1;if(typeof t=="string"&&(t=s.from(t,a)),s.isBuffer(t))return t.length===0?-1:z(n,t,e,a,l);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?l?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):z(n,[t],e,a,l);throw new TypeError("val must be string, number or Buffer")}function z(n,t,e,a,l){var x=1,d=n.length,k=t.length;if(a!==void 0&&(a=String(a).toLowerCase(),a==="ucs2"||a==="ucs-2"||a==="utf16le"||a==="utf-16le")){if(n.length<2||t.length<2)return-1;x=2,d/=2,k/=2,e/=2}function N(ae,se){return x===1?ae[se]:ae.readUInt16BE(se*x)}var L;if(l){var G=-1;for(L=e;L<d;L++)if(N(n,L)===N(t,G===-1?0:L-G)){if(G===-1&&(G=L),L-G+1===k)return G*x}else G!==-1&&(L-=L-G),G=-1}else for(e+k>d&&(e=d-k),L=e;L>=0;L--){for(var P=!0,Ft=0;Ft<k;Ft++)if(N(n,L+Ft)!==N(t,Ft)){P=!1;break}if(P)return L}return-1}s.prototype.includes=function(t,e,a){return this.indexOf(t,e,a)!==-1},s.prototype.indexOf=function(t,e,a){return W(this,t,e,a,!0)},s.prototype.lastIndexOf=function(t,e,a){return W(this,t,e,a,!1)};function ht(n,t,e,a){e=Number(e)||0;var l=n.length-e;a?(a=Number(a),a>l&&(a=l)):a=l;var x=t.length;a>x/2&&(a=x/2);for(var d=0;d<a;++d){var k=parseInt(t.substr(d*2,2),16);if(Ct(k))return d;n[e+d]=k}return d}function mt(n,t,e,a){return At(V(t,n.length-e),n,e,a)}function pt(n,t,e,a){return At(Q(t),n,e,a)}function ct(n,t,e,a){return At(lt(t),n,e,a)}function Ut(n,t,e,a){return At(tt(t,n.length-e),n,e,a)}s.prototype.write=function(t,e,a,l){if(e===void 0)l="utf8",a=this.length,e=0;else if(a===void 0&&typeof e=="string")l=e,a=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(a)?(a=a>>>0,l===void 0&&(l="utf8")):(l=a,a=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var x=this.length-e;if((a===void 0||a>x)&&(a=x),t.length>0&&(a<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");l||(l="utf8");for(var d=!1;;)switch(l){case"hex":return ht(this,t,e,a);case"utf8":case"utf-8":return mt(this,t,e,a);case"ascii":case"latin1":case"binary":return pt(this,t,e,a);case"base64":return ct(this,t,e,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ut(this,t,e,a);default:if(d)throw new TypeError("Unknown encoding: "+l);l=(""+l).toLowerCase(),d=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function X(n,t,e){return t===0&&e===n.length?i.fromByteArray(n):i.fromByteArray(n.slice(t,e))}function m(n,t,e){e=Math.min(n.length,e);for(var a=[],l=t;l<e;){var x=n[l],d=null,k=x>239?4:x>223?3:x>191?2:1;if(l+k<=e){var N,L,G,P;switch(k){case 1:x<128&&(d=x);break;case 2:N=n[l+1],(N&192)===128&&(P=(x&31)<<6|N&63,P>127&&(d=P));break;case 3:N=n[l+1],L=n[l+2],(N&192)===128&&(L&192)===128&&(P=(x&15)<<12|(N&63)<<6|L&63,P>2047&&(P<55296||P>57343)&&(d=P));break;case 4:N=n[l+1],L=n[l+2],G=n[l+3],(N&192)===128&&(L&192)===128&&(G&192)===128&&(P=(x&15)<<18|(N&63)<<12|(L&63)<<6|G&63,P>65535&&P<1114112&&(d=P))}}d===null?(d=65533,k=1):d>65535&&(d-=65536,a.push(d>>>10&1023|55296),d=56320|d&1023),a.push(d),l+=k}return D(a)}var v=4096;function D(n){var t=n.length;if(t<=v)return String.fromCharCode.apply(String,n);for(var e="",a=0;a<t;)e+=String.fromCharCode.apply(String,n.slice(a,a+=v));return e}function B(n,t,e){var a="";e=Math.min(n.length,e);for(var l=t;l<e;++l)a+=String.fromCharCode(n[l]&127);return a}function U(n,t,e){var a="";e=Math.min(n.length,e);for(var l=t;l<e;++l)a+=String.fromCharCode(n[l]);return a}function A(n,t,e){var a=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>a)&&(e=a);for(var l="",x=t;x<e;++x)l+=Ze[n[x]];return l}function T(n,t,e){for(var a=n.slice(t,e),l="",x=0;x<a.length-1;x+=2)l+=String.fromCharCode(a[x]+a[x+1]*256);return l}s.prototype.slice=function(t,e){var a=this.length;t=~~t,e=e===void 0?a:~~e,t<0?(t+=a,t<0&&(t=0)):t>a&&(t=a),e<0?(e+=a,e<0&&(e=0)):e>a&&(e=a),e<t&&(e=t);var l=this.subarray(t,e);return Object.setPrototypeOf(l,s.prototype),l};function O(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,a){t=t>>>0,e=e>>>0,a||O(t,e,this.length);for(var l=this[t],x=1,d=0;++d<e&&(x*=256);)l+=this[t+d]*x;return l},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,a){t=t>>>0,e=e>>>0,a||O(t,e,this.length);for(var l=this[t+--e],x=1;e>0&&(x*=256);)l+=this[t+--e]*x;return l},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t=t>>>0,e||O(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||O(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||O(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||O(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,a){t=t>>>0,e=e>>>0,a||O(t,e,this.length);for(var l=this[t],x=1,d=0;++d<e&&(x*=256);)l+=this[t+d]*x;return x*=128,l>=x&&(l-=Math.pow(2,8*e)),l},s.prototype.readIntBE=function(t,e,a){t=t>>>0,e=e>>>0,a||O(t,e,this.length);for(var l=e,x=1,d=this[t+--l];l>0&&(x*=256);)d+=this[t+--l]*x;return x*=128,d>=x&&(d-=Math.pow(2,8*e)),d},s.prototype.readInt8=function(t,e){return t=t>>>0,e||O(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},s.prototype.readInt16LE=function(t,e){t=t>>>0,e||O(t,2,this.length);var a=this[t]|this[t+1]<<8;return a&32768?a|4294901760:a},s.prototype.readInt16BE=function(t,e){t=t>>>0,e||O(t,2,this.length);var a=this[t+1]|this[t]<<8;return a&32768?a|4294901760:a},s.prototype.readInt32LE=function(t,e){return t=t>>>0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t=t>>>0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t=t>>>0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t=t>>>0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||O(t,8,this.length),o.read(this,t,!1,52,8)};function I(n,t,e,a,l,x){if(!s.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>l||t<x)throw new RangeError('"value" argument is out of bounds');if(e+a>n.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,a,l){if(t=+t,e=e>>>0,a=a>>>0,!l){var x=Math.pow(2,8*a)-1;I(this,t,e,a,x,0)}var d=1,k=0;for(this[e]=t&255;++k<a&&(d*=256);)this[e+k]=t/d&255;return e+a},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,a,l){if(t=+t,e=e>>>0,a=a>>>0,!l){var x=Math.pow(2,8*a)-1;I(this,t,e,a,x,0)}var d=a-1,k=1;for(this[e+d]=t&255;--d>=0&&(k*=256);)this[e+d]=t/k&255;return e+a},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,1,255,0),this[e]=t&255,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},s.prototype.writeIntLE=function(t,e,a,l){if(t=+t,e=e>>>0,!l){var x=Math.pow(2,8*a-1);I(this,t,e,a,x-1,-x)}var d=0,k=1,N=0;for(this[e]=t&255;++d<a&&(k*=256);)t<0&&N===0&&this[e+d-1]!==0&&(N=1),this[e+d]=(t/k>>0)-N&255;return e+a},s.prototype.writeIntBE=function(t,e,a,l){if(t=+t,e=e>>>0,!l){var x=Math.pow(2,8*a-1);I(this,t,e,a,x-1,-x)}var d=a-1,k=1,N=0;for(this[e+d]=t&255;--d>=0&&(k*=256);)t<0&&N===0&&this[e+d+1]!==0&&(N=1),this[e+d]=(t/k>>0)-N&255;return e+a},s.prototype.writeInt8=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},s.prototype.writeInt16LE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},s.prototype.writeInt32LE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,a){return t=+t,e=e>>>0,a||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function R(n,t,e,a,l,x){if(e+a>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function H(n,t,e,a,l){return t=+t,e=e>>>0,l||R(n,t,e,4),o.write(n,t,e,a,23,4),e+4}s.prototype.writeFloatLE=function(t,e,a){return H(this,t,e,!0,a)},s.prototype.writeFloatBE=function(t,e,a){return H(this,t,e,!1,a)};function C(n,t,e,a,l){return t=+t,e=e>>>0,l||R(n,t,e,8),o.write(n,t,e,a,52,8),e+8}s.prototype.writeDoubleLE=function(t,e,a){return C(this,t,e,!0,a)},s.prototype.writeDoubleBE=function(t,e,a){return C(this,t,e,!1,a)},s.prototype.copy=function(t,e,a,l){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(a||(a=0),!l&&l!==0&&(l=this.length),e>=t.length&&(e=t.length),e||(e=0),l>0&&l<a&&(l=a),l===a||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(a<0||a>=this.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("sourceEnd out of bounds");l>this.length&&(l=this.length),t.length-e<l-a&&(l=t.length-e+a);var x=l-a;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,a,l):Uint8Array.prototype.set.call(t,this.subarray(a,l),e),x},s.prototype.fill=function(t,e,a,l){if(typeof t=="string"){if(typeof e=="string"?(l=e,e=0,a=this.length):typeof a=="string"&&(l=a,a=this.length),l!==void 0&&typeof l!="string")throw new TypeError("encoding must be a string");if(typeof l=="string"&&!s.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(t.length===1){var x=t.charCodeAt(0);(l==="utf8"&&x<128||l==="latin1")&&(t=x)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<a)throw new RangeError("Out of range index");if(a<=e)return this;e=e>>>0,a=a===void 0?this.length:a>>>0,t||(t=0);var d;if(typeof t=="number")for(d=e;d<a;++d)this[d]=t;else{var k=s.isBuffer(t)?t:s.from(t,l),N=k.length;if(N===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(d=0;d<a-e;++d)this[d+e]=k[d%N]}return this};var K=/[^+/0-9A-Za-z-_]/g;function Y(n){if(n=n.split("=")[0],n=n.trim().replace(K,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function V(n,t){t=t||1/0;for(var e,a=n.length,l=null,x=[],d=0;d<a;++d){if(e=n.charCodeAt(d),e>55295&&e<57344){if(!l){if(e>56319){(t-=3)>-1&&x.push(239,191,189);continue}else if(d+1===a){(t-=3)>-1&&x.push(239,191,189);continue}l=e;continue}if(e<56320){(t-=3)>-1&&x.push(239,191,189),l=e;continue}e=(l-55296<<10|e-56320)+65536}else l&&(t-=3)>-1&&x.push(239,191,189);if(l=null,e<128){if((t-=1)<0)break;x.push(e)}else if(e<2048){if((t-=2)<0)break;x.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;x.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;x.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return x}function Q(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function tt(n,t){for(var e,a,l,x=[],d=0;d<n.length&&!((t-=2)<0);++d)e=n.charCodeAt(d),a=e>>8,l=e%256,x.push(l),x.push(a);return x}function lt(n){return i.toByteArray(Y(n))}function At(n,t,e,a){for(var l=0;l<a&&!(l+e>=t.length||l>=n.length);++l)t[l+e]=n[l];return l}function it(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Ct(n){return n!==n}var Ze=function(){for(var n="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var a=e*16,l=0;l<16;++l)t[a+l]=n[e]+n[l];return t}()})(Fe);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(r,i){var o=Fe,p=o.Buffer;function u(c,s){for(var h in c)s[h]=c[h]}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?r.exports=o:(u(o,i),i.Buffer=f);function f(c,s,h){return p(c,s,h)}f.prototype=Object.create(p.prototype),u(p,f),f.from=function(c,s,h){if(typeof c=="number")throw new TypeError("Argument must not be a number");return p(c,s,h)},f.alloc=function(c,s,h){if(typeof c!="number")throw new TypeError("Argument must be a number");var g=p(c);return s!==void 0?typeof h=="string"?g.fill(s,h):g.fill(s):g.fill(0),g},f.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return p(c)},f.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(c)}})(Rt,Rt.exports);var Zt=Rt.exports,Be=Zt.Buffer;function Dt(r,i){this._block=Be.alloc(r),this._finalSize=i,this._blockSize=r,this._len=0}Dt.prototype.update=function(r,i){typeof r=="string"&&(i=i||"utf8",r=Be.from(r,i));for(var o=this._block,p=this._blockSize,u=r.length,f=this._len,c=0;c<u;){for(var s=f%p,h=Math.min(u-c,p-s),g=0;g<h;g++)o[s+g]=r[c+g];f+=h,c+=h,f%p===0&&this._update(o)}return this._len+=u,this};Dt.prototype.digest=function(r){var i=this._len%this._blockSize;this._block[i]=128,this._block.fill(0,i+1),i>=this._finalSize&&(this._update(this._block),this._block.fill(0));var o=this._len*8;if(o<=4294967295)this._block.writeUInt32BE(o,this._blockSize-4);else{var p=(o&4294967295)>>>0,u=(o-p)/4294967296;this._block.writeUInt32BE(u,this._blockSize-8),this._block.writeUInt32BE(p,this._blockSize-4)}this._update(this._block);var f=this._hash();return r?f.toString(r):f};Dt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Ie=Dt,vr=Ae,je=Ie,_r=Zt.Buffer,Ar=[1518500249,1859775393,-1894007588,-899497514],Fr=new Array(80);function vt(){this.init(),this._w=Fr,je.call(this,64,56)}vr(vt,je);vt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Or(r){return r<<1|r>>>31}function Br(r){return r<<5|r>>>27}function Ir(r){return r<<30|r>>>2}function jr(r,i,o,p){return r===0?i&o|~i&p:r===2?i&o|i&p|o&p:i^o^p}vt.prototype._update=function(r){for(var i=this._w,o=this._a|0,p=this._b|0,u=this._c|0,f=this._d|0,c=this._e|0,s=0;s<16;++s)i[s]=r.readInt32BE(s*4);for(;s<80;++s)i[s]=Or(i[s-3]^i[s-8]^i[s-14]^i[s-16]);for(var h=0;h<80;++h){var g=~~(h/20),y=Br(o)+jr(g,p,u,f)+c+i[h]+Ar[g]|0;c=f,f=u,u=Ir(p),p=o,o=y}this._a=o+this._a|0,this._b=p+this._b|0,this._c=u+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0};vt.prototype._hash=function(){var r=_r.allocUnsafe(20);return r.writeInt32BE(this._a|0,0),r.writeInt32BE(this._b|0,4),r.writeInt32BE(this._c|0,8),r.writeInt32BE(this._d|0,12),r.writeInt32BE(this._e|0,16),r};var Dr=vt;const Tr=Kt(Dr);var kr=Ae,De=Ie,Ur=Zt.Buffer,Cr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],$r=new Array(64);function _t(){this.init(),this._w=$r,De.call(this,64,56)}kr(_t,De);_t.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Nr(r,i,o){return o^r&(i^o)}function zr(r,i,o){return r&i|o&(r|i)}function Mr(r){return(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10)}function Rr(r){return(r>>>6|r<<26)^(r>>>11|r<<21)^(r>>>25|r<<7)}function Lr(r){return(r>>>7|r<<25)^(r>>>18|r<<14)^r>>>3}function Pr(r){return(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10}_t.prototype._update=function(r){for(var i=this._w,o=this._a|0,p=this._b|0,u=this._c|0,f=this._d|0,c=this._e|0,s=this._f|0,h=this._g|0,g=this._h|0,y=0;y<16;++y)i[y]=r.readInt32BE(y*4);for(;y<64;++y)i[y]=Pr(i[y-2])+i[y-7]+Lr(i[y-15])+i[y-16]|0;for(var b=0;b<64;++b){var F=g+Rr(c)+Nr(c,s,h)+Cr[b]+i[b]|0,j=Mr(o)+zr(o,p,u)|0;g=h,h=s,s=c,c=f+F|0,f=u,u=p,p=o,o=F+j|0}this._a=o+this._a|0,this._b=p+this._b|0,this._c=u+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0,this._f=s+this._f|0,this._g=h+this._g|0,this._h=g+this._h|0};_t.prototype._hash=function(){var r=Ur.allocUnsafe(32);return r.writeInt32BE(this._a,0),r.writeInt32BE(this._b,4),r.writeInt32BE(this._c,8),r.writeInt32BE(this._d,12),r.writeInt32BE(this._e,16),r.writeInt32BE(this._f,20),r.writeInt32BE(this._g,24),r.writeInt32BE(this._h,28),r};var qr=_t;const Hr=Kt(qr),Yt=new Error("File system not available.");function Jr(r,i,o){throw Yt}function Te(r){throw Yt}function Wr(r){throw Yt}const Xr=async r=>Te(),Vr={sha1:Tr,sha256:Hr},Tt=(r,i="sha1")=>{if(!["sha1","sha256"].includes(i))throw new Error("Hashing algorithm not supported: Available: sha1, sha256");const o=Vr[i];return new o().update(r).digest("base64")};function ke(r){const i=[],o=Object.keys(r);for(const p of o){const u=r[p].sort((f,c)=>f.index-c.index);for(let f=0;f<u.length;f++)u[f].index!==f&&i.push({message:`Invalid operation index ${u[f].index} at position ${f}`,details:{position:f,operation:u[f],scope:u[f].scope}})}return i}const Qt=async r=>{const i=new pe,{name:o,revision:p,documentType:u,created:f,lastModified:c}=r,s={name:o,revision:p,documentType:u,created:f,lastModified:c};return i.file("header.json",JSON.stringify(s,null,2)),i.file("state.json",JSON.stringify(r.initialState||{},null,2)),i.file("operations.json",JSON.stringify(r.operations,null,2)),Object.keys(r.attachments).forEach(g=>{const{data:y,...b}=r.attachments[g];i.file(g,y,{base64:!0,createFolders:!0,comment:JSON.stringify(b)})}),i},Ue=async(r,i,o,p)=>{await(await Qt(r)).generateAsync({type:"uint8array",streamFiles:!0});const f=p??r.name,c=`.${o}.zip`;return Jr(i,f.endsWith(c)?f:`${f}${c}`)},Kr=async(r,i)=>{const p=await(await Qt(r)).generateAsync({type:"blob"}),u=await i.createWritable();await u.write(p),await u.close()},Lt=async(r,i,o)=>{const p=Te();return Ce(p,i,o)},Ce=async(r,i,o)=>{const p=new pe;return await p.loadAsync(r),Gr(p,i,o)};async function Gr(r,i,o){const p=r.file("state.json");if(!p)throw new Error("Initial state not found");const u=await p.async("string"),f=JSON.parse(u),c=r.file("header.json");let s;c&&(s=JSON.parse(await c.async("string")));const h=r.file("operations.json");if(!h)throw new Error("Operations history not found");const g=JSON.parse(await h.async("string")),y=ke(g);if(y.length){const F=y.map(j=>j.message);throw new Error(F.join(`
|
|
25
|
+
`))}let b=ie(f,g,i,void 0,s,{},o);return s&&(b={...b,...s}),b}function $e(r){const i=r.replace(/^.*\./,"")||void 0,o=r.replace(/^.*[/\\]/,"")||void 0;return{extension:i,fileName:o}}async function Zr(r){const{buffer:i,mimeType:o="application/octet-stream"}=await Wr(),p=$e(r),u=i.toString("base64");return{data:u,hash:Tt(u),mimeType:o,...p}}async function Yr(r){const i=await Xr(),o=mr.getType(r)||"application/octet-stream",p=$e(r),u=i.toString("base64");return{data:u,hash:Tt(u),mimeType:o,...p}}var Ne=(r=>(r.UNEXPECTED_INDEX="UNEXPECTED_INDEX",r))(Ne||{}),ze=(r=>(r.DUPLICATED_INDEX="DUPLICATED_INDEX",r.MISSING_INDEX="MISSING_INDEX",r))(ze||{});function te(r){const i=[];let o=-1;for(const p of r){const u=p.index-p.skip;u!==o+1&&i.push({operation:{index:p.index,skip:p.skip},issue:"UNEXPECTED_INDEX",category:u>o+1?"MISSING_INDEX":"DUPLICATED_INDEX",message:`Expected index ${o+1} with skip 0 or equivalent, got index ${p.index} with skip ${p.skip}`}),o=p.index}return i}function at(r){var p,u,f;const i=[];let o=r.length-1;for(;o>-1;){i.unshift(r[o]);const c=(((p=r[o])==null?void 0:p.index)||0)-(((u=r[o])==null?void 0:u.skip)||0)-1;let s=o-1;for(;s>-1&&(((f=r[s])==null?void 0:f.index)||0)>c;)s--;o=s}return i}function Qr(r){const i=[...r],o=i[i.length-1];return o&&(o.type==="NOOP"?i.push({...o,index:o.index,type:"NOOP",skip:Le(r)}):i.push({type:"NOOP",index:o.index+1,timestamp:new Date().toISOString(),input:{},skip:1,scope:o.scope,hash:o.hash})),i}function st(r){return r.slice().sort((i,o)=>i.skip-o.skip).sort((i,o)=>i.index-o.index)}const ti=(r,i,o)=>[...i,...o].sort((p,u)=>new Date(p.timestamp).getTime()-new Date(u.timestamp).getTime()).map((p,u)=>({...p,index:r.index+u,skip:u===0?r.skip:0})),ei=(r,i,o)=>[...i,...o].sort((p,u)=>new Date(p.timestamp).getTime()-new Date(u.timestamp).getTime()).sort((p,u)=>p.index-u.index).map((p,u)=>({...p,index:r.index+u,skip:u===0?r.skip:0}));function ee(r,i){return gt(r)===gt(i)}function ri(r,i){const o=at(st(r.slice())),p=at(st(i.slice()));if(o.length<1)return[p,[]];const u=[];let f=!1;for(;p.length>0;){const c=p[0];let s=o.shift();for(;s&&Me(s,c);)u.push(s),s=o.shift();if(s?f||(ee(s,c)?(p.shift(),u.push(s)):(o.unshift(s),f=!0)):f=!0,f){let h=p.shift();for(;h;)u.push(h),h=p.shift()}}if(!f){let c=o.shift();for(;c;)u.push(c),c=o.shift()}return[at(u),o]}function Me(r,i){return r.index<i.index||r.index===i.index&&r.skip<i.skip}function Re(r,i){const o=[],p=[],u=[],f=Math.max(r.length,i.length);let c=!1;for(let s=0;s<f;s++){const h=r[s],g=i[s];h&&g?!c&&ee(h,g)?o.push(h):(c=!0,p.push(h),u.push(g)):h?p.push(h):g&&u.push(g)}return[o,p,u]}function ii(r,i,o){const[p,u,f]=Re(at(r),at(i)),c=Nt(p),s=1+Math.max(c,Nt(u),Nt(f)),h=o({index:s,skip:s-(c+1)},u,f);return p.concat(h)}function Nt(r){const i=r[r.length-1];return i?i.index:-1}function Le(r){var p,u,f;if(r.length<1)return-1;const i=at(r);let o=(((p=i[i.length-1])==null?void 0:p.skip)||0)+1;return i.length>1&&(o+=((u=i[i.length-2])==null?void 0:u.skip)||0),(((f=i[i.length-1])==null?void 0:f.index)||-1)<o?-1:o}const ni=r=>te(at(st(r))),oi=r=>r.reduce((o,p)=>{var u;return o[p.scope]||(o[p.scope]=[]),(u=o[p.scope])==null||u.push(p),o},{}),ai=(r,i)=>{var h;const o={integrityIssues:[],validOperations:[],invalidOperations:[],duplicatedOperations:[]},p=st(r),u=st(i),f=te([...p,...u]),s=(h=[...f.filter(g=>g.category==="MISSING_INDEX")].sort((g,y)=>y.operation.index-g.operation.index).pop())==null?void 0:h.operation;for(const g of u){if(s&&g.index>=s.index){o.invalidOperations.push(g);continue}if(f.some(b=>b.operation.index===g.index&&b.operation.skip===g.skip&&b.category==="DUPLICATED_INDEX")){o.duplicatedOperations.push(g);continue}o.validOperations.push(g)}return o.integrityIssues.push(...f),o};function si(r,i){return r.filter(o=>!i.some(p=>o.type==="NOOP"&&o.skip===0&&o.index===p.index||o.index===p.index&&o.skip===p.skip&&o.scope===p.scope&&o.hash===p.hash&&o.type===p.type))}function Pe(r,i){const[o]=st(r).slice(-1),p=(o==null?void 0:o.index)??-1,u=p+1,f={...i,index:i.index??u};if(f.index<p)throw new Error(`The skip header operation index must be greater than or equal to ${p}`);return(at(st([...r,f]))||[]).slice(0,-1)}function Pt(r){return{...Object.entries(r).reduce((o,p)=>{const[u,f]=p;return{...o,[u]:at(st(f))}},{})}}const pi=Object.freeze(Object.defineProperty({__proto__:null,IntegrityIssueSubType:ze,IntegrityIssueType:Ne,addUndo:Qr,attachBranch:ri,checkCleanedOperationsIntegrity:te,checkOperationsIntegrity:ni,garbageCollect:at,garbageCollectDocumentOperations:Pt,groupOperationsByScope:oi,merge:ii,nextSkipNumber:Le,operationsAreEqual:ee,precedes:Me,prepareOperations:ai,removeExistingOperations:si,reshuffleByTimestamp:ti,reshuffleByTimestampAndIndex:ei,skipHeaderOperations:Pe,sortOperations:st,split:Re},Symbol.toStringTag,{value:"Module"}));function ci(r,i){let o;return"index"in i?o={...i}:o=r.operations[i.scope].at(-1),((o==null?void 0:o.index)??-1)+1}function li(r,i){return{...r,revision:{...r.revision,[i.scope]:ci(r,i)},lastModified:new Date().toISOString()}}function ui(r,i,o=0){if([bt,St,It].includes(i.type))return r;const{scope:p}=i,u=r.operations[p].slice(),f=u.at(-1);let c=((f==null?void 0:f.index)??-1)+1;if("index"in i){if(i.index-o>c)throw new Error(`Missing operations: expected ${c} with skip 0 or equivalent, got index ${i.index} with skip ${o}`);c=i.index}return u.push({...i,index:c,timestamp:new Date().toISOString(),hash:"",scope:p,skip:o,error:void 0}),{...r,operations:{...r.operations,[p]:u}}}function fi(r,i,o=0){let p=ui(r,i,o);return p=li(p,i),p}function hi(r,i,o){switch(xe().parse(i),i.type){case Se:return sr(r,i.input);case It:return lr(r,i,o);case ve:return ur(r,i.input.state);default:return r}}function mi(r,i,o){switch(i.type){case bt:return pr(r,i,o);case St:return cr(r,i,o);default:return{document:r,action:i,skip:o}}}function xi(r,i,o,p,u=!1,f=ne){const c=i.scope,s=r.operations[c].at(-1);if(!s)return r;const h=Pt({...r.operations,[c]:Pe(r.operations[c],s)});let g;const y=h[c].at(-1);if(u&&(y!=null&&y.resultingState))g=f(y.resultingState);else{const{state:b}=Bt(r.initialState,h,o,void 0,void 0,void 0,void 0,{reuseHash:!0,reuseOperationResultingState:u,operationResultingStateParser:f});g=b[c]}return{...r,state:{...r.state,[c]:g},operations:Pt({...r.operations})}}function re(r,i,o,p,u={}){const{skip:f,ignoreSkipOperations:c=!1,reuseHash:s=!1,reuseOperationResultingState:h=!1,operationResultingStateParser:g}=u,y={...i},b=f||0;let F={...r};const j=!c&&(b>0||"index"in y&&y.skip>0);return qt(y)&&(F=hi(F,y,o)),F=fi(F,y,b),j&&(F=xi(F,y,o,b,h,g)),F=nt.produce(F,$=>{try{const q=o($.state,y,p);if(q)return nt.castDraft({...F,state:q})}catch(q){const Z=F.operations[y.scope].length-1;$.operations[y.scope][Z].error=q.message,$.operations[y.scope][Z].skip=0,j&&($.state=nt.castDraft({...r.state}),$.operations=nt.castDraft({...r.operations,[y.scope]:[...r.operations[y.scope],{...$.operations[y.scope][Z]}]}))}}),nt.produce(F,$=>{if([bt,St,It].includes(y.type))return $;const q=y.scope||"global",Z=s&&Object.prototype.hasOwnProperty.call(y,"hash")?y.hash:kt($,q);$.operations[q][$.operations[q].length-1].hash=Z,!qt(y)&&y.attachments&&y.attachments.forEach(w=>{const{hash:E,...S}=w;$.attachments[E]={...S}})})}function di(r){return r.type===fr&&r.skip!==void 0&&r.skip>0&&r.hash!==void 0}function gi(r){return[bt,St].includes(r.type)}function qt(r){return[Se,bt,St,It,ve].includes(r.type)}function ft(r,i,o,p,u="global"){if(!r)throw new Error("Empty action type");if(typeof r!="string")throw new Error(`Invalid action type: ${JSON.stringify(r)}`);const f={type:r,input:i,scope:u};o&&(f.attachments=o);try{p==null||p().parse(f.input)}catch(c){throw new Error(`Invalid action input: ${c}`)}return f}function qe(r,i=re){return(o,p,u,f)=>i(o,p,r,u,f)}const He=(r,i)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...r,state:(i==null?void 0:i(r==null?void 0:r.state))??(r==null?void 0:r.state)??{global:{},local:{}}}),Je=(r,i)=>{const o=He(r,i);return{...o,initialState:o,operations:{global:[],local:[]},clipboard:[]}},kt=(r,i="global")=>Tt(gt(r.state[i]||"")),yi=(r,i=1e3)=>{const o=Math.random()*i;return Tt(`${(r??new Date).toISOString()}${o}`)};function wt(r){return nt.castImmutable(nt.freeze(r,!0))}function wi(r,i){const o=[...r];let p=i||0,u=o.length>0?o[o.length-1].index:0;const f=[];for(const c of o.reverse()){if(p>0){const g=u-c.index;p-=g}if(p<0)throw new Error("Invalid operation index, missing operations");const s={ignore:p>0,operation:c},h=c.skip>0?c.skip+1:0;if(h>0&&h>p){const g=h-p;p=p+g}u=c.index,f.push(s)}return f.reverse()}function Ei(r,i,o){const p=r.slice().sort((s,h)=>s.skip-h.skip).sort((s,h)=>s.index-h.index);let u=o,f=0,c=i;for(const s of p.reverse()){const h=c-s.index;if(u=u-h,u>-1)f++,c=s.index;else break}return f}function bi(r){return Object.values(r).flatMap(i=>i).sort((i,o)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime())}function Si(r){return Object.values(r).flatMap(i=>i).sort((i,o)=>new Date(i.operation.timestamp).getTime()-new Date(o.operation.timestamp).getTime())}function Bt(r,i,o,p,u,f=re,c={},s){const h=qe(o,f);return ie(r,i,h,p,u,c,s)}function ie(r,i,o,p,u,f={},c){const{checkHashes:s=!0,reuseOperationResultingState:h,operationResultingStateParser:g=ne}=c||{};let y=r;const b=[],F={global:[],local:[]};if(h)for(const[w,E]of Object.entries(i)){const S=E.findLastIndex(J=>!!J.resultingState);if(S<0){b.push(...E);continue}const M=E[S];try{const J=g(M.resultingState);y={...y,state:{...y.state,[w]:J}},F[w].push(...E.slice(0,S+1)),b.push(...E.slice(S+1))}catch{b.push(...E)}}else b.push(...Object.values(i).flat());const j=Je(y);j.initialState=r,j.operations=F;const $=b.reduce((w,E)=>o(w,E,p,{skip:E.skip,ignoreSkipOperations:!0,reuseHash:!s}),j);if(!s)for(const w of Object.keys($.state))for(let E=b.length-1;E>=0;E--){const S=b[E];if(S.scope===w){if(S.hash!==kt($,w))throw new Error(`Hash mismatch for scope ${w}`);break}}const q=Object.keys($.operations).reduce((w,E)=>{const S=E;return{...w,[S]:[...$.operations[S].map((M,J)=>{var W;return{...M,timestamp:((W=i[S][J])==null?void 0:W.timestamp)??M.timestamp}})]}},{global:[],local:[]}),Z=Object.values(q).reduce((w,E)=>{const S=E[E.length-1];return(S==null?void 0:S.timestamp)>w&&(w=S.timestamp),w},r.lastModified);return{...$,operations:q,lastModified:Z}}function vi(r,i){return gt(r)===gt(i)}function ne(r){const i=typeof r;if(i==="string")return JSON.parse(r);if(i==="object")return r;throw new Error(`Providing resulting state is of type: ${i}`)}const We=r=>ft("SET_NAME",r,void 0,Xt,void 0),Xe=(r=1,i="global")=>ft("UNDO",r,void 0,Vt,i),Ve=(r=1,i="global")=>ft("REDO",r,void 0,Wt,i),Ke=(r,i,o="global")=>ft("PRUNE",{start:r,end:i},void 0,Jt,o),oe=(r,i)=>ft("LOAD_STATE",{state:r,operations:i},void 0,Ht),Ge=(r="global")=>ft("NOOP",{},void 0,void 0,r),_i=Object.freeze(Object.defineProperty({__proto__:null,loadState:oe,noop:Ge,prune:Ke,redo:Ve,setName:We,undo:Xe},Symbol.toStringTag,{value:"Module"}));class Ai{constructor(i,o,p){Ot(this,"_document");Ot(this,"_reducer");Ot(this,"_signalDispatch");this._reducer=i,this._document=o,this._signalDispatch=p}dispatch(i,o){return this._document=this._reducer(this._document,i,this._signalDispatch,o),this}saveToFile(i,o,p){return Ue(this._document,i,o,p)}async loadFromFile(i){this._document=await Lt(i,this._reducer)}static async stateFromFile(i,o){return await Lt(i,o)}get state(){return wt(this._document.state)}get operations(){return wt(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.global}getRevision(i){return this._document.revision[i]}get initialState(){return wt(this._document.initialState)}toDocument(){return wt(this._document)}getAttachment(i){return this._document.attachments[i]}setName(i){return this.dispatch(We(i)),this}undo(i){return this.dispatch(Xe(i)),this}redo(i){return this.dispatch(Ve(i)),this}prune(i,o){return this.dispatch(Ke(i,o)),this}loadState(i,o){return this.dispatch(oe(i,o)),this}}function Fi(r,i){i.forEach(o=>{Object.getOwnPropertyNames(o.prototype).forEach(p=>{Object.defineProperty(r.prototype,p,Object.getOwnPropertyDescriptor(o.prototype,p)||Object.create(null))})})}exports.BaseActions=_i;exports.BaseDocument=Ai;exports.applyMixins=Fi;exports.baseReducer=re;exports.calculateSkipsLeft=Ei;exports.createAction=ft;exports.createDocument=Je;exports.createExtendedState=He;exports.createReducer=qe;exports.createZip=Qt;exports.documentHelpers=pi;exports.getLocalFile=Yr;exports.getRemoteFile=Zr;exports.hashDocument=kt;exports.hashKey=yi;exports.isBaseAction=qt;exports.isNoopOperation=di;exports.isSameDocument=vi;exports.isUndoRedo=gi;exports.loadFromFile=Lt;exports.loadFromInput=Ce;exports.mapSkippedOperations=wi;exports.parseResultingState=ne;exports.processUndoRedo=mi;exports.readOnly=wt;exports.replayDocument=ie;exports.replayOperations=Bt;exports.saveToFile=Ue;exports.saveToFileHandle=Kr;exports.sortMappedOperations=Si;exports.sortOperations=bi;exports.validateOperations=ke;exports.zod=or;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import "./internal/object-
|
|
1
|
+
import "./internal/object-FFc9n_3I.js";
|
|
2
2
|
import "immer";
|
|
3
3
|
import "jszip";
|
|
4
|
-
import { b, a, c, d, m, r, u, v, g, h, f, e, z } from "./internal/index-
|
|
4
|
+
import { b as i, a as l, c as m, d as r, m as u, r as c, u as n, v as p, g as v, h as M, f as S, e as f, z as h } from "./internal/index-CL_1ivGq.js";
|
|
5
5
|
import "zod";
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
z
|
|
7
|
+
i as Document,
|
|
8
|
+
l as DocumentModel,
|
|
9
|
+
m as actions,
|
|
10
|
+
r as documentModel,
|
|
11
|
+
u as module,
|
|
12
|
+
c as reducer,
|
|
13
|
+
n as utils,
|
|
14
|
+
p as validateInitialState,
|
|
15
|
+
v as validateModule,
|
|
16
|
+
M as validateModuleOperation,
|
|
17
|
+
S as validateModules,
|
|
18
|
+
f as validateStateSchemaName,
|
|
19
|
+
h as z
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=document-model.js.map
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { B, h, g
|
|
2
|
-
import { i } from "./internal/index-
|
|
1
|
+
import { B as i, h as p, g as t, E as m, F as c, G as n } from "./internal/object-FFc9n_3I.js";
|
|
2
|
+
import { i as u } from "./internal/index-BzNpRs2a.js";
|
|
3
3
|
import "immer";
|
|
4
4
|
import "zod";
|
|
5
5
|
import "jszip";
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
i as BaseDocument,
|
|
8
|
+
p as actions,
|
|
9
|
+
t as applyMixins,
|
|
10
|
+
m as baseReducer,
|
|
11
|
+
c as processUndoRedo,
|
|
12
|
+
u as utils,
|
|
13
|
+
n as z
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=document.js.map
|
package/dist/browser/es/index.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
import { D as
|
|
3
|
-
import "./internal/object-
|
|
1
|
+
import { D as o } from "./internal/index-BzNpRs2a.js";
|
|
2
|
+
import { D as e } from "./internal/index-CL_1ivGq.js";
|
|
3
|
+
import "./internal/object-FFc9n_3I.js";
|
|
4
4
|
import "immer";
|
|
5
5
|
import "zod";
|
|
6
6
|
import "jszip";
|
|
7
|
-
const
|
|
8
|
-
"powerhouse/document":
|
|
9
|
-
"powerhouse/document-model":
|
|
10
|
-
};
|
|
11
|
-
const index = { Document, DocumentModel };
|
|
7
|
+
const u = {
|
|
8
|
+
"powerhouse/document": o,
|
|
9
|
+
"powerhouse/document-model": e
|
|
10
|
+
}, c = { Document: o, DocumentModel: e };
|
|
12
11
|
export {
|
|
13
|
-
Document,
|
|
14
|
-
DocumentModel,
|
|
15
|
-
DocumentModels,
|
|
16
|
-
|
|
12
|
+
o as Document,
|
|
13
|
+
e as DocumentModel,
|
|
14
|
+
u as DocumentModels,
|
|
15
|
+
c as default
|
|
17
16
|
};
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { j as e, f as a, b as s, a as t, c as o, k as r, m as i, n, o as l, p as c, q as p, i as d, r as u, t as m, u as O, l as y, e as S, v as b, w as g, x as D, y as F, z as _, s as f, d as v, A as R, C as h, D as j, B as x, h as z, g as A, E as B, F as M, G as T } from "./object-FFc9n_3I.js";
|
|
2
|
+
const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
|
+
__proto__: null,
|
|
4
|
+
calculateSkipsLeft: e,
|
|
5
|
+
createAction: a,
|
|
6
|
+
createDocument: s,
|
|
7
|
+
createExtendedState: t,
|
|
8
|
+
createReducer: o,
|
|
9
|
+
createZip: r,
|
|
10
|
+
documentHelpers: i,
|
|
11
|
+
getLocalFile: n,
|
|
12
|
+
getRemoteFile: l,
|
|
13
|
+
hashDocument: c,
|
|
14
|
+
hashKey: p,
|
|
15
|
+
isBaseAction: d,
|
|
16
|
+
isNoopOperation: u,
|
|
17
|
+
isSameDocument: m,
|
|
18
|
+
isUndoRedo: O,
|
|
19
|
+
loadFromFile: y,
|
|
20
|
+
loadFromInput: S,
|
|
21
|
+
mapSkippedOperations: b,
|
|
22
|
+
parseResultingState: g,
|
|
23
|
+
readOnly: D,
|
|
24
|
+
replayDocument: F,
|
|
25
|
+
replayOperations: _,
|
|
26
|
+
saveToFile: f,
|
|
27
|
+
saveToFileHandle: v,
|
|
28
|
+
sortMappedOperations: R,
|
|
29
|
+
sortOperations: h,
|
|
30
|
+
validateOperations: j
|
|
31
|
+
}, Symbol.toStringTag, { value: "Module" })), H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
32
|
+
__proto__: null,
|
|
33
|
+
BaseDocument: x,
|
|
34
|
+
actions: z,
|
|
35
|
+
applyMixins: A,
|
|
36
|
+
baseReducer: B,
|
|
37
|
+
processUndoRedo: M,
|
|
38
|
+
utils: k,
|
|
39
|
+
z: T
|
|
40
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
41
|
+
export {
|
|
42
|
+
H as D,
|
|
43
|
+
k as i
|
|
44
|
+
};
|