document-model 1.0.39 → 1.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/browser/document-model.cjs +1 -1
  2. package/dist/browser/document-model.js +2 -2
  3. package/dist/browser/document.cjs +1 -1
  4. package/dist/browser/document.js +2 -2
  5. package/dist/browser/index.cjs +1 -1
  6. package/dist/browser/index.js +3 -3
  7. package/dist/{node/internal/index-DyCS1h0M.js → browser/internal/index-BD_7XeO5.js} +1 -1
  8. package/dist/{node/internal/index-Dl5T5qdc.js → browser/internal/index-BNBYVtaF.js} +1 -1
  9. package/dist/browser/internal/{index-4Z_H8F_J.js → index-BWV1Osza.js} +1 -1
  10. package/dist/browser/internal/{index-6u2yDIEF.js → index-BxGRRPwY.js} +1 -1
  11. package/dist/browser/internal/{object-EriwiDIs.js → object-DHqlosWD.js} +3 -3
  12. package/dist/browser/internal/{object-Fq6PThAX.js → object-StihF423.js} +413 -413
  13. package/dist/browser/src/document/object.d.ts +30 -0
  14. package/dist/browser/src/document/types.d.ts +2 -0
  15. package/dist/node/document-model.cjs +1 -1
  16. package/dist/node/document-model.js +2 -2
  17. package/dist/node/document.cjs +1 -1
  18. package/dist/node/document.js +2 -2
  19. package/dist/node/index.cjs +1 -1
  20. package/dist/node/index.js +3 -3
  21. package/dist/node/internal/{index-A6Rqm2SZ.js → index-DeKx7EaE.js} +1 -1
  22. package/dist/node/internal/{index-BpBnSlTZ.js → index-Dh0vfIdX.js} +1 -1
  23. package/dist/{browser/internal/index-QJX_Fa1V.js → node/internal/index-LD_vrQff.js} +1 -1
  24. package/dist/{browser/internal/index-DQeD1Q-a.js → node/internal/index-LEexvgqj.js} +1 -1
  25. package/dist/node/internal/object-CKxJA706.js +2 -0
  26. package/dist/node/internal/{object-S6TngMa9.js → object-CudRLU4J.js} +62 -62
  27. package/dist/node/src/document/object.d.ts +30 -0
  28. package/dist/node/src/document/types.d.ts +2 -0
  29. package/package.json +1 -1
  30. package/dist/node/internal/object-ifvac9k2.js +0 -2
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-EriwiDIs.js");require("immer");require("json-stringify-deterministic");require("jszip");const e=require("./internal/index-6u2yDIEF.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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-DHqlosWD.js");require("immer");require("json-stringify-deterministic");require("jszip");const e=require("./internal/index-BxGRRPwY.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,8 +1,8 @@
1
- import "./internal/object-Fq6PThAX.js";
1
+ import "./internal/object-StihF423.js";
2
2
  import "immer";
3
3
  import "json-stringify-deterministic";
4
4
  import "jszip";
5
- import { b as l, a as m, c as r, d as u, m as c, r as p, u as n, v, g as M, h as S, f, e as h, z as D } from "./internal/index-4Z_H8F_J.js";
5
+ import { b as l, a as m, c as r, d as u, m as c, r as p, u as n, v, g as M, h as S, f, e as h, z as D } from "./internal/index-BWV1Osza.js";
6
6
  import "zod";
7
7
  export {
8
8
  l as Document,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-EriwiDIs.js"),r=require("./internal/index-QJX_Fa1V.js");require("immer");require("json-stringify-deterministic");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=r.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-DHqlosWD.js"),r=require("./internal/index-BD_7XeO5.js");require("immer");require("json-stringify-deterministic");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=r.index;
@@ -1,5 +1,5 @@
1
- import { B as p, h as t, g as m, C as c, D as n, E as d } from "./internal/object-Fq6PThAX.js";
2
- import { i as x } from "./internal/index-DQeD1Q-a.js";
1
+ import { B as p, h as t, g as m, C as c, D as n, E as d } from "./internal/object-StihF423.js";
2
+ import { i as x } from "./internal/index-BNBYVtaF.js";
3
3
  import "immer";
4
4
  import "json-stringify-deterministic";
5
5
  import "zod";
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-QJX_Fa1V.js"),o=require("./internal/index-6u2yDIEF.js");require("./internal/object-EriwiDIs.js");require("immer");require("json-stringify-deterministic");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;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-BD_7XeO5.js"),o=require("./internal/index-BxGRRPwY.js");require("./internal/object-DHqlosWD.js");require("immer");require("json-stringify-deterministic");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;
@@ -1,6 +1,6 @@
1
- import { D as o } from "./internal/index-DQeD1Q-a.js";
2
- import { D as t } from "./internal/index-4Z_H8F_J.js";
3
- import "./internal/object-Fq6PThAX.js";
1
+ import { D as o } from "./internal/index-BNBYVtaF.js";
2
+ import { D as t } from "./internal/index-BWV1Osza.js";
3
+ import "./internal/object-StihF423.js";
4
4
  import "immer";
5
5
  import "json-stringify-deterministic";
6
6
  import "zod";
@@ -1 +1 @@
1
- "use strict";const e=require("./object-ifvac9k2.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,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,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;
1
+ "use strict";const e=require("./object-DHqlosWD.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,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,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;
@@ -1,4 +1,4 @@
1
- import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-S6TngMa9.js";
1
+ import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-StihF423.js";
2
2
  const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  calculateSkipsLeft: e,
@@ -1,7 +1,7 @@
1
1
  var Rt = Object.defineProperty;
2
2
  var xt = (t, e, r) => e in t ? Rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var Ee = (t, e, r) => (xt(t, typeof e != "symbol" ? e + "" : e, r), r);
4
- import { c as At, i as Mt, a as Dt, b as Nt, s as Lt, d as Pt, l as Ct, e as jt, f as a, B as c, g as yt, h as wt } from "./object-Fq6PThAX.js";
4
+ import { c as At, i as Mt, a as Dt, b as Nt, s as Lt, d as Pt, l as Ct, e as jt, f as a, B as c, g as yt, h as wt } from "./object-StihF423.js";
5
5
  import "immer";
6
6
  import "json-stringify-deterministic";
7
7
  import "jszip";
@@ -1,4 +1,4 @@
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-EriwiDIs.js");require("immer");require("json-stringify-deterministic");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:`{
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-DHqlosWD.js");require("immer");require("json-stringify-deterministic");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
2
  "id": "",
3
3
  "name": "",
4
4
  "extension": "",
@@ -1,7 +1,7 @@
1
- "use strict";var Le=Object.defineProperty;var Ce=(n,r,p)=>r in n?Le(n,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):n[r]=p;var Q=(n,r,p)=>(Ce(n,typeof r!="symbol"?r+"":r,p),p);const D=require("immer"),pt=require("json-stringify-deterministic"),w=require("zod"),Nt=require("jszip"),Rt=n=>n!=null,qe=w.z.any().refine(n=>Rt(n)),Lt=w.z.enum(["LOAD_STATE"]),Ct=w.z.enum(["PRUNE"]),qt=w.z.enum(["REDO"]),$t=w.z.enum(["SET_NAME"]),Pt=w.z.enum(["UNDO"]);function $e(){return w.z.object({__typename:w.z.literal("Action").optional(),type:w.z.string()})}function Z(){return w.z.literal("global").or(w.z.literal("local"))}function Wt(){return w.z.union([Jt(),Zt(),Kt(),Yt(),Gt()])}function Pe(){return w.z.object({__typename:w.z.literal("DocumentFile").optional(),data:w.z.string(),extension:w.z.string().nullable(),fileName:w.z.string().nullable(),mimeType:w.z.string()})}function Jt(){return w.z.object({input:w.z.lazy(()=>mt()),type:Lt,scope:Z()})}function mt(){return w.z.object({operations:w.z.number(),state:w.z.lazy(()=>Ht())})}function Ht(){return w.z.object({data:w.z.unknown().nullish(),name:w.z.string()})}function We(){return w.z.object({__typename:w.z.literal("Operation").optional(),hash:w.z.string(),index:w.z.number(),timestamp:w.z.string().datetime(),type:w.z.string()})}function Zt(){return w.z.object({input:w.z.lazy(()=>ht()),type:Ct,scope:Z()})}function ht(){return w.z.object({end:w.z.number().nullish(),start:w.z.number().nullish()})}const xt=w.z.number;function Kt(){return w.z.object({input:xt(),type:qt,scope:Z()})}const dt=w.z.string;function Yt(){return w.z.object({input:dt(),type:$t,scope:w.z.literal("global")})}function Je(){return w.z.object({__typename:w.z.literal("SetNameOperation").optional(),hash:w.z.string(),index:w.z.number(),input:w.z.string(),timestamp:w.z.string().datetime(),type:w.z.string()})}const wt=w.z.number;function Gt(){return w.z.object({input:wt(),type:Pt,scope:Z()})}const He=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:$e,BaseActionSchema:Wt,DocumentFileSchema:Pe,LoadStateActionInputSchema:mt,LoadStateActionSchema:Jt,LoadStateActionStateInputSchema:Ht,Load_StateSchema:Lt,OperationSchema:We,OperationScopeSchema:Z,PruneActionInputSchema:ht,PruneActionSchema:Zt,PruneSchema:Ct,RedoActionInputSchema:xt,RedoActionSchema:Kt,RedoSchema:qt,SetNameActionInputSchema:dt,SetNameActionSchema:Yt,SetNameOperationSchema:Je,Set_NameSchema:$t,UndoActionInputSchema:wt,UndoActionSchema:Gt,UndoSchema:Pt,definedNonNullAnySchema:qe,isDefinedNonNullAny:Rt},Symbol.toStringTag,{value:"Module"}));function Ze(n,r){return{...n,name:r}}function Ke(n,r,p){const c={skip:p,document:n},{scope:f}=r;return!f||r.skip===void 0?c:D.produce(c,u=>{const[l]=u.document.operations[f].slice(-1);r.skip&&r.skip>0&&(u.skip=r.skip),l.type==="NOOP"&&r.index===l.index&&u.skip>l.skip&&u.document.operations[f].pop()})}function Ye(n,r,p){const{scope:c,input:f}=r,u={document:n,action:r,skip:p};return D.produce(u,l=>{if(l.document.operations[c].length<1)throw new Error(`Cannot undo: no operations in history for scope "${c}"`);if(f<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(l.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[a]=l.document.operations[c].slice(-1),x=a.type==="NOOP"&&a.skip>0;if(l.skip+=f,x){l.skip+=a.skip;const y=l.document.operations[c][l.document.operations[c].length-2];y&&a.index-y.index===1&&l.document.operations[c].pop()}if(l.document.operations[c].length<l.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const d=l.document.operations[c].length-1;let v=f,g=x?d-a.skip:d;for(;v>0&&g>=0;){const y=l.document.operations[c][g];if(!y){v--,g--;continue}y.type==="NOOP"&&y.skip>0?(g=g-(y.skip+1),l.skip+=y.skip+1):(l.document.clipboard.push({...y}),v--,g--)}l.action=_t(c)})}function Ge(n,r,p){const{scope:c,input:f}=r,u={document:n,action:r,skip:p};return D.produce(u,l=>{if(l.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(f>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(f<1)throw new Error("Invalid REDO action: invalid redo input value");if(l.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const a=l.document.clipboard.findLastIndex(d=>d.scope===c);if(a<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${c}"`);const x=l.document.clipboard.splice(a,1)[0];l.action=D.castDraft({type:x.type,scope:x.scope,input:x.input})})}function Ve(n,r,p){const{scope:c}=r,f=n.operations[c];let{input:{start:u,end:l}}=r;u=u||0,l=l||f.length;const a=f.slice(u,l),x=f.slice(0,u),d=f.slice(l),v=tt(n.initialState,{...n.operations,[c]:x.concat(a)},p),{name:g,state:y}=v,b=x.length,E=x.length?x[x.length-1].timestamp:d.length?d[0].timestamp:new Date().toISOString();return tt(n.initialState,{...n.operations,[c]:[...x,{...Ft({name:g,state:y},a.length),timestamp:E,index:b,hash:bt({state:y},"global")},...d.map((U,L)=>({...U,index:b+L+1}))]},p)}function Xe(n,r){return{...n,name:r.name,state:r.state??{global:{},local:{}}}}const Vt="SET_NAME",$="UNDO",P="REDO",K="PRUNE",Xt="LOAD_STATE",Qe="NOOP";function ti(n,r){const p=n.revision[r.scope];return[$,P,K].includes(r.type)?p:p+1}function ei(n,r){return{...n,revision:{...n.revision,[r.scope]:ti(n,r)},lastModified:new Date().toISOString()}}function ii(n,r,p=0){if([$,P,K].includes(r.type))return n;const{scope:c}=r,f=n.operations[c].slice(0,n.revision[c]),u=[...f].pop();let l=((u==null?void 0:u.index)??-1)+1;if("index"in r){if(r.index>l+p)throw new Error(`Missing operations: expected ${l} with skip 0 or equivalent, got index ${r.index} with skip ${p}`);l=r.index}return f.push({...r,index:l,timestamp:new Date().toISOString(),hash:"",scope:c,skip:p}),{...n,operations:{...n.operations,[c]:f}}}function ri(n,r,p=0){let c=ii(n,r,p);return c=ei(c,r),c}function ni(n,r,p){switch(Wt().parse(r),r.type){case Vt:return Ze(n,r.input);case K:return Ve(n,r,p);case Xt:return Xe(n,r.input.state);default:return n}}function Qt(n,r,p){switch(r.type){case $:return Ye(n,r,p);case P:return Ge(n,r,p);default:return{document:n,action:r,skip:p}}}function gt(n,r,p,c,f={}){const{skip:u,ignoreSkipOperations:l=!1}=f;let a={...r},x=u||0,d=n,v=[...n.clipboard];if(ae(a)){const{document:g,skip:y}=Ke(d,a,x);x=y,d=g}if(lt(a)){const{skip:g,action:y,document:b}=Qt(n,a,x);a=y,x=g,d=b,v=[...d.clipboard]}if(ut(a)&&(d=ni(d,a,p)),x>0&&!l){let g=x;"index"in a&&(g=ue(d.operations[a.scope],a.index,x)),d=tt(d.initialState,d.operations,p,void 0,void 0,void 0,{[a.scope]:g})}return d=ri(d,a,x),d=D.produce(d,g=>{const y=p(g.state,a,c),b=lt(r)?[...v]:[];if(y)return D.castDraft({...d,clipboard:[...b],state:y});g.clipboard=D.castDraft([...b])}),D.produce(d,g=>{if([$,P,K].includes(a.type))return g;const y=a.scope||"global";g.operations[y][g.operations[y].length-1].hash=bt(g,y),!ut(a)&&a.attachments&&a.attachments.forEach(b=>{const{hash:E,...U}=b;g.attachments[E]={...U}})})}function oi(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var st={exports:{}};typeof Object.create=="function"?st.exports=function(r,p){p&&(r.super_=p,r.prototype=Object.create(p.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:st.exports=function(r,p){if(p){r.super_=p;var c=function(){};c.prototype=p.prototype,r.prototype=new c,r.prototype.constructor=r}};var ai=st.exports,ct={exports:{}},te={},et={};et.byteLength=ci;et.toByteArray=ui;et.fromByteArray=hi;var z=[],I=[],pi=typeof Uint8Array<"u"?Uint8Array:Array,at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var C=0,si=at.length;C<si;++C)z[C]=at[C],I[at.charCodeAt(C)]=C;I[45]=62;I[95]=63;function ee(n){var r=n.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var p=n.indexOf("=");p===-1&&(p=r);var c=p===r?0:4-p%4;return[p,c]}function ci(n){var r=ee(n),p=r[0],c=r[1];return(p+c)*3/4-c}function li(n,r,p){return(r+p)*3/4-p}function ui(n){var r,p=ee(n),c=p[0],f=p[1],u=new pi(li(n,c,f)),l=0,a=f>0?c-4:c,x;for(x=0;x<a;x+=4)r=I[n.charCodeAt(x)]<<18|I[n.charCodeAt(x+1)]<<12|I[n.charCodeAt(x+2)]<<6|I[n.charCodeAt(x+3)],u[l++]=r>>16&255,u[l++]=r>>8&255,u[l++]=r&255;return f===2&&(r=I[n.charCodeAt(x)]<<2|I[n.charCodeAt(x+1)]>>4,u[l++]=r&255),f===1&&(r=I[n.charCodeAt(x)]<<10|I[n.charCodeAt(x+1)]<<4|I[n.charCodeAt(x+2)]>>2,u[l++]=r>>8&255,u[l++]=r&255),u}function fi(n){return z[n>>18&63]+z[n>>12&63]+z[n>>6&63]+z[n&63]}function mi(n,r,p){for(var c,f=[],u=r;u<p;u+=3)c=(n[u]<<16&16711680)+(n[u+1]<<8&65280)+(n[u+2]&255),f.push(fi(c));return f.join("")}function hi(n){for(var r,p=n.length,c=p%3,f=[],u=16383,l=0,a=p-c;l<a;l+=u)f.push(mi(n,l,l+u>a?a:l+u));return c===1?(r=n[p-1],f.push(z[r>>2]+z[r<<4&63]+"==")):c===2&&(r=(n[p-2]<<8)+n[p-1],f.push(z[r>>10]+z[r>>4&63]+z[r<<2&63]+"=")),f.join("")}var yt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */yt.read=function(n,r,p,c,f){var u,l,a=f*8-c-1,x=(1<<a)-1,d=x>>1,v=-7,g=p?f-1:0,y=p?-1:1,b=n[r+g];for(g+=y,u=b&(1<<-v)-1,b>>=-v,v+=a;v>0;u=u*256+n[r+g],g+=y,v-=8);for(l=u&(1<<-v)-1,u>>=-v,v+=c;v>0;l=l*256+n[r+g],g+=y,v-=8);if(u===0)u=1-d;else{if(u===x)return l?NaN:(b?-1:1)*(1/0);l=l+Math.pow(2,c),u=u-d}return(b?-1:1)*l*Math.pow(2,u-c)};yt.write=function(n,r,p,c,f,u){var l,a,x,d=u*8-f-1,v=(1<<d)-1,g=v>>1,y=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=c?0:u-1,E=c?1:-1,U=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,l=v):(l=Math.floor(Math.log(r)/Math.LN2),r*(x=Math.pow(2,-l))<1&&(l--,x*=2),l+g>=1?r+=y/x:r+=y*Math.pow(2,1-g),r*x>=2&&(l++,x/=2),l+g>=v?(a=0,l=v):l+g>=1?(a=(r*x-1)*Math.pow(2,f),l=l+g):(a=r*Math.pow(2,g-1)*Math.pow(2,f),l=0));f>=8;n[p+b]=a&255,b+=E,a/=256,f-=8);for(l=l<<f|a,d+=f;d>0;n[p+b]=l&255,b+=E,l/=256,d-=8);n[p+b-E]|=U*128};/*!
1
+ "use strict";var Le=Object.defineProperty;var Ce=(n,i,p)=>i in n?Le(n,i,{enumerable:!0,configurable:!0,writable:!0,value:p}):n[i]=p;var X=(n,i,p)=>(Ce(n,typeof i!="symbol"?i+"":i,p),p);const D=require("immer"),pt=require("json-stringify-deterministic"),w=require("zod"),Nt=require("jszip"),Rt=n=>n!=null,qe=w.z.any().refine(n=>Rt(n)),Lt=w.z.enum(["LOAD_STATE"]),Ct=w.z.enum(["PRUNE"]),qt=w.z.enum(["REDO"]),$t=w.z.enum(["SET_NAME"]),Pt=w.z.enum(["UNDO"]);function $e(){return w.z.object({__typename:w.z.literal("Action").optional(),type:w.z.string()})}function J(){return w.z.literal("global").or(w.z.literal("local"))}function Wt(){return w.z.union([Jt(),Zt(),Kt(),Yt(),Gt()])}function Pe(){return w.z.object({__typename:w.z.literal("DocumentFile").optional(),data:w.z.string(),extension:w.z.string().nullable(),fileName:w.z.string().nullable(),mimeType:w.z.string()})}function Jt(){return w.z.object({input:w.z.lazy(()=>mt()),type:Lt,scope:J()})}function mt(){return w.z.object({operations:w.z.number(),state:w.z.lazy(()=>Ht())})}function Ht(){return w.z.object({data:w.z.unknown().nullish(),name:w.z.string()})}function We(){return w.z.object({__typename:w.z.literal("Operation").optional(),hash:w.z.string(),index:w.z.number(),timestamp:w.z.string().datetime(),type:w.z.string()})}function Zt(){return w.z.object({input:w.z.lazy(()=>ht()),type:Ct,scope:J()})}function ht(){return w.z.object({end:w.z.number().nullish(),start:w.z.number().nullish()})}const xt=w.z.number;function Kt(){return w.z.object({input:xt(),type:qt,scope:J()})}const dt=w.z.string;function Yt(){return w.z.object({input:dt(),type:$t,scope:w.z.literal("global")})}function Je(){return w.z.object({__typename:w.z.literal("SetNameOperation").optional(),hash:w.z.string(),index:w.z.number(),input:w.z.string(),timestamp:w.z.string().datetime(),type:w.z.string()})}const wt=w.z.number;function Gt(){return w.z.object({input:wt(),type:Pt,scope:J()})}const He=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:$e,BaseActionSchema:Wt,DocumentFileSchema:Pe,LoadStateActionInputSchema:mt,LoadStateActionSchema:Jt,LoadStateActionStateInputSchema:Ht,Load_StateSchema:Lt,OperationSchema:We,OperationScopeSchema:J,PruneActionInputSchema:ht,PruneActionSchema:Zt,PruneSchema:Ct,RedoActionInputSchema:xt,RedoActionSchema:Kt,RedoSchema:qt,SetNameActionInputSchema:dt,SetNameActionSchema:Yt,SetNameOperationSchema:Je,Set_NameSchema:$t,UndoActionInputSchema:wt,UndoActionSchema:Gt,UndoSchema:Pt,definedNonNullAnySchema:qe,isDefinedNonNullAny:Rt},Symbol.toStringTag,{value:"Module"}));function Ze(n,i){return{...n,name:i}}function Ke(n,i,p){const c={skip:p,document:n},{scope:f}=i;return!f||i.skip===void 0?c:D.produce(c,u=>{const[l]=u.document.operations[f].slice(-1);i.skip&&i.skip>0&&(u.skip=i.skip),l.type==="NOOP"&&i.index===l.index&&u.skip>l.skip&&u.document.operations[f].pop()})}function Ye(n,i,p){const{scope:c,input:f}=i,u={document:n,action:i,skip:p};return D.produce(u,l=>{if(l.document.operations[c].length<1)throw new Error(`Cannot undo: no operations in history for scope "${c}"`);if(f<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(l.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[a]=l.document.operations[c].slice(-1),x=a.type==="NOOP"&&a.skip>0;if(l.skip+=f,x){l.skip+=a.skip;const y=l.document.operations[c][l.document.operations[c].length-2];y&&a.index-y.index===1&&l.document.operations[c].pop()}if(l.document.operations[c].length<l.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const d=l.document.operations[c].length-1;let v=f,g=x?d-a.skip:d;for(;v>0&&g>=0;){const y=l.document.operations[c][g];if(!y){v--,g--;continue}y.type==="NOOP"&&y.skip>0?(g=g-(y.skip+1),l.skip+=y.skip+1):(l.document.clipboard.push({...y}),v--,g--)}l.action=_t(c)})}function Ge(n,i,p){const{scope:c,input:f}=i,u={document:n,action:i,skip:p};return D.produce(u,l=>{if(l.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(f>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(f<1)throw new Error("Invalid REDO action: invalid redo input value");if(l.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const a=l.document.clipboard.findLastIndex(d=>d.scope===c);if(a<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${c}"`);const x=l.document.clipboard.splice(a,1)[0];l.action=D.castDraft({type:x.type,scope:x.scope,input:x.input})})}function Ve(n,i,p){const{scope:c}=i,f=n.operations[c];let{input:{start:u,end:l}}=i;u=u||0,l=l||f.length;const a=f.slice(u,l),x=f.slice(0,u),d=f.slice(l),v=Q(n.initialState,{...n.operations,[c]:x.concat(a)},p),{name:g,state:y}=v,b=x.length,E=x.length?x[x.length-1].timestamp:d.length?d[0].timestamp:new Date().toISOString();return Q(n.initialState,{...n.operations,[c]:[...x,{...Ft({name:g,state:y},a.length),timestamp:E,index:b,hash:bt({state:y},"global")},...d.map((U,L)=>({...U,index:b+L+1}))]},p)}function Xe(n,i){return{...n,name:i.name,state:i.state??{global:{},local:{}}}}const Vt="SET_NAME",H="UNDO",Z="REDO",tt="PRUNE",Xt="LOAD_STATE",Qe="NOOP";function ti(n,i){let p;return"index"in i?p={...i}:p=n.operations[i.scope].slice(-1)[0],((p==null?void 0:p.index)??-1)+1}function ei(n,i){return{...n,revision:{...n.revision,[i.scope]:ti(n,i)},lastModified:new Date().toISOString()}}function ii(n,i,p=0){if([H,Z,tt].includes(i.type))return n;const{scope:c}=i,f=n.operations[c].slice(0,n.revision[c]),u=[...f].pop();let l=((u==null?void 0:u.index)??-1)+1;if("index"in i){if(i.index>l+p)throw new Error(`Missing operations: expected ${l} with skip 0 or equivalent, got index ${i.index} with skip ${p}`);l=i.index}return f.push({...i,index:l,timestamp:new Date().toISOString(),hash:"",scope:c,skip:p}),{...n,operations:{...n.operations,[c]:f}}}function ri(n,i,p=0){let c=ii(n,i,p);return c=ei(c,i),c}function ni(n,i,p){switch(Wt().parse(i),i.type){case Vt:return Ze(n,i.input);case tt:return Ve(n,i,p);case Xt:return Xe(n,i.input.state);default:return n}}function Qt(n,i,p){switch(i.type){case H:return Ye(n,i,p);case Z:return Ge(n,i,p);default:return{document:n,action:i,skip:p}}}function gt(n,i,p,c,f={}){const{skip:u,ignoreSkipOperations:l=!1}=f;let a={...i},x=u||0,d=n,v=[...n.clipboard];if(ae(a)){const{document:g,skip:y}=Ke(d,a,x);x=y,d=g}if(lt(a)){const{skip:g,action:y,document:b}=Qt(n,a,x);a=y,x=g,d=b,v=[...d.clipboard]}if(ut(a)&&(d=ni(d,a,p)),x>0&&!l){let g=x;"index"in a&&(g=ue(d.operations[a.scope],a.index,x)),d=Q(d.initialState,d.operations,p,void 0,void 0,void 0,{[a.scope]:g})}return d=ri(d,a,x),d=D.produce(d,g=>{const y=p(g.state,a,c),b=lt(i)?[...v]:[];if(y)return D.castDraft({...d,clipboard:[...b],state:y});g.clipboard=D.castDraft([...b])}),D.produce(d,g=>{if([H,Z,tt].includes(a.type))return g;const y=a.scope||"global";g.operations[y][g.operations[y].length-1].hash=bt(g,y),!ut(a)&&a.attachments&&a.attachments.forEach(b=>{const{hash:E,...U}=b;g.attachments[E]={...U}})})}function oi(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var st={exports:{}};typeof Object.create=="function"?st.exports=function(i,p){p&&(i.super_=p,i.prototype=Object.create(p.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}))}:st.exports=function(i,p){if(p){i.super_=p;var c=function(){};c.prototype=p.prototype,i.prototype=new c,i.prototype.constructor=i}};var ai=st.exports,ct={exports:{}},te={},et={};et.byteLength=ci;et.toByteArray=ui;et.fromByteArray=hi;var z=[],I=[],pi=typeof Uint8Array<"u"?Uint8Array:Array,at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var C=0,si=at.length;C<si;++C)z[C]=at[C],I[at.charCodeAt(C)]=C;I[45]=62;I[95]=63;function ee(n){var i=n.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var p=n.indexOf("=");p===-1&&(p=i);var c=p===i?0:4-p%4;return[p,c]}function ci(n){var i=ee(n),p=i[0],c=i[1];return(p+c)*3/4-c}function li(n,i,p){return(i+p)*3/4-p}function ui(n){var i,p=ee(n),c=p[0],f=p[1],u=new pi(li(n,c,f)),l=0,a=f>0?c-4:c,x;for(x=0;x<a;x+=4)i=I[n.charCodeAt(x)]<<18|I[n.charCodeAt(x+1)]<<12|I[n.charCodeAt(x+2)]<<6|I[n.charCodeAt(x+3)],u[l++]=i>>16&255,u[l++]=i>>8&255,u[l++]=i&255;return f===2&&(i=I[n.charCodeAt(x)]<<2|I[n.charCodeAt(x+1)]>>4,u[l++]=i&255),f===1&&(i=I[n.charCodeAt(x)]<<10|I[n.charCodeAt(x+1)]<<4|I[n.charCodeAt(x+2)]>>2,u[l++]=i>>8&255,u[l++]=i&255),u}function fi(n){return z[n>>18&63]+z[n>>12&63]+z[n>>6&63]+z[n&63]}function mi(n,i,p){for(var c,f=[],u=i;u<p;u+=3)c=(n[u]<<16&16711680)+(n[u+1]<<8&65280)+(n[u+2]&255),f.push(fi(c));return f.join("")}function hi(n){for(var i,p=n.length,c=p%3,f=[],u=16383,l=0,a=p-c;l<a;l+=u)f.push(mi(n,l,l+u>a?a:l+u));return c===1?(i=n[p-1],f.push(z[i>>2]+z[i<<4&63]+"==")):c===2&&(i=(n[p-2]<<8)+n[p-1],f.push(z[i>>10]+z[i>>4&63]+z[i<<2&63]+"=")),f.join("")}var yt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */yt.read=function(n,i,p,c,f){var u,l,a=f*8-c-1,x=(1<<a)-1,d=x>>1,v=-7,g=p?f-1:0,y=p?-1:1,b=n[i+g];for(g+=y,u=b&(1<<-v)-1,b>>=-v,v+=a;v>0;u=u*256+n[i+g],g+=y,v-=8);for(l=u&(1<<-v)-1,u>>=-v,v+=c;v>0;l=l*256+n[i+g],g+=y,v-=8);if(u===0)u=1-d;else{if(u===x)return l?NaN:(b?-1:1)*(1/0);l=l+Math.pow(2,c),u=u-d}return(b?-1:1)*l*Math.pow(2,u-c)};yt.write=function(n,i,p,c,f,u){var l,a,x,d=u*8-f-1,v=(1<<d)-1,g=v>>1,y=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,b=c?0:u-1,E=c?1:-1,U=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(a=isNaN(i)?1:0,l=v):(l=Math.floor(Math.log(i)/Math.LN2),i*(x=Math.pow(2,-l))<1&&(l--,x*=2),l+g>=1?i+=y/x:i+=y*Math.pow(2,1-g),i*x>=2&&(l++,x/=2),l+g>=v?(a=0,l=v):l+g>=1?(a=(i*x-1)*Math.pow(2,f),l=l+g):(a=i*Math.pow(2,g-1)*Math.pow(2,f),l=0));f>=8;n[p+b]=a&255,b+=E,a/=256,f-=8);for(l=l<<f|a,d+=f;d>0;n[p+b]=l&255,b+=E,l/=256,d-=8);n[p+b-E]|=U*128};/*!
2
2
  * The buffer module from node.js, for the browser.
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */(function(n){var r=et,p=yt,c=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=G,n.INSPECT_MAX_BYTES=50;var f=2147483647;n.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=u(),!a.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 u(){try{var i=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(i,t),i.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function l(i){if(i>f)throw new RangeError('The value "'+i+'" is invalid for option "size"');var t=new Uint8Array(i);return Object.setPrototypeOf(t,a.prototype),t}function a(i,t,e){if(typeof i=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(i)}return x(i,t,e)}a.poolSize=8192;function x(i,t,e){if(typeof i=="string")return y(i,t);if(ArrayBuffer.isView(i))return E(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(T(i,ArrayBuffer)||i&&T(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(T(i,SharedArrayBuffer)||i&&T(i.buffer,SharedArrayBuffer)))return U(i,t,e);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var o=i.valueOf&&i.valueOf();if(o!=null&&o!==i)return a.from(o,t,e);var s=L(i);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return a.from(i[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 i)}a.from=function(i,t,e){return x(i,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function d(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function v(i,t,e){return d(i),i<=0?l(i):t!==void 0?typeof e=="string"?l(i).fill(t,e):l(i).fill(t):l(i)}a.alloc=function(i,t,e){return v(i,t,e)};function g(i){return d(i),l(i<0?0:W(i)|0)}a.allocUnsafe=function(i){return g(i)},a.allocUnsafeSlow=function(i){return g(i)};function y(i,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=St(i,t)|0,o=l(e),s=o.write(i,t);return s!==e&&(o=o.slice(0,s)),o}function b(i){for(var t=i.length<0?0:W(i.length)|0,e=l(t),o=0;o<t;o+=1)e[o]=i[o]&255;return e}function E(i){if(T(i,Uint8Array)){var t=new Uint8Array(i);return U(t.buffer,t.byteOffset,t.byteLength)}return b(i)}function U(i,t,e){if(t<0||i.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var o;return t===void 0&&e===void 0?o=new Uint8Array(i):e===void 0?o=new Uint8Array(i,t):o=new Uint8Array(i,t,e),Object.setPrototypeOf(o,a.prototype),o}function L(i){if(a.isBuffer(i)){var t=W(i.length)|0,e=l(t);return e.length===0||i.copy(e,0,0,t),e}if(i.length!==void 0)return typeof i.length!="number"||ot(i.length)?l(0):b(i);if(i.type==="Buffer"&&Array.isArray(i.data))return b(i.data)}function W(i){if(i>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return i|0}function G(i){return+i!=i&&(i=0),a.alloc(+i)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){if(T(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),T(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var o=t.length,s=e.length,m=0,h=Math.min(o,s);m<h;++m)if(t[m]!==e[m]){o=t[m],s=e[m];break}return o<s?-1:s<o?1:0},a.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}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var o;if(e===void 0)for(e=0,o=0;o<t.length;++o)e+=t[o].length;var s=a.allocUnsafe(e),m=0;for(o=0;o<t.length;++o){var h=t[o];if(T(h,Uint8Array))m+h.length>s.length?a.from(h).copy(s,m):Uint8Array.prototype.set.call(s,h,m);else if(a.isBuffer(h))h.copy(s,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=h.length}return s};function St(i,t){if(a.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||T(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);var e=i.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&e===0)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return nt(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return zt(i).length;default:if(s)return o?-1:nt(i).length;t=(""+t).toLowerCase(),s=!0}}a.byteLength=St;function Ee(i,t,e){var o=!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(i||(i="utf8");;)switch(i){case"hex":return Ue(this,t,e);case"utf8":case"utf-8":return jt(this,t,e);case"ascii":return Oe(this,t,e);case"latin1":case"binary":return Ie(this,t,e);case"base64":return Be(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Te(this,t,e);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),o=!0}}a.prototype._isBuffer=!0;function M(i,t,e){var o=i[t];i[t]=i[e],i[e]=o}a.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)M(this,e,e+1);return this},a.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)M(this,e,e+3),M(this,e+1,e+2);return this},a.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)M(this,e,e+7),M(this,e+1,e+6),M(this,e+2,e+5),M(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?jt(this,0,t):Ee.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){var t="",e=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},c&&(a.prototype[c]=a.prototype.inspect),a.prototype.compare=function(t,e,o,s,m){if(T(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.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),o===void 0&&(o=t?t.length:0),s===void 0&&(s=0),m===void 0&&(m=this.length),e<0||o>t.length||s<0||m>this.length)throw new RangeError("out of range index");if(s>=m&&e>=o)return 0;if(s>=m)return-1;if(e>=o)return 1;if(e>>>=0,o>>>=0,s>>>=0,m>>>=0,this===t)return 0;for(var h=m-s,F=o-e,_=Math.min(h,F),k=this.slice(s,m),B=t.slice(e,o),S=0;S<_;++S)if(k[S]!==B[S]){h=k[S],F=B[S];break}return h<F?-1:F<h?1:0};function At(i,t,e,o,s){if(i.length===0)return-1;if(typeof e=="string"?(o=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,ot(e)&&(e=s?0:i.length-1),e<0&&(e=i.length+e),e>=i.length){if(s)return-1;e=i.length-1}else if(e<0)if(s)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:Bt(i,t,e,o,s);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(i,t,e):Uint8Array.prototype.lastIndexOf.call(i,t,e):Bt(i,[t],e,o,s);throw new TypeError("val must be string, number or Buffer")}function Bt(i,t,e,o,s){var m=1,h=i.length,F=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(i.length<2||t.length<2)return-1;m=2,h/=2,F/=2,e/=2}function _(Dt,Mt){return m===1?Dt[Mt]:Dt.readUInt16BE(Mt*m)}var k;if(s){var B=-1;for(k=e;k<h;k++)if(_(i,k)===_(t,B===-1?0:k-B)){if(B===-1&&(B=k),k-B+1===F)return B*m}else B!==-1&&(k-=k-B),B=-1}else for(e+F>h&&(e=h-F),k=e;k>=0;k--){for(var S=!0,X=0;X<F;X++)if(_(i,k+X)!==_(t,X)){S=!1;break}if(S)return k}return-1}a.prototype.includes=function(t,e,o){return this.indexOf(t,e,o)!==-1},a.prototype.indexOf=function(t,e,o){return At(this,t,e,o,!0)},a.prototype.lastIndexOf=function(t,e,o){return At(this,t,e,o,!1)};function Fe(i,t,e,o){e=Number(e)||0;var s=i.length-e;o?(o=Number(o),o>s&&(o=s)):o=s;var m=t.length;o>m/2&&(o=m/2);for(var h=0;h<o;++h){var F=parseInt(t.substr(h*2,2),16);if(ot(F))return h;i[e+h]=F}return h}function _e(i,t,e,o){return V(nt(t,i.length-e),i,e,o)}function ke(i,t,e,o){return V(Me(t),i,e,o)}function Se(i,t,e,o){return V(zt(t),i,e,o)}function Ae(i,t,e,o){return V(Ne(t,i.length-e),i,e,o)}a.prototype.write=function(t,e,o,s){if(e===void 0)s="utf8",o=this.length,e=0;else if(o===void 0&&typeof e=="string")s=e,o=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(o)?(o=o>>>0,s===void 0&&(s="utf8")):(s=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var m=this.length-e;if((o===void 0||o>m)&&(o=m),t.length>0&&(o<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var h=!1;;)switch(s){case"hex":return Fe(this,t,e,o);case"utf8":case"utf-8":return _e(this,t,e,o);case"ascii":case"latin1":case"binary":return ke(this,t,e,o);case"base64":return Se(this,t,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ae(this,t,e,o);default:if(h)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),h=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Be(i,t,e){return t===0&&e===i.length?r.fromByteArray(i):r.fromByteArray(i.slice(t,e))}function jt(i,t,e){e=Math.min(i.length,e);for(var o=[],s=t;s<e;){var m=i[s],h=null,F=m>239?4:m>223?3:m>191?2:1;if(s+F<=e){var _,k,B,S;switch(F){case 1:m<128&&(h=m);break;case 2:_=i[s+1],(_&192)===128&&(S=(m&31)<<6|_&63,S>127&&(h=S));break;case 3:_=i[s+1],k=i[s+2],(_&192)===128&&(k&192)===128&&(S=(m&15)<<12|(_&63)<<6|k&63,S>2047&&(S<55296||S>57343)&&(h=S));break;case 4:_=i[s+1],k=i[s+2],B=i[s+3],(_&192)===128&&(k&192)===128&&(B&192)===128&&(S=(m&15)<<18|(_&63)<<12|(k&63)<<6|B&63,S>65535&&S<1114112&&(h=S))}}h===null?(h=65533,F=1):h>65535&&(h-=65536,o.push(h>>>10&1023|55296),h=56320|h&1023),o.push(h),s+=F}return je(o)}var Ot=4096;function je(i){var t=i.length;if(t<=Ot)return String.fromCharCode.apply(String,i);for(var e="",o=0;o<t;)e+=String.fromCharCode.apply(String,i.slice(o,o+=Ot));return e}function Oe(i,t,e){var o="";e=Math.min(i.length,e);for(var s=t;s<e;++s)o+=String.fromCharCode(i[s]&127);return o}function Ie(i,t,e){var o="";e=Math.min(i.length,e);for(var s=t;s<e;++s)o+=String.fromCharCode(i[s]);return o}function Ue(i,t,e){var o=i.length;(!t||t<0)&&(t=0),(!e||e<0||e>o)&&(e=o);for(var s="",m=t;m<e;++m)s+=Re[i[m]];return s}function Te(i,t,e){for(var o=i.slice(t,e),s="",m=0;m<o.length-1;m+=2)s+=String.fromCharCode(o[m]+o[m+1]*256);return s}a.prototype.slice=function(t,e){var o=this.length;t=~~t,e=e===void 0?o:~~e,t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),e<t&&(e=t);var s=this.subarray(t,e);return Object.setPrototypeOf(s,a.prototype),s};function A(i,t,e){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||A(t,e,this.length);for(var s=this[t],m=1,h=0;++h<e&&(m*=256);)s+=this[t+h]*m;return s},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||A(t,e,this.length);for(var s=this[t+--e],m=1;e>0&&(m*=256);)s+=this[t+--e]*m;return s},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||A(t,e,this.length);for(var s=this[t],m=1,h=0;++h<e&&(m*=256);)s+=this[t+h]*m;return m*=128,s>=m&&(s-=Math.pow(2,8*e)),s},a.prototype.readIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||A(t,e,this.length);for(var s=e,m=1,h=this[t+--s];s>0&&(m*=256);)h+=this[t+--s]*m;return m*=128,h>=m&&(h-=Math.pow(2,8*e)),h},a.prototype.readInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||A(t,2,this.length);var o=this[t]|this[t+1]<<8;return o&32768?o|4294901760:o},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||A(t,2,this.length);var o=this[t+1]|this[t]<<8;return o&32768?o|4294901760:o},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t=t>>>0,e||A(t,4,this.length),p.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||A(t,4,this.length),p.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||A(t,8,this.length),p.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||A(t,8,this.length),p.read(this,t,!1,52,8)};function j(i,t,e,o,s,m){if(!a.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<m)throw new RangeError('"value" argument is out of bounds');if(e+o>i.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,o,s){if(t=+t,e=e>>>0,o=o>>>0,!s){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var h=1,F=0;for(this[e]=t&255;++F<o&&(h*=256);)this[e+F]=t/h&255;return e+o},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,o,s){if(t=+t,e=e>>>0,o=o>>>0,!s){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var h=o-1,F=1;for(this[e+h]=t&255;--h>=0&&(F*=256);)this[e+h]=t/F&255;return e+o},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(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},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(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},a.prototype.writeIntLE=function(t,e,o,s){if(t=+t,e=e>>>0,!s){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var h=0,F=1,_=0;for(this[e]=t&255;++h<o&&(F*=256);)t<0&&_===0&&this[e+h-1]!==0&&(_=1),this[e+h]=(t/F>>0)-_&255;return e+o},a.prototype.writeIntBE=function(t,e,o,s){if(t=+t,e=e>>>0,!s){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var h=o-1,F=1,_=0;for(this[e+h]=t&255;--h>=0&&(F*=256);)t<0&&_===0&&this[e+h+1]!==0&&(_=1),this[e+h]=(t/F>>0)-_&255;return e+o},a.prototype.writeInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(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},a.prototype.writeInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(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 It(i,t,e,o,s,m){if(e+o>i.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ut(i,t,e,o,s){return t=+t,e=e>>>0,s||It(i,t,e,4),p.write(i,t,e,o,23,4),e+4}a.prototype.writeFloatLE=function(t,e,o){return Ut(this,t,e,!0,o)},a.prototype.writeFloatBE=function(t,e,o){return Ut(this,t,e,!1,o)};function Tt(i,t,e,o,s){return t=+t,e=e>>>0,s||It(i,t,e,8),p.write(i,t,e,o,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,o){return Tt(this,t,e,!0,o)},a.prototype.writeDoubleBE=function(t,e,o){return Tt(this,t,e,!1,o)},a.prototype.copy=function(t,e,o,s){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),!s&&s!==0&&(s=this.length),e>=t.length&&(e=t.length),e||(e=0),s>0&&s<o&&(s=o),s===o||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-e<s-o&&(s=t.length-e+o);var m=s-o;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,o,s):Uint8Array.prototype.set.call(t,this.subarray(o,s),e),m},a.prototype.fill=function(t,e,o,s){if(typeof t=="string"){if(typeof e=="string"?(s=e,e=0,o=this.length):typeof o=="string"&&(s=o,o=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(t.length===1){var m=t.charCodeAt(0);(s==="utf8"&&m<128||s==="latin1")&&(t=m)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<o)throw new RangeError("Out of range index");if(o<=e)return this;e=e>>>0,o=o===void 0?this.length:o>>>0,t||(t=0);var h;if(typeof t=="number")for(h=e;h<o;++h)this[h]=t;else{var F=a.isBuffer(t)?t:a.from(t,s),_=F.length;if(_===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(h=0;h<o-e;++h)this[h+e]=F[h%_]}return this};var ze=/[^+/0-9A-Za-z-_]/g;function De(i){if(i=i.split("=")[0],i=i.trim().replace(ze,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function nt(i,t){t=t||1/0;for(var e,o=i.length,s=null,m=[],h=0;h<o;++h){if(e=i.charCodeAt(h),e>55295&&e<57344){if(!s){if(e>56319){(t-=3)>-1&&m.push(239,191,189);continue}else if(h+1===o){(t-=3)>-1&&m.push(239,191,189);continue}s=e;continue}if(e<56320){(t-=3)>-1&&m.push(239,191,189),s=e;continue}e=(s-55296<<10|e-56320)+65536}else s&&(t-=3)>-1&&m.push(239,191,189);if(s=null,e<128){if((t-=1)<0)break;m.push(e)}else if(e<2048){if((t-=2)<0)break;m.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;m.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;m.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return m}function Me(i){for(var t=[],e=0;e<i.length;++e)t.push(i.charCodeAt(e)&255);return t}function Ne(i,t){for(var e,o,s,m=[],h=0;h<i.length&&!((t-=2)<0);++h)e=i.charCodeAt(h),o=e>>8,s=e%256,m.push(s),m.push(o);return m}function zt(i){return r.toByteArray(De(i))}function V(i,t,e,o){for(var s=0;s<o&&!(s+e>=t.length||s>=i.length);++s)t[s+e]=i[s];return s}function T(i,t){return i instanceof t||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===t.name}function ot(i){return i!==i}var Re=function(){for(var i="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var o=e*16,s=0;s<16;++s)t[o+s]=i[e]+i[s];return t}()})(te);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,r){var p=te,c=p.Buffer;function f(l,a){for(var x in l)a[x]=l[x]}c.from&&c.alloc&&c.allocUnsafe&&c.allocUnsafeSlow?n.exports=p:(f(p,r),r.Buffer=u);function u(l,a,x){return c(l,a,x)}u.prototype=Object.create(c.prototype),f(c,u),u.from=function(l,a,x){if(typeof l=="number")throw new TypeError("Argument must not be a number");return c(l,a,x)},u.alloc=function(l,a,x){if(typeof l!="number")throw new TypeError("Argument must be a number");var d=c(l);return a!==void 0?typeof x=="string"?d.fill(a,x):d.fill(a):d.fill(0),d},u.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return c(l)},u.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return p.SlowBuffer(l)}})(ct,ct.exports);var ie=ct.exports,re=ie.Buffer;function it(n,r){this._block=re.alloc(n),this._finalSize=r,this._blockSize=n,this._len=0}it.prototype.update=function(n,r){typeof n=="string"&&(r=r||"utf8",n=re.from(n,r));for(var p=this._block,c=this._blockSize,f=n.length,u=this._len,l=0;l<f;){for(var a=u%c,x=Math.min(f-l,c-a),d=0;d<x;d++)p[a+d]=n[l+d];u+=x,l+=x,u%c===0&&this._update(p)}return this._len+=f,this};it.prototype.digest=function(n){var r=this._len%this._blockSize;this._block[r]=128,this._block.fill(0,r+1),r>=this._finalSize&&(this._update(this._block),this._block.fill(0));var p=this._len*8;if(p<=4294967295)this._block.writeUInt32BE(p,this._blockSize-4);else{var c=(p&4294967295)>>>0,f=(p-c)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(c,this._blockSize-4)}this._update(this._block);var u=this._hash();return n?u.toString(n):u};it.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var xi=it,di=ai,ne=xi,wi=ie.Buffer,gi=[1518500249,1859775393,-1894007588,-899497514],yi=new Array(80);function Y(){this.init(),this._w=yi,ne.call(this,64,56)}di(Y,ne);Y.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function vi(n){return n<<1|n>>>31}function bi(n){return n<<5|n>>>27}function Ei(n){return n<<30|n>>>2}function Fi(n,r,p,c){return n===0?r&p|~r&c:n===2?r&p|r&c|p&c:r^p^c}Y.prototype._update=function(n){for(var r=this._w,p=this._a|0,c=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=0;a<16;++a)r[a]=n.readInt32BE(a*4);for(;a<80;++a)r[a]=vi(r[a-3]^r[a-8]^r[a-14]^r[a-16]);for(var x=0;x<80;++x){var d=~~(x/20),v=bi(p)+Fi(d,c,f,u)+l+r[x]+gi[d]|0;l=u,u=f,f=Ei(c),c=p,p=v}this._a=p+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0};Y.prototype._hash=function(){var n=wi.allocUnsafe(20);return n.writeInt32BE(this._a|0,0),n.writeInt32BE(this._b|0,4),n.writeInt32BE(this._c|0,8),n.writeInt32BE(this._d|0,12),n.writeInt32BE(this._e|0,16),n};var _i=Y;const ki=oi(_i),vt=new Error("File system not available.");function Si(n,r,p){throw vt}function oe(n){throw vt}function Ai(n){throw vt}const Bi=async n=>oe();function ji(n){let r="";for(let p=0;p<n.length;p+=2)r+=String.fromCharCode(parseInt(n.substr(p,2),16));return btoa(r)}const rt=(n,r="sha1")=>{if(r!=="sha1")throw new Error("Only sha1 algorithm is available.");const p=new ki;return ji(p.update(n).digest("hex"))};function ae(n){return n.type===Qe&&n.skip!==void 0&&n.skip>0&&n.hash!==void 0}function lt(n){return[$,P].includes(n.type)}function ut(n){return[Vt,$,P,K,Xt].includes(n.type)}function R(n,r,p,c,f="global"){if(!n)throw new Error("Empty action type");if(typeof n!="string")throw new Error(`Invalid action type: ${n}`);const u={type:n,input:r,scope:f};p&&(u.attachments=p);try{c==null||c().parse(u.input)}catch(l){throw new Error(`Invalid action input: ${l}`)}return u}function pe(n,r=gt){return(p,c,f,u)=>r(p,c,n,f,u)}const se=(n,r)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...n,state:(r==null?void 0:r(n==null?void 0:n.state))??(n==null?void 0:n.state)??{global:{},local:{}}}),ce=(n,r)=>{const p=se(n,r);return{...p,initialState:p,operations:{global:[],local:[]},clipboard:[]}},bt=(n,r="global")=>rt(pt(n.state[r])),Oi=(n,r=1e3)=>{const p=Math.random()*r;return rt(`${(n??new Date).toISOString()}${p}`)};function J(n){return D.castImmutable(D.freeze(n,!0))}function le(n,r){const p=[...n];let c=r||0,f=p.length>0?p[p.length-1].index:0;const u=[];for(const l of p.reverse()){if(c>0){const d=f-l.index;c-=d}if(c<0)throw new Error("Invalid operation index, missing operations");const a={ignore:c>0,operation:l},x=l.skip>0?l.skip+1:0;if(x>0&&x>c){const d=x-c;c=c+d}f=l.index,u.push(a)}return u.reverse()}function ue(n,r,p){const c=n.slice().sort((a,x)=>a.skip-x.skip).sort((a,x)=>a.index-x.index);let f=p,u=0,l=r;for(const a of c.reverse()){const x=l-a.index;if(f=f-x,f>-1)u++,l=a.index;else break}return u}function Ii(n){return Object.values(n).flatMap(r=>r).sort((r,p)=>new Date(r.timestamp).getTime()-new Date(p.timestamp).getTime())}function fe(n){return Object.values(n).flatMap(r=>r).sort((r,p)=>new Date(r.operation.timestamp).getTime()-new Date(p.operation.timestamp).getTime())}function tt(n,r,p,c,f,u=gt,l={}){const a=pe(p,u);return Et(n,r,a,c,f,l)}function Et(n,r,p,c,f,u={}){const l=ce(n),a=Object.keys(r).reduce((y,b)=>{const E=b;return{...y,[E]:r[E].slice(0,f==null?void 0:f.revision[E])}},{}),x=Object.keys(a).reduce((y,b)=>{const E=b;return{...y,[E]:le(a[E],u[E])}},{}),d=fe(x).reduce((y,{ignore:b,operation:E})=>b?p(y,_t(E.scope),c,{skip:E.skip,ignoreSkipOperations:!0}):p(y,E,c,{skip:E.skip,ignoreSkipOperations:!0}),l),v=Object.keys(d.operations).reduce((y,b)=>{const E=b,U=f&&f.revision[E]<r[E].length?r[E].slice(f.revision[E]):[];return{...y,[E]:[...d.operations[E].map((L,W)=>{var G;return{...L,timestamp:((G=r[E][W])==null?void 0:G.timestamp)??L.timestamp}}),...U]}},{global:[],local:[]}),g=Object.values(v).reduce((y,b)=>{for(const E of b)E.timestamp>y&&(y=E.timestamp);return y},n.lastModified);return{...d,operations:v,lastModified:g}}function Ui(n,r){return pt(n)===pt(r)}const me=n=>R("SET_NAME",n,void 0,dt,void 0),he=(n=1,r="global")=>R("UNDO",n,void 0,wt,r),xe=(n=1,r="global")=>R("REDO",n,void 0,xt,r),de=(n,r,p="global")=>R("PRUNE",{start:n,end:r},void 0,ht,p),Ft=(n,r)=>R("LOAD_STATE",{state:n,operations:r},void 0,mt),_t=(n="global")=>R("NOOP",{},void 0,void 0,n),Ti=Object.freeze(Object.defineProperty({__proto__:null,loadState:Ft,noop:_t,prune:de,redo:xe,setName:me,undo:he},Symbol.toStringTag,{value:"Module"})),we={"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(we);var O=function(n,r,p,c){if(p==="a"&&!c)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?n!==r||!c:!r.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return p==="m"?c:p==="a"?c.call(n):c?c.value:r.get(n)},q,H,N;class zi{constructor(...r){q.set(this,new Map),H.set(this,new Map),N.set(this,new Map);for(const p of r)this.define(p)}define(r,p=!1){for(let[c,f]of Object.entries(r)){c=c.toLowerCase(),f=f.map(a=>a.toLowerCase()),O(this,N,"f").has(c)||O(this,N,"f").set(c,new Set);const u=O(this,N,"f").get(c);let l=!0;for(let a of f){const x=a.startsWith("*");if(a=x?a.slice(1):a,u==null||u.add(a),l&&O(this,H,"f").set(c,a),l=!1,x)continue;const d=O(this,q,"f").get(a);if(d&&d!=c&&!p)throw new Error(`"${c} -> ${a}" conflicts with "${d} -> ${a}". Pass \`force=true\` to override this definition.`);O(this,q,"f").set(a,c)}}return this}getType(r){if(typeof r!="string")return null;const p=r.replace(/^.*[/\\]/,"").toLowerCase(),c=p.replace(/^.*\./,"").toLowerCase(),f=p.length<r.length;return!(c.length<p.length-1)&&f?null:O(this,q,"f").get(c)??null}getExtension(r){var p;return typeof r!="string"?null:(r=(p=r==null?void 0:r.split)==null?void 0:p.call(r,";")[0],(r&&O(this,H,"f").get(r.trim().toLowerCase()))??null)}getAllExtensions(r){return typeof r!="string"?null:O(this,N,"f").get(r.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 r of O(this,N,"f").values())Object.freeze(r);return this}_getTestState(){return{types:O(this,q,"f"),extensions:O(this,H,"f")}}}q=new WeakMap,H=new WeakMap,N=new WeakMap;const Di=new zi(we)._freeze();function ge(n){const r=[],p=Object.keys(n);for(const c of p){const f=n[c].sort((u,l)=>u.index-l.index);for(let u=0;u<f.length;u++)f[u].index!==u&&r.push({message:`Invalid operation index ${f[u].index} at position ${u}`,details:{position:u,operation:f[u],scope:f[u].scope}})}return r}const kt=async n=>{const r=new Nt,{name:p,revision:c,documentType:f,created:u,lastModified:l}=n,a={name:p,revision:c,documentType:f,created:u,lastModified:l};return r.file("header.json",JSON.stringify(a,null,2)),r.file("state.json",JSON.stringify(n.initialState||{},null,2)),r.file("operations.json",JSON.stringify(n.operations,null,2)),Object.keys(n.attachments).forEach(d=>{const{data:v,...g}=n.attachments[d];r.file(d,v,{base64:!0,createFolders:!0,comment:JSON.stringify(g)})}),r},ye=async(n,r,p,c)=>{await(await kt(n)).generateAsync({type:"uint8array",streamFiles:!0});const u=c??n.name,l=`.${p}.zip`;return Si(r,u.endsWith(l)?u:`${u}${l}`)},Mi=async(n,r)=>{const c=await(await kt(n)).generateAsync({type:"blob"}),f=await r.createWritable();await f.write(c),await f.close()},ft=async(n,r)=>{const p=oe();return ve(p,r)},ve=async(n,r)=>{const p=new Nt;return await p.loadAsync(n),Ni(p,r)};async function Ni(n,r){const p=n.file("state.json");if(!p)throw new Error("Initial state not found");const c=await p.async("string"),f=JSON.parse(c),u=n.file("header.json");let l;u&&(l=JSON.parse(await u.async("string")));const a=n.file("operations.json");if(!a)throw new Error("Operations history not found");const x=JSON.parse(await a.async("string")),d=ge(x);if(d.length){const g=d.map(y=>y.message);throw new Error(g.join(`
7
- `))}let v=Et(f,x,r,void 0,l);return l&&(v={...v,...l}),v}function be(n){const r=n.replace(/^.*\./,"")||void 0,p=n.replace(/^.*[/\\]/,"")||void 0;return{extension:r,fileName:p}}async function Ri(n){const{buffer:r,mimeType:p="application/octet-stream"}=await Ai(),c=be(n),f=r.toString("base64");return{data:f,hash:rt(f),mimeType:p,...c}}async function Li(n){const r=await Bi(),p=Di.getType(n)||"application/octet-stream",c=be(n),f=r.toString("base64");return{data:f,hash:rt(f),mimeType:p,...c}}class Ci{constructor(r,p,c){Q(this,"_document");Q(this,"_reducer");Q(this,"_signalDispatch");this._reducer=r,this._document=p,this._signalDispatch=c}dispatch(r,p){return this._document=this._reducer(this._document,r,this._signalDispatch,p),this}saveToFile(r,p,c){return ye(this._document,r,p,c)}async loadFromFile(r){this._document=await ft(r,this._reducer)}static async stateFromFile(r,p){return await ft(r,p)}get state(){return J(this._document.state)}get operations(){return J(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(r){return this._document.revision[r]}get initialState(){return J(this._document.initialState)}toDocument(){return J(this._document)}getAttachment(r){return this._document.attachments[r]}setName(r){return this.dispatch(me(r)),this}undo(r){return this.dispatch(he(r)),this}redo(r){return this.dispatch(xe(r)),this}prune(r,p){return this.dispatch(de(r,p)),this}loadState(r,p){return this.dispatch(Ft(r,p)),this}}function qi(n,r){r.forEach(p=>{Object.getOwnPropertyNames(p.prototype).forEach(c=>{Object.defineProperty(n.prototype,c,Object.getOwnPropertyDescriptor(p.prototype,c)||Object.create(null))})})}exports.BaseActions=Ti;exports.BaseDocument=Ci;exports.applyMixins=qi;exports.baseReducer=gt;exports.calculateSkipsLeft=ue;exports.createAction=R;exports.createDocument=ce;exports.createExtendedState=se;exports.createReducer=pe;exports.createZip=kt;exports.getLocalFile=Li;exports.getRemoteFile=Ri;exports.hashDocument=bt;exports.hashKey=Oi;exports.isBaseAction=ut;exports.isNoopOperation=ae;exports.isSameDocument=Ui;exports.isUndoRedo=lt;exports.loadFromFile=ft;exports.loadFromInput=ve;exports.mapSkippedOperations=le;exports.processUndoRedo=Qt;exports.readOnly=J;exports.replayDocument=Et;exports.replayOperations=tt;exports.saveToFile=ye;exports.saveToFileHandle=Mi;exports.sortMappedOperations=fe;exports.sortOperations=Ii;exports.validateOperations=ge;exports.zod=He;
6
+ */(function(n){var i=et,p=yt,c=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=Y,n.INSPECT_MAX_BYTES=50;var f=2147483647;n.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=u(),!a.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 u(){try{var r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function l(r){if(r>f)throw new RangeError('The value "'+r+'" is invalid for option "size"');var t=new Uint8Array(r);return Object.setPrototypeOf(t,a.prototype),t}function a(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(r)}return x(r,t,e)}a.poolSize=8192;function x(r,t,e){if(typeof r=="string")return y(r,t);if(ArrayBuffer.isView(r))return E(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(T(r,ArrayBuffer)||r&&T(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(T(r,SharedArrayBuffer)||r&&T(r.buffer,SharedArrayBuffer)))return U(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var o=r.valueOf&&r.valueOf();if(o!=null&&o!==r)return a.from(o,t,e);var s=L(r);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return a.from(r[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 r)}a.from=function(r,t,e){return x(r,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function d(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function v(r,t,e){return d(r),r<=0?l(r):t!==void 0?typeof e=="string"?l(r).fill(t,e):l(r).fill(t):l(r)}a.alloc=function(r,t,e){return v(r,t,e)};function g(r){return d(r),l(r<0?0:$(r)|0)}a.allocUnsafe=function(r){return g(r)},a.allocUnsafeSlow=function(r){return g(r)};function y(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=St(r,t)|0,o=l(e),s=o.write(r,t);return s!==e&&(o=o.slice(0,s)),o}function b(r){for(var t=r.length<0?0:$(r.length)|0,e=l(t),o=0;o<t;o+=1)e[o]=r[o]&255;return e}function E(r){if(T(r,Uint8Array)){var t=new Uint8Array(r);return U(t.buffer,t.byteOffset,t.byteLength)}return b(r)}function U(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var o;return t===void 0&&e===void 0?o=new Uint8Array(r):e===void 0?o=new Uint8Array(r,t):o=new Uint8Array(r,t,e),Object.setPrototypeOf(o,a.prototype),o}function L(r){if(a.isBuffer(r)){var t=$(r.length)|0,e=l(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||ot(r.length)?l(0):b(r);if(r.type==="Buffer"&&Array.isArray(r.data))return b(r.data)}function $(r){if(r>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return r|0}function Y(r){return+r!=r&&(r=0),a.alloc(+r)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){if(T(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),T(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var o=t.length,s=e.length,m=0,h=Math.min(o,s);m<h;++m)if(t[m]!==e[m]){o=t[m],s=e[m];break}return o<s?-1:s<o?1:0},a.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}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var o;if(e===void 0)for(e=0,o=0;o<t.length;++o)e+=t[o].length;var s=a.allocUnsafe(e),m=0;for(o=0;o<t.length;++o){var h=t[o];if(T(h,Uint8Array))m+h.length>s.length?a.from(h).copy(s,m):Uint8Array.prototype.set.call(s,h,m);else if(a.isBuffer(h))h.copy(s,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=h.length}return s};function St(r,t){if(a.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||T(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var e=r.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&e===0)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return nt(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return zt(r).length;default:if(s)return o?-1:nt(r).length;t=(""+t).toLowerCase(),s=!0}}a.byteLength=St;function Ee(r,t,e){var o=!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(r||(r="utf8");;)switch(r){case"hex":return Ue(this,t,e);case"utf8":case"utf-8":return jt(this,t,e);case"ascii":return Oe(this,t,e);case"latin1":case"binary":return Ie(this,t,e);case"base64":return Be(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Te(this,t,e);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),o=!0}}a.prototype._isBuffer=!0;function M(r,t,e){var o=r[t];r[t]=r[e],r[e]=o}a.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)M(this,e,e+1);return this},a.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)M(this,e,e+3),M(this,e+1,e+2);return this},a.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)M(this,e,e+7),M(this,e+1,e+6),M(this,e+2,e+5),M(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?jt(this,0,t):Ee.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){var t="",e=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},c&&(a.prototype[c]=a.prototype.inspect),a.prototype.compare=function(t,e,o,s,m){if(T(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.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),o===void 0&&(o=t?t.length:0),s===void 0&&(s=0),m===void 0&&(m=this.length),e<0||o>t.length||s<0||m>this.length)throw new RangeError("out of range index");if(s>=m&&e>=o)return 0;if(s>=m)return-1;if(e>=o)return 1;if(e>>>=0,o>>>=0,s>>>=0,m>>>=0,this===t)return 0;for(var h=m-s,F=o-e,_=Math.min(h,F),k=this.slice(s,m),B=t.slice(e,o),S=0;S<_;++S)if(k[S]!==B[S]){h=k[S],F=B[S];break}return h<F?-1:F<h?1:0};function At(r,t,e,o,s){if(r.length===0)return-1;if(typeof e=="string"?(o=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,ot(e)&&(e=s?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(s)return-1;e=r.length-1}else if(e<0)if(s)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:Bt(r,t,e,o,s);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Bt(r,[t],e,o,s);throw new TypeError("val must be string, number or Buffer")}function Bt(r,t,e,o,s){var m=1,h=r.length,F=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(r.length<2||t.length<2)return-1;m=2,h/=2,F/=2,e/=2}function _(Dt,Mt){return m===1?Dt[Mt]:Dt.readUInt16BE(Mt*m)}var k;if(s){var B=-1;for(k=e;k<h;k++)if(_(r,k)===_(t,B===-1?0:k-B)){if(B===-1&&(B=k),k-B+1===F)return B*m}else B!==-1&&(k-=k-B),B=-1}else for(e+F>h&&(e=h-F),k=e;k>=0;k--){for(var S=!0,V=0;V<F;V++)if(_(r,k+V)!==_(t,V)){S=!1;break}if(S)return k}return-1}a.prototype.includes=function(t,e,o){return this.indexOf(t,e,o)!==-1},a.prototype.indexOf=function(t,e,o){return At(this,t,e,o,!0)},a.prototype.lastIndexOf=function(t,e,o){return At(this,t,e,o,!1)};function Fe(r,t,e,o){e=Number(e)||0;var s=r.length-e;o?(o=Number(o),o>s&&(o=s)):o=s;var m=t.length;o>m/2&&(o=m/2);for(var h=0;h<o;++h){var F=parseInt(t.substr(h*2,2),16);if(ot(F))return h;r[e+h]=F}return h}function _e(r,t,e,o){return G(nt(t,r.length-e),r,e,o)}function ke(r,t,e,o){return G(Me(t),r,e,o)}function Se(r,t,e,o){return G(zt(t),r,e,o)}function Ae(r,t,e,o){return G(Ne(t,r.length-e),r,e,o)}a.prototype.write=function(t,e,o,s){if(e===void 0)s="utf8",o=this.length,e=0;else if(o===void 0&&typeof e=="string")s=e,o=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(o)?(o=o>>>0,s===void 0&&(s="utf8")):(s=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var m=this.length-e;if((o===void 0||o>m)&&(o=m),t.length>0&&(o<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var h=!1;;)switch(s){case"hex":return Fe(this,t,e,o);case"utf8":case"utf-8":return _e(this,t,e,o);case"ascii":case"latin1":case"binary":return ke(this,t,e,o);case"base64":return Se(this,t,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ae(this,t,e,o);default:if(h)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),h=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Be(r,t,e){return t===0&&e===r.length?i.fromByteArray(r):i.fromByteArray(r.slice(t,e))}function jt(r,t,e){e=Math.min(r.length,e);for(var o=[],s=t;s<e;){var m=r[s],h=null,F=m>239?4:m>223?3:m>191?2:1;if(s+F<=e){var _,k,B,S;switch(F){case 1:m<128&&(h=m);break;case 2:_=r[s+1],(_&192)===128&&(S=(m&31)<<6|_&63,S>127&&(h=S));break;case 3:_=r[s+1],k=r[s+2],(_&192)===128&&(k&192)===128&&(S=(m&15)<<12|(_&63)<<6|k&63,S>2047&&(S<55296||S>57343)&&(h=S));break;case 4:_=r[s+1],k=r[s+2],B=r[s+3],(_&192)===128&&(k&192)===128&&(B&192)===128&&(S=(m&15)<<18|(_&63)<<12|(k&63)<<6|B&63,S>65535&&S<1114112&&(h=S))}}h===null?(h=65533,F=1):h>65535&&(h-=65536,o.push(h>>>10&1023|55296),h=56320|h&1023),o.push(h),s+=F}return je(o)}var Ot=4096;function je(r){var t=r.length;if(t<=Ot)return String.fromCharCode.apply(String,r);for(var e="",o=0;o<t;)e+=String.fromCharCode.apply(String,r.slice(o,o+=Ot));return e}function Oe(r,t,e){var o="";e=Math.min(r.length,e);for(var s=t;s<e;++s)o+=String.fromCharCode(r[s]&127);return o}function Ie(r,t,e){var o="";e=Math.min(r.length,e);for(var s=t;s<e;++s)o+=String.fromCharCode(r[s]);return o}function Ue(r,t,e){var o=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>o)&&(e=o);for(var s="",m=t;m<e;++m)s+=Re[r[m]];return s}function Te(r,t,e){for(var o=r.slice(t,e),s="",m=0;m<o.length-1;m+=2)s+=String.fromCharCode(o[m]+o[m+1]*256);return s}a.prototype.slice=function(t,e){var o=this.length;t=~~t,e=e===void 0?o:~~e,t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),e<t&&(e=t);var s=this.subarray(t,e);return Object.setPrototypeOf(s,a.prototype),s};function A(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||A(t,e,this.length);for(var s=this[t],m=1,h=0;++h<e&&(m*=256);)s+=this[t+h]*m;return s},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||A(t,e,this.length);for(var s=this[t+--e],m=1;e>0&&(m*=256);)s+=this[t+--e]*m;return s},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||A(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||A(t,e,this.length);for(var s=this[t],m=1,h=0;++h<e&&(m*=256);)s+=this[t+h]*m;return m*=128,s>=m&&(s-=Math.pow(2,8*e)),s},a.prototype.readIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||A(t,e,this.length);for(var s=e,m=1,h=this[t+--s];s>0&&(m*=256);)h+=this[t+--s]*m;return m*=128,h>=m&&(h-=Math.pow(2,8*e)),h},a.prototype.readInt8=function(t,e){return t=t>>>0,e||A(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||A(t,2,this.length);var o=this[t]|this[t+1]<<8;return o&32768?o|4294901760:o},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||A(t,2,this.length);var o=this[t+1]|this[t]<<8;return o&32768?o|4294901760:o},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t=t>>>0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t=t>>>0,e||A(t,4,this.length),p.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||A(t,4,this.length),p.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||A(t,8,this.length),p.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||A(t,8,this.length),p.read(this,t,!1,52,8)};function j(r,t,e,o,s,m){if(!a.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<m)throw new RangeError('"value" argument is out of bounds');if(e+o>r.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,o,s){if(t=+t,e=e>>>0,o=o>>>0,!s){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var h=1,F=0;for(this[e]=t&255;++F<o&&(h*=256);)this[e+F]=t/h&255;return e+o},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,o,s){if(t=+t,e=e>>>0,o=o>>>0,!s){var m=Math.pow(2,8*o)-1;j(this,t,e,o,m,0)}var h=o-1,F=1;for(this[e+h]=t&255;--h>=0&&(F*=256);)this[e+h]=t/F&255;return e+o},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(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},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(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},a.prototype.writeIntLE=function(t,e,o,s){if(t=+t,e=e>>>0,!s){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var h=0,F=1,_=0;for(this[e]=t&255;++h<o&&(F*=256);)t<0&&_===0&&this[e+h-1]!==0&&(_=1),this[e+h]=(t/F>>0)-_&255;return e+o},a.prototype.writeIntBE=function(t,e,o,s){if(t=+t,e=e>>>0,!s){var m=Math.pow(2,8*o-1);j(this,t,e,o,m-1,-m)}var h=o-1,F=1,_=0;for(this[e+h]=t&255;--h>=0&&(F*=256);)t<0&&_===0&&this[e+h+1]!==0&&(_=1),this[e+h]=(t/F>>0)-_&255;return e+o},a.prototype.writeInt8=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||j(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||j(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},a.prototype.writeInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||j(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 It(r,t,e,o,s,m){if(e+o>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ut(r,t,e,o,s){return t=+t,e=e>>>0,s||It(r,t,e,4),p.write(r,t,e,o,23,4),e+4}a.prototype.writeFloatLE=function(t,e,o){return Ut(this,t,e,!0,o)},a.prototype.writeFloatBE=function(t,e,o){return Ut(this,t,e,!1,o)};function Tt(r,t,e,o,s){return t=+t,e=e>>>0,s||It(r,t,e,8),p.write(r,t,e,o,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,o){return Tt(this,t,e,!0,o)},a.prototype.writeDoubleBE=function(t,e,o){return Tt(this,t,e,!1,o)},a.prototype.copy=function(t,e,o,s){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),!s&&s!==0&&(s=this.length),e>=t.length&&(e=t.length),e||(e=0),s>0&&s<o&&(s=o),s===o||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),t.length-e<s-o&&(s=t.length-e+o);var m=s-o;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,o,s):Uint8Array.prototype.set.call(t,this.subarray(o,s),e),m},a.prototype.fill=function(t,e,o,s){if(typeof t=="string"){if(typeof e=="string"?(s=e,e=0,o=this.length):typeof o=="string"&&(s=o,o=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(t.length===1){var m=t.charCodeAt(0);(s==="utf8"&&m<128||s==="latin1")&&(t=m)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<o)throw new RangeError("Out of range index");if(o<=e)return this;e=e>>>0,o=o===void 0?this.length:o>>>0,t||(t=0);var h;if(typeof t=="number")for(h=e;h<o;++h)this[h]=t;else{var F=a.isBuffer(t)?t:a.from(t,s),_=F.length;if(_===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(h=0;h<o-e;++h)this[h+e]=F[h%_]}return this};var ze=/[^+/0-9A-Za-z-_]/g;function De(r){if(r=r.split("=")[0],r=r.trim().replace(ze,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function nt(r,t){t=t||1/0;for(var e,o=r.length,s=null,m=[],h=0;h<o;++h){if(e=r.charCodeAt(h),e>55295&&e<57344){if(!s){if(e>56319){(t-=3)>-1&&m.push(239,191,189);continue}else if(h+1===o){(t-=3)>-1&&m.push(239,191,189);continue}s=e;continue}if(e<56320){(t-=3)>-1&&m.push(239,191,189),s=e;continue}e=(s-55296<<10|e-56320)+65536}else s&&(t-=3)>-1&&m.push(239,191,189);if(s=null,e<128){if((t-=1)<0)break;m.push(e)}else if(e<2048){if((t-=2)<0)break;m.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;m.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;m.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return m}function Me(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Ne(r,t){for(var e,o,s,m=[],h=0;h<r.length&&!((t-=2)<0);++h)e=r.charCodeAt(h),o=e>>8,s=e%256,m.push(s),m.push(o);return m}function zt(r){return i.toByteArray(De(r))}function G(r,t,e,o){for(var s=0;s<o&&!(s+e>=t.length||s>=r.length);++s)t[s+e]=r[s];return s}function T(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function ot(r){return r!==r}var Re=function(){for(var r="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var o=e*16,s=0;s<16;++s)t[o+s]=r[e]+r[s];return t}()})(te);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,i){var p=te,c=p.Buffer;function f(l,a){for(var x in l)a[x]=l[x]}c.from&&c.alloc&&c.allocUnsafe&&c.allocUnsafeSlow?n.exports=p:(f(p,i),i.Buffer=u);function u(l,a,x){return c(l,a,x)}u.prototype=Object.create(c.prototype),f(c,u),u.from=function(l,a,x){if(typeof l=="number")throw new TypeError("Argument must not be a number");return c(l,a,x)},u.alloc=function(l,a,x){if(typeof l!="number")throw new TypeError("Argument must be a number");var d=c(l);return a!==void 0?typeof x=="string"?d.fill(a,x):d.fill(a):d.fill(0),d},u.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return c(l)},u.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return p.SlowBuffer(l)}})(ct,ct.exports);var ie=ct.exports,re=ie.Buffer;function it(n,i){this._block=re.alloc(n),this._finalSize=i,this._blockSize=n,this._len=0}it.prototype.update=function(n,i){typeof n=="string"&&(i=i||"utf8",n=re.from(n,i));for(var p=this._block,c=this._blockSize,f=n.length,u=this._len,l=0;l<f;){for(var a=u%c,x=Math.min(f-l,c-a),d=0;d<x;d++)p[a+d]=n[l+d];u+=x,l+=x,u%c===0&&this._update(p)}return this._len+=f,this};it.prototype.digest=function(n){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 p=this._len*8;if(p<=4294967295)this._block.writeUInt32BE(p,this._blockSize-4);else{var c=(p&4294967295)>>>0,f=(p-c)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(c,this._blockSize-4)}this._update(this._block);var u=this._hash();return n?u.toString(n):u};it.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var xi=it,di=ai,ne=xi,wi=ie.Buffer,gi=[1518500249,1859775393,-1894007588,-899497514],yi=new Array(80);function K(){this.init(),this._w=yi,ne.call(this,64,56)}di(K,ne);K.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function vi(n){return n<<1|n>>>31}function bi(n){return n<<5|n>>>27}function Ei(n){return n<<30|n>>>2}function Fi(n,i,p,c){return n===0?i&p|~i&c:n===2?i&p|i&c|p&c:i^p^c}K.prototype._update=function(n){for(var i=this._w,p=this._a|0,c=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=0;a<16;++a)i[a]=n.readInt32BE(a*4);for(;a<80;++a)i[a]=vi(i[a-3]^i[a-8]^i[a-14]^i[a-16]);for(var x=0;x<80;++x){var d=~~(x/20),v=bi(p)+Fi(d,c,f,u)+l+i[x]+gi[d]|0;l=u,u=f,f=Ei(c),c=p,p=v}this._a=p+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0};K.prototype._hash=function(){var n=wi.allocUnsafe(20);return n.writeInt32BE(this._a|0,0),n.writeInt32BE(this._b|0,4),n.writeInt32BE(this._c|0,8),n.writeInt32BE(this._d|0,12),n.writeInt32BE(this._e|0,16),n};var _i=K;const ki=oi(_i),vt=new Error("File system not available.");function Si(n,i,p){throw vt}function oe(n){throw vt}function Ai(n){throw vt}const Bi=async n=>oe();function ji(n){let i="";for(let p=0;p<n.length;p+=2)i+=String.fromCharCode(parseInt(n.substr(p,2),16));return btoa(i)}const rt=(n,i="sha1")=>{if(i!=="sha1")throw new Error("Only sha1 algorithm is available.");const p=new ki;return ji(p.update(n).digest("hex"))};function ae(n){return n.type===Qe&&n.skip!==void 0&&n.skip>0&&n.hash!==void 0}function lt(n){return[H,Z].includes(n.type)}function ut(n){return[Vt,H,Z,tt,Xt].includes(n.type)}function R(n,i,p,c,f="global"){if(!n)throw new Error("Empty action type");if(typeof n!="string")throw new Error(`Invalid action type: ${n}`);const u={type:n,input:i,scope:f};p&&(u.attachments=p);try{c==null||c().parse(u.input)}catch(l){throw new Error(`Invalid action input: ${l}`)}return u}function pe(n,i=gt){return(p,c,f,u)=>i(p,c,n,f,u)}const se=(n,i)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...n,state:(i==null?void 0:i(n==null?void 0:n.state))??(n==null?void 0:n.state)??{global:{},local:{}}}),ce=(n,i)=>{const p=se(n,i);return{...p,initialState:p,operations:{global:[],local:[]},clipboard:[]}},bt=(n,i="global")=>rt(pt(n.state[i])),Oi=(n,i=1e3)=>{const p=Math.random()*i;return rt(`${(n??new Date).toISOString()}${p}`)};function P(n){return D.castImmutable(D.freeze(n,!0))}function le(n,i){const p=[...n];let c=i||0,f=p.length>0?p[p.length-1].index:0;const u=[];for(const l of p.reverse()){if(c>0){const d=f-l.index;c-=d}if(c<0)throw new Error("Invalid operation index, missing operations");const a={ignore:c>0,operation:l},x=l.skip>0?l.skip+1:0;if(x>0&&x>c){const d=x-c;c=c+d}f=l.index,u.push(a)}return u.reverse()}function ue(n,i,p){const c=n.slice().sort((a,x)=>a.skip-x.skip).sort((a,x)=>a.index-x.index);let f=p,u=0,l=i;for(const a of c.reverse()){const x=l-a.index;if(f=f-x,f>-1)u++,l=a.index;else break}return u}function Ii(n){return Object.values(n).flatMap(i=>i).sort((i,p)=>new Date(i.timestamp).getTime()-new Date(p.timestamp).getTime())}function fe(n){return Object.values(n).flatMap(i=>i).sort((i,p)=>new Date(i.operation.timestamp).getTime()-new Date(p.operation.timestamp).getTime())}function Q(n,i,p,c,f,u=gt,l={}){const a=pe(p,u);return Et(n,i,a,c,f,l)}function Et(n,i,p,c,f,u={}){const l=ce(n),a=Object.keys(i).reduce((y,b)=>{const E=b;return{...y,[E]:i[E].slice(0,f==null?void 0:f.revision[E])}},{}),x=Object.keys(a).reduce((y,b)=>{const E=b;return{...y,[E]:le(a[E],u[E])}},{}),d=fe(x).reduce((y,{ignore:b,operation:E})=>b?p(y,_t(E.scope),c,{skip:E.skip,ignoreSkipOperations:!0}):p(y,E,c,{skip:E.skip,ignoreSkipOperations:!0}),l),v=Object.keys(d.operations).reduce((y,b)=>{const E=b,U=f&&f.revision[E]<i[E].length?i[E].slice(f.revision[E]):[];return{...y,[E]:[...d.operations[E].map((L,$)=>{var Y;return{...L,timestamp:((Y=i[E][$])==null?void 0:Y.timestamp)??L.timestamp}}),...U]}},{global:[],local:[]}),g=Object.values(v).reduce((y,b)=>{for(const E of b)E.timestamp>y&&(y=E.timestamp);return y},n.lastModified);return{...d,operations:v,lastModified:g}}function Ui(n,i){return pt(n)===pt(i)}const me=n=>R("SET_NAME",n,void 0,dt,void 0),he=(n=1,i="global")=>R("UNDO",n,void 0,wt,i),xe=(n=1,i="global")=>R("REDO",n,void 0,xt,i),de=(n,i,p="global")=>R("PRUNE",{start:n,end:i},void 0,ht,p),Ft=(n,i)=>R("LOAD_STATE",{state:n,operations:i},void 0,mt),_t=(n="global")=>R("NOOP",{},void 0,void 0,n),Ti=Object.freeze(Object.defineProperty({__proto__:null,loadState:Ft,noop:_t,prune:de,redo:xe,setName:me,undo:he},Symbol.toStringTag,{value:"Module"})),we={"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(we);var O=function(n,i,p,c){if(p==="a"&&!c)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?n!==i||!c:!i.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return p==="m"?c:p==="a"?c.call(n):c?c.value:i.get(n)},q,W,N;class zi{constructor(...i){q.set(this,new Map),W.set(this,new Map),N.set(this,new Map);for(const p of i)this.define(p)}define(i,p=!1){for(let[c,f]of Object.entries(i)){c=c.toLowerCase(),f=f.map(a=>a.toLowerCase()),O(this,N,"f").has(c)||O(this,N,"f").set(c,new Set);const u=O(this,N,"f").get(c);let l=!0;for(let a of f){const x=a.startsWith("*");if(a=x?a.slice(1):a,u==null||u.add(a),l&&O(this,W,"f").set(c,a),l=!1,x)continue;const d=O(this,q,"f").get(a);if(d&&d!=c&&!p)throw new Error(`"${c} -> ${a}" conflicts with "${d} -> ${a}". Pass \`force=true\` to override this definition.`);O(this,q,"f").set(a,c)}}return this}getType(i){if(typeof i!="string")return null;const p=i.replace(/^.*[/\\]/,"").toLowerCase(),c=p.replace(/^.*\./,"").toLowerCase(),f=p.length<i.length;return!(c.length<p.length-1)&&f?null:O(this,q,"f").get(c)??null}getExtension(i){var p;return typeof i!="string"?null:(i=(p=i==null?void 0:i.split)==null?void 0:p.call(i,";")[0],(i&&O(this,W,"f").get(i.trim().toLowerCase()))??null)}getAllExtensions(i){return typeof i!="string"?null:O(this,N,"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 O(this,N,"f").values())Object.freeze(i);return this}_getTestState(){return{types:O(this,q,"f"),extensions:O(this,W,"f")}}}q=new WeakMap,W=new WeakMap,N=new WeakMap;const Di=new zi(we)._freeze();function ge(n){const i=[],p=Object.keys(n);for(const c of p){const f=n[c].sort((u,l)=>u.index-l.index);for(let u=0;u<f.length;u++)f[u].index!==u&&i.push({message:`Invalid operation index ${f[u].index} at position ${u}`,details:{position:u,operation:f[u],scope:f[u].scope}})}return i}const kt=async n=>{const i=new Nt,{name:p,revision:c,documentType:f,created:u,lastModified:l}=n,a={name:p,revision:c,documentType:f,created:u,lastModified:l};return i.file("header.json",JSON.stringify(a,null,2)),i.file("state.json",JSON.stringify(n.initialState||{},null,2)),i.file("operations.json",JSON.stringify(n.operations,null,2)),Object.keys(n.attachments).forEach(d=>{const{data:v,...g}=n.attachments[d];i.file(d,v,{base64:!0,createFolders:!0,comment:JSON.stringify(g)})}),i},ye=async(n,i,p,c)=>{await(await kt(n)).generateAsync({type:"uint8array",streamFiles:!0});const u=c??n.name,l=`.${p}.zip`;return Si(i,u.endsWith(l)?u:`${u}${l}`)},Mi=async(n,i)=>{const c=await(await kt(n)).generateAsync({type:"blob"}),f=await i.createWritable();await f.write(c),await f.close()},ft=async(n,i)=>{const p=oe();return ve(p,i)},ve=async(n,i)=>{const p=new Nt;return await p.loadAsync(n),Ni(p,i)};async function Ni(n,i){const p=n.file("state.json");if(!p)throw new Error("Initial state not found");const c=await p.async("string"),f=JSON.parse(c),u=n.file("header.json");let l;u&&(l=JSON.parse(await u.async("string")));const a=n.file("operations.json");if(!a)throw new Error("Operations history not found");const x=JSON.parse(await a.async("string")),d=ge(x);if(d.length){const g=d.map(y=>y.message);throw new Error(g.join(`
7
+ `))}let v=Et(f,x,i,void 0,l);return l&&(v={...v,...l}),v}function be(n){const i=n.replace(/^.*\./,"")||void 0,p=n.replace(/^.*[/\\]/,"")||void 0;return{extension:i,fileName:p}}async function Ri(n){const{buffer:i,mimeType:p="application/octet-stream"}=await Ai(),c=be(n),f=i.toString("base64");return{data:f,hash:rt(f),mimeType:p,...c}}async function Li(n){const i=await Bi(),p=Di.getType(n)||"application/octet-stream",c=be(n),f=i.toString("base64");return{data:f,hash:rt(f),mimeType:p,...c}}class Ci{constructor(i,p,c){X(this,"_document");X(this,"_reducer");X(this,"_signalDispatch");this._reducer=i,this._document=p,this._signalDispatch=c}dispatch(i,p){return this._document=this._reducer(this._document,i,this._signalDispatch,p),this}saveToFile(i,p,c){return ye(this._document,i,p,c)}async loadFromFile(i){this._document=await ft(i,this._reducer)}static async stateFromFile(i,p){return await ft(i,p)}get state(){return P(this._document.state)}get operations(){return P(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 P(this._document.initialState)}toDocument(){return P(this._document)}getAttachment(i){return this._document.attachments[i]}setName(i){return this.dispatch(me(i)),this}undo(i){return this.dispatch(he(i)),this}redo(i){return this.dispatch(xe(i)),this}prune(i,p){return this.dispatch(de(i,p)),this}loadState(i,p){return this.dispatch(Ft(i,p)),this}}function qi(n,i){i.forEach(p=>{Object.getOwnPropertyNames(p.prototype).forEach(c=>{Object.defineProperty(n.prototype,c,Object.getOwnPropertyDescriptor(p.prototype,c)||Object.create(null))})})}exports.BaseActions=Ti;exports.BaseDocument=Ci;exports.applyMixins=qi;exports.baseReducer=gt;exports.calculateSkipsLeft=ue;exports.createAction=R;exports.createDocument=ce;exports.createExtendedState=se;exports.createReducer=pe;exports.createZip=kt;exports.getLocalFile=Li;exports.getRemoteFile=Ri;exports.hashDocument=bt;exports.hashKey=Oi;exports.isBaseAction=ut;exports.isNoopOperation=ae;exports.isSameDocument=Ui;exports.isUndoRedo=lt;exports.loadFromFile=ft;exports.loadFromInput=ve;exports.mapSkippedOperations=le;exports.processUndoRedo=Qt;exports.readOnly=P;exports.replayDocument=Et;exports.replayOperations=Q;exports.saveToFile=ye;exports.saveToFileHandle=Mi;exports.sortMappedOperations=fe;exports.sortOperations=Ii;exports.validateOperations=ge;exports.zod=He;