document-model 1.0.17 → 1.0.19

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 (59) hide show
  1. package/dist/browser/document/utils/base.d.ts +6 -2
  2. package/dist/browser/document-model/gen/header/object.d.ts +2 -2
  3. package/dist/browser/document-model/gen/module/object.d.ts +2 -2
  4. package/dist/browser/document-model/gen/object.d.ts +4 -4
  5. package/dist/browser/document-model/gen/operation/object.d.ts +2 -2
  6. package/dist/browser/document-model/gen/operation-error/object.d.ts +2 -2
  7. package/dist/browser/document-model/gen/operation-example/object.d.ts +2 -2
  8. package/dist/browser/document-model/gen/reducer.d.ts +2 -2
  9. package/dist/browser/document-model/gen/schema/types.d.ts +1 -1
  10. package/dist/browser/document-model/gen/state/object.d.ts +2 -2
  11. package/dist/browser/document-model/gen/types.d.ts +3 -3
  12. package/dist/browser/document-model/gen/utils.d.ts +4 -2
  13. package/dist/browser/document-model/gen/versioning/object.d.ts +2 -2
  14. package/dist/browser/document-model/index.d.ts +9 -9
  15. package/dist/browser/document-model.cjs +1 -1
  16. package/dist/browser/document-model.js +2 -2
  17. package/dist/browser/document.cjs +1 -1
  18. package/dist/browser/document.js +6 -6
  19. package/dist/browser/index.cjs +1 -1
  20. package/dist/browser/index.js +4 -4
  21. package/dist/browser/internal/{index-01030c3f.js → index-1ad32a2e.js} +2 -2
  22. package/dist/browser/internal/index-2551382e.js +34 -0
  23. package/dist/{node/internal/index-0db636da.js → browser/internal/index-46b68530.js} +22 -25
  24. package/dist/browser/internal/index-869c5d0d.js +1 -0
  25. package/dist/browser/internal/object-1fdba77d.js +6 -0
  26. package/dist/browser/internal/{object-7e8eaff4.js → object-d50f7d2f.js} +744 -715
  27. package/dist/node/document/utils/base.d.ts +6 -2
  28. package/dist/node/document-model/gen/header/object.d.ts +2 -2
  29. package/dist/node/document-model/gen/module/object.d.ts +2 -2
  30. package/dist/node/document-model/gen/object.d.ts +4 -4
  31. package/dist/node/document-model/gen/operation/object.d.ts +2 -2
  32. package/dist/node/document-model/gen/operation-error/object.d.ts +2 -2
  33. package/dist/node/document-model/gen/operation-example/object.d.ts +2 -2
  34. package/dist/node/document-model/gen/reducer.d.ts +2 -2
  35. package/dist/node/document-model/gen/schema/types.d.ts +1 -1
  36. package/dist/node/document-model/gen/state/object.d.ts +2 -2
  37. package/dist/node/document-model/gen/types.d.ts +3 -3
  38. package/dist/node/document-model/gen/utils.d.ts +4 -2
  39. package/dist/node/document-model/gen/versioning/object.d.ts +2 -2
  40. package/dist/node/document-model/index.d.ts +9 -9
  41. package/dist/node/document-model.cjs +1 -1
  42. package/dist/node/document-model.js +3 -3
  43. package/dist/node/document.cjs +1 -1
  44. package/dist/node/document.js +5 -5
  45. package/dist/node/index.cjs +1 -1
  46. package/dist/node/index.js +4 -4
  47. package/dist/node/internal/{index-cddc9dfd.js → index-631ba7bf.js} +2 -2
  48. package/dist/node/internal/index-6477ee0a.js +1 -0
  49. package/dist/{browser/internal/index-5f1909ad.js → node/internal/index-8d582c48.js} +26 -21
  50. package/dist/node/internal/index-f235f9be.js +34 -0
  51. package/dist/node/internal/object-08bd169a.js +1 -0
  52. package/dist/node/internal/{object-c32ea0a0.js → object-773231ca.js} +473 -444
  53. package/package.json +1 -1
  54. package/dist/browser/internal/index-2aee8ea9.js +0 -1
  55. package/dist/browser/internal/index-a1282d5c.js +0 -31
  56. package/dist/browser/internal/object-24df9d92.js +0 -6
  57. package/dist/node/internal/index-2d4783d9.js +0 -1
  58. package/dist/node/internal/index-5ef0c6b0.js +0 -31
  59. package/dist/node/internal/object-21f3d2ee.js +0 -1
@@ -1,10 +1,14 @@
1
1
  var dt = Object.defineProperty;
2
2
  var ut = (t, e, o) => e in t ? dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
3
  var le = (t, e, o) => (ut(t, typeof e != "symbol" ? e + "" : e, o), o);
4
- import { c as mt, i as Et, a as ht, b as Ot, s as gt, d as St, l as bt, e as ft, f as s, B as l, g as _t, h as It } from "./object-7e8eaff4.js";
4
+ import { c as mt, i as Et, a as ht, b as Ot, s as gt, d as St, l as bt, e as ft, f as s, B as l, g as _t, h as It } from "./object-773231ca.js";
5
5
  import "json-stringify-deterministic";
6
6
  import "immer";
7
7
  import "jszip";
8
+ import "crypto";
9
+ import "fs";
10
+ import "https";
11
+ import "path";
8
12
  import { z as r } from "zod";
9
13
  const Tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10
14
  __proto__: null
@@ -1486,9 +1490,7 @@ const Dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1486
1490
  default:
1487
1491
  return t;
1488
1492
  }
1489
- }, g = mt(
1490
- Ct
1491
- ), kt = {
1493
+ }, g = mt(Ct), kt = {
1492
1494
  id: "",
1493
1495
  name: "",
1494
1496
  extension: "",
@@ -1516,10 +1518,13 @@ const Dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1516
1518
  modules: []
1517
1519
  }
1518
1520
  ]
1519
- }, O = {
1521
+ }, yt = {}, O = {
1520
1522
  fileExtension: "phdm",
1521
1523
  createState(t) {
1522
- return { global: { ...kt, ...t }, local: {} };
1524
+ return {
1525
+ global: { ...kt, ...t == null ? void 0 : t.global },
1526
+ local: { ...yt, ...t == null ? void 0 : t.local }
1527
+ };
1523
1528
  },
1524
1529
  createExtendedState(t) {
1525
1530
  return ht(
@@ -1564,7 +1569,7 @@ const Dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1564
1569
  "SET_AUTHOR_WEBSITE",
1565
1570
  { ...t }
1566
1571
  );
1567
- class yt extends l {
1572
+ class wt extends l {
1568
1573
  setModelName(e) {
1569
1574
  return this.dispatch(be(e));
1570
1575
  }
@@ -1597,7 +1602,7 @@ const Ae = (t) => s(
1597
1602
  "REORDER_CHANGE_LOG_ITEMS",
1598
1603
  { ...t }
1599
1604
  ), Ne = () => s("RELEASE_NEW_VERSION");
1600
- class wt extends l {
1605
+ class vt extends l {
1601
1606
  addChangeLogItem(e) {
1602
1607
  return this.dispatch(Ae(e));
1603
1608
  }
@@ -1630,7 +1635,7 @@ const Le = (t) => s(
1630
1635
  "REORDER_MODULES",
1631
1636
  { ...t }
1632
1637
  );
1633
- class vt extends l {
1638
+ class Ut extends l {
1634
1639
  addModule(e) {
1635
1640
  return this.dispatch(Le(e));
1636
1641
  }
@@ -1669,7 +1674,7 @@ const ye = (t) => s(
1669
1674
  "REORDER_OPERATION_ERRORS",
1670
1675
  { ...t }
1671
1676
  );
1672
- class Ut extends l {
1677
+ class Vt extends l {
1673
1678
  addOperationError(e) {
1674
1679
  return this.dispatch(ye(e));
1675
1680
  }
@@ -1705,7 +1710,7 @@ const Xe = (t) => s(
1705
1710
  "REORDER_OPERATION_EXAMPLES",
1706
1711
  { ...t }
1707
1712
  );
1708
- class Vt extends l {
1713
+ class Ft extends l {
1709
1714
  addOperationExample(e) {
1710
1715
  return this.dispatch(Xe(e));
1711
1716
  }
@@ -1750,7 +1755,7 @@ const ze = (t) => s(
1750
1755
  "REORDER_MODULE_OPERATIONS",
1751
1756
  { ...t }
1752
1757
  );
1753
- class Ft extends l {
1758
+ class Ht extends l {
1754
1759
  addOperation(e) {
1755
1760
  return this.dispatch(ze(e));
1756
1761
  }
@@ -1801,7 +1806,7 @@ const rt = (t) => s(
1801
1806
  "REORDER_STATE_EXAMPLES",
1802
1807
  { ...t }
1803
1808
  );
1804
- class Ht extends l {
1809
+ class Xt extends l {
1805
1810
  setStateSchema(e) {
1806
1811
  return this.dispatch(rt(e));
1807
1812
  }
@@ -1838,15 +1843,15 @@ let pe = (m = class extends l {
1838
1843
  }
1839
1844
  }, le(m, "fileExtension", "phdm"), m);
1840
1845
  _t(pe, [
1841
- yt,
1842
1846
  wt,
1843
1847
  vt,
1844
1848
  Ut,
1845
1849
  Vt,
1846
1850
  Ft,
1847
- Ht
1851
+ Ht,
1852
+ Xt
1848
1853
  ]);
1849
- const Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1854
+ const Gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1850
1855
  __proto__: null,
1851
1856
  addChangeLogItem: Ae,
1852
1857
  addModule: Le,
@@ -1891,30 +1896,30 @@ const Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1891
1896
  updateChangeLogItem: xe,
1892
1897
  updateOperationExample: Ge,
1893
1898
  updateStateExample: it
1894
- }, Symbol.toStringTag, { value: "Module" })), pt = pe, lt = { ...O, ...Tt }, ct = { ...It, ...Xt }, Gt = {
1899
+ }, Symbol.toStringTag, { value: "Module" })), pt = pe, lt = { ...O, ...Tt }, ct = { ...It, ...Gt }, $t = {
1895
1900
  Document: pt,
1896
1901
  reducer: g,
1897
1902
  actions: ct,
1898
1903
  utils: lt,
1899
1904
  documentModel: ce
1900
- }, Kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1905
+ }, tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1901
1906
  __proto__: null,
1902
1907
  Document: pt,
1903
1908
  DocumentModel: pe,
1904
1909
  actions: ct,
1905
1910
  documentModel: ce,
1906
- module: Gt,
1911
+ module: $t,
1907
1912
  reducer: g,
1908
1913
  utils: lt,
1909
1914
  z: Dt
1910
1915
  }, Symbol.toStringTag, { value: "Module" }));
1911
1916
  export {
1912
- Kt as D,
1917
+ tr as D,
1913
1918
  pe as a,
1914
1919
  pt as b,
1915
1920
  ct as c,
1916
1921
  ce as d,
1917
- Gt as m,
1922
+ $t as m,
1918
1923
  g as r,
1919
1924
  lt as u,
1920
1925
  Dt as z
@@ -0,0 +1,34 @@
1
+ import { f as e, b as a, a as s, c as t, j as o, k as r, m as n, n as l, o as c, i, l as u, e as d, r as p, p as m, q as y, s as b, d as _, t as g, B as F, h as O, g as f, u as D, z as h } from "./object-773231ca.js";
2
+ const j = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
+ __proto__: null,
4
+ createAction: e,
5
+ createDocument: a,
6
+ createExtendedState: s,
7
+ createReducer: t,
8
+ createZip: o,
9
+ getLocalFile: r,
10
+ getRemoteFile: n,
11
+ hashDocument: l,
12
+ hashKey: c,
13
+ isBaseAction: i,
14
+ loadFromFile: u,
15
+ loadFromInput: d,
16
+ readOnly: p,
17
+ replayDocument: m,
18
+ replayOperations: y,
19
+ saveToFile: b,
20
+ saveToFileHandle: _,
21
+ sortOperations: g
22
+ }, Symbol.toStringTag, { value: "Module" })), S = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
23
+ __proto__: null,
24
+ BaseDocument: F,
25
+ actions: O,
26
+ applyMixins: f,
27
+ baseReducer: D,
28
+ utils: j,
29
+ z: h
30
+ }, Symbol.toStringTag, { value: "Module" }));
31
+ export {
32
+ S as D,
33
+ j as i
34
+ };
@@ -0,0 +1 @@
1
+ "use strict";var dt=Object.defineProperty;var xt=(t,e,i)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var y=(t,e,i)=>(xt(t,typeof e!="symbol"?e+"":e,i),i);const gt=require("json-stringify-deterministic"),g=require("immer"),o=require("zod"),R=require("jszip"),ft=require("crypto"),O=require("fs"),ht=require("https"),bt=require("path"),L=t=>t!=null,vt=o.z.any().refine(t=>L(t)),U=o.z.enum(["LOAD_STATE"]),J=o.z.enum(["PRUNE"]),$=o.z.enum(["REDO"]),B=o.z.enum(["SET_NAME"]),C=o.z.enum(["UNDO"]);function yt(){return o.z.object({__typename:o.z.literal("Action").optional(),type:o.z.string()})}function Z(){return o.z.union([H(),W(),G(),Q(),V()])}function jt(){return o.z.object({__typename:o.z.literal("DocumentFile").optional(),data:o.z.string(),extension:o.z.string().nullable(),fileName:o.z.string().nullable(),mimeType:o.z.string()})}function H(){return o.z.object({input:o.z.lazy(()=>k()),type:U,scope:o.z.literal("global")})}function k(){return o.z.object({operations:o.z.number(),state:o.z.lazy(()=>K())})}function K(){return o.z.object({data:o.z.unknown().nullish(),name:o.z.string()})}function wt(){return o.z.object({__typename:o.z.literal("Operation").optional(),hash:o.z.string(),index:o.z.number(),timestamp:o.z.string().datetime(),type:o.z.string()})}function W(){return o.z.object({input:o.z.lazy(()=>E()),type:J,scope:o.z.literal("global")})}function E(){return o.z.object({end:o.z.number().nullish(),start:o.z.number().nullish()})}const A=o.z.number;function G(){return o.z.object({input:A(),type:$,scope:o.z.literal("global")})}const N=o.z.string;function Q(){return o.z.object({input:N(),type:B,scope:o.z.literal("global")})}function zt(){return o.z.object({__typename:o.z.literal("SetNameOperation").optional(),hash:o.z.string(),index:o.z.number(),input:o.z.string(),timestamp:o.z.string().datetime(),type:o.z.string()})}const T=o.z.number;function V(){return o.z.object({input:T(),type:C,scope:o.z.literal("global")})}const St=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:yt,BaseActionSchema:Z,DocumentFileSchema:jt,LoadStateActionInputSchema:k,LoadStateActionSchema:H,LoadStateActionStateInputSchema:K,Load_StateSchema:U,OperationSchema:wt,PruneActionInputSchema:E,PruneActionSchema:W,PruneSchema:J,RedoActionInputSchema:A,RedoActionSchema:G,RedoSchema:$,SetNameActionInputSchema:N,SetNameActionSchema:Q,SetNameOperationSchema:zt,Set_NameSchema:B,UndoActionInputSchema:T,UndoActionSchema:V,UndoSchema:C,definedNonNullAnySchema:vt,isDefinedNonNullAny:L},Symbol.toStringTag,{value:"Module"}));function Ot(t,e){return{...t,name:e}}function _t(t,e,i){const n=Math.min(e,t.revision),a=t.operations.global.slice(0,t.revision-n);return{...f(t.initialState,{global:a,local:t.operations.local},i),operations:t.operations,revision:t.revision-n}}function Dt(t,e,i){const n=t.operations.global.length-t.revision;if(!n)throw new Error("There is no UNDO operation to REDO");const a=e<n?e:n,s=t.operations.global.slice(0,t.revision+a);return{...f(t.initialState,{global:s,local:t.operations.local},i),operations:t.operations,revision:t.revision+a}}function kt(t,e,i,n){e=e||0,i=i||t.operations.global.length;const a=t.operations.global.slice(e,i),s=t.operations.global.slice(0,e),p=t.operations.global.slice(i),l=f(t.initialState,{global:s.concat(a),local:t.operations.local},n),{name:r,state:c}=l,m=s.length,u=s.length?s[s.length-1].timestamp:p.length?p[0].timestamp:new Date().toISOString();return f(t.initialState,{global:[...s,{...P({name:r,state:c},a.length),timestamp:u,index:m,hash:I({state:c},"global")},...p.map((z,S)=>({...z,index:m+S+1}))],local:t.operations.local},n)}function Et(t,e){return{...t,name:e.name,state:e.state??{global:{},local:{}}}}const X="SET_NAME",h="UNDO",b="REDO",v="PRUNE",Y="LOAD_STATE";function At(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function j(){this._types=Object.create(null),this._extensions=Object.create(null);for(let t=0;t<arguments.length;t++)this.define(arguments[t]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}j.prototype.define=function(t,e){for(let i in t){let n=t[i].map(function(a){return a.toLowerCase()});i=i.toLowerCase();for(let a=0;a<n.length;a++){const s=n[a];if(s[0]!=="*"){if(!e&&s in this._types)throw new Error('Attempt to change mapping for "'+s+'" extension from "'+this._types[s]+'" to "'+i+'". Pass `force=true` to allow this, otherwise remove "'+s+'" from the list of extensions for "'+i+'".');this._types[s]=i}}if(e||!this._extensions[i]){const a=n[0];this._extensions[i]=a[0]!=="*"?a:a.substr(1)}}};j.prototype.getType=function(t){t=String(t);let e=t.replace(/^.*[/\\]/,"").toLowerCase(),i=e.replace(/^.*\./,"").toLowerCase(),n=e.length<t.length;return(i.length<e.length-1||!n)&&this._types[i]||null};j.prototype.getExtension=function(t){return t=/^\s*([^;\s]*)/.test(t)&&RegExp.$1,t&&this._extensions[t.toLowerCase()]||null};var Nt=j,Tt={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};let Ft=Nt;var qt=new Ft(Tt);const It=At(qt);function Mt(t,e,i){const n=bt.join(t,e);return O.mkdirSync(t,{recursive:!0}),new Promise((a,s)=>{try{O.writeFile(n,i,{},p=>{p?s(p):a(n)})}catch(p){s(p)}})}function tt(t){return O.readFileSync(t)}function Pt(t){return new Promise((e,i)=>{ht.get(t,n=>{const a=[],s=n.headers["content-type"];n.on("data",p=>{a.push(p)}),n.on("end",()=>{e({buffer:Buffer.concat(a),mimeType:s})})}).on("error",n=>{i(n)})})}const Rt=async t=>tt(t),w=(t,e="sha1")=>ft.createHash(e).update(t).digest("base64"),F=async t=>{const e=new R,{name:i,revision:n,documentType:a,created:s,lastModified:p}=t,l={name:i,revision:n,documentType:a,created:s,lastModified:p};return e.file("header.json",JSON.stringify(l,null,2)),e.file("state.json",JSON.stringify(t.initialState||{},null,2)),e.file("operations.json",JSON.stringify(t.operations,null,2)),Object.keys(t.attachments).forEach(c=>{const{data:m,...u}=t.attachments[c];e.file(c,m,{base64:!0,createFolders:!0,comment:JSON.stringify(u)})}),e},et=async(t,e,i,n)=>{const s=await(await F(t)).generateAsync({type:"uint8array",streamFiles:!0}),p=n??t.name,l=`.${i}.zip`;return Mt(e,p.endsWith(l)?p:`${p}${l}`,s)},Lt=async(t,e)=>{const n=await(await F(t)).generateAsync({type:"blob"}),a=await e.createWritable();await a.write(n),await a.close()},_=async(t,e)=>{const i=tt(t);return it(i,e)},it=async(t,e)=>{const i=new R;return await i.loadAsync(t),Ut(i,e)};async function Ut(t,e){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const n=await i.async("string"),a=JSON.parse(n),s=t.file("header.json");let p;s&&(p=JSON.parse(await s.async("string")));const l=t.file("operations.json");if(!l)throw new Error("Operations history not found");const r=JSON.parse(await l.async("string"));let c=M(a,r,e,void 0,p);return p&&(c={...c,...p}),c}function at(t){const e=t.replace(/^.*\./,"")||void 0,i=t.replace(/^.*[/\\]/,"")||void 0;return{extension:e,fileName:i}}async function Jt(t){const{buffer:e,mimeType:i="application/octet-stream"}=await Pt(t),n=at(t),a=e.toString("base64");return{data:a,hash:w(a),mimeType:i,...n}}async function $t(t){const e=await Rt(t),i=It.getType(t)||"application/octet-stream",n=at(t),a=e.toString("base64");return{data:a,hash:w(a),mimeType:i,...n}}function Bt(t,e){return[h,b,v].includes(e.type)?t.revision:t.revision+1}function Ct(t,e){return{...t,revision:Bt(t,e),lastModified:new Date().toISOString()}}function Zt(t,e){if([h,b,v].includes(e.type))return t;const i=t.operations.global.slice(0,t.revision),n=e.scope||"global",a=n==="global"?i:t.operations[n];return a.push({...e,index:a.length,timestamp:new Date().toISOString(),hash:"",scope:n}),{...t,operations:{...t.operations,[n]:a}}}function Ht(t,e){let i=Zt(t,e);return(!e.scope||e.scope==="global")&&(i=Ct(i,e)),i}function Kt(t,e,i){switch(Z().parse(e),e.type){case X:return Ot(t,e.input);case h:return _t(t,e.input,i);case b:return Dt(t,e.input,i);case v:return kt(t,e.input.start,e.input.end,i);case Y:return Et(t,e.input.state);default:return t}}function q(t,e,i,n){let a=t;return D(e)&&(a=Kt(a,e,i)),a=Ht(a,e),a=g.produce(a,s=>{const p=i(s.state,e,n);if(p)return g.castDraft({...a,state:p})}),g.produce(a,s=>{if([h,b,v].includes(e.type))return s;const p=e.scope||"global";s.operations[p][s.operations[p].length-1].hash=I(s,p),!D(e)&&e.attachments&&e.attachments.forEach(l=>{const{hash:r,...c}=l;s.attachments[r]={...c}})})}function D(t){return[X,h,b,v,Y].includes(t.type)}function d(t,e,i,n,a="global"){if(!t)throw new Error("Empty action type");if(typeof t!="string")throw new Error(`Invalid action type: ${t}`);const s={type:t,input:e,scope:a};i&&(s.attachments=i);try{n==null||n().parse(s.input)}catch(p){throw new Error(`Invalid action input: ${p}`)}return s}function nt(t,e=q){return(i,n,a)=>e(i,n,t,a)}const ot=(t,e)=>({name:"",documentType:"",revision:0,created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...t,state:(e==null?void 0:e(t==null?void 0:t.state))??(t==null?void 0:t.state)??{global:{},local:{}}}),st=(t,e)=>{const i=ot(t,e);return{...i,initialState:i,operations:{global:[],local:[]}}},I=(t,e="global")=>w(gt(t.state[e])),Wt=(t,e=1e3)=>{const i=Math.random()*e;return w(`${(t??new Date).toISOString()}${i}`)};function x(t){return g.castImmutable(g.freeze(t,!0))}function pt(t){return Object.values(t).flatMap(e=>e).sort((e,i)=>new Date(e.timestamp).getTime()-new Date(i.timestamp).getTime())}function f(t,e,i,n,a,s=q){const p=nt(i,s);return M(t,e,p,n,a)}function M(t,e,i,n,a){const s=st(t),p={...e,global:e.global.slice(0,a==null?void 0:a.revision)},l=pt(p).reduce((c,m)=>i(c,m,n),s),r=Object.keys(l.operations).reduce((c,m)=>{const u=m,z=u==="global"&&a&&a.revision<e.global.length?e.global.slice(a==null?void 0:a.revision):[];return{...c,[u]:[...l.operations[u].map((S,ut)=>({...S,timestamp:e[u][ut].timestamp})),...z]}},{global:[],local:[]});return{...l,operations:r}}const lt=t=>d("SET_NAME",t,void 0,N),ct=(t=1)=>d("UNDO",t,void 0,T),rt=(t=1)=>d("REDO",t,void 0,A),mt=(t,e)=>d("PRUNE",{start:t,end:e},void 0,E),P=(t,e)=>d("LOAD_STATE",{state:t,operations:e},void 0,k),Gt=Object.freeze(Object.defineProperty({__proto__:null,loadState:P,prune:mt,redo:rt,setName:lt,undo:ct},Symbol.toStringTag,{value:"Module"}));class Qt{constructor(e,i,n){y(this,"_document");y(this,"_reducer");y(this,"_signalDispatch");this._reducer=e,this._document=i,this._signalDispatch=n}dispatch(e){return this._document=this._reducer(this._document,e,this._signalDispatch),this}saveToFile(e,i,n){return et(this._document,e,i,n)}async loadFromFile(e){this._document=await _(e,this._reducer)}static async stateFromFile(e,i){return await _(e,i)}get state(){return x(this._document.state)}get operations(){return x(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision}get initialState(){return x(this._document.initialState)}toDocument(){return x(this._document)}getAttachment(e){return this._document.attachments[e]}setName(e){return this.dispatch(lt(e)),this}undo(e){return this.dispatch(ct(e)),this}redo(e){return this.dispatch(rt(e)),this}prune(e,i){return this.dispatch(mt(e,i)),this}loadState(e,i){return this.dispatch(P(e,i)),this}}function Vt(t,e){e.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{Object.defineProperty(t.prototype,n,Object.getOwnPropertyDescriptor(i.prototype,n)||Object.create(null))})})}exports.BaseActions=Gt;exports.BaseDocument=Qt;exports.applyMixins=Vt;exports.baseReducer=q;exports.createAction=d;exports.createDocument=st;exports.createExtendedState=ot;exports.createReducer=nt;exports.createZip=F;exports.getLocalFile=$t;exports.getRemoteFile=Jt;exports.hashDocument=I;exports.hashKey=Wt;exports.isBaseAction=D;exports.loadFromFile=_;exports.loadFromInput=it;exports.readOnly=x;exports.replayDocument=M;exports.replayOperations=f;exports.saveToFile=et;exports.saveToFileHandle=Lt;exports.sortOperations=pt;exports.zod=St;