document-model 1.1.0-experimental.3 → 1.1.0

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 (37) hide show
  1. package/dist/browser/cjs/document-model.js +1 -1
  2. package/dist/browser/cjs/document.js +1 -1
  3. package/dist/browser/cjs/index.js +1 -1
  4. package/dist/browser/cjs/internal/{index-dwAOfmBp.js → index-Bqu_Uzaf.js} +1 -1
  5. package/dist/browser/cjs/internal/{index-DMRH7zDy.js → index-DD_uV5_l.js} +1 -1
  6. package/dist/browser/cjs/internal/object-CHFtJl_E.js +25 -0
  7. package/dist/browser/es/document-model.js +2 -2
  8. package/dist/browser/es/document.js +9 -7
  9. package/dist/browser/es/index.js +3 -3
  10. package/dist/browser/es/internal/{index-DQztOVJu.js → index-C9_nWw6z.js} +1 -1
  11. package/dist/browser/es/internal/index-CNILoLzv.js +46 -0
  12. package/dist/browser/es/internal/{object-iTBekDVP.js → object-CJvDhUxl.js} +1003 -965
  13. package/dist/browser/src/document/object.d.ts +35 -0
  14. package/dist/browser/src/document/reducer.d.ts +17 -0
  15. package/dist/browser/src/document/types.d.ts +2 -0
  16. package/dist/browser/src/document/utils/document-helpers.d.ts +9 -0
  17. package/dist/node/cjs/document-model.js +1 -1
  18. package/dist/node/cjs/document.js +1 -1
  19. package/dist/node/cjs/index.js +1 -1
  20. package/dist/node/cjs/internal/{index-BNFVmPew.js → index-DSsY5px9.js} +1 -1
  21. package/dist/node/cjs/internal/{index-FvRO8SnG.js → index-eJODAZgf.js} +1 -1
  22. package/dist/node/cjs/internal/object-9bv72oJK.js +20 -0
  23. package/dist/node/es/document-model.js +2 -2
  24. package/dist/node/es/document.js +10 -8
  25. package/dist/node/es/index.js +3 -3
  26. package/dist/node/es/internal/index-Dug-2E00.js +46 -0
  27. package/dist/node/es/internal/{index-DOpbr_uw.js → index-nccvxxIw.js} +1 -1
  28. package/dist/node/es/internal/{object-C2s2eZ08.js → object-B9OVOSMl.js} +668 -630
  29. package/dist/node/src/document/object.d.ts +35 -0
  30. package/dist/node/src/document/reducer.d.ts +17 -0
  31. package/dist/node/src/document/types.d.ts +2 -0
  32. package/dist/node/src/document/utils/document-helpers.d.ts +9 -0
  33. package/package.json +3 -1
  34. package/dist/browser/cjs/internal/object-C-PazS9q.js +0 -25
  35. package/dist/browser/es/internal/index-BVJxzkIs.js +0 -44
  36. package/dist/node/cjs/internal/object-Xvr4kDQj.js +0 -20
  37. package/dist/node/es/internal/index-BIrQOTP_.js +0 -44
@@ -1,20 +0,0 @@
1
- "use strict";var fe=Object.defineProperty;var de=(t,e,n)=>e in t?fe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var at=(t,e,n)=>(de(t,typeof e!="symbol"?e+"":e,n),n);const H=require("immer"),f=require("zod"),_t=require("jszip"),ge=require("crypto"),ft=require("fs"),he=require("https"),xe=require("path"),vt=t=>t!=null,ye=f.z.any().refine(t=>vt(t)),Nt=f.z.enum(["LOAD_STATE"]),It=f.z.enum(["PRUNE"]),At=f.z.enum(["REDO"]),Pt=f.z.enum(["SET_NAME"]),Mt=f.z.enum(["UNDO"]);function be(){return f.z.object({__typename:f.z.literal("Action").optional(),type:f.z.string()})}function et(){return f.z.literal("global").or(f.z.literal("local"))}function Ft(){return f.z.union([Rt(),qt(),Ct(),Ut(),Jt()])}function we(){return f.z.object({__typename:f.z.literal("DocumentFile").optional(),data:f.z.string(),extension:f.z.string().nullable(),fileName:f.z.string().nullable(),mimeType:f.z.string()})}function Rt(){return f.z.object({input:f.z.lazy(()=>yt()),type:Nt,scope:et()})}function yt(){return f.z.object({operations:f.z.number(),state:f.z.lazy(()=>Lt())})}function Lt(){return f.z.object({data:f.z.unknown().nullish(),name:f.z.string()})}function Oe(){return f.z.object({__typename:f.z.literal("Operation").optional(),hash:f.z.string(),index:f.z.number(),timestamp:f.z.string().datetime(),type:f.z.string()})}function qt(){return f.z.object({input:f.z.lazy(()=>bt()),type:It,scope:et()})}function bt(){return f.z.object({end:f.z.number().nullish(),start:f.z.number().nullish()})}const wt=f.z.number;function Ct(){return f.z.object({input:wt(),type:At,scope:et()})}const Ot=f.z.string;function Ut(){return f.z.object({input:Ot(),type:Pt,scope:f.z.literal("global")})}function Se(){return f.z.object({__typename:f.z.literal("SetNameOperation").optional(),hash:f.z.string(),index:f.z.number(),input:f.z.string(),timestamp:f.z.string().datetime(),type:f.z.string()})}const St=f.z.number;function Jt(){return f.z.object({input:St(),type:Mt,scope:et()})}const je=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:be,BaseActionSchema:Ft,DocumentFileSchema:we,LoadStateActionInputSchema:yt,LoadStateActionSchema:Rt,LoadStateActionStateInputSchema:Lt,Load_StateSchema:Nt,OperationSchema:Oe,OperationScopeSchema:et,PruneActionInputSchema:bt,PruneActionSchema:qt,PruneSchema:It,RedoActionInputSchema:wt,RedoActionSchema:Ct,RedoSchema:At,SetNameActionInputSchema:Ot,SetNameActionSchema:Ut,SetNameOperationSchema:Se,Set_NameSchema:Pt,UndoActionInputSchema:St,UndoActionSchema:Jt,UndoSchema:Mt,definedNonNullAnySchema:ye,isDefinedNonNullAny:vt},Symbol.toStringTag,{value:"Module"}));function Ee(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var dt={exports:{}};(function(t,e){const{hasOwnProperty:n}=Object.prototype,i=R();i.configure=R,i.stringify=i,i.default=i,e.stringify=i,e.configure=R,t.exports=i;const o=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function a(c){return c.length<5e3&&!o.test(c)?`"${c}"`:JSON.stringify(c)}function r(c){if(c.length>200)return c.sort();for(let l=1;l<c.length;l++){const u=c[l];let T=l;for(;T!==0&&c[T-1]>u;)c[T]=c[T-1],T--;c[T]=u}return c}const p=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function m(c){return p.call(c)!==void 0&&c.length!==0}function d(c,l,u){c.length<u&&(u=c.length);const T=l===","?"":" ";let L=`"0":${T}${c[0]}`;for(let P=1;P<u;P++)L+=`${l}"${P}":${T}${c[P]}`;return L}function h(c){if(n.call(c,"circularValue")){const l=c.circularValue;if(typeof l=="string")return`"${l}"`;if(l==null)return l;if(l===Error||l===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function b(c,l){let u;if(n.call(c,l)&&(u=c[l],typeof u!="boolean"))throw new TypeError(`The "${l}" argument must be of type boolean`);return u===void 0?!0:u}function O(c,l){let u;if(n.call(c,l)){if(u=c[l],typeof u!="number")throw new TypeError(`The "${l}" argument must be of type number`);if(!Number.isInteger(u))throw new TypeError(`The "${l}" argument must be an integer`);if(u<1)throw new RangeError(`The "${l}" argument must be >= 1`)}return u===void 0?1/0:u}function v(c){return c===1?"1 item":`${c} items`}function z(c){const l=new Set;for(const u of c)(typeof u=="string"||typeof u=="number")&&l.add(String(u));return l}function A(c){if(n.call(c,"strict")){const l=c.strict;if(typeof l!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(l)return u=>{let T=`Object can not safely be stringified. Received type ${typeof u}`;throw typeof u!="function"&&(T+=` (${u.toString()})`),new Error(T)}}}function R(c){c={...c};const l=A(c);l&&(c.bigint===void 0&&(c.bigint=!1),"circularValue"in c||(c.circularValue=Error));const u=h(c),T=b(c,"bigint"),L=b(c,"deterministic"),P=O(c,"maximumDepth"),D=O(c,"maximumBreadth");function ot(I,s,g,w,y,j){let x=s[I];switch(typeof x=="object"&&x!==null&&typeof x.toJSON=="function"&&(x=x.toJSON(I)),x=w.call(s,I,x),typeof x){case"string":return a(x);case"object":{if(x===null)return"null";if(g.indexOf(x)!==-1)return u;let S="",$=",";const k=j;if(Array.isArray(x)){if(x.length===0)return"[]";if(P<g.length+1)return'"[Array]"';g.push(x),y!==""&&(j+=y,S+=`
2
- ${j}`,$=`,
3
- ${j}`);const F=Math.min(x.length,D);let U=0;for(;U<F-1;U++){const rt=ot(String(U),x,g,w,y,j);S+=rt!==void 0?rt:"null",S+=$}const J=ot(String(U),x,g,w,y,j);if(S+=J!==void 0?J:"null",x.length-1>D){const rt=x.length-D-1;S+=`${$}"... ${v(rt)} not stringified"`}return y!==""&&(S+=`
4
- ${k}`),g.pop(),`[${S}]`}let _=Object.keys(x);const N=_.length;if(N===0)return"{}";if(P<g.length+1)return'"[Object]"';let E="",M="";y!==""&&(j+=y,$=`,
5
- ${j}`,E=" ");const C=Math.min(N,D);L&&!m(x)&&(_=r(_)),g.push(x);for(let F=0;F<C;F++){const U=_[F],J=ot(U,x,g,w,y,j);J!==void 0&&(S+=`${M}${a(U)}:${E}${J}`,M=$)}if(N>D){const F=N-D;S+=`${M}"...":${E}"${v(F)} not stringified"`,M=$}return y!==""&&M.length>1&&(S=`
6
- ${j}${S}
7
- ${k}`),g.pop(),`{${S}}`}case"number":return isFinite(x)?String(x):l?l(x):"null";case"boolean":return x===!0?"true":"false";case"undefined":return;case"bigint":if(T)return String(x);default:return l?l(x):void 0}}function st(I,s,g,w,y,j){switch(typeof s=="object"&&s!==null&&typeof s.toJSON=="function"&&(s=s.toJSON(I)),typeof s){case"string":return a(s);case"object":{if(s===null)return"null";if(g.indexOf(s)!==-1)return u;const x=j;let S="",$=",";if(Array.isArray(s)){if(s.length===0)return"[]";if(P<g.length+1)return'"[Array]"';g.push(s),y!==""&&(j+=y,S+=`
8
- ${j}`,$=`,
9
- ${j}`);const N=Math.min(s.length,D);let E=0;for(;E<N-1;E++){const C=st(String(E),s[E],g,w,y,j);S+=C!==void 0?C:"null",S+=$}const M=st(String(E),s[E],g,w,y,j);if(S+=M!==void 0?M:"null",s.length-1>D){const C=s.length-D-1;S+=`${$}"... ${v(C)} not stringified"`}return y!==""&&(S+=`
10
- ${x}`),g.pop(),`[${S}]`}g.push(s);let k="";y!==""&&(j+=y,$=`,
11
- ${j}`,k=" ");let _="";for(const N of w){const E=st(N,s[N],g,w,y,j);E!==void 0&&(S+=`${_}${a(N)}:${k}${E}`,_=$)}return y!==""&&_.length>1&&(S=`
12
- ${j}${S}
13
- ${x}`),g.pop(),`{${S}}`}case"number":return isFinite(s)?String(s):l?l(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(T)return String(s);default:return l?l(s):void 0}}function Z(I,s,g,w,y){switch(typeof s){case"string":return a(s);case"object":{if(s===null)return"null";if(typeof s.toJSON=="function"){if(s=s.toJSON(I),typeof s!="object")return Z(I,s,g,w,y);if(s===null)return"null"}if(g.indexOf(s)!==-1)return u;const j=y;if(Array.isArray(s)){if(s.length===0)return"[]";if(P<g.length+1)return'"[Array]"';g.push(s),y+=w;let E=`
14
- ${y}`;const M=`,
15
- ${y}`,C=Math.min(s.length,D);let F=0;for(;F<C-1;F++){const J=Z(String(F),s[F],g,w,y);E+=J!==void 0?J:"null",E+=M}const U=Z(String(F),s[F],g,w,y);if(E+=U!==void 0?U:"null",s.length-1>D){const J=s.length-D-1;E+=`${M}"... ${v(J)} not stringified"`}return E+=`
16
- ${j}`,g.pop(),`[${E}]`}let x=Object.keys(s);const S=x.length;if(S===0)return"{}";if(P<g.length+1)return'"[Object]"';y+=w;const $=`,
17
- ${y}`;let k="",_="",N=Math.min(S,D);m(s)&&(k+=d(s,$,D),x=x.slice(s.length),N-=s.length,_=$),L&&(x=r(x)),g.push(s);for(let E=0;E<N;E++){const M=x[E],C=Z(M,s[M],g,w,y);C!==void 0&&(k+=`${_}${a(M)}: ${C}`,_=$)}if(S>D){const E=S-D;k+=`${_}"...": "${v(E)} not stringified"`,_=$}return _!==""&&(k=`
18
- ${y}${k}
19
- ${j}`),g.pop(),`{${k}}`}case"number":return isFinite(s)?String(s):l?l(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(T)return String(s);default:return l?l(s):void 0}}function Q(I,s,g){switch(typeof s){case"string":return a(s);case"object":{if(s===null)return"null";if(typeof s.toJSON=="function"){if(s=s.toJSON(I),typeof s!="object")return Q(I,s,g);if(s===null)return"null"}if(g.indexOf(s)!==-1)return u;let w="";if(Array.isArray(s)){if(s.length===0)return"[]";if(P<g.length+1)return'"[Array]"';g.push(s);const $=Math.min(s.length,D);let k=0;for(;k<$-1;k++){const N=Q(String(k),s[k],g);w+=N!==void 0?N:"null",w+=","}const _=Q(String(k),s[k],g);if(w+=_!==void 0?_:"null",s.length-1>D){const N=s.length-D-1;w+=`,"... ${v(N)} not stringified"`}return g.pop(),`[${w}]`}let y=Object.keys(s);const j=y.length;if(j===0)return"{}";if(P<g.length+1)return'"[Object]"';let x="",S=Math.min(j,D);m(s)&&(w+=d(s,",",D),y=y.slice(s.length),S-=s.length,x=","),L&&(y=r(y)),g.push(s);for(let $=0;$<S;$++){const k=y[$],_=Q(k,s[k],g);_!==void 0&&(w+=`${x}${a(k)}:${_}`,x=",")}if(j>D){const $=j-D;w+=`${x}"...":"${v($)} not stringified"`}return g.pop(),`{${w}}`}case"number":return isFinite(s)?String(s):l?l(s):"null";case"boolean":return s===!0?"true":"false";case"undefined":return;case"bigint":if(T)return String(s);default:return l?l(s):void 0}}function ue(I,s,g){if(arguments.length>1){let w="";if(typeof g=="number"?w=" ".repeat(Math.min(g,10)):typeof g=="string"&&(w=g.slice(0,10)),s!=null){if(typeof s=="function")return ot("",{"":I},[],s,w,"");if(Array.isArray(s))return st("",I,[],z(s),w,"")}if(w.length!==0)return Z("",I,[],w,"")}return Q("",I,[])}return ue}})(dt,dt.exports);var $e=dt.exports;const G=Ee($e);G.configure;function De(t,e){return{...t,name:e}}function ke(t,e,n){const{scope:i,input:o}=e,a={document:t,action:e,skip:n};return H.produce(a,r=>{if(r.document.operations[i].length<1)throw new Error(`Cannot undo: no operations in history for scope "${i}"`);if(o<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(r.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const p=r.document.operations[i].at(-1),m=p&&p.type==="NOOP"&&p.skip>0;if(r.skip+=o,m){r.skip+=p.skip;const O=r.document.operations[i][r.document.operations[i].length-2];O&&p.index-O.index===1&&r.document.operations[i].pop()}if(r.document.operations[i].length<r.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const d=r.document.operations[i].length-1;let h=o,b=m?d-p.skip:d;for(;h>0&&b>=0;){const O=r.document.operations[i][b];if(!O){h--,b--;continue}O.type==="NOOP"&&O.skip>0?(b=b-(O.skip+1),r.skip+=O.skip+1):(r.document.clipboard.push({...O}),h--,b--)}r.action=me(i)})}function ze(t,e,n){const{scope:i,input:o}=e,a={document:t,action:e,skip:n};return H.produce(a,r=>{if(r.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(o>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(o<1)throw new Error("Invalid REDO action: invalid redo input value");if(r.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const p=r.document.clipboard.findLastIndex(d=>d.scope===i);if(p<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${i}"`);const m=r.document.clipboard.splice(p,1)[0];r.action=H.castDraft({type:m.type,scope:m.scope,input:m.input})})}function Te(t,e,n){const{scope:i}=e,o=t.operations[i];let{input:{start:a,end:r}}=e;a=a||0,r=r||o.length;const p=o.slice(a,r),m=o.slice(0,a),d=o.slice(r),h=pt(t.initialState,{...t.operations,[i]:m.concat(p)},n),{name:b,state:O}=h,v=m.length,z=m.length?m[m.length-1].timestamp:d.length?d[0].timestamp:new Date().toISOString();return pt(t.initialState,{...t.operations,[i]:[...m,{...Tt({name:b,state:O},p.length),timestamp:z,index:v,hash:mt({state:O},"global")},...d.map((A,R)=>({...A,index:v+R+1}))]},n)}function _e(t,e){return{...t,name:e.name,state:e.state??{global:{},local:{}}}}const Ht="SET_NAME",nt="UNDO",it="REDO",ct="PRUNE",Vt="LOAD_STATE",ve="NOOP",Bt={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(Bt);var q=function(t,e,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(t):i?i.value:e.get(t)},W,Y,X;class Ne{constructor(...e){W.set(this,new Map),Y.set(this,new Map),X.set(this,new Map);for(const n of e)this.define(n)}define(e,n=!1){for(let[i,o]of Object.entries(e)){i=i.toLowerCase(),o=o.map(p=>p.toLowerCase()),q(this,X,"f").has(i)||q(this,X,"f").set(i,new Set);const a=q(this,X,"f").get(i);let r=!0;for(let p of o){const m=p.startsWith("*");if(p=m?p.slice(1):p,a==null||a.add(p),r&&q(this,Y,"f").set(i,p),r=!1,m)continue;const d=q(this,W,"f").get(p);if(d&&d!=i&&!n)throw new Error(`"${i} -> ${p}" conflicts with "${d} -> ${p}". Pass \`force=true\` to override this definition.`);q(this,W,"f").set(p,i)}}return this}getType(e){if(typeof e!="string")return null;const n=e.replace(/^.*[/\\]/,"").toLowerCase(),i=n.replace(/^.*\./,"").toLowerCase(),o=n.length<e.length;return!(i.length<n.length-1)&&o?null:q(this,W,"f").get(i)??null}getExtension(e){var n;return typeof e!="string"?null:(e=(n=e==null?void 0:e.split)==null?void 0:n.call(e,";")[0],(e&&q(this,Y,"f").get(e.trim().toLowerCase()))??null)}getAllExtensions(e){return typeof e!="string"?null:q(this,X,"f").get(e.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const e of q(this,X,"f").values())Object.freeze(e);return this}_getTestState(){return{types:q(this,W,"f"),extensions:q(this,Y,"f")}}}W=new WeakMap,Y=new WeakMap,X=new WeakMap;const Ie=new Ne(Bt)._freeze();function Ae(t,e,n){const i=xe.join(t,e);return ft.mkdirSync(t,{recursive:!0}),new Promise((o,a)=>{try{ft.writeFile(i,n,{},r=>{r?a(r):o(i)})}catch(r){a(r)}})}function Xt(t){return ft.readFileSync(t)}function Pe(t){return new Promise((e,n)=>{he.get(t,i=>{const o=[],a=i.headers["content-type"];i.on("data",r=>{o.push(r)}),i.on("end",()=>{e({buffer:Buffer.concat(o),mimeType:a})})}).on("error",i=>{n(i)})})}const Me=async t=>Xt(t),lt=(t,e="sha1")=>ge.createHash(e).update(t).digest("base64");function Kt(t){const e=[],n=Object.keys(t);for(const i of n){const o=t[i].sort((a,r)=>a.index-r.index);for(let a=0;a<o.length;a++)o[a].index!==a&&e.push({message:`Invalid operation index ${o[a].index} at position ${a}`,details:{position:a,operation:o[a],scope:o[a].scope}})}return e}const jt=async t=>{const e=new _t,{name:n,revision:i,documentType:o,created:a,lastModified:r}=t,p={name:n,revision:i,documentType:o,created:a,lastModified:r};return e.file("header.json",JSON.stringify(p,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(d=>{const{data:h,...b}=t.attachments[d];e.file(d,h,{base64:!0,createFolders:!0,comment:JSON.stringify(b)})}),e},Wt=async(t,e,n,i)=>{const a=await(await jt(t)).generateAsync({type:"uint8array",streamFiles:!0}),r=i??t.name,p=`.${n}.zip`;return Ae(e,r.endsWith(p)?r:`${r}${p}`,a)},Fe=async(t,e)=>{const i=await(await jt(t)).generateAsync({type:"blob"}),o=await e.createWritable();await o.write(i),await o.close()},gt=async(t,e,n)=>{const i=Xt(t);return Gt(i,e,n)},Gt=async(t,e,n)=>{const i=new _t;return await i.loadAsync(t),Re(i,e,n)};async function Re(t,e,n){const i=t.file("state.json");if(!i)throw new Error("Initial state not found");const o=await i.async("string"),a=JSON.parse(o),r=t.file("header.json");let p;r&&(p=JSON.parse(await r.async("string")));const m=t.file("operations.json");if(!m)throw new Error("Operations history not found");const d=JSON.parse(await m.async("string")),h=Kt(d);if(h.length){const O=h.map(v=>v.message);throw new Error(O.join(`
20
- `))}let b=kt(a,d,e,void 0,p,{},n);return p&&(b={...b,...p}),b}function Zt(t){const e=t.replace(/^.*\./,"")||void 0,n=t.replace(/^.*[/\\]/,"")||void 0;return{extension:e,fileName:n}}async function Le(t){const{buffer:e,mimeType:n="application/octet-stream"}=await Pe(t),i=Zt(t),o=e.toString("base64");return{data:o,hash:lt(o),mimeType:n,...i}}async function qe(t){const e=await Me(t),n=Ie.getType(t)||"application/octet-stream",i=Zt(t),o=e.toString("base64");return{data:o,hash:lt(o),mimeType:n,...i}}var Qt=(t=>(t.UNEXPECTED_INDEX="UNEXPECTED_INDEX",t))(Qt||{}),Yt=(t=>(t.DUPLICATED_INDEX="DUPLICATED_INDEX",t.MISSING_INDEX="MISSING_INDEX",t))(Yt||{});function Et(t){const e=[];let n=-1;for(const i of t){const o=i.index-i.skip;o!==n+1&&e.push({operation:{index:i.index,skip:i.skip},issue:"UNEXPECTED_INDEX",category:o>n+1?"MISSING_INDEX":"DUPLICATED_INDEX",message:`Expected index ${n+1} with skip 0 or equivalent, got index ${i.index} with skip ${i.skip}`}),n=i.index}return e}function V(t){var i,o,a;const e=[];let n=t.length-1;for(;n>-1;){e.unshift(t[n]);const r=(((i=t[n])==null?void 0:i.index)||0)-(((o=t[n])==null?void 0:o.skip)||0)-1;let p=n-1;for(;p>-1&&(((a=t[p])==null?void 0:a.index)||0)>r;)p--;n=p}return e}function Ce(t){const e=[...t],n=e[e.length-1];return n&&(n.type==="NOOP"?e.push({...n,index:n.index,type:"NOOP",skip:ne(t)}):e.push({type:"NOOP",index:n.index+1,timestamp:new Date().toISOString(),input:{},skip:1,scope:n.scope,hash:n.hash})),e}function B(t){return t.slice().sort((e,n)=>e.skip-n.skip).sort((e,n)=>e.index-n.index)}const Ue=(t,e,n)=>[...e,...n].sort((i,o)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime()).map((i,o)=>({...i,index:t.index+o,skip:o===0?t.skip:0})),Je=(t,e,n)=>[...e,...n].sort((i,o)=>new Date(i.timestamp).getTime()-new Date(o.timestamp).getTime()).sort((i,o)=>i.index-o.index).map((i,o)=>({...i,index:t.index+o,skip:o===0?t.skip:0}));function $t(t,e){return G(t)===G(e)}function He(t,e){const n=V(B(t.slice())),i=V(B(e.slice()));if(n.length<1)return[i,[]];const o=[];let a=!1;for(;i.length>0;){const r=i[0];let p=n.shift();for(;p&&te(p,r);)o.push(p),p=n.shift();if(p?a||($t(p,r)?(i.shift(),o.push(p)):(n.unshift(p),a=!0)):a=!0,a){let m=i.shift();for(;m;)o.push(m),m=i.shift()}}if(!a){let r=n.shift();for(;r;)o.push(r),r=n.shift()}return[V(o),n]}function te(t,e){return t.index<e.index||t.index===e.index&&t.skip<e.skip}function ee(t,e){const n=[],i=[],o=[],a=Math.max(t.length,e.length);let r=!1;for(let p=0;p<a;p++){const m=t[p],d=e[p];m&&d?!r&&$t(m,d)?n.push(m):(r=!0,i.push(m),o.push(d)):m?i.push(m):d&&o.push(d)}return[n,i,o]}function Ve(t,e,n){const[i,o,a]=ee(V(t),V(e)),r=ut(i),p=1+Math.max(r,ut(o),ut(a)),m=n({index:p,skip:p-(r+1)},o,a);return i.concat(m)}function ut(t){const e=t[t.length-1];return e?e.index:-1}function ne(t){var i,o,a;if(t.length<1)return-1;const e=V(t);let n=(((i=e[e.length-1])==null?void 0:i.skip)||0)+1;return e.length>1&&(n+=((o=e[e.length-2])==null?void 0:o.skip)||0),(((a=e[e.length-1])==null?void 0:a.index)||-1)<n?-1:n}const Be=t=>Et(V(B(t))),Xe=t=>t.reduce((n,i)=>{var o;return n[i.scope]||(n[i.scope]=[]),(o=n[i.scope])==null||o.push(i),n},{}),Ke=(t,e)=>{var m;const n={integrityIssues:[],validOperations:[],invalidOperations:[],duplicatedOperations:[]},i=B(t),o=B(e),a=Et([...i,...o]),p=(m=[...a.filter(d=>d.category==="MISSING_INDEX")].sort((d,h)=>h.operation.index-d.operation.index).pop())==null?void 0:m.operation;for(const d of o){if(p&&d.index>=p.index){n.invalidOperations.push(d);continue}if(a.some(b=>b.operation.index===d.index&&b.operation.skip===d.skip&&b.category==="DUPLICATED_INDEX")){n.duplicatedOperations.push(d);continue}n.validOperations.push(d)}return n.integrityIssues.push(...a),n};function We(t,e){return t.filter(n=>!e.some(i=>n.type==="NOOP"&&n.skip===0&&n.index===i.index||n.index===i.index&&n.skip===i.skip&&n.scope===i.scope&&n.hash===i.hash&&n.type===i.type))}function ie(t,e){const[n]=B(t).slice(-1),i=(n==null?void 0:n.index)??-1,o=i+1,a={...e,index:e.index??o};if(a.index<i)throw new Error(`The skip header operation index must be greater than or equal to ${i}`);return(V(B([...t,a]))||[]).slice(0,-1)}function ht(t){return{...Object.entries(t).reduce((n,i)=>{const[o,a]=i;return{...n,[o]:V(B(a))}},{})}}const Ge=Object.freeze(Object.defineProperty({__proto__:null,IntegrityIssueSubType:Yt,IntegrityIssueType:Qt,addUndo:Ce,attachBranch:He,checkCleanedOperationsIntegrity:Et,checkOperationsIntegrity:Be,garbageCollect:V,garbageCollectDocumentOperations:ht,groupOperationsByScope:Xe,merge:Ve,nextSkipNumber:ne,operationsAreEqual:$t,precedes:te,prepareOperations:Ke,removeExistingOperations:We,reshuffleByTimestamp:Ue,reshuffleByTimestampAndIndex:Je,skipHeaderOperations:ie,sortOperations:B,split:ee},Symbol.toStringTag,{value:"Module"}));function Ze(t,e){let n;return"index"in e?n={...e}:n=t.operations[e.scope].at(-1),((n==null?void 0:n.index)??-1)+1}function Qe(t,e){return{...t,revision:{...t.revision,[e.scope]:Ze(t,e)},lastModified:new Date().toISOString()}}function Ye(t,e,n=0,i=!1){if([nt,it,ct].includes(e.type))return t;const{scope:o}=e,a=t.operations[o].slice(),r=a.at(-1);let p=((r==null?void 0:r.index)??-1)+1;if("index"in e){if(e.index-n>p)throw new Error(`Missing operations: expected ${p} with skip 0 or equivalent, got index ${e.index} with skip ${n}`);p=e.index}const m={...e,index:p,timestamp:new Date().toISOString(),hash:"",scope:o,skip:n,error:void 0};return i&&(m.resultingState=t.state[o]),a.push(m),{...t,operations:{...t.operations,[o]:a}}}function tn(t,e,n=0,i=!1){let o=Ye(t,e,n,i);return o=Qe(o,e),o}function en(t,e,n){switch(Ft().parse(e),e.type){case Ht:return De(t,e.input);case ct:return Te(t,e,n);case Vt:return _e(t,e.input.state);default:return t}}function nn(t,e,n){switch(e.type){case nt:return ke(t,e,n);case it:return ze(t,e,n);default:return{document:t,action:e,skip:n}}}function on(t,e,n,i,o=!1,a=zt){const r=e.scope,p=t.operations[r].at(-1);if(!p)return t;const m=ht({...t.operations,[r]:ie(t.operations[r],p)});let d;const h=m[r].at(-1);if(o&&(h!=null&&h.resultingState))d=a(h.resultingState);else{const{state:b}=pt(t.initialState,m,n,void 0,void 0,void 0,void 0,{reuseHash:!0,reuseOperationResultingState:o,operationResultingStateParser:a});d=b[r]}return{...t,state:{...t.state,[r]:d},operations:ht({...t.operations})}}function Dt(t,e,n,i,o={}){const{skip:a,ignoreSkipOperations:r=!1,reuseHash:p=!1,reuseOperationResultingState:m=!1,operationResultingStateParser:d}=o,h={...e},b=a||0;let O={...t};const v=!r&&(b>0||"index"in h&&h.skip>0);return xt(h)&&(O=en(O,h,n)),O=tn(O,h,b,m),v&&(O=on(O,h,n,b,m,d)),O=H.produce(O,z=>{try{const A=n(z.state,h,i);if(A)return H.castDraft({...O,state:A})}catch(A){const R=O.operations[h.scope].length-1;z.operations[h.scope][R].error=A.message,z.operations[h.scope][R].skip=0,v&&(z.state=H.castDraft({...t.state}),z.operations=H.castDraft({...t.operations,[h.scope]:[...t.operations[h.scope],{...z.operations[h.scope][R]}]}))}}),H.produce(O,z=>{if([nt,it,ct].includes(h.type))return z;const A=h.scope||"global",R=p&&Object.prototype.hasOwnProperty.call(h,"hash")?h.hash:mt(z,A);z.operations[A][z.operations[A].length-1].hash=R,!xt(h)&&h.attachments&&h.attachments.forEach(c=>{const{hash:l,...u}=c;z.attachments[l]={...u}})})}function sn(t){return t.type===ve&&t.skip!==void 0&&t.skip>0&&t.hash!==void 0}function rn(t){return[nt,it].includes(t.type)}function xt(t){return[Ht,nt,it,ct,Vt].includes(t.type)}function K(t,e,n,i,o="global"){if(!t)throw new Error("Empty action type");if(typeof t!="string")throw new Error(`Invalid action type: ${JSON.stringify(t)}`);const a={type:t,input:e,scope:o};n&&(a.attachments=n);try{i==null||i().parse(a.input)}catch(r){throw new Error(`Invalid action input: ${r}`)}return a}function oe(t,e=Dt){return(n,i,o,a)=>e(n,i,t,o,a)}const se=(t,e)=>({name:"",documentType:"",revision:{global:0,local: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:{}}}),re=(t,e)=>{const n=se(t,e);return{...n,initialState:n,operations:{global:[],local:[]},clipboard:[]}},mt=(t,e="global")=>lt(G(t.state[e]||"")),an=(t,e=1e3)=>{const n=Math.random()*e;return lt(`${(t??new Date).toISOString()}${n}`)};function tt(t){return H.castImmutable(H.freeze(t,!0))}function pn(t,e){const n=[...t];let i=e||0,o=n.length>0?n[n.length-1].index:0;const a=[];for(const r of n.reverse()){if(i>0){const d=o-r.index;i-=d}if(i<0)throw new Error("Invalid operation index, missing operations");const p={ignore:i>0,operation:r},m=r.skip>0?r.skip+1:0;if(m>0&&m>i){const d=m-i;i=i+d}o=r.index,a.push(p)}return a.reverse()}function cn(t,e,n){const i=t.slice().sort((p,m)=>p.skip-m.skip).sort((p,m)=>p.index-m.index);let o=n,a=0,r=e;for(const p of i.reverse()){const m=r-p.index;if(o=o-m,o>-1)a++,r=p.index;else break}return a}function ln(t){return Object.values(t).flatMap(e=>e).sort((e,n)=>new Date(e.timestamp).getTime()-new Date(n.timestamp).getTime())}function mn(t){return Object.values(t).flatMap(e=>e).sort((e,n)=>new Date(e.operation.timestamp).getTime()-new Date(n.operation.timestamp).getTime())}function pt(t,e,n,i,o,a=Dt,r={},p){const m=oe(n,a);return kt(t,e,m,i,o,r,p)}function kt(t,e,n,i,o,a={},r){const{checkHashes:p=!0,reuseOperationResultingState:m,operationResultingStateParser:d=zt}=r||{};let h=t;const b=[],O={global:[],local:[]};if(m)for(const[c,l]of Object.entries(e)){const u=l.findLastIndex(L=>!!L.resultingState);if(u<0){b.push(...l);continue}const T=l[u];try{const L=d(T.resultingState);h={...h,state:{...h.state,[c]:L}},O[c].push(...l.slice(0,u+1)),b.push(...l.slice(u+1))}catch{b.push(...l)}}else b.push(...Object.values(e).flat());const v=re(h);v.initialState=t,v.operations=O;const z=b.reduce((c,l)=>n(c,l,i,{skip:l.skip,ignoreSkipOperations:!0,reuseHash:!p}),v);if(!p)for(const c of Object.keys(z.state))for(let l=b.length-1;l>=0;l--){const u=b[l];if(u.scope===c){if(u.hash!==mt(z,c))throw new Error(`Hash mismatch for scope ${c}`);break}}const A=Object.keys(z.operations).reduce((c,l)=>{const u=l;return{...c,[u]:[...z.operations[u].map((T,L)=>{var P;return{...T,timestamp:((P=e[u][L])==null?void 0:P.timestamp)??T.timestamp}})]}},{global:[],local:[]}),R=Object.values(A).reduce((c,l)=>{const u=l[l.length-1];return(u==null?void 0:u.timestamp)>c&&(c=u.timestamp),c},t.lastModified);return{...z,operations:A,lastModified:R}}function un(t,e){return G(t)===G(e)}function zt(t){const e=typeof t;if(e==="string")return JSON.parse(t);if(e==="object")return t;throw new Error(`Providing resulting state is of type: ${e}`)}const ae=t=>K("SET_NAME",t,void 0,Ot,void 0),pe=(t=1,e="global")=>K("UNDO",t,void 0,St,e),ce=(t=1,e="global")=>K("REDO",t,void 0,wt,e),le=(t,e,n="global")=>K("PRUNE",{start:t,end:e},void 0,bt,n),Tt=(t,e)=>K("LOAD_STATE",{state:t,operations:e},void 0,yt),me=(t="global")=>K("NOOP",{},void 0,void 0,t),fn=Object.freeze(Object.defineProperty({__proto__:null,loadState:Tt,noop:me,prune:le,redo:ce,setName:ae,undo:pe},Symbol.toStringTag,{value:"Module"}));class dn{constructor(e,n,i){at(this,"_document");at(this,"_reducer");at(this,"_signalDispatch");this._reducer=e,this._document=n,this._signalDispatch=i}dispatch(e,n){return this._document=this._reducer(this._document,e,this._signalDispatch,n),this}saveToFile(e,n,i){return Wt(this._document,e,n,i)}async loadFromFile(e){this._document=await gt(e,this._reducer)}static async stateFromFile(e,n){return await gt(e,n)}get state(){return tt(this._document.state)}get operations(){return tt(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(e){return this._document.revision[e]}get initialState(){return tt(this._document.initialState)}toDocument(){return tt(this._document)}getAttachment(e){return this._document.attachments[e]}setName(e){return this.dispatch(ae(e)),this}undo(e){return this.dispatch(pe(e)),this}redo(e){return this.dispatch(ce(e)),this}prune(e,n){return this.dispatch(le(e,n)),this}loadState(e,n){return this.dispatch(Tt(e,n)),this}}function gn(t,e){e.forEach(n=>{Object.getOwnPropertyNames(n.prototype).forEach(i=>{Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(n.prototype,i)||Object.create(null))})})}exports.BaseActions=fn;exports.BaseDocument=dn;exports.applyMixins=gn;exports.baseReducer=Dt;exports.calculateSkipsLeft=cn;exports.createAction=K;exports.createDocument=re;exports.createExtendedState=se;exports.createReducer=oe;exports.createZip=jt;exports.documentHelpers=Ge;exports.getLocalFile=qe;exports.getRemoteFile=Le;exports.hashDocument=mt;exports.hashKey=an;exports.isBaseAction=xt;exports.isNoopOperation=sn;exports.isSameDocument=un;exports.isUndoRedo=rn;exports.loadFromFile=gt;exports.loadFromInput=Gt;exports.mapSkippedOperations=pn;exports.parseResultingState=zt;exports.processUndoRedo=nn;exports.readOnly=tt;exports.replayDocument=kt;exports.replayOperations=pt;exports.saveToFile=Wt;exports.saveToFileHandle=Fe;exports.sortMappedOperations=mn;exports.sortOperations=ln;exports.validateOperations=Kt;exports.zod=je;
@@ -1,44 +0,0 @@
1
- import { j as e, f as a, b as s, a as t, c as o, k as r, m as i, n, o as l, p as c, q as p, i as d, r as u, t as m, u as O, l as y, e as S, v as b, w as g, x as D, y as F, z as _, s as f, d as v, A as R, C as h, D as j, B as x, h as z, g as A, E as B, F as M, G as T } from "./object-C2s2eZ08.js";
2
- const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
- __proto__: null,
4
- calculateSkipsLeft: e,
5
- createAction: a,
6
- createDocument: s,
7
- createExtendedState: t,
8
- createReducer: o,
9
- createZip: r,
10
- documentHelpers: i,
11
- getLocalFile: n,
12
- getRemoteFile: l,
13
- hashDocument: c,
14
- hashKey: p,
15
- isBaseAction: d,
16
- isNoopOperation: u,
17
- isSameDocument: m,
18
- isUndoRedo: O,
19
- loadFromFile: y,
20
- loadFromInput: S,
21
- mapSkippedOperations: b,
22
- parseResultingState: g,
23
- readOnly: D,
24
- replayDocument: F,
25
- replayOperations: _,
26
- saveToFile: f,
27
- saveToFileHandle: v,
28
- sortMappedOperations: R,
29
- sortOperations: h,
30
- validateOperations: j
31
- }, Symbol.toStringTag, { value: "Module" })), H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
32
- __proto__: null,
33
- BaseDocument: x,
34
- actions: z,
35
- applyMixins: A,
36
- baseReducer: B,
37
- processUndoRedo: M,
38
- utils: k,
39
- z: T
40
- }, Symbol.toStringTag, { value: "Module" }));
41
- export {
42
- H as D,
43
- k as i
44
- };