document-model 1.0.4 → 1.0.6

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 (29) hide show
  1. package/dist/browser/document/object.d.ts +4 -0
  2. package/dist/browser/document-model.cjs +1 -1
  3. package/dist/browser/document-model.js +7 -8
  4. package/dist/browser/document.cjs +1 -1
  5. package/dist/browser/document.js +7 -8
  6. package/dist/browser/index.cjs +1 -1
  7. package/dist/browser/index.js +7 -8
  8. package/dist/browser/internal/{index-19c8f57b.js → index-05f6fe71.js} +1 -1
  9. package/dist/{node/internal/index-bb0a856f.js → browser/internal/index-336e6f47.js} +1 -1
  10. package/dist/browser/internal/{index-ba0b84c2.js → index-91e3abf2.js} +1 -1
  11. package/dist/browser/internal/{index-1ee8db0c.js → index-d577364b.js} +3 -4
  12. package/dist/browser/internal/object-41731a51.js +6 -0
  13. package/dist/browser/internal/object-e8af0c3a.js +1656 -0
  14. package/dist/node/document/object.d.ts +4 -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-027f73ec.js → index-574ece31.js} +1 -1
  22. package/dist/{browser/internal/index-ebc86e7b.js → node/internal/index-6ee6330b.js} +1 -1
  23. package/dist/node/internal/{index-6317539b.js → index-af4b7a66.js} +1 -1
  24. package/dist/node/internal/{index-551f2c89.js → index-f3fdeced.js} +1 -1
  25. package/dist/node/internal/{object-8edc0f76.js → object-19968a54.js} +17 -11
  26. package/dist/node/internal/{object-2bb87214.js → object-9fcc9b3e.js} +1 -1
  27. package/package.json +2 -2
  28. package/dist/browser/internal/object-05addf9f.js +0 -641
  29. package/dist/browser/internal/object-5f0a8dc6.js +0 -1
@@ -72,6 +72,10 @@ export declare abstract class BaseDocument<T, A extends Action> {
72
72
  * Gets the initial state of the document.
73
73
  */
74
74
  get initialState(): ExtendedState<T>;
75
+ /**
76
+ * Returns the current document as an object
77
+ */
78
+ toDocument(): Document<T, A>;
75
79
  /**
76
80
  * Gets the attachment associated with the given key.
77
81
  * @param attachment - The key of the attachment to retrieve.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-5f0a8dc6.js");require("json-stringify-deterministic");require("immer");require("sha.js/sha1");require("jszip");const e=require("./internal/index-ba0b84c2.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.z=e.zod;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-41731a51.js");require("json-stringify-deterministic");require("immer");require("jszip");const e=require("./internal/index-91e3abf2.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.z=e.zod;
@@ -1,17 +1,16 @@
1
- import "./internal/object-05addf9f.js";
1
+ import "./internal/object-e8af0c3a.js";
2
2
  import "json-stringify-deterministic";
3
3
  import "immer";
4
- import "sha.js/sha1";
5
4
  import "jszip";
6
- import { b as p, a as u, c, d, m as l, r as n, u as D, z as M } from "./internal/index-1ee8db0c.js";
5
+ import { b as i, a as u, c, d, m as p, r as l, u as n, z as D } from "./internal/index-d577364b.js";
7
6
  import "zod";
8
7
  export {
9
- p as Document,
8
+ i as Document,
10
9
  u as DocumentModel,
11
10
  c as actions,
12
11
  d as documentModel,
13
- l as module,
14
- n as reducer,
15
- D as utils,
16
- M as z
12
+ p as module,
13
+ l as reducer,
14
+ n as utils,
15
+ D as z
17
16
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-5f0a8dc6.js"),r=require("./internal/index-ebc86e7b.js");require("json-stringify-deterministic");require("immer");require("zod");require("sha.js/sha1");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.z=e.zod;exports.utils=r.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-41731a51.js"),r=require("./internal/index-336e6f47.js");require("json-stringify-deterministic");require("immer");require("zod");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.z=e.zod;exports.utils=r.index;
@@ -1,15 +1,14 @@
1
- import { B as m, h as e, g as c, p as n, z as u } from "./internal/object-05addf9f.js";
2
- import { i as f } from "./internal/index-19c8f57b.js";
1
+ import { B as t, h as e, g as m, p as c, z as n } from "./internal/object-e8af0c3a.js";
2
+ import { i as x } from "./internal/index-05f6fe71.js";
3
3
  import "json-stringify-deterministic";
4
4
  import "immer";
5
5
  import "zod";
6
- import "sha.js/sha1";
7
6
  import "jszip";
8
7
  export {
9
- m as BaseDocument,
8
+ t as BaseDocument,
10
9
  e as actions,
11
- c as applyMixins,
12
- n as baseReducer,
13
- f as utils,
14
- u as z
10
+ m as applyMixins,
11
+ c as baseReducer,
12
+ x as utils,
13
+ n as z
15
14
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-ebc86e7b.js"),o=require("./internal/index-ba0b84c2.js");require("./internal/object-5f0a8dc6.js");require("json-stringify-deterministic");require("immer");require("zod");require("sha.js/sha1");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-336e6f47.js"),o=require("./internal/index-91e3abf2.js");require("./internal/object-41731a51.js");require("json-stringify-deterministic");require("immer");require("zod");require("jszip");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
@@ -1,18 +1,17 @@
1
- import { D as o } from "./internal/index-19c8f57b.js";
2
- import { D as t } from "./internal/index-1ee8db0c.js";
3
- import "./internal/object-05addf9f.js";
1
+ import { D as o } from "./internal/index-05f6fe71.js";
2
+ import { D as t } from "./internal/index-d577364b.js";
3
+ import "./internal/object-e8af0c3a.js";
4
4
  import "json-stringify-deterministic";
5
5
  import "immer";
6
6
  import "zod";
7
- import "sha.js/sha1";
8
7
  import "jszip";
9
- const c = {
8
+ const u = {
10
9
  "powerhouse/document": o,
11
10
  "powerhouse/document-model": t
12
- }, d = { Document: o, DocumentModel: t };
11
+ }, c = { Document: o, DocumentModel: t };
13
12
  export {
14
13
  o as Document,
15
14
  t as DocumentModel,
16
- c as DocumentModels,
17
- d as default
15
+ u as DocumentModels,
16
+ c as default
18
17
  };
@@ -1,4 +1,4 @@
1
- import { f as e, b as a, a as s, c as t, j as o, k as c, m as i, n as l, o as n, i as r, l as d, e as u, s as m, d as p, B as b, h as _, g, p as F, z as f } from "./object-05addf9f.js";
1
+ import { f as e, b as a, a as s, c as t, j as o, k as c, m as i, n as l, o as n, i as r, l as d, e as u, s as m, d as p, B as b, h as _, g, p as F, z as f } from "./object-e8af0c3a.js";
2
2
  const y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  createAction: e,
@@ -1 +1 @@
1
- "use strict";const e=require("./object-2bb87214.js"),t=Object.freeze(Object.defineProperty({__proto__:null,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,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
1
+ "use strict";const e=require("./object-41731a51.js"),t=Object.freeze(Object.defineProperty({__proto__:null,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,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
@@ -1,4 +1,4 @@
1
- "use strict";var ct=Object.defineProperty;var lt=(t,e,o)=>e in t?ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var de=(t,e,o)=>(lt(t,typeof e!="symbol"?e+"":e,o),o);const s=require("./object-5f0a8dc6.js");require("json-stringify-deterministic");require("immer");require("sha.js/sha1");require("jszip");const r=require("zod"),dt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),_={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""}],state:{schema:"",initialValue:`{
1
+ "use strict";var ct=Object.defineProperty;var lt=(t,e,o)=>e in t?ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var de=(t,e,o)=>(lt(t,typeof e!="symbol"?e+"":e,o),o);const s=require("./object-41731a51.js");require("json-stringify-deterministic");require("immer");require("jszip");const r=require("zod"),dt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),_={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[]}],id:"",description:""}],state:{schema:"",initialValue:`{
2
2
  "id": "",
3
3
  "name": "",
4
4
  "extension": "",
@@ -1,10 +1,9 @@
1
1
  var pt = Object.defineProperty;
2
2
  var lt = (t, e, i) => e in t ? pt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
3
  var pe = (t, e, i) => (lt(t, typeof e != "symbol" ? e + "" : e, i), i);
4
- import { c as dt, i as ct, a as ut, b as mt, s as Et, d as ht, l as Ot, e as St, f as s, B as l, g as gt, h as ft } from "./object-05addf9f.js";
4
+ import { c as dt, i as ct, a as ut, b as mt, s as Et, d as ht, l as Ot, e as St, f as s, B as l, g as gt, h as ft } from "./object-e8af0c3a.js";
5
5
  import "json-stringify-deterministic";
6
6
  import "immer";
7
- import "sha.js/sha1";
8
7
  import "jszip";
9
8
  import { z as r } from "zod";
10
9
  const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -1752,7 +1751,7 @@ const Ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1752
1751
  actions: at,
1753
1752
  utils: st,
1754
1753
  documentModel: le
1755
- }, qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1754
+ }, Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1756
1755
  __proto__: null,
1757
1756
  Document: ot,
1758
1757
  DocumentModel: ae,
@@ -1764,7 +1763,7 @@ const Ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1764
1763
  z: Dt
1765
1764
  }, Symbol.toStringTag, { value: "Module" }));
1766
1765
  export {
1767
- qt as D,
1766
+ Bt as D,
1768
1767
  ae as a,
1769
1768
  ot as b,
1770
1769
  at as c,
@@ -0,0 +1,6 @@
1
+ "use strict";var Er=Object.defineProperty;var br=(n,a,s)=>a in n?Er(n,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[a]=s;var G=(n,a,s)=>(br(n,typeof a!="symbol"?a+"":a,s),s);const Fr=require("json-stringify-deterministic"),V=require("immer"),d=require("zod"),_t=require("jszip"),At=n=>n!=null,_r=d.z.any().refine(n=>At(n)),Bt=d.z.enum(["LOAD_STATE"]),St=d.z.enum(["PRUNE"]),jt=d.z.enum(["REDO"]),Ut=d.z.enum(["SET_NAME"]),It=d.z.enum(["UNDO"]);function Ar(){return d.z.object({__typename:d.z.literal("Action").optional(),type:d.z.string()})}function Tt(){return d.z.union([nt(),at(),ot(),pt(),st()])}function Br(){return d.z.object({__typename:d.z.literal("DocumentFile").optional(),data:d.z.string(),extension:d.z.string().nullable(),fileName:d.z.string().nullable(),mimeType:d.z.string()})}function nt(){return d.z.object({input:d.z.lazy(()=>kt()),type:Bt})}function kt(){return d.z.object({operations:d.z.number(),state:d.z.lazy(()=>zt())})}function zt(){return d.z.object({data:d.z.unknown().nullish(),name:d.z.string()})}function Sr(){return d.z.object({__typename:d.z.literal("Operation").optional(),hash:d.z.string(),index:d.z.number(),timestamp:d.z.string().datetime(),type:d.z.string()})}function at(){return d.z.object({input:d.z.lazy(()=>Dt()),type:St})}function Dt(){return d.z.object({end:d.z.number().nullish(),start:d.z.number().nullish()})}function ot(){return d.z.object({input:d.z.number(),type:jt})}function pt(){return d.z.object({input:d.z.string(),type:Ut})}function jr(){return d.z.object({__typename:d.z.literal("SetNameOperation").optional(),hash:d.z.string(),index:d.z.number(),input:d.z.string(),timestamp:d.z.string().datetime(),type:d.z.string()})}function st(){return d.z.object({input:d.z.number(),type:It})}const Ur=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Ar,BaseActionSchema:Tt,DocumentFileSchema:Br,LoadStateActionInputSchema:kt,LoadStateActionSchema:nt,LoadStateActionStateInputSchema:zt,Load_StateSchema:Bt,OperationSchema:Sr,PruneActionInputSchema:Dt,PruneActionSchema:at,PruneSchema:St,RedoActionSchema:ot,RedoSchema:jt,SetNameActionSchema:pt,SetNameOperationSchema:jr,Set_NameSchema:Ut,UndoActionSchema:st,UndoSchema:It,definedNonNullAnySchema:_r,isDefinedNonNullAny:At},Symbol.toStringTag,{value:"Module"}));function Ot(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function $(){this._types=Object.create(null),this._extensions=Object.create(null);for(let n=0;n<arguments.length;n++)this.define(arguments[n]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}$.prototype.define=function(n,a){for(let s in n){let c=n[s].map(function(f){return f.toLowerCase()});s=s.toLowerCase();for(let f=0;f<c.length;f++){const m=c[f];if(m[0]!=="*"){if(!a&&m in this._types)throw new Error('Attempt to change mapping for "'+m+'" extension from "'+this._types[m]+'" to "'+s+'". Pass `force=true` to allow this, otherwise remove "'+m+'" from the list of extensions for "'+s+'".');this._types[m]=s}}if(a||!this._extensions[s]){const f=c[0];this._extensions[s]=f[0]!=="*"?f:f.substr(1)}}};$.prototype.getType=function(n){n=String(n);let a=n.replace(/^.*[/\\]/,"").toLowerCase(),s=a.replace(/^.*\./,"").toLowerCase(),c=a.length<n.length;return(s.length<a.length-1||!c)&&this._types[s]||null};$.prototype.getExtension=function(n){return n=/^\s*([^;\s]*)/.test(n)&&RegExp.$1,n&&this._extensions[n.toLowerCase()]||null};var Ir=$,Tr={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};let kr=Ir;var zr=new kr(Tr);const Dr=Ot(zr);var tt={exports:{}};typeof Object.create=="function"?tt.exports=function(a,s){s&&(a.super_=s,a.prototype=Object.create(s.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:tt.exports=function(a,s){if(s){a.super_=s;var c=function(){};c.prototype=s.prototype,a.prototype=new c,a.prototype.constructor=a}};var Or=tt.exports,rt={exports:{}},Nt={},J={};J.byteLength=Rr;J.toByteArray=Lr;J.fromByteArray=Jr;var T=[],j=[],Nr=typeof Uint8Array<"u"?Uint8Array:Array,Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var z=0,Mr=Q.length;z<Mr;++z)T[z]=Q[z],j[Q.charCodeAt(z)]=z;j["-".charCodeAt(0)]=62;j["_".charCodeAt(0)]=63;function Mt(n){var a=n.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=n.indexOf("=");s===-1&&(s=a);var c=s===a?0:4-s%4;return[s,c]}function Rr(n){var a=Mt(n),s=a[0],c=a[1];return(s+c)*3/4-c}function Cr(n,a,s){return(a+s)*3/4-s}function Lr(n){var a,s=Mt(n),c=s[0],f=s[1],m=new Nr(Cr(n,c,f)),u=0,o=f>0?c-4:c,x;for(x=0;x<o;x+=4)a=j[n.charCodeAt(x)]<<18|j[n.charCodeAt(x+1)]<<12|j[n.charCodeAt(x+2)]<<6|j[n.charCodeAt(x+3)],m[u++]=a>>16&255,m[u++]=a>>8&255,m[u++]=a&255;return f===2&&(a=j[n.charCodeAt(x)]<<2|j[n.charCodeAt(x+1)]>>4,m[u++]=a&255),f===1&&(a=j[n.charCodeAt(x)]<<10|j[n.charCodeAt(x+1)]<<4|j[n.charCodeAt(x+2)]>>2,m[u++]=a>>8&255,m[u++]=a&255),m}function qr(n){return T[n>>18&63]+T[n>>12&63]+T[n>>6&63]+T[n&63]}function $r(n,a,s){for(var c,f=[],m=a;m<s;m+=3)c=(n[m]<<16&16711680)+(n[m+1]<<8&65280)+(n[m+2]&255),f.push(qr(c));return f.join("")}function Jr(n){for(var a,s=n.length,c=s%3,f=[],m=16383,u=0,o=s-c;u<o;u+=m)f.push($r(n,u,u+m>o?o:u+m));return c===1?(a=n[s-1],f.push(T[a>>2]+T[a<<4&63]+"==")):c===2&&(a=(n[s-2]<<8)+n[s-1],f.push(T[a>>10]+T[a>>4&63]+T[a<<2&63]+"=")),f.join("")}var ct={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ct.read=function(n,a,s,c,f){var m,u,o=f*8-c-1,x=(1<<o)-1,y=x>>1,v=-7,F=s?f-1:0,U=s?-1:1,B=n[a+F];for(F+=U,m=B&(1<<-v)-1,B>>=-v,v+=o;v>0;m=m*256+n[a+F],F+=U,v-=8);for(u=m&(1<<-v)-1,m>>=-v,v+=c;v>0;u=u*256+n[a+F],F+=U,v-=8);if(m===0)m=1-y;else{if(m===x)return u?NaN:(B?-1:1)*(1/0);u=u+Math.pow(2,c),m=m-y}return(B?-1:1)*u*Math.pow(2,m-c)};ct.write=function(n,a,s,c,f,m){var u,o,x,y=m*8-f-1,v=(1<<y)-1,F=v>>1,U=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=c?0:m-1,O=c?1:-1,N=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(o=isNaN(a)?1:0,u=v):(u=Math.floor(Math.log(a)/Math.LN2),a*(x=Math.pow(2,-u))<1&&(u--,x*=2),u+F>=1?a+=U/x:a+=U*Math.pow(2,1-F),a*x>=2&&(u++,x/=2),u+F>=v?(o=0,u=v):u+F>=1?(o=(a*x-1)*Math.pow(2,f),u=u+F):(o=a*Math.pow(2,F-1)*Math.pow(2,f),u=0));f>=8;n[s+B]=o&255,B+=O,o/=256,f-=8);for(u=u<<f|o,y+=f;y>0;n[s+B]=u&255,B+=O,u/=256,y-=8);n[s+B-O]|=N*128};/*!
2
+ * The buffer module from node.js, for the browser.
3
+ *
4
+ * @author Feross Aboukhadijeh <https://feross.org>
5
+ * @license MIT
6
+ */(function(n){var a=J,s=ct,c=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=o,n.SlowBuffer=er,n.INSPECT_MAX_BYTES=50;var f=2147483647;n.kMaxLength=f,o.TYPED_ARRAY_SUPPORT=m(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function m(){try{var i=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(i,t),i.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function u(i){if(i>f)throw new RangeError('The value "'+i+'" is invalid for option "size"');var t=new Uint8Array(i);return Object.setPrototypeOf(t,o.prototype),t}function o(i,t,r){if(typeof i=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return F(i)}return x(i,t,r)}o.poolSize=8192;function x(i,t,r){if(typeof i=="string")return U(i,t);if(ArrayBuffer.isView(i))return O(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(I(i,ArrayBuffer)||i&&I(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(I(i,SharedArrayBuffer)||i&&I(i.buffer,SharedArrayBuffer)))return N(i,t,r);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var e=i.valueOf&&i.valueOf();if(e!=null&&e!==i)return o.from(e,t,r);var p=ir(i);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return o.from(i[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}o.from=function(i,t,r){return x(i,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function y(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function v(i,t,r){return y(i),i<=0?u(i):t!==void 0?typeof r=="string"?u(i).fill(t,r):u(i).fill(t):u(i)}o.alloc=function(i,t,r){return v(i,t,r)};function F(i){return y(i),u(i<0?0:K(i)|0)}o.allocUnsafe=function(i){return F(i)},o.allocUnsafeSlow=function(i){return F(i)};function U(i,t){if((typeof t!="string"||t==="")&&(t="utf8"),!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=ht(i,t)|0,e=u(r),p=e.write(i,t);return p!==r&&(e=e.slice(0,p)),e}function B(i){for(var t=i.length<0?0:K(i.length)|0,r=u(t),e=0;e<t;e+=1)r[e]=i[e]&255;return r}function O(i){if(I(i,Uint8Array)){var t=new Uint8Array(i);return N(t.buffer,t.byteOffset,t.byteLength)}return B(i)}function N(i,t,r){if(t<0||i.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var e;return t===void 0&&r===void 0?e=new Uint8Array(i):r===void 0?e=new Uint8Array(i,t):e=new Uint8Array(i,t,r),Object.setPrototypeOf(e,o.prototype),e}function ir(i){if(o.isBuffer(i)){var t=K(i.length)|0,r=u(t);return r.length===0||i.copy(r,0,0,t),r}if(i.length!==void 0)return typeof i.length!="number"||X(i.length)?u(0):B(i);if(i.type==="Buffer"&&Array.isArray(i.data))return B(i.data)}function K(i){if(i>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return i|0}function er(i){return+i!=i&&(i=0),o.alloc(+i)}o.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==o.prototype},o.compare=function(t,r){if(I(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),I(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(t)||!o.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;for(var e=t.length,p=r.length,l=0,h=Math.min(e,p);l<h;++l)if(t[l]!==r[l]){e=t[l],p=r[l];break}return e<p?-1:p<e?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return o.alloc(0);var e;if(r===void 0)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var p=o.allocUnsafe(r),l=0;for(e=0;e<t.length;++e){var h=t[e];if(I(h,Uint8Array))l+h.length>p.length?o.from(h).copy(p,l):Uint8Array.prototype.set.call(p,h,l);else if(o.isBuffer(h))h.copy(p,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=h.length}return p};function ht(i,t){if(o.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||I(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);var r=i.length,e=arguments.length>2&&arguments[2]===!0;if(!e&&r===0)return 0;for(var p=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Y(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Et(i).length;default:if(p)return e?-1:Y(i).length;t=(""+t).toLowerCase(),p=!0}}o.byteLength=ht;function nr(i,t,r){var e=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(i||(i="utf8");;)switch(i){case"hex":return mr(this,t,r);case"utf8":case"utf-8":return dt(this,t,r);case"ascii":return fr(this,t,r);case"latin1":case"binary":return hr(this,t,r);case"base64":return lr(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xr(this,t,r);default:if(e)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),e=!0}}o.prototype._isBuffer=!0;function k(i,t,r){var e=i[t];i[t]=i[r],i[r]=e}o.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)k(this,r,r+1);return this},o.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)k(this,r,r+3),k(this,r+1,r+2);return this},o.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)k(this,r,r+7),k(this,r+1,r+6),k(this,r+2,r+5),k(this,r+3,r+4);return this},o.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?dt(this,0,t):nr.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:o.compare(this,t)===0},o.prototype.inspect=function(){var t="",r=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},c&&(o.prototype[c]=o.prototype.inspect),o.prototype.compare=function(t,r,e,p,l){if(I(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),e===void 0&&(e=t?t.length:0),p===void 0&&(p=0),l===void 0&&(l=this.length),r<0||e>t.length||p<0||l>this.length)throw new RangeError("out of range index");if(p>=l&&r>=e)return 0;if(p>=l)return-1;if(r>=e)return 1;if(r>>>=0,e>>>=0,p>>>=0,l>>>=0,this===t)return 0;for(var h=l-p,w=e-r,g=Math.min(h,w),E=this.slice(p,l),A=t.slice(r,e),b=0;b<g;++b)if(E[b]!==A[b]){h=E[b],w=A[b];break}return h<w?-1:w<h?1:0};function mt(i,t,r,e,p){if(i.length===0)return-1;if(typeof r=="string"?(e=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,X(r)&&(r=p?0:i.length-1),r<0&&(r=i.length+r),r>=i.length){if(p)return-1;r=i.length-1}else if(r<0)if(p)r=0;else return-1;if(typeof t=="string"&&(t=o.from(t,e)),o.isBuffer(t))return t.length===0?-1:xt(i,t,r,e,p);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(i,t,r):Uint8Array.prototype.lastIndexOf.call(i,t,r):xt(i,[t],r,e,p);throw new TypeError("val must be string, number or Buffer")}function xt(i,t,r,e,p){var l=1,h=i.length,w=t.length;if(e!==void 0&&(e=String(e).toLowerCase(),e==="ucs2"||e==="ucs-2"||e==="utf16le"||e==="utf-16le")){if(i.length<2||t.length<2)return-1;l=2,h/=2,w/=2,r/=2}function g(bt,Ft){return l===1?bt[Ft]:bt.readUInt16BE(Ft*l)}var E;if(p){var A=-1;for(E=r;E<h;E++)if(g(i,E)===g(t,A===-1?0:E-A)){if(A===-1&&(A=E),E-A+1===w)return A*l}else A!==-1&&(E-=E-A),A=-1}else for(r+w>h&&(r=h-w),E=r;E>=0;E--){for(var b=!0,L=0;L<w;L++)if(g(i,E+L)!==g(t,L)){b=!1;break}if(b)return E}return-1}o.prototype.includes=function(t,r,e){return this.indexOf(t,r,e)!==-1},o.prototype.indexOf=function(t,r,e){return mt(this,t,r,e,!0)},o.prototype.lastIndexOf=function(t,r,e){return mt(this,t,r,e,!1)};function ar(i,t,r,e){r=Number(r)||0;var p=i.length-r;e?(e=Number(e),e>p&&(e=p)):e=p;var l=t.length;e>l/2&&(e=l/2);for(var h=0;h<e;++h){var w=parseInt(t.substr(h*2,2),16);if(X(w))return h;i[r+h]=w}return h}function or(i,t,r,e){return C(Y(t,i.length-r),i,r,e)}function pr(i,t,r,e){return C(yr(t),i,r,e)}function sr(i,t,r,e){return C(Et(t),i,r,e)}function cr(i,t,r,e){return C(gr(t,i.length-r),i,r,e)}o.prototype.write=function(t,r,e,p){if(r===void 0)p="utf8",e=this.length,r=0;else if(e===void 0&&typeof r=="string")p=r,e=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(e)?(e=e>>>0,p===void 0&&(p="utf8")):(p=e,e=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var l=this.length-r;if((e===void 0||e>l)&&(e=l),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");for(var h=!1;;)switch(p){case"hex":return ar(this,t,r,e);case"utf8":case"utf-8":return or(this,t,r,e);case"ascii":case"latin1":case"binary":return pr(this,t,r,e);case"base64":return sr(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cr(this,t,r,e);default:if(h)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),h=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function lr(i,t,r){return t===0&&r===i.length?a.fromByteArray(i):a.fromByteArray(i.slice(t,r))}function dt(i,t,r){r=Math.min(i.length,r);for(var e=[],p=t;p<r;){var l=i[p],h=null,w=l>239?4:l>223?3:l>191?2:1;if(p+w<=r){var g,E,A,b;switch(w){case 1:l<128&&(h=l);break;case 2:g=i[p+1],(g&192)===128&&(b=(l&31)<<6|g&63,b>127&&(h=b));break;case 3:g=i[p+1],E=i[p+2],(g&192)===128&&(E&192)===128&&(b=(l&15)<<12|(g&63)<<6|E&63,b>2047&&(b<55296||b>57343)&&(h=b));break;case 4:g=i[p+1],E=i[p+2],A=i[p+3],(g&192)===128&&(E&192)===128&&(A&192)===128&&(b=(l&15)<<18|(g&63)<<12|(E&63)<<6|A&63,b>65535&&b<1114112&&(h=b))}}h===null?(h=65533,w=1):h>65535&&(h-=65536,e.push(h>>>10&1023|55296),h=56320|h&1023),e.push(h),p+=w}return ur(e)}var wt=4096;function ur(i){var t=i.length;if(t<=wt)return String.fromCharCode.apply(String,i);for(var r="",e=0;e<t;)r+=String.fromCharCode.apply(String,i.slice(e,e+=wt));return r}function fr(i,t,r){var e="";r=Math.min(i.length,r);for(var p=t;p<r;++p)e+=String.fromCharCode(i[p]&127);return e}function hr(i,t,r){var e="";r=Math.min(i.length,r);for(var p=t;p<r;++p)e+=String.fromCharCode(i[p]);return e}function mr(i,t,r){var e=i.length;(!t||t<0)&&(t=0),(!r||r<0||r>e)&&(r=e);for(var p="",l=t;l<r;++l)p+=vr[i[l]];return p}function xr(i,t,r){for(var e=i.slice(t,r),p="",l=0;l<e.length-1;l+=2)p+=String.fromCharCode(e[l]+e[l+1]*256);return p}o.prototype.slice=function(t,r){var e=this.length;t=~~t,r=r===void 0?e:~~r,t<0?(t+=e,t<0&&(t=0)):t>e&&(t=e),r<0?(r+=e,r<0&&(r=0)):r>e&&(r=e),r<t&&(r=t);var p=this.subarray(t,r);return Object.setPrototypeOf(p,o.prototype),p};function _(i,t,r){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+t>r)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(t,r,e){t=t>>>0,r=r>>>0,e||_(t,r,this.length);for(var p=this[t],l=1,h=0;++h<r&&(l*=256);)p+=this[t+h]*l;return p},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,r,e){t=t>>>0,r=r>>>0,e||_(t,r,this.length);for(var p=this[t+--r],l=1;r>0&&(l*=256);)p+=this[t+--r]*l;return p},o.prototype.readUint8=o.prototype.readUInt8=function(t,r){return t=t>>>0,r||_(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||_(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||_(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||_(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,r,e){t=t>>>0,r=r>>>0,e||_(t,r,this.length);for(var p=this[t],l=1,h=0;++h<r&&(l*=256);)p+=this[t+h]*l;return l*=128,p>=l&&(p-=Math.pow(2,8*r)),p},o.prototype.readIntBE=function(t,r,e){t=t>>>0,r=r>>>0,e||_(t,r,this.length);for(var p=r,l=1,h=this[t+--p];p>0&&(l*=256);)h+=this[t+--p]*l;return l*=128,h>=l&&(h-=Math.pow(2,8*r)),h},o.prototype.readInt8=function(t,r){return t=t>>>0,r||_(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,r){t=t>>>0,r||_(t,2,this.length);var e=this[t]|this[t+1]<<8;return e&32768?e|4294901760:e},o.prototype.readInt16BE=function(t,r){t=t>>>0,r||_(t,2,this.length);var e=this[t+1]|this[t]<<8;return e&32768?e|4294901760:e},o.prototype.readInt32LE=function(t,r){return t=t>>>0,r||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,r){return t=t>>>0,r||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,r){return t=t>>>0,r||_(t,4,this.length),s.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,r){return t=t>>>0,r||_(t,4,this.length),s.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||_(t,8,this.length),s.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||_(t,8,this.length),s.read(this,t,!1,52,8)};function S(i,t,r,e,p,l){if(!o.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>p||t<l)throw new RangeError('"value" argument is out of bounds');if(r+e>i.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,r,e,p){if(t=+t,r=r>>>0,e=e>>>0,!p){var l=Math.pow(2,8*e)-1;S(this,t,r,e,l,0)}var h=1,w=0;for(this[r]=t&255;++w<e&&(h*=256);)this[r+w]=t/h&255;return r+e},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,r,e,p){if(t=+t,r=r>>>0,e=e>>>0,!p){var l=Math.pow(2,8*e)-1;S(this,t,r,e,l,0)}var h=e-1,w=1;for(this[r+h]=t&255;--h>=0&&(w*=256);)this[r+h]=t/w&255;return r+e},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,1,255,0),this[r]=t&255,r+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4},o.prototype.writeIntLE=function(t,r,e,p){if(t=+t,r=r>>>0,!p){var l=Math.pow(2,8*e-1);S(this,t,r,e,l-1,-l)}var h=0,w=1,g=0;for(this[r]=t&255;++h<e&&(w*=256);)t<0&&g===0&&this[r+h-1]!==0&&(g=1),this[r+h]=(t/w>>0)-g&255;return r+e},o.prototype.writeIntBE=function(t,r,e,p){if(t=+t,r=r>>>0,!p){var l=Math.pow(2,8*e-1);S(this,t,r,e,l-1,-l)}var h=e-1,w=1,g=0;for(this[r+h]=t&255;--h>=0&&(w*=256);)t<0&&g===0&&this[r+h+1]!==0&&(g=1),this[r+h]=(t/w>>0)-g&255;return r+e},o.prototype.writeInt8=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1},o.prototype.writeInt16LE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2},o.prototype.writeInt16BE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2},o.prototype.writeInt32LE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},o.prototype.writeInt32BE=function(t,r,e){return t=+t,r=r>>>0,e||S(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function yt(i,t,r,e,p,l){if(r+e>i.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function gt(i,t,r,e,p){return t=+t,r=r>>>0,p||yt(i,t,r,4),s.write(i,t,r,e,23,4),r+4}o.prototype.writeFloatLE=function(t,r,e){return gt(this,t,r,!0,e)},o.prototype.writeFloatBE=function(t,r,e){return gt(this,t,r,!1,e)};function vt(i,t,r,e,p){return t=+t,r=r>>>0,p||yt(i,t,r,8),s.write(i,t,r,e,52,8),r+8}o.prototype.writeDoubleLE=function(t,r,e){return vt(this,t,r,!0,e)},o.prototype.writeDoubleBE=function(t,r,e){return vt(this,t,r,!1,e)},o.prototype.copy=function(t,r,e,p){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),!p&&p!==0&&(p=this.length),r>=t.length&&(r=t.length),r||(r=0),p>0&&p<e&&(p=e),p===e||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),t.length-r<p-e&&(p=t.length-r+e);var l=p-e;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,e,p):Uint8Array.prototype.set.call(t,this.subarray(e,p),r),l},o.prototype.fill=function(t,r,e,p){if(typeof t=="string"){if(typeof r=="string"?(p=r,r=0,e=this.length):typeof e=="string"&&(p=e,e=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!o.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(t.length===1){var l=t.charCodeAt(0);(p==="utf8"&&l<128||p==="latin1")&&(t=l)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<e)throw new RangeError("Out of range index");if(e<=r)return this;r=r>>>0,e=e===void 0?this.length:e>>>0,t||(t=0);var h;if(typeof t=="number")for(h=r;h<e;++h)this[h]=t;else{var w=o.isBuffer(t)?t:o.from(t,p),g=w.length;if(g===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(h=0;h<e-r;++h)this[h+r]=w[h%g]}return this};var dr=/[^+/0-9A-Za-z-_]/g;function wr(i){if(i=i.split("=")[0],i=i.trim().replace(dr,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function Y(i,t){t=t||1/0;for(var r,e=i.length,p=null,l=[],h=0;h<e;++h){if(r=i.charCodeAt(h),r>55295&&r<57344){if(!p){if(r>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(h+1===e){(t-=3)>-1&&l.push(239,191,189);continue}p=r;continue}if(r<56320){(t-=3)>-1&&l.push(239,191,189),p=r;continue}r=(p-55296<<10|r-56320)+65536}else p&&(t-=3)>-1&&l.push(239,191,189);if(p=null,r<128){if((t-=1)<0)break;l.push(r)}else if(r<2048){if((t-=2)<0)break;l.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;l.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;l.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return l}function yr(i){for(var t=[],r=0;r<i.length;++r)t.push(i.charCodeAt(r)&255);return t}function gr(i,t){for(var r,e,p,l=[],h=0;h<i.length&&!((t-=2)<0);++h)r=i.charCodeAt(h),e=r>>8,p=r%256,l.push(p),l.push(e);return l}function Et(i){return a.toByteArray(wr(i))}function C(i,t,r,e){for(var p=0;p<e&&!(p+r>=t.length||p>=i.length);++p)t[p+r]=i[p];return p}function I(i,t){return i instanceof t||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===t.name}function X(i){return i!==i}var vr=function(){for(var i="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var e=r*16,p=0;p<16;++p)t[e+p]=i[r]+i[p];return t}()})(Nt);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,a){var s=Nt,c=s.Buffer;function f(u,o){for(var x in u)o[x]=u[x]}c.from&&c.alloc&&c.allocUnsafe&&c.allocUnsafeSlow?n.exports=s:(f(s,a),a.Buffer=m);function m(u,o,x){return c(u,o,x)}m.prototype=Object.create(c.prototype),f(c,m),m.from=function(u,o,x){if(typeof u=="number")throw new TypeError("Argument must not be a number");return c(u,o,x)},m.alloc=function(u,o,x){if(typeof u!="number")throw new TypeError("Argument must be a number");var y=c(u);return o!==void 0?typeof x=="string"?y.fill(o,x):y.fill(o):y.fill(0),y},m.allocUnsafe=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return c(u)},m.allocUnsafeSlow=function(u){if(typeof u!="number")throw new TypeError("Argument must be a number");return s.SlowBuffer(u)}})(rt,rt.exports);var Rt=rt.exports,Ct=Rt.Buffer;function P(n,a){this._block=Ct.alloc(n),this._finalSize=a,this._blockSize=n,this._len=0}P.prototype.update=function(n,a){typeof n=="string"&&(a=a||"utf8",n=Ct.from(n,a));for(var s=this._block,c=this._blockSize,f=n.length,m=this._len,u=0;u<f;){for(var o=m%c,x=Math.min(f-u,c-o),y=0;y<x;y++)s[o+y]=n[u+y];m+=x,u+=x,m%c===0&&this._update(s)}return this._len+=f,this};P.prototype.digest=function(n){var a=this._len%this._blockSize;this._block[a]=128,this._block.fill(0,a+1),a>=this._finalSize&&(this._update(this._block),this._block.fill(0));var s=this._len*8;if(s<=4294967295)this._block.writeUInt32BE(s,this._blockSize-4);else{var c=(s&4294967295)>>>0,f=(s-c)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(c,this._blockSize-4)}this._update(this._block);var m=this._hash();return n?m.toString(n):m};P.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Pr=P,Wr=Or,Lt=Pr,Hr=Rt.Buffer,Zr=[1518500249,1859775393,-1894007588,-899497514],Kr=new Array(80);function R(){this.init(),this._w=Kr,Lt.call(this,64,56)}Wr(R,Lt);R.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Yr(n){return n<<1|n>>>31}function Xr(n){return n<<5|n>>>27}function Gr(n){return n<<30|n>>>2}function Vr(n,a,s,c){return n===0?a&s|~a&c:n===2?a&s|a&c|s&c:a^s^c}R.prototype._update=function(n){for(var a=this._w,s=this._a|0,c=this._b|0,f=this._c|0,m=this._d|0,u=this._e|0,o=0;o<16;++o)a[o]=n.readInt32BE(o*4);for(;o<80;++o)a[o]=Yr(a[o-3]^a[o-8]^a[o-14]^a[o-16]);for(var x=0;x<80;++x){var y=~~(x/20),v=Xr(s)+Vr(y,c,f,m)+u+a[x]+Zr[y]|0;u=m,m=f,f=Gr(c),c=s,s=v}this._a=s+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=m+this._d|0,this._e=u+this._e|0};R.prototype._hash=function(){var n=Hr.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 Qr=R;const ti=Ot(Qr),lt=new Error("File system not available.");function ri(n,a,s){throw lt}function qt(n){throw lt}function ii(n){throw lt}const ei=async n=>qt();function ni(n){let a="";for(let s=0;s<n.length;s+=2)a+=String.fromCharCode(parseInt(n.substr(s,2),16));return btoa(a)}const W=(n,a="sha1")=>{if(a!=="sha1")throw new Error("Only sha1 algorithm is available.");const s=new ti;return ni(s.update(n).digest("hex"))},ut=async n=>{const a=new _t,{name:s,revision:c,documentType:f,created:m,lastModified:u}=n,o={name:s,revision:c,documentType:f,created:m,lastModified:u};return a.file("header.json",JSON.stringify(o,null,2)),a.file("state.json",JSON.stringify(n.initialState||{},null,2)),a.file("operations.json",JSON.stringify(n.operations,null,2)),Object.keys(n.attachments).forEach(y=>{const{data:v,...F}=n.attachments[y];a.file(y,v,{base64:!0,createFolders:!0,comment:JSON.stringify(F)})}),a},$t=async(n,a,s,c)=>{await(await ut(n)).generateAsync({type:"uint8array",streamFiles:!0});const m=c??n.name,u=`.${s}.zip`;return ri(a,m.endsWith(u)?m:`${m}${u}`)},ai=async(n,a)=>{const c=await(await ut(n)).generateAsync({type:"blob"}),f=await a.createWritable();await f.write(c),await f.close()},it=async(n,a)=>{const s=qt();return Jt(s,a)},Jt=async(n,a)=>{const s=new _t;return await s.loadAsync(n),oi(s,a)};async function oi(n,a){const s=n.file("state.json");if(!s)throw new Error("Initial state not found");const c=await s.async("string"),f=JSON.parse(c),m=n.file("header.json");let u=null;m&&(u=JSON.parse(await m.async("string")));const o=n.file("operations.json");if(!o)throw new Error("Operations history not found");const x=JSON.parse(await o.async("string")),y={...f,...u,initialState:f,operations:[],attachments:{...f.attachments}};let v=x.slice(0,u==null?void 0:u.revision).reduce((F,U)=>a(F,U),y);return u&&(v={...v,...u,operations:[...v.operations,...x.slice(u.revision)]}),v}function Pt(n){const a=n.replace(/^.*\./,"")||void 0,s=n.replace(/^.*[/\\]/,"")||void 0;return{extension:a,fileName:s}}async function pi(n){const{buffer:a,mimeType:s="application/octet-stream"}=await ii(),c=Pt(n),f=a.toString("base64");return{data:f,hash:W(f),mimeType:s,...c}}async function si(n){const a=await ei(),s=Dr.getType(n)||"application/octet-stream",c=Pt(n),f=a.toString("base64");return{data:f,hash:W(f),mimeType:s,...c}}function q(n,a,s){const c=Xt(n),f=Kt(s);return a.reduce((m,u)=>f(m,u),c)}function ci(n,a){return{...n,name:a}}function li(n,a,s){const c=Math.min(a,n.revision),f=n.operations.slice(0,n.revision-c);return{...q(n.initialState,f,s),operations:n.operations,revision:n.revision-c}}function ui(n,a,s){const c=n.operations.length-n.revision;if(!c)throw new Error("There is no UNDO operation to REDO");const f=a<c?a:c,m=n.operations.slice(0,n.revision+f);return{...q(n.initialState,m,s),operations:n.operations,revision:n.revision+f}}function fi(n,a,s,c){a=a||0,s=s||n.operations.length;const f=n.operations.slice(a,s),m=n.operations.slice(0,a),u=n.operations.slice(s),o=q(n.initialState,m.concat(f),c),{name:x,state:y}=o;return q(n.initialState,[...m,ft({name:x,state:y},f.length),...u],c)}function hi(n,a){return{...n,name:a.name,state:a.state??{}}}const Wt="SET_NAME",H="UNDO",Z="REDO",M="PRUNE",Ht="LOAD_STATE";function mi(n,a){return[H,Z,M].includes(a.type)?n.revision:n.revision+1}function xi(n,a){return{...n,revision:mi(n,a),lastModified:new Date().toISOString()}}function di(n,a){if([H,Z,M,M].includes(a.type))return n;const s=n.operations.slice(0,n.revision);return{...n,operations:[...s,{...a,index:s.length,timestamp:new Date().toISOString(),hash:""}]}}function wi(n,a){let s=di(n,a);return s=xi(s,a),s}function yi(n,a,s){switch(Tt().parse(a),a.type){case Wt:return ci(n,a.input);case H:return li(n,a.input,s);case Z:return ui(n,a.input,s);case M:return fi(n,a.input.start,a.input.end,s);case Ht:return hi(n,a.input.state);default:return n}}function Zt(n,a,s){let c=n;return et(a)&&(c=yi(c,a,s)),c=wi(c,a),c=V.produce(c,f=>{const m=s(f.state,a);if(m)return V.castDraft({...c,state:m})}),V.produce(c,f=>{f.operations[f.operations.length-1].hash=Gt(f),!et(a)&&a.attachments&&a.attachments.forEach(m=>{const{hash:u,...o}=m;f.attachments[u]={...o}})})}function et(n){return[Wt,H,Z,M,Ht].includes(n.type)}function D(n,a,s,c){if(!n)throw new Error("Empty action type");if(typeof n!="string")throw new Error(`Invalid action type: ${n}`);const f=s?{type:n,input:a,attachments:s}:{type:n,input:a};return c==null||c().parse(f),f}function Kt(n,a=Zt){return(s,c)=>a(s,c,n)}const Yt=(n,a)=>({name:"",documentType:"",revision:0,created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...n,state:(a==null?void 0:a(n==null?void 0:n.state))??(n==null?void 0:n.state)??{}}),Xt=(n,a)=>{const s=Yt(n,a);return{...s,initialState:s,operations:[]}},Gt=n=>W(Fr(n.state)),gi=(n,a=1e3)=>{const s=Math.random()*a;return W(`${(n??new Date).toISOString()}${s}`)},Vt=n=>D("SET_NAME",n,void 0,pt),Qt=(n=1)=>D("UNDO",n,void 0,st),tr=(n=1)=>D("REDO",n,void 0,ot),rr=(n,a)=>D("PRUNE",{start:n,end:a},void 0,at),ft=(n,a)=>D("LOAD_STATE",{state:n,operations:a},void 0,nt),vi=Object.freeze(Object.defineProperty({__proto__:null,loadState:ft,prune:rr,redo:tr,setName:Vt,undo:Qt},Symbol.toStringTag,{value:"Module"}));class Ei{constructor(a,s){G(this,"_document");G(this,"_reducer");this._reducer=a,this._document=s}dispatch(a){return this._document=this._reducer(this._document,a),this}saveToFile(a,s,c){return $t(this._document,a,s,c)}async loadFromFile(a){this._document=await it(a,this._reducer)}static async stateFromFile(a,s){return await it(a,s)}get state(){return this._document.state}get operations(){return this._document.operations}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision}get initialState(){return this._document.initialState}toDocument(){return this._document}getAttachment(a){return this._document.attachments[a]}setName(a){return this.dispatch(Vt(a)),this}undo(a){return this.dispatch(Qt(a)),this}redo(a){return this.dispatch(tr(a)),this}prune(a,s){return this.dispatch(rr(a,s)),this}loadState(a,s){return this.dispatch(ft(a,s)),this}}function bi(n,a){a.forEach(s=>{Object.getOwnPropertyNames(s.prototype).forEach(c=>{Object.defineProperty(n.prototype,c,Object.getOwnPropertyDescriptor(s.prototype,c)||Object.create(null))})})}exports.BaseActions=vi;exports.BaseDocument=Ei;exports.applyMixins=bi;exports.baseReducer=Zt;exports.createAction=D;exports.createDocument=Xt;exports.createExtendedState=Yt;exports.createReducer=Kt;exports.createZip=ut;exports.getLocalFile=si;exports.getRemoteFile=pi;exports.hashDocument=Gt;exports.hashKey=gi;exports.isBaseAction=et;exports.loadFromFile=it;exports.loadFromInput=Jt;exports.saveToFile=$t;exports.saveToFileHandle=ai;exports.zod=Ur;