document-model 1.0.42 → 1.0.44

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 (33) hide show
  1. package/dist/browser/document-model.cjs +1 -1
  2. package/dist/browser/document-model.js +2 -2
  3. package/dist/browser/document.cjs +1 -1
  4. package/dist/browser/document.js +2 -2
  5. package/dist/browser/index.cjs +1 -1
  6. package/dist/browser/index.js +3 -3
  7. package/dist/browser/internal/{index-CDcO7NCS.js → index-CJWLwwNi.js} +1 -1
  8. package/dist/{node/internal/index-fctxJxHD.js → browser/internal/index-CvQOfeml.js} +1 -1
  9. package/dist/{node/internal/index-D_LMFQg7.js → browser/internal/index-QMhrjNyi.js} +1 -1
  10. package/dist/browser/internal/{index-DhzefrNj.js → index-eSGNXD4L.js} +1 -1
  11. package/dist/browser/internal/{object-CrDRbO7a.js → object-ChusgY57.js} +822 -808
  12. package/dist/browser/internal/object-NkahWZEb.js +25 -0
  13. package/dist/browser/src/document/types.d.ts +2 -0
  14. package/dist/browser/src/document/utils/base.d.ts +7 -2
  15. package/dist/browser/src/document/utils/file.d.ts +3 -2
  16. package/dist/node/document-model.cjs +1 -1
  17. package/dist/node/document-model.js +2 -2
  18. package/dist/node/document.cjs +1 -1
  19. package/dist/node/document.js +2 -2
  20. package/dist/node/index.cjs +1 -1
  21. package/dist/node/index.js +3 -3
  22. package/dist/node/internal/{index-Cz8HaIxu.js → index-CAadnKaJ.js} +1 -1
  23. package/dist/{browser/internal/index-CfgX2mMt.js → node/internal/index-CKwU8URS.js} +1 -1
  24. package/dist/node/internal/{index-BWW7KbVk.js → index-CkYTa7KK.js} +1 -1
  25. package/dist/{browser/internal/index-EdTViyyq.js → node/internal/index-DphjSNet.js} +1 -1
  26. package/dist/node/internal/object-BLNJYMtQ.js +20 -0
  27. package/dist/node/internal/{object-BDRv-l-h.js → object-BsCssWq4.js} +622 -608
  28. package/dist/node/src/document/types.d.ts +2 -0
  29. package/dist/node/src/document/utils/base.d.ts +7 -2
  30. package/dist/node/src/document/utils/file.d.ts +3 -2
  31. package/package.json +3 -5
  32. package/dist/browser/internal/object-BkewFVld.js +0 -25
  33. package/dist/node/internal/object-Br6jYeW0.js +0 -20
@@ -0,0 +1,25 @@
1
+ "use strict";var We=Object.defineProperty;var He=(i,r,s)=>r in i?We(i,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[r]=s;var St=(i,r,s)=>(He(i,typeof r!="symbol"?r+"":r,s),s);const ot=require("immer"),A=require("zod"),ie=require("jszip"),ne=i=>i!=null,Ve=A.z.any().refine(i=>ne(i)),oe=A.z.enum(["LOAD_STATE"]),ae=A.z.enum(["PRUNE"]),se=A.z.enum(["REDO"]),pe=A.z.enum(["SET_NAME"]),ce=A.z.enum(["UNDO"]);function Ke(){return A.z.object({__typename:A.z.literal("Action").optional(),type:A.z.string()})}function gt(){return A.z.literal("global").or(A.z.literal("local"))}function le(){return A.z.union([ue(),he(),me(),xe(),de()])}function Ze(){return A.z.object({__typename:A.z.literal("DocumentFile").optional(),data:A.z.string(),extension:A.z.string().nullable(),fileName:A.z.string().nullable(),mimeType:A.z.string()})}function ue(){return A.z.object({input:A.z.lazy(()=>Lt()),type:oe,scope:gt()})}function Lt(){return A.z.object({operations:A.z.number(),state:A.z.lazy(()=>fe())})}function fe(){return A.z.object({data:A.z.unknown().nullish(),name:A.z.string()})}function Ge(){return A.z.object({__typename:A.z.literal("Operation").optional(),hash:A.z.string(),index:A.z.number(),timestamp:A.z.string().datetime(),type:A.z.string()})}function he(){return A.z.object({input:A.z.lazy(()=>Pt()),type:ae,scope:gt()})}function Pt(){return A.z.object({end:A.z.number().nullish(),start:A.z.number().nullish()})}const qt=A.z.number;function me(){return A.z.object({input:qt(),type:se,scope:gt()})}const Jt=A.z.string;function xe(){return A.z.object({input:Jt(),type:pe,scope:A.z.literal("global")})}function Ye(){return A.z.object({__typename:A.z.literal("SetNameOperation").optional(),hash:A.z.string(),index:A.z.number(),input:A.z.string(),timestamp:A.z.string().datetime(),type:A.z.string()})}const Wt=A.z.number;function de(){return A.z.object({input:Wt(),type:ce,scope:gt()})}const Xe=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Ke,BaseActionSchema:le,DocumentFileSchema:Ze,LoadStateActionInputSchema:Lt,LoadStateActionSchema:ue,LoadStateActionStateInputSchema:fe,Load_StateSchema:oe,OperationSchema:Ge,OperationScopeSchema:gt,PruneActionInputSchema:Pt,PruneActionSchema:he,PruneSchema:ae,RedoActionInputSchema:qt,RedoActionSchema:me,RedoSchema:se,SetNameActionInputSchema:Jt,SetNameActionSchema:xe,SetNameOperationSchema:Ye,Set_NameSchema:pe,UndoActionInputSchema:Wt,UndoActionSchema:de,UndoSchema:ce,definedNonNullAnySchema:Ve,isDefinedNonNullAny:ne},Symbol.toStringTag,{value:"Module"}));function Ht(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var $t={exports:{}};(function(i,r){const{hasOwnProperty:s}=Object.prototype,p=N();p.configure=N,p.stringify=p,p.default=p,r.stringify=p,r.configure=N,i.exports=p;const f=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function u(g){return g.length<5e3&&!f.test(g)?`"${g}"`:JSON.stringify(g)}function l(g){if(g.length>200)return g.sort();for(let b=1;b<g.length;b++){const j=g[b];let P=b;for(;P!==0&&g[P-1]>j;)g[P]=g[P-1],P--;g[P]=j}return g}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function h(g){return a.call(g)!==void 0&&g.length!==0}function y(g,b,j){g.length<j&&(j=g.length);const P=b===","?"":" ";let K=`"0":${P}${g[0]}`;for(let Y=1;Y<j;Y++)K+=`${b}"${Y}":${P}${g[Y]}`;return K}function w(g){if(s.call(g,"circularValue")){const b=g.circularValue;if(typeof b=="string")return`"${b}"`;if(b==null)return b;if(b===Error||b===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 S(g,b){let j;if(s.call(g,b)&&(j=g[b],typeof j!="boolean"))throw new TypeError(`The "${b}" argument must be of type boolean`);return j===void 0?!0:j}function v(g,b){let j;if(s.call(g,b)){if(j=g[b],typeof j!="number")throw new TypeError(`The "${b}" argument must be of type number`);if(!Number.isInteger(j))throw new TypeError(`The "${b}" argument must be an integer`);if(j<1)throw new RangeError(`The "${b}" argument must be >= 1`)}return j===void 0?1/0:j}function B(g){return g===1?"1 item":`${g} items`}function W(g){const b=new Set;for(const j of g)(typeof j=="string"||typeof j=="number")&&b.add(String(j));return b}function C(g){if(s.call(g,"strict")){const b=g.strict;if(typeof b!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(b)return j=>{let P=`Object can not safely be stringified. Received type ${typeof j}`;throw typeof j!="function"&&(P+=` (${j.toString()})`),new Error(P)}}}function N(g){g={...g};const b=C(g);b&&(g.bigint===void 0&&(g.bigint=!1),"circularValue"in g||(g.circularValue=Error));const j=w(g),P=S(g,"bigint"),K=S(g,"deterministic"),Y=v(g,"maximumDepth"),M=v(g,"maximumBreadth");function ut(H,m,E,T,O,U){let _=m[H];switch(typeof _=="object"&&_!==null&&typeof _.toJSON=="function"&&(_=_.toJSON(H)),_=T.call(m,H,_),typeof _){case"string":return u(_);case"object":{if(_===null)return"null";if(E.indexOf(_)!==-1)return j;let k="",F=",";const I=U;if(Array.isArray(_)){if(_.length===0)return"[]";if(Y<E.length+1)return'"[Array]"';E.push(_),O!==""&&(U+=O,k+=`
2
+ ${U}`,F=`,
3
+ ${U}`);const V=Math.min(_.length,M);let Q=0;for(;Q<V-1;Q++){const pt=ut(String(Q),_,E,T,O,U);k+=pt!==void 0?pt:"null",k+=F}const tt=ut(String(Q),_,E,T,O,U);if(k+=tt!==void 0?tt:"null",_.length-1>M){const pt=_.length-M-1;k+=`${F}"... ${B(pt)} not stringified"`}return O!==""&&(k+=`
4
+ ${I}`),E.pop(),`[${k}]`}let R=Object.keys(_);const J=R.length;if(J===0)return"{}";if(Y<E.length+1)return'"[Object]"';let $="",Z="";O!==""&&(U+=O,F=`,
5
+ ${U}`,$=" ");const X=Math.min(J,M);K&&!h(_)&&(R=l(R)),E.push(_);for(let V=0;V<X;V++){const Q=R[V],tt=ut(Q,_,E,T,O,U);tt!==void 0&&(k+=`${Z}${u(Q)}:${$}${tt}`,Z=F)}if(J>M){const V=J-M;k+=`${Z}"...":${$}"${B(V)} not stringified"`,Z=F}return O!==""&&Z.length>1&&(k=`
6
+ ${U}${k}
7
+ ${I}`),E.pop(),`{${k}}`}case"number":return isFinite(_)?String(_):b?b(_):"null";case"boolean":return _===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(_);default:return b?b(_):void 0}}function ft(H,m,E,T,O,U){switch(typeof m=="object"&&m!==null&&typeof m.toJSON=="function"&&(m=m.toJSON(H)),typeof m){case"string":return u(m);case"object":{if(m===null)return"null";if(E.indexOf(m)!==-1)return j;const _=U;let k="",F=",";if(Array.isArray(m)){if(m.length===0)return"[]";if(Y<E.length+1)return'"[Array]"';E.push(m),O!==""&&(U+=O,k+=`
8
+ ${U}`,F=`,
9
+ ${U}`);const J=Math.min(m.length,M);let $=0;for(;$<J-1;$++){const X=ft(String($),m[$],E,T,O,U);k+=X!==void 0?X:"null",k+=F}const Z=ft(String($),m[$],E,T,O,U);if(k+=Z!==void 0?Z:"null",m.length-1>M){const X=m.length-M-1;k+=`${F}"... ${B(X)} not stringified"`}return O!==""&&(k+=`
10
+ ${_}`),E.pop(),`[${k}]`}E.push(m);let I="";O!==""&&(U+=O,F=`,
11
+ ${U}`,I=" ");let R="";for(const J of T){const $=ft(J,m[J],E,T,O,U);$!==void 0&&(k+=`${R}${u(J)}:${I}${$}`,R=F)}return O!==""&&R.length>1&&(k=`
12
+ ${U}${k}
13
+ ${_}`),E.pop(),`{${k}}`}case"number":return isFinite(m)?String(m):b?b(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(m);default:return b?b(m):void 0}}function at(H,m,E,T,O){switch(typeof m){case"string":return u(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(H),typeof m!="object")return at(H,m,E,T,O);if(m===null)return"null"}if(E.indexOf(m)!==-1)return j;const U=O;if(Array.isArray(m)){if(m.length===0)return"[]";if(Y<E.length+1)return'"[Array]"';E.push(m),O+=T;let $=`
14
+ ${O}`;const Z=`,
15
+ ${O}`,X=Math.min(m.length,M);let V=0;for(;V<X-1;V++){const tt=at(String(V),m[V],E,T,O);$+=tt!==void 0?tt:"null",$+=Z}const Q=at(String(V),m[V],E,T,O);if($+=Q!==void 0?Q:"null",m.length-1>M){const tt=m.length-M-1;$+=`${Z}"... ${B(tt)} not stringified"`}return $+=`
16
+ ${U}`,E.pop(),`[${$}]`}let _=Object.keys(m);const k=_.length;if(k===0)return"{}";if(Y<E.length+1)return'"[Object]"';O+=T;const F=`,
17
+ ${O}`;let I="",R="",J=Math.min(k,M);h(m)&&(I+=y(m,F,M),_=_.slice(m.length),J-=m.length,R=F),K&&(_=l(_)),E.push(m);for(let $=0;$<J;$++){const Z=_[$],X=at(Z,m[Z],E,T,O);X!==void 0&&(I+=`${R}${u(Z)}: ${X}`,R=F)}if(k>M){const $=k-M;I+=`${R}"...": "${B($)} not stringified"`,R=F}return R!==""&&(I=`
18
+ ${O}${I}
19
+ ${U}`),E.pop(),`{${I}}`}case"number":return isFinite(m)?String(m):b?b(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(m);default:return b?b(m):void 0}}function st(H,m,E){switch(typeof m){case"string":return u(m);case"object":{if(m===null)return"null";if(typeof m.toJSON=="function"){if(m=m.toJSON(H),typeof m!="object")return st(H,m,E);if(m===null)return"null"}if(E.indexOf(m)!==-1)return j;let T="";if(Array.isArray(m)){if(m.length===0)return"[]";if(Y<E.length+1)return'"[Array]"';E.push(m);const F=Math.min(m.length,M);let I=0;for(;I<F-1;I++){const J=st(String(I),m[I],E);T+=J!==void 0?J:"null",T+=","}const R=st(String(I),m[I],E);if(T+=R!==void 0?R:"null",m.length-1>M){const J=m.length-M-1;T+=`,"... ${B(J)} not stringified"`}return E.pop(),`[${T}]`}let O=Object.keys(m);const U=O.length;if(U===0)return"{}";if(Y<E.length+1)return'"[Object]"';let _="",k=Math.min(U,M);h(m)&&(T+=y(m,",",M),O=O.slice(m.length),k-=m.length,_=","),K&&(O=l(O)),E.push(m);for(let F=0;F<k;F++){const I=O[F],R=st(I,m[I],E);R!==void 0&&(T+=`${_}${u(I)}:${R}`,_=",")}if(U>M){const F=U-M;T+=`${_}"...":"${B(F)} not stringified"`}return E.pop(),`{${T}}`}case"number":return isFinite(m)?String(m):b?b(m):"null";case"boolean":return m===!0?"true":"false";case"undefined":return;case"bigint":if(P)return String(m);default:return b?b(m):void 0}}function kt(H,m,E){if(arguments.length>1){let T="";if(typeof E=="number"?T=" ".repeat(Math.min(E,10)):typeof E=="string"&&(T=E.slice(0,10)),m!=null){if(typeof m=="function")return ut("",{"":H},[],m,T,"");if(Array.isArray(m))return ft("",H,[],W(m),T,"")}if(T.length!==0)return at("",H,[],T,"")}return st("",H,[])}return kt}})($t,$t.exports);var Qe=$t.exports;const _t=Ht(Qe);_t.configure;function tr(i,r){return{...i,name:r}}function er(i,r,s){const p={skip:s,document:i},{scope:f}=r;return!f||r.skip===void 0?p:ot.produce(p,u=>{const[l]=u.document.operations[f].slice(-1);r.skip&&r.skip>0&&(u.skip=r.skip),l.type==="NOOP"&&r.index===l.index&&u.skip>l.skip&&u.document.operations[f].pop()})}function rr(i,r,s){const{scope:p,input:f}=r,u={document:i,action:r,skip:s};return ot.produce(u,l=>{if(l.document.operations[p].length<1)throw new Error(`Cannot undo: no operations in history for scope "${p}"`);if(f<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(l.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[a]=l.document.operations[p].slice(-1),h=a.type==="NOOP"&&a.skip>0;if(l.skip+=f,h){l.skip+=a.skip;const v=l.document.operations[p][l.document.operations[p].length-2];v&&a.index-v.index===1&&l.document.operations[p].pop()}if(l.document.operations[p].length<l.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const y=l.document.operations[p].length-1;let w=f,S=h?y-a.skip:y;for(;w>0&&S>=0;){const v=l.document.operations[p][S];if(!v){w--,S--;continue}v.type==="NOOP"&&v.skip>0?(S=S-(v.skip+1),l.skip+=v.skip+1):(l.document.clipboard.push({...v}),w--,S--)}l.action=Qt(p)})}function ir(i,r,s){const{scope:p,input:f}=r,u={document:i,action:r,skip:s};return ot.produce(u,l=>{if(l.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(f>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(f<1)throw new Error("Invalid REDO action: invalid redo input value");if(l.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const a=l.document.clipboard.findLastIndex(y=>y.scope===p);if(a<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${p}"`);const h=l.document.clipboard.splice(a,1)[0];l.action=ot.castDraft({type:h.type,scope:h.scope,input:h.input})})}function nr(i,r,s){const{scope:p}=r,f=i.operations[p];let{input:{start:u,end:l}}=r;u=u||0,l=l||f.length;const a=f.slice(u,l),h=f.slice(0,u),y=f.slice(l),w=Ft(i.initialState,{...i.operations,[p]:h.concat(a)},s),{name:S,state:v}=w,B=h.length,W=h.length?h[h.length-1].timestamp:y.length?y[0].timestamp:new Date().toISOString();return Ft(i.initialState,{...i.operations,[p]:[...h,{...Xt({name:S,state:v},a.length),timestamp:W,index:B,hash:Tt({state:v},"global")},...y.map((C,N)=>({...C,index:B+N+1}))]},s)}function or(i,r){return{...i,name:r.name,state:r.state??{global:{},local:{}}}}const ge="SET_NAME",yt="UNDO",wt="REDO",Bt="PRUNE",ye="LOAD_STATE",ar="NOOP";function sr(i,r){let s;return"index"in r?s={...r}:s=i.operations[r.scope].slice(-1)[0],((s==null?void 0:s.index)??-1)+1}function pr(i,r){return{...i,revision:{...i.revision,[r.scope]:sr(i,r)},lastModified:new Date().toISOString()}}function cr(i,r,s=0){if([yt,wt,Bt].includes(r.type))return i;const{scope:p}=r,f=i.operations[p].slice(0,i.revision[p]),u=[...f].pop();let l=((u==null?void 0:u.index)??-1)+1;if("index"in r){if(r.index>l+s)throw new Error(`Missing operations: expected ${l} with skip 0 or equivalent, got index ${r.index} with skip ${s}`);l=r.index}return f.push({...r,index:l,timestamp:new Date().toISOString(),hash:"",scope:p,skip:s}),{...i,operations:{...i.operations,[p]:f}}}function lr(i,r,s=0){let p=cr(i,r,s);return p=pr(p,r),p}function ur(i,r,s){switch(le().parse(r),r.type){case ge:return tr(i,r.input);case Bt:return nr(i,r,s);case ye:return or(i,r.input.state);default:return i}}function we(i,r,s){switch(r.type){case yt:return rr(i,r,s);case wt:return ir(i,r,s);default:return{document:i,action:r,skip:s}}}function Vt(i,r,s,p,f={}){const{skip:u,ignoreSkipOperations:l=!1,reuseHash:a=!1}=f;let h={...r},y=u||0,w=i,S=[...i.clipboard];if(Oe(h)){const{document:v,skip:B}=er(w,h,y);y=B,w=v}if(Mt(h)){const{skip:v,action:B,document:W}=we(i,h,y);h=B,y=v,w=W,S=[...w.clipboard]}if(Nt(h)&&(w=ur(w,h,s)),y>0&&!l){let v=y;"index"in h&&(v=De(w.operations[h.scope],h.index,y)),w=Ft(w.initialState,w.operations,s,void 0,void 0,void 0,{[h.scope]:v})}return w=lr(w,h,y),w=ot.produce(w,v=>{const B=s(v.state,h,p),W=Mt(r)?[...S]:[];if(B)return ot.castDraft({...w,clipboard:[...W],state:B});v.clipboard=ot.castDraft([...W])}),ot.produce(w,v=>{if([yt,wt,Bt].includes(h.type))return v;const B=h.scope||"global";console.time("hash");const W=a&&Object.prototype.hasOwnProperty.call(h,"hash")?h.hash:Tt(v,B);console.timeEnd("hash"),v.operations[B][v.operations[B].length-1].hash=W,!Nt(h)&&h.attachments&&h.attachments.forEach(C=>{const{hash:N,...g}=C;v.attachments[N]={...g}})})}var Ct={exports:{}};typeof Object.create=="function"?Ct.exports=function(r,s){s&&(r.super_=s,r.prototype=Object.create(s.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:Ct.exports=function(r,s){if(s){r.super_=s;var p=function(){};p.prototype=s.prototype,r.prototype=new p,r.prototype.constructor=r}};var be=Ct.exports,zt={exports:{}},Ee={},Ot={};Ot.byteLength=mr;Ot.toByteArray=dr;Ot.fromByteArray=wr;var nt=[],rt=[],fr=typeof Uint8Array<"u"?Uint8Array:Array,Ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var ht=0,hr=Ut.length;ht<hr;++ht)nt[ht]=Ut[ht],rt[Ut.charCodeAt(ht)]=ht;rt[45]=62;rt[95]=63;function ve(i){var r=i.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=i.indexOf("=");s===-1&&(s=r);var p=s===r?0:4-s%4;return[s,p]}function mr(i){var r=ve(i),s=r[0],p=r[1];return(s+p)*3/4-p}function xr(i,r,s){return(r+s)*3/4-s}function dr(i){var r,s=ve(i),p=s[0],f=s[1],u=new fr(xr(i,p,f)),l=0,a=f>0?p-4:p,h;for(h=0;h<a;h+=4)r=rt[i.charCodeAt(h)]<<18|rt[i.charCodeAt(h+1)]<<12|rt[i.charCodeAt(h+2)]<<6|rt[i.charCodeAt(h+3)],u[l++]=r>>16&255,u[l++]=r>>8&255,u[l++]=r&255;return f===2&&(r=rt[i.charCodeAt(h)]<<2|rt[i.charCodeAt(h+1)]>>4,u[l++]=r&255),f===1&&(r=rt[i.charCodeAt(h)]<<10|rt[i.charCodeAt(h+1)]<<4|rt[i.charCodeAt(h+2)]>>2,u[l++]=r>>8&255,u[l++]=r&255),u}function gr(i){return nt[i>>18&63]+nt[i>>12&63]+nt[i>>6&63]+nt[i&63]}function yr(i,r,s){for(var p,f=[],u=r;u<s;u+=3)p=(i[u]<<16&16711680)+(i[u+1]<<8&65280)+(i[u+2]&255),f.push(gr(p));return f.join("")}function wr(i){for(var r,s=i.length,p=s%3,f=[],u=16383,l=0,a=s-p;l<a;l+=u)f.push(yr(i,l,l+u>a?a:l+u));return p===1?(r=i[s-1],f.push(nt[r>>2]+nt[r<<4&63]+"==")):p===2&&(r=(i[s-2]<<8)+i[s-1],f.push(nt[r>>10]+nt[r>>4&63]+nt[r<<2&63]+"=")),f.join("")}var Kt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Kt.read=function(i,r,s,p,f){var u,l,a=f*8-p-1,h=(1<<a)-1,y=h>>1,w=-7,S=s?f-1:0,v=s?-1:1,B=i[r+S];for(S+=v,u=B&(1<<-w)-1,B>>=-w,w+=a;w>0;u=u*256+i[r+S],S+=v,w-=8);for(l=u&(1<<-w)-1,u>>=-w,w+=p;w>0;l=l*256+i[r+S],S+=v,w-=8);if(u===0)u=1-y;else{if(u===h)return l?NaN:(B?-1:1)*(1/0);l=l+Math.pow(2,p),u=u-y}return(B?-1:1)*l*Math.pow(2,u-p)};Kt.write=function(i,r,s,p,f,u){var l,a,h,y=u*8-f-1,w=(1<<y)-1,S=w>>1,v=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=p?0:u-1,W=p?1:-1,C=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,l=w):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),l+S>=1?r+=v/h:r+=v*Math.pow(2,1-S),r*h>=2&&(l++,h/=2),l+S>=w?(a=0,l=w):l+S>=1?(a=(r*h-1)*Math.pow(2,f),l=l+S):(a=r*Math.pow(2,S-1)*Math.pow(2,f),l=0));f>=8;i[s+B]=a&255,B+=W,a/=256,f-=8);for(l=l<<f|a,y+=f;y>0;i[s+B]=l&255,B+=W,l/=256,y-=8);i[s+B-W]|=C*128};/*!
20
+ * The buffer module from node.js, for the browser.
21
+ *
22
+ * @author Feross Aboukhadijeh <https://feross.org>
23
+ * @license MIT
24
+ */(function(i){var r=Ot,s=Kt,p=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=a,i.SlowBuffer=b,i.INSPECT_MAX_BYTES=50;var f=2147483647;i.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=u(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function u(){try{var n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function l(n){if(n>f)throw new RangeError('The value "'+n+'" is invalid for option "size"');var t=new Uint8Array(n);return Object.setPrototypeOf(t,a.prototype),t}function a(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return S(n)}return h(n,t,e)}a.poolSize=8192;function h(n,t,e){if(typeof n=="string")return v(n,t);if(ArrayBuffer.isView(n))return W(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(it(n,ArrayBuffer)||n&&it(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(it(n,SharedArrayBuffer)||n&&it(n.buffer,SharedArrayBuffer)))return C(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var o=n.valueOf&&n.valueOf();if(o!=null&&o!==n)return a.from(o,t,e);var c=N(n);if(c)return c;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return a.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}a.from=function(n,t,e){return h(n,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function y(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function w(n,t,e){return y(n),n<=0?l(n):t!==void 0?typeof e=="string"?l(n).fill(t,e):l(n).fill(t):l(n)}a.alloc=function(n,t,e){return w(n,t,e)};function S(n){return y(n),l(n<0?0:g(n)|0)}a.allocUnsafe=function(n){return S(n)},a.allocUnsafeSlow=function(n){return S(n)};function v(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=j(n,t)|0,o=l(e),c=o.write(n,t);return c!==e&&(o=o.slice(0,c)),o}function B(n){for(var t=n.length<0?0:g(n.length)|0,e=l(t),o=0;o<t;o+=1)e[o]=n[o]&255;return e}function W(n){if(it(n,Uint8Array)){var t=new Uint8Array(n);return C(t.buffer,t.byteOffset,t.byteLength)}return B(n)}function C(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');var o;return t===void 0&&e===void 0?o=new Uint8Array(n):e===void 0?o=new Uint8Array(n,t):o=new Uint8Array(n,t,e),Object.setPrototypeOf(o,a.prototype),o}function N(n){if(a.isBuffer(n)){var t=g(n.length)|0,e=l(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Dt(n.length)?l(0):B(n);if(n.type==="Buffer"&&Array.isArray(n.data))return B(n.data)}function g(n){if(n>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return n|0}function b(n){return+n!=n&&(n=0),a.alloc(+n)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,e){if(it(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),it(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var o=t.length,c=e.length,x=0,d=Math.min(o,c);x<d;++x)if(t[x]!==e[x]){o=t[x],c=e[x];break}return o<c?-1:c<o?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var o;if(e===void 0)for(e=0,o=0;o<t.length;++o)e+=t[o].length;var c=a.allocUnsafe(e),x=0;for(o=0;o<t.length;++o){var d=t[o];if(it(d,Uint8Array))x+d.length>c.length?a.from(d).copy(c,x):Uint8Array.prototype.set.call(c,d,x);else if(a.isBuffer(d))d.copy(c,x);else throw new TypeError('"list" argument must be an Array of Buffers');x+=d.length}return c};function j(n,t){if(a.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||it(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);var e=n.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&e===0)return 0;for(var c=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return V(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return pt(n).length;default:if(c)return o?-1:V(n).length;t=(""+t).toLowerCase(),c=!0}}a.byteLength=j;function P(n,t,e){var o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return _(this,t,e);case"utf8":case"utf-8":return m(this,t,e);case"ascii":return O(this,t,e);case"latin1":case"binary":return U(this,t,e);case"base64":return H(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),o=!0}}a.prototype._isBuffer=!0;function K(n,t,e){var o=n[t];n[t]=n[e],n[e]=o}a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)K(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)K(this,e,e+3),K(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)K(this,e,e+7),K(this,e+1,e+6),K(this,e+2,e+5),K(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?m(this,0,t):P.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){var t="",e=i.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},p&&(a.prototype[p]=a.prototype.inspect),a.prototype.compare=function(t,e,o,c,x){if(it(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),o===void 0&&(o=t?t.length:0),c===void 0&&(c=0),x===void 0&&(x=this.length),e<0||o>t.length||c<0||x>this.length)throw new RangeError("out of range index");if(c>=x&&e>=o)return 0;if(c>=x)return-1;if(e>=o)return 1;if(e>>>=0,o>>>=0,c>>>=0,x>>>=0,this===t)return 0;for(var d=x-c,D=o-e,z=Math.min(d,D),L=this.slice(c,x),G=t.slice(e,o),q=0;q<z;++q)if(L[q]!==G[q]){d=L[q],D=G[q];break}return d<D?-1:D<d?1:0};function Y(n,t,e,o,c){if(n.length===0)return-1;if(typeof e=="string"?(o=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Dt(e)&&(e=c?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(c)return-1;e=n.length-1}else if(e<0)if(c)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:M(n,t,e,o,c);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?c?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):M(n,[t],e,o,c);throw new TypeError("val must be string, number or Buffer")}function M(n,t,e,o,c){var x=1,d=n.length,D=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(n.length<2||t.length<2)return-1;x=2,d/=2,D/=2,e/=2}function z(ee,re){return x===1?ee[re]:ee.readUInt16BE(re*x)}var L;if(c){var G=-1;for(L=e;L<d;L++)if(z(n,L)===z(t,G===-1?0:L-G)){if(G===-1&&(G=L),L-G+1===D)return G*x}else G!==-1&&(L-=L-G),G=-1}else for(e+D>d&&(e=d-D),L=e;L>=0;L--){for(var q=!0,At=0;At<D;At++)if(z(n,L+At)!==z(t,At)){q=!1;break}if(q)return L}return-1}a.prototype.includes=function(t,e,o){return this.indexOf(t,e,o)!==-1},a.prototype.indexOf=function(t,e,o){return Y(this,t,e,o,!0)},a.prototype.lastIndexOf=function(t,e,o){return Y(this,t,e,o,!1)};function ut(n,t,e,o){e=Number(e)||0;var c=n.length-e;o?(o=Number(o),o>c&&(o=c)):o=c;var x=t.length;o>x/2&&(o=x/2);for(var d=0;d<o;++d){var D=parseInt(t.substr(d*2,2),16);if(Dt(D))return d;n[e+d]=D}return d}function ft(n,t,e,o){return vt(V(t,n.length-e),n,e,o)}function at(n,t,e,o){return vt(Q(t),n,e,o)}function st(n,t,e,o){return vt(pt(t),n,e,o)}function kt(n,t,e,o){return vt(tt(t,n.length-e),n,e,o)}a.prototype.write=function(t,e,o,c){if(e===void 0)c="utf8",o=this.length,e=0;else if(o===void 0&&typeof e=="string")c=e,o=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(o)?(o=o>>>0,c===void 0&&(c="utf8")):(c=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var x=this.length-e;if((o===void 0||o>x)&&(o=x),t.length>0&&(o<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");c||(c="utf8");for(var d=!1;;)switch(c){case"hex":return ut(this,t,e,o);case"utf8":case"utf-8":return ft(this,t,e,o);case"ascii":case"latin1":case"binary":return at(this,t,e,o);case"base64":return st(this,t,e,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return kt(this,t,e,o);default:if(d)throw new TypeError("Unknown encoding: "+c);c=(""+c).toLowerCase(),d=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function H(n,t,e){return t===0&&e===n.length?r.fromByteArray(n):r.fromByteArray(n.slice(t,e))}function m(n,t,e){e=Math.min(n.length,e);for(var o=[],c=t;c<e;){var x=n[c],d=null,D=x>239?4:x>223?3:x>191?2:1;if(c+D<=e){var z,L,G,q;switch(D){case 1:x<128&&(d=x);break;case 2:z=n[c+1],(z&192)===128&&(q=(x&31)<<6|z&63,q>127&&(d=q));break;case 3:z=n[c+1],L=n[c+2],(z&192)===128&&(L&192)===128&&(q=(x&15)<<12|(z&63)<<6|L&63,q>2047&&(q<55296||q>57343)&&(d=q));break;case 4:z=n[c+1],L=n[c+2],G=n[c+3],(z&192)===128&&(L&192)===128&&(G&192)===128&&(q=(x&15)<<18|(z&63)<<12|(L&63)<<6|G&63,q>65535&&q<1114112&&(d=q))}}d===null?(d=65533,D=1):d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d),c+=D}return T(o)}var E=4096;function T(n){var t=n.length;if(t<=E)return String.fromCharCode.apply(String,n);for(var e="",o=0;o<t;)e+=String.fromCharCode.apply(String,n.slice(o,o+=E));return e}function O(n,t,e){var o="";e=Math.min(n.length,e);for(var c=t;c<e;++c)o+=String.fromCharCode(n[c]&127);return o}function U(n,t,e){var o="";e=Math.min(n.length,e);for(var c=t;c<e;++c)o+=String.fromCharCode(n[c]);return o}function _(n,t,e){var o=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>o)&&(e=o);for(var c="",x=t;x<e;++x)c+=Je[n[x]];return c}function k(n,t,e){for(var o=n.slice(t,e),c="",x=0;x<o.length-1;x+=2)c+=String.fromCharCode(o[x]+o[x+1]*256);return c}a.prototype.slice=function(t,e){var o=this.length;t=~~t,e=e===void 0?o:~~e,t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),e<t&&(e=t);var c=this.subarray(t,e);return Object.setPrototypeOf(c,a.prototype),c};function F(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||F(t,e,this.length);for(var c=this[t],x=1,d=0;++d<e&&(x*=256);)c+=this[t+d]*x;return c},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||F(t,e,this.length);for(var c=this[t+--e],x=1;e>0&&(x*=256);)c+=this[t+--e]*x;return c},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||F(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,o){t=t>>>0,e=e>>>0,o||F(t,e,this.length);for(var c=this[t],x=1,d=0;++d<e&&(x*=256);)c+=this[t+d]*x;return x*=128,c>=x&&(c-=Math.pow(2,8*e)),c},a.prototype.readIntBE=function(t,e,o){t=t>>>0,e=e>>>0,o||F(t,e,this.length);for(var c=e,x=1,d=this[t+--c];c>0&&(x*=256);)d+=this[t+--c]*x;return x*=128,d>=x&&(d-=Math.pow(2,8*e)),d},a.prototype.readInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,e){t=t>>>0,e||F(t,2,this.length);var o=this[t]|this[t+1]<<8;return o&32768?o|4294901760:o},a.prototype.readInt16BE=function(t,e){t=t>>>0,e||F(t,2,this.length);var o=this[t+1]|this[t]<<8;return o&32768?o|4294901760:o},a.prototype.readInt32LE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t=t>>>0,e||F(t,4,this.length),s.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t=t>>>0,e||F(t,4,this.length),s.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||F(t,8,this.length),s.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||F(t,8,this.length),s.read(this,t,!1,52,8)};function I(n,t,e,o,c,x){if(!a.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>c||t<x)throw new RangeError('"value" argument is out of bounds');if(e+o>n.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,o,c){if(t=+t,e=e>>>0,o=o>>>0,!c){var x=Math.pow(2,8*o)-1;I(this,t,e,o,x,0)}var d=1,D=0;for(this[e]=t&255;++D<o&&(d*=256);)this[e+D]=t/d&255;return e+o},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,o,c){if(t=+t,e=e>>>0,o=o>>>0,!c){var x=Math.pow(2,8*o)-1;I(this,t,e,o,x,0)}var d=o-1,D=1;for(this[e+d]=t&255;--d>=0&&(D*=256);)this[e+d]=t/D&255;return e+o},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,1,255,0),this[e]=t&255,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},a.prototype.writeIntLE=function(t,e,o,c){if(t=+t,e=e>>>0,!c){var x=Math.pow(2,8*o-1);I(this,t,e,o,x-1,-x)}var d=0,D=1,z=0;for(this[e]=t&255;++d<o&&(D*=256);)t<0&&z===0&&this[e+d-1]!==0&&(z=1),this[e+d]=(t/D>>0)-z&255;return e+o},a.prototype.writeIntBE=function(t,e,o,c){if(t=+t,e=e>>>0,!c){var x=Math.pow(2,8*o-1);I(this,t,e,o,x-1,-x)}var d=o-1,D=1,z=0;for(this[e+d]=t&255;--d>=0&&(D*=256);)t<0&&z===0&&this[e+d+1]!==0&&(z=1),this[e+d]=(t/D>>0)-z&255;return e+o},a.prototype.writeInt8=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},a.prototype.writeInt16LE=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},a.prototype.writeInt32LE=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,o){return t=+t,e=e>>>0,o||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function R(n,t,e,o,c,x){if(e+o>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function J(n,t,e,o,c){return t=+t,e=e>>>0,c||R(n,t,e,4),s.write(n,t,e,o,23,4),e+4}a.prototype.writeFloatLE=function(t,e,o){return J(this,t,e,!0,o)},a.prototype.writeFloatBE=function(t,e,o){return J(this,t,e,!1,o)};function $(n,t,e,o,c){return t=+t,e=e>>>0,c||R(n,t,e,8),s.write(n,t,e,o,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,o){return $(this,t,e,!0,o)},a.prototype.writeDoubleBE=function(t,e,o){return $(this,t,e,!1,o)},a.prototype.copy=function(t,e,o,c){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),!c&&c!==0&&(c=this.length),e>=t.length&&(e=t.length),e||(e=0),c>0&&c<o&&(c=o),c===o||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(c<0)throw new RangeError("sourceEnd out of bounds");c>this.length&&(c=this.length),t.length-e<c-o&&(c=t.length-e+o);var x=c-o;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,o,c):Uint8Array.prototype.set.call(t,this.subarray(o,c),e),x},a.prototype.fill=function(t,e,o,c){if(typeof t=="string"){if(typeof e=="string"?(c=e,e=0,o=this.length):typeof o=="string"&&(c=o,o=this.length),c!==void 0&&typeof c!="string")throw new TypeError("encoding must be a string");if(typeof c=="string"&&!a.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(t.length===1){var x=t.charCodeAt(0);(c==="utf8"&&x<128||c==="latin1")&&(t=x)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<o)throw new RangeError("Out of range index");if(o<=e)return this;e=e>>>0,o=o===void 0?this.length:o>>>0,t||(t=0);var d;if(typeof t=="number")for(d=e;d<o;++d)this[d]=t;else{var D=a.isBuffer(t)?t:a.from(t,c),z=D.length;if(z===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(d=0;d<o-e;++d)this[d+e]=D[d%z]}return this};var Z=/[^+/0-9A-Za-z-_]/g;function X(n){if(n=n.split("=")[0],n=n.trim().replace(Z,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function V(n,t){t=t||1/0;for(var e,o=n.length,c=null,x=[],d=0;d<o;++d){if(e=n.charCodeAt(d),e>55295&&e<57344){if(!c){if(e>56319){(t-=3)>-1&&x.push(239,191,189);continue}else if(d+1===o){(t-=3)>-1&&x.push(239,191,189);continue}c=e;continue}if(e<56320){(t-=3)>-1&&x.push(239,191,189),c=e;continue}e=(c-55296<<10|e-56320)+65536}else c&&(t-=3)>-1&&x.push(239,191,189);if(c=null,e<128){if((t-=1)<0)break;x.push(e)}else if(e<2048){if((t-=2)<0)break;x.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;x.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;x.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return x}function Q(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function tt(n,t){for(var e,o,c,x=[],d=0;d<n.length&&!((t-=2)<0);++d)e=n.charCodeAt(d),o=e>>8,c=e%256,x.push(c),x.push(o);return x}function pt(n){return r.toByteArray(X(n))}function vt(n,t,e,o){for(var c=0;c<o&&!(c+e>=t.length||c>=n.length);++c)t[c+e]=n[c];return c}function it(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Dt(n){return n!==n}var Je=function(){for(var n="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var o=e*16,c=0;c<16;++c)t[o+c]=n[e]+n[c];return t}()})(Ee);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(i,r){var s=Ee,p=s.Buffer;function f(l,a){for(var h in l)a[h]=l[h]}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?i.exports=s:(f(s,r),r.Buffer=u);function u(l,a,h){return p(l,a,h)}u.prototype=Object.create(p.prototype),f(p,u),u.from=function(l,a,h){if(typeof l=="number")throw new TypeError("Argument must not be a number");return p(l,a,h)},u.alloc=function(l,a,h){if(typeof l!="number")throw new TypeError("Argument must be a number");var y=p(l);return a!==void 0?typeof h=="string"?y.fill(a,h):y.fill(a):y.fill(0),y},u.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return p(l)},u.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return s.SlowBuffer(l)}})(zt,zt.exports);var Zt=zt.exports,Ae=Zt.Buffer;function jt(i,r){this._block=Ae.alloc(i),this._finalSize=r,this._blockSize=i,this._len=0}jt.prototype.update=function(i,r){typeof i=="string"&&(r=r||"utf8",i=Ae.from(i,r));for(var s=this._block,p=this._blockSize,f=i.length,u=this._len,l=0;l<f;){for(var a=u%p,h=Math.min(f-l,p-a),y=0;y<h;y++)s[a+y]=i[l+y];u+=h,l+=h,u%p===0&&this._update(s)}return this._len+=f,this};jt.prototype.digest=function(i){var r=this._len%this._blockSize;this._block[r]=128,this._block.fill(0,r+1),r>=this._finalSize&&(this._update(this._block),this._block.fill(0));var s=this._len*8;if(s<=4294967295)this._block.writeUInt32BE(s,this._blockSize-4);else{var p=(s&4294967295)>>>0,f=(s-p)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(p,this._blockSize-4)}this._update(this._block);var u=this._hash();return i?u.toString(i):u};jt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Se=jt,br=be,_e=Se,Er=Zt.Buffer,vr=[1518500249,1859775393,-1894007588,-899497514],Ar=new Array(80);function bt(){this.init(),this._w=Ar,_e.call(this,64,56)}br(bt,_e);bt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Sr(i){return i<<1|i>>>31}function _r(i){return i<<5|i>>>27}function Fr(i){return i<<30|i>>>2}function Br(i,r,s,p){return i===0?r&s|~r&p:i===2?r&s|r&p|s&p:r^s^p}bt.prototype._update=function(i){for(var r=this._w,s=this._a|0,p=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=0;a<16;++a)r[a]=i.readInt32BE(a*4);for(;a<80;++a)r[a]=Sr(r[a-3]^r[a-8]^r[a-14]^r[a-16]);for(var h=0;h<80;++h){var y=~~(h/20),w=_r(s)+Br(y,p,f,u)+l+r[h]+vr[y]|0;l=u,u=f,f=Fr(p),p=s,s=w}this._a=s+this._a|0,this._b=p+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0};bt.prototype._hash=function(){var i=Er.allocUnsafe(20);return i.writeInt32BE(this._a|0,0),i.writeInt32BE(this._b|0,4),i.writeInt32BE(this._c|0,8),i.writeInt32BE(this._d|0,12),i.writeInt32BE(this._e|0,16),i};var Or=bt;const jr=Ht(Or);var Ir=be,Fe=Se,Tr=Zt.Buffer,kr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Dr=new Array(64);function Et(){this.init(),this._w=Dr,Fe.call(this,64,56)}Ir(Et,Fe);Et.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Ur(i,r,s){return s^i&(r^s)}function $r(i,r,s){return i&r|s&(i|r)}function Cr(i){return(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10)}function zr(i){return(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7)}function Mr(i){return(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3}function Nr(i){return(i>>>17|i<<15)^(i>>>19|i<<13)^i>>>10}Et.prototype._update=function(i){for(var r=this._w,s=this._a|0,p=this._b|0,f=this._c|0,u=this._d|0,l=this._e|0,a=this._f|0,h=this._g|0,y=this._h|0,w=0;w<16;++w)r[w]=i.readInt32BE(w*4);for(;w<64;++w)r[w]=Nr(r[w-2])+r[w-7]+Mr(r[w-15])+r[w-16]|0;for(var S=0;S<64;++S){var v=y+zr(l)+Ur(l,a,h)+kr[S]+r[S]|0,B=Cr(s)+$r(s,p,f)|0;y=h,h=a,a=l,l=u+v|0,u=f,f=p,p=s,s=v+B|0}this._a=s+this._a|0,this._b=p+this._b|0,this._c=f+this._c|0,this._d=u+this._d|0,this._e=l+this._e|0,this._f=a+this._f|0,this._g=h+this._g|0,this._h=y+this._h|0};Et.prototype._hash=function(){var i=Tr.allocUnsafe(32);return i.writeInt32BE(this._a,0),i.writeInt32BE(this._b,4),i.writeInt32BE(this._c,8),i.writeInt32BE(this._d,12),i.writeInt32BE(this._e,16),i.writeInt32BE(this._f,20),i.writeInt32BE(this._g,24),i.writeInt32BE(this._h,28),i};var Rr=Et;const Lr=Ht(Rr),Gt=new Error("File system not available.");function Pr(i,r,s){throw Gt}function Be(i){throw Gt}function qr(i){throw Gt}const Jr=async i=>Be(),Wr={sha1:jr,sha256:Lr},It=(i,r="sha1")=>{if(!["sha1","sha256"].includes(r))throw new Error("Hashing algorithm not supported: Available: sha1, sha256");const s=Wr[r];return new s().update(i).digest("base64")};function Oe(i){return i.type===ar&&i.skip!==void 0&&i.skip>0&&i.hash!==void 0}function Mt(i){return[yt,wt].includes(i.type)}function Nt(i){return[ge,yt,wt,Bt,ye].includes(i.type)}function lt(i,r,s,p,f="global"){if(!i)throw new Error("Empty action type");if(typeof i!="string")throw new Error(`Invalid action type: ${JSON.stringify(i)}`);const u={type:i,input:r,scope:f};s&&(u.attachments=s);try{p==null||p().parse(u.input)}catch(l){throw new Error(`Invalid action input: ${l}`)}return u}function je(i,r=Vt){return(s,p,f,u)=>r(s,p,i,f,u)}const Ie=(i,r)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...i,state:(r==null?void 0:r(i==null?void 0:i.state))??(i==null?void 0:i.state)??{global:{},local:{}}}),Te=(i,r)=>{const s=Ie(i,r);return{...s,initialState:s,operations:{global:[],local:[]},clipboard:[]}},Tt=(i,r="global")=>It(_t(i.state[r]||"")),Hr=(i,r=1e3)=>{const s=Math.random()*r;return It(`${(i??new Date).toISOString()}${s}`)};function xt(i){return ot.castImmutable(ot.freeze(i,!0))}function ke(i,r){const s=[...i];let p=r||0,f=s.length>0?s[s.length-1].index:0;const u=[];for(const l of s.reverse()){if(p>0){const y=f-l.index;p-=y}if(p<0)throw new Error("Invalid operation index, missing operations");const a={ignore:p>0,operation:l},h=l.skip>0?l.skip+1:0;if(h>0&&h>p){const y=h-p;p=p+y}f=l.index,u.push(a)}return u.reverse()}function De(i,r,s){const p=i.slice().sort((a,h)=>a.skip-h.skip).sort((a,h)=>a.index-h.index);let f=s,u=0,l=r;for(const a of p.reverse()){const h=l-a.index;if(f=f-h,f>-1)u++,l=a.index;else break}return u}function Vr(i){return Object.values(i).flatMap(r=>r).sort((r,s)=>new Date(r.timestamp).getTime()-new Date(s.timestamp).getTime())}function Ue(i){return Object.values(i).flatMap(r=>r).sort((r,s)=>new Date(r.operation.timestamp).getTime()-new Date(s.operation.timestamp).getTime())}function Ft(i,r,s,p,f,u=Vt,l={},a){const h=je(s,u);return Yt(i,r,h,p,f,l,a)}function Yt(i,r,s,p,f,u={},l){const a=(l==null?void 0:l.checkHashes)??!0,h=Te(i),y=Object.keys(r).reduce((C,N)=>{const g=N;return{...C,[g]:r[g].slice(0,f==null?void 0:f.revision[g])}},{}),w=Object.keys(y).reduce((C,N)=>{const g=N;return{...C,[g]:ke(y[g],u[g])}},{}),S=Ue(w),v=S.reduce((C,{ignore:N,operation:g},b,j)=>N?s(C,Qt(g.scope),p,{skip:g.skip,ignoreSkipOperations:!0}):s(C,g,p,{skip:g.skip,ignoreSkipOperations:!0,reuseHash:!a}),h);for(const C of Object.keys(v.state))for(let N=S.length-1;N>=0;N--)if(S[N].operation.scope===C){if(S[N].operation.hash!==Tt(v,C))throw new Error(`Hash mismatch for scope ${C}`);break}const B=Object.keys(v.operations).reduce((C,N)=>{const g=N,b=f&&f.revision[g]<r[g].length?r[g].slice(f.revision[g]):[];return{...C,[g]:[...v.operations[g].map((j,P)=>{var K;return{...j,timestamp:((K=r[g][P])==null?void 0:K.timestamp)??j.timestamp}}),...b]}},{global:[],local:[]}),W=Object.values(B).reduce((C,N)=>{for(const g of N)g.timestamp>C&&(C=g.timestamp);return C},i.lastModified);return{...v,operations:B,lastModified:W}}function Kr(i,r){return _t(i)===_t(r)}const $e=i=>lt("SET_NAME",i,void 0,Jt,void 0),Ce=(i=1,r="global")=>lt("UNDO",i,void 0,Wt,r),ze=(i=1,r="global")=>lt("REDO",i,void 0,qt,r),Me=(i,r,s="global")=>lt("PRUNE",{start:i,end:r},void 0,Pt,s),Xt=(i,r)=>lt("LOAD_STATE",{state:i,operations:r},void 0,Lt),Qt=(i="global")=>lt("NOOP",{},void 0,void 0,i),Zr=Object.freeze(Object.defineProperty({__proto__:null,loadState:Xt,noop:Qt,prune:Me,redo:ze,setName:$e,undo:Ce},Symbol.toStringTag,{value:"Module"})),Ne={"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(Ne);var et=function(i,r,s,p){if(s==="a"&&!p)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?i!==r||!p:!r.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return s==="m"?p:s==="a"?p.call(i):p?p.value:r.get(i)},mt,dt,ct;class Gr{constructor(...r){mt.set(this,new Map),dt.set(this,new Map),ct.set(this,new Map);for(const s of r)this.define(s)}define(r,s=!1){for(let[p,f]of Object.entries(r)){p=p.toLowerCase(),f=f.map(a=>a.toLowerCase()),et(this,ct,"f").has(p)||et(this,ct,"f").set(p,new Set);const u=et(this,ct,"f").get(p);let l=!0;for(let a of f){const h=a.startsWith("*");if(a=h?a.slice(1):a,u==null||u.add(a),l&&et(this,dt,"f").set(p,a),l=!1,h)continue;const y=et(this,mt,"f").get(a);if(y&&y!=p&&!s)throw new Error(`"${p} -> ${a}" conflicts with "${y} -> ${a}". Pass \`force=true\` to override this definition.`);et(this,mt,"f").set(a,p)}}return this}getType(r){if(typeof r!="string")return null;const s=r.replace(/^.*[/\\]/,"").toLowerCase(),p=s.replace(/^.*\./,"").toLowerCase(),f=s.length<r.length;return!(p.length<s.length-1)&&f?null:et(this,mt,"f").get(p)??null}getExtension(r){var s;return typeof r!="string"?null:(r=(s=r==null?void 0:r.split)==null?void 0:s.call(r,";")[0],(r&&et(this,dt,"f").get(r.trim().toLowerCase()))??null)}getAllExtensions(r){return typeof r!="string"?null:et(this,ct,"f").get(r.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const r of et(this,ct,"f").values())Object.freeze(r);return this}_getTestState(){return{types:et(this,mt,"f"),extensions:et(this,dt,"f")}}}mt=new WeakMap,dt=new WeakMap,ct=new WeakMap;const Yr=new Gr(Ne)._freeze();function Re(i){const r=[],s=Object.keys(i);for(const p of s){const f=i[p].sort((u,l)=>u.index-l.index);for(let u=0;u<f.length;u++)f[u].index!==u&&r.push({message:`Invalid operation index ${f[u].index} at position ${u}`,details:{position:u,operation:f[u],scope:f[u].scope}})}return r}const te=async i=>{const r=new ie,{name:s,revision:p,documentType:f,created:u,lastModified:l}=i,a={name:s,revision:p,documentType:f,created:u,lastModified:l};return r.file("header.json",JSON.stringify(a,null,2)),r.file("state.json",JSON.stringify(i.initialState||{},null,2)),r.file("operations.json",JSON.stringify(i.operations,null,2)),Object.keys(i.attachments).forEach(y=>{const{data:w,...S}=i.attachments[y];r.file(y,w,{base64:!0,createFolders:!0,comment:JSON.stringify(S)})}),r},Le=async(i,r,s,p)=>{await(await te(i)).generateAsync({type:"uint8array",streamFiles:!0});const u=p??i.name,l=`.${s}.zip`;return Pr(r,u.endsWith(l)?u:`${u}${l}`)},Xr=async(i,r)=>{const p=await(await te(i)).generateAsync({type:"blob"}),f=await r.createWritable();await f.write(p),await f.close()},Rt=async(i,r,s)=>{const p=Be();return Pe(p,r)},Pe=async(i,r,s)=>{const p=new ie;return await p.loadAsync(i),Qr(p,r)};async function Qr(i,r,s){const p=i.file("state.json");if(!p)throw new Error("Initial state not found");const f=await p.async("string"),u=JSON.parse(f),l=i.file("header.json");let a;l&&(a=JSON.parse(await l.async("string")));const h=i.file("operations.json");if(!h)throw new Error("Operations history not found");const y=JSON.parse(await h.async("string")),w=Re(y);if(w.length){const v=w.map(B=>B.message);throw new Error(v.join(`
25
+ `))}let S=Yt(u,y,r,void 0,a);return a&&(S={...S,...a}),S}function qe(i){const r=i.replace(/^.*\./,"")||void 0,s=i.replace(/^.*[/\\]/,"")||void 0;return{extension:r,fileName:s}}async function ti(i){const{buffer:r,mimeType:s="application/octet-stream"}=await qr(),p=qe(i),f=r.toString("base64");return{data:f,hash:It(f),mimeType:s,...p}}async function ei(i){const r=await Jr(),s=Yr.getType(i)||"application/octet-stream",p=qe(i),f=r.toString("base64");return{data:f,hash:It(f),mimeType:s,...p}}class ri{constructor(r,s,p){St(this,"_document");St(this,"_reducer");St(this,"_signalDispatch");this._reducer=r,this._document=s,this._signalDispatch=p}dispatch(r,s){return this._document=this._reducer(this._document,r,this._signalDispatch,s),this}saveToFile(r,s,p){return Le(this._document,r,s,p)}async loadFromFile(r){this._document=await Rt(r,this._reducer)}static async stateFromFile(r,s){return await Rt(r,s)}get state(){return xt(this._document.state)}get operations(){return xt(this._document.operations)}get name(){return this._document.name}get documentType(){return this._document.documentType}get created(){return this._document.created}get lastModified(){return this._document.lastModified}get revision(){return this._document.revision.global}getRevision(r){return this._document.revision[r]}get initialState(){return xt(this._document.initialState)}toDocument(){return xt(this._document)}getAttachment(r){return this._document.attachments[r]}setName(r){return this.dispatch($e(r)),this}undo(r){return this.dispatch(Ce(r)),this}redo(r){return this.dispatch(ze(r)),this}prune(r,s){return this.dispatch(Me(r,s)),this}loadState(r,s){return this.dispatch(Xt(r,s)),this}}function ii(i,r){r.forEach(s=>{Object.getOwnPropertyNames(s.prototype).forEach(p=>{Object.defineProperty(i.prototype,p,Object.getOwnPropertyDescriptor(s.prototype,p)||Object.create(null))})})}exports.BaseActions=Zr;exports.BaseDocument=ri;exports.applyMixins=ii;exports.baseReducer=Vt;exports.calculateSkipsLeft=De;exports.createAction=lt;exports.createDocument=Te;exports.createExtendedState=Ie;exports.createReducer=je;exports.createZip=te;exports.getLocalFile=ei;exports.getRemoteFile=ti;exports.hashDocument=Tt;exports.hashKey=Hr;exports.isBaseAction=Nt;exports.isNoopOperation=Oe;exports.isSameDocument=Kr;exports.isUndoRedo=Mt;exports.loadFromFile=Rt;exports.loadFromInput=Pe;exports.mapSkippedOperations=ke;exports.processUndoRedo=we;exports.readOnly=xt;exports.replayDocument=Yt;exports.replayOperations=Ft;exports.saveToFile=Le;exports.saveToFileHandle=Xr;exports.sortMappedOperations=Ue;exports.sortOperations=Vr;exports.validateOperations=Re;exports.zod=Xe;
@@ -50,6 +50,8 @@ export type ReducerOptions = {
50
50
  skip?: number;
51
51
  /** When true the skip count is ignored and the action is applied regardless of the skip count */
52
52
  ignoreSkipOperations?: boolean;
53
+ /** if true reuses the provided action hash */
54
+ reuseHash?: boolean;
53
55
  };
54
56
  /**
55
57
  * A pure function that takes an action and the previous state
@@ -74,7 +74,12 @@ export declare function mapSkippedOperations<A extends Action>(operations: Opera
74
74
  export declare function calculateSkipsLeft<A extends Action>(operations: Operation<BaseAction | A>[], currentIndex: number, skip: number): number;
75
75
  export declare function sortOperations<A extends Action>(operations: DocumentOperations<A>): Operation<BaseAction | A>[];
76
76
  export declare function sortMappedOperations<A extends Action>(operations: DocumentOperationsIgnoreMap<A>): MappedOperation<A>[];
77
- export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer, skipHeaderOperations?: SkipHeaderOperations): Document<T, A, L>;
77
+ export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer, skipHeaderOperations?: SkipHeaderOperations, options?: {
78
+ checkHashes?: boolean;
79
+ }): Document<T, A, L>;
78
80
  export type SkipHeaderOperations = Partial<Record<OperationScope, number>>;
79
- export declare function replayDocument<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: Reducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, skipHeaderOperations?: SkipHeaderOperations): Document<T, A, L>;
81
+ export type ReplayDocumentOptions = {
82
+ checkHashes?: boolean;
83
+ };
84
+ export declare function replayDocument<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: Reducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, skipHeaderOperations?: SkipHeaderOperations, options?: ReplayDocumentOptions): Document<T, A, L>;
80
85
  export declare function isSameDocument(documentA: Document, documentB: Document): boolean;
@@ -1,5 +1,6 @@
1
1
  import JSZip from 'jszip';
2
2
  import type { Action, AttachmentInput, Document, Reducer } from '../types';
3
+ import { ReplayDocumentOptions } from './base';
3
4
  export type FileInput = string | number[] | Uint8Array | ArrayBuffer | Blob;
4
5
  export declare const createZip: (document: Document) => Promise<JSZip>;
5
6
  /**
@@ -31,8 +32,8 @@ export declare const saveToFileHandle: (document: Document, input: FileSystemFil
31
32
  * @returns A promise that resolves to the document state after applying all the operations.
32
33
  * @throws An error if the initial state or the operations history is not found in the ZIP file.
33
34
  */
34
- export declare const loadFromFile: <S, A extends Action, L>(path: string, reducer: Reducer<S, A, L>) => Promise<Document<S, A, L>>;
35
- export declare const loadFromInput: <S, A extends Action, L>(input: FileInput, reducer: Reducer<S, A, L>) => Promise<Document<S, A, L>>;
35
+ export declare const loadFromFile: <S, A extends Action, L>(path: string, reducer: Reducer<S, A, L>, options?: ReplayDocumentOptions) => Promise<Document<S, A, L>>;
36
+ export declare const loadFromInput: <S, A extends Action, L>(input: FileInput, reducer: Reducer<S, A, L>, options?: ReplayDocumentOptions) => Promise<Document<S, A, L>>;
36
37
  /**
37
38
  * Fetches an attachment from a URL and returns its base64-encoded data and MIME type.
38
39
  * @param url - The URL of the attachment to fetch.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-Br6jYeW0.js");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const e=require("./internal/index-BWW7KbVk.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.validateInitialState=e.validateInitialState;exports.validateModule=e.validateModule;exports.validateModuleOperation=e.validateModuleOperation;exports.validateModules=e.validateModules;exports.validateStateSchemaName=e.validateStateSchemaName;exports.z=e.zod;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-BLNJYMtQ.js");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const e=require("./internal/index-CkYTa7KK.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.validateInitialState=e.validateInitialState;exports.validateModule=e.validateModule;exports.validateModuleOperation=e.validateModuleOperation;exports.validateModules=e.validateModules;exports.validateStateSchemaName=e.validateStateSchemaName;exports.z=e.zod;
@@ -1,11 +1,11 @@
1
- import "./internal/object-BDRv-l-h.js";
1
+ import "./internal/object-BsCssWq4.js";
2
2
  import "immer";
3
3
  import "crypto";
4
4
  import "fs";
5
5
  import "https";
6
6
  import "path";
7
7
  import "jszip";
8
- import { b as p, a as u, c, d as n, m as v, r as M, u as S, v as f, g as h, h as D, f as b, e as g, z as x } from "./internal/index-Cz8HaIxu.js";
8
+ import { b as p, a as u, c, d as n, m as v, r as M, u as S, v as f, g as h, h as D, f as b, e as g, z as x } from "./internal/index-CAadnKaJ.js";
9
9
  import "zod";
10
10
  export {
11
11
  p as Document,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-Br6jYeW0.js"),r=require("./internal/index-fctxJxHD.js");require("immer");require("zod");require("crypto");require("fs");require("https");require("path");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.z=e.zod;exports.utils=r.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-BLNJYMtQ.js"),r=require("./internal/index-CKwU8URS.js");require("immer");require("zod");require("crypto");require("fs");require("https");require("path");require("jszip");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.processUndoRedo=e.processUndoRedo;exports.z=e.zod;exports.utils=r.index;
@@ -1,5 +1,5 @@
1
- import { B as c, h as n, g as d, C as u, D as x, E as f } from "./internal/object-BDRv-l-h.js";
2
- import { i as B } from "./internal/index-D_LMFQg7.js";
1
+ import { B as c, h as n, g as d, C as u, D as x, E as f } from "./internal/object-BsCssWq4.js";
2
+ import { i as B } from "./internal/index-DphjSNet.js";
3
3
  import "immer";
4
4
  import "zod";
5
5
  import "crypto";
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-fctxJxHD.js"),o=require("./internal/index-BWW7KbVk.js");require("./internal/object-Br6jYeW0.js");require("immer");require("zod");require("crypto");require("fs");require("https");require("path");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-CKwU8URS.js"),o=require("./internal/index-CkYTa7KK.js");require("./internal/object-BLNJYMtQ.js");require("immer");require("zod");require("crypto");require("fs");require("https");require("path");require("jszip");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
@@ -1,6 +1,6 @@
1
- import { D as o } from "./internal/index-D_LMFQg7.js";
2
- import { D as t } from "./internal/index-Cz8HaIxu.js";
3
- import "./internal/object-BDRv-l-h.js";
1
+ import { D as o } from "./internal/index-DphjSNet.js";
2
+ import { D as t } from "./internal/index-CAadnKaJ.js";
3
+ import "./internal/object-BsCssWq4.js";
4
4
  import "immer";
5
5
  import "zod";
6
6
  import "crypto";
@@ -1,7 +1,7 @@
1
1
  var Rt = Object.defineProperty;
2
2
  var xt = (t, e, r) => e in t ? Rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var Ee = (t, e, r) => (xt(t, typeof e != "symbol" ? e + "" : e, r), r);
4
- import { c as At, i as Mt, a as Dt, b as Nt, s as Lt, d as Pt, l as Ct, e as jt, f as a, B as c, g as yt, h as wt } from "./object-BDRv-l-h.js";
4
+ import { c as At, i as Mt, a as Dt, b as Nt, s as Lt, d as Pt, l as Ct, e as jt, f as a, B as c, g as yt, h as wt } from "./object-BsCssWq4.js";
5
5
  import "immer";
6
6
  import "crypto";
7
7
  import "fs";
@@ -1 +1 @@
1
- "use strict";const e=require("./object-BkewFVld.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
1
+ "use strict";const e=require("./object-BLNJYMtQ.js"),t=Object.freeze(Object.defineProperty({__proto__:null,calculateSkipsLeft:e.calculateSkipsLeft,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,isNoopOperation:e.isNoopOperation,isSameDocument:e.isSameDocument,isUndoRedo:e.isUndoRedo,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,mapSkippedOperations:e.mapSkippedOperations,readOnly:e.readOnly,replayDocument:e.replayDocument,replayOperations:e.replayOperations,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle,sortMappedOperations:e.sortMappedOperations,sortOperations:e.sortOperations,validateOperations:e.validateOperations},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,processUndoRedo:e.processUndoRedo,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
@@ -1,4 +1,4 @@
1
- "use strict";var Tt=Object.defineProperty;var Rt=(t,e,r)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var be=(t,e,r)=>(Rt(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-Br6jYeW0.js");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const o=require("zod"),xt=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Mt=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Dt=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Nt=/[^\p{L}\d]+/giu,_e="$1\0$2",Ae="";function ze(t){let e=t.trim();e=e.replace(xt,_e).replace(Mt,_e),e=e.replace(Nt,"\0");let r=0,n=e.length;for(;e.charAt(r)==="\0";)r++;if(r===n)return[];for(;e.charAt(n-1)==="\0";)n--;return e.slice(r,n).split(/\0/g)}function Lt(t){const e=ze(t);for(let r=0;r<e.length;r++){const n=e[r],i=Dt.exec(n);if(i){const a=i.index+(i[1]??i[2]).length;e.splice(r,1,n.slice(0,a),n.slice(a))}}return e}function Ie(t,e){const[r,n,i]=wt(t,e),a=Pt(e==null?void 0:e.locale),l=jt(e==null?void 0:e.locale),d=e!=null&&e.mergeAmbiguousCharacters?Ct(a,l):yt(a,l);return r+n.map(d).join((e==null?void 0:e.delimiter)??"")+i}function Pt(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function jt(t){return t===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t)}function Ct(t,e){return r=>`${e(r[0])}${t(r.slice(1))}`}function yt(t,e){return(r,n)=>{const i=r[0];return(n>0&&i>="0"&&i<="9"?"_"+i:e(i))+t(r.slice(1))}}function wt(t,e={}){const r=e.split??(e.separateNumbers?Lt:ze),n=e.prefixCharacters??Ae,i=e.suffixCharacters??Ae;let a=0,l=t.length;for(;a<t.length;){const d=t.charAt(a);if(!n.includes(d))break;a++}for(;l>a;){const d=l-1,zt=t.charAt(d);if(!i.includes(zt))break;l=d}return[t.slice(0,a),r(t.slice(a,l)),t.slice(l)]}function T(t,e=!1){const r=[];if(e&&t==="")return r;try{const n=JSON.parse(t);!e&&!Object.keys(n).length&&r.push({message:"Initial state cannot be empty",details:{initialState:t}})}catch{r.push({message:"Invalid initial state",details:{initialState:t}})}return r}function R(t,e,r="",n=!0){const i=[];if(!n&&!t)return i.push({message:"State schema is required",details:{schema:t}}),i;if(n&&!t)return i;const a=`type ${Ie(e)}${Ie(r)}State`;return t.includes(a)||i.push({message:`Invalid state schema name. Expected ${a}`,details:{schema:t}}),i}function x(t){const e=[];t.length||e.push({message:"Modules are required",details:{modules:t}});const r=t.reduce((n,i)=>[...n,...b(i)],[]);return[...e,...r]}function b(t){const e=[];t.name||e.push({message:"Module name is required",details:{module:t}}),t.operations.length||e.push({message:"Module operations are required",details:{module:t}});const r=t.operations.reduce((n,i)=>[...n,..._(i)],[]);return[...e,...r]}function _(t){const e=[];return t.name||e.push({message:"Operation name is required",details:{operation:t}}),t.schema||e.push({message:"Operation schema is required",details:{operation:t}}),e}const kt=Object.freeze(Object.defineProperty({__proto__:null,validateInitialState:T,validateModule:b,validateModuleOperation:_,validateModules:x,validateStateSchemaName:R},Symbol.toStringTag,{value:"Module"})),M={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
1
+ "use strict";var Tt=Object.defineProperty;var Rt=(t,e,r)=>e in t?Tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var be=(t,e,r)=>(Rt(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-BLNJYMtQ.js");require("immer");require("crypto");require("fs");require("https");require("path");require("jszip");const o=require("zod"),xt=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),Mt=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),Dt=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),Nt=/[^\p{L}\d]+/giu,_e="$1\0$2",Ae="";function ze(t){let e=t.trim();e=e.replace(xt,_e).replace(Mt,_e),e=e.replace(Nt,"\0");let r=0,n=e.length;for(;e.charAt(r)==="\0";)r++;if(r===n)return[];for(;e.charAt(n-1)==="\0";)n--;return e.slice(r,n).split(/\0/g)}function Lt(t){const e=ze(t);for(let r=0;r<e.length;r++){const n=e[r],i=Dt.exec(n);if(i){const a=i.index+(i[1]??i[2]).length;e.splice(r,1,n.slice(0,a),n.slice(a))}}return e}function Ie(t,e){const[r,n,i]=wt(t,e),a=Pt(e==null?void 0:e.locale),l=jt(e==null?void 0:e.locale),d=e!=null&&e.mergeAmbiguousCharacters?Ct(a,l):yt(a,l);return r+n.map(d).join((e==null?void 0:e.delimiter)??"")+i}function Pt(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function jt(t){return t===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t)}function Ct(t,e){return r=>`${e(r[0])}${t(r.slice(1))}`}function yt(t,e){return(r,n)=>{const i=r[0];return(n>0&&i>="0"&&i<="9"?"_"+i:e(i))+t(r.slice(1))}}function wt(t,e={}){const r=e.split??(e.separateNumbers?Lt:ze),n=e.prefixCharacters??Ae,i=e.suffixCharacters??Ae;let a=0,l=t.length;for(;a<t.length;){const d=t.charAt(a);if(!n.includes(d))break;a++}for(;l>a;){const d=l-1,zt=t.charAt(d);if(!i.includes(zt))break;l=d}return[t.slice(0,a),r(t.slice(a,l)),t.slice(l)]}function T(t,e=!1){const r=[];if(e&&t==="")return r;try{const n=JSON.parse(t);!e&&!Object.keys(n).length&&r.push({message:"Initial state cannot be empty",details:{initialState:t}})}catch{r.push({message:"Invalid initial state",details:{initialState:t}})}return r}function R(t,e,r="",n=!0){const i=[];if(!n&&!t)return i.push({message:"State schema is required",details:{schema:t}}),i;if(n&&!t)return i;const a=`type ${Ie(e)}${Ie(r)}State`;return t.includes(a)||i.push({message:`Invalid state schema name. Expected ${a}`,details:{schema:t}}),i}function x(t){const e=[];t.length||e.push({message:"Modules are required",details:{modules:t}});const r=t.reduce((n,i)=>[...n,...b(i)],[]);return[...e,...r]}function b(t){const e=[];t.name||e.push({message:"Module name is required",details:{module:t}}),t.operations.length||e.push({message:"Module operations are required",details:{module:t}});const r=t.operations.reduce((n,i)=>[...n,..._(i)],[]);return[...e,...r]}function _(t){const e=[];return t.name||e.push({message:"Operation name is required",details:{operation:t}}),t.schema||e.push({message:"Operation schema is required",details:{operation:t}}),e}const kt=Object.freeze(Object.defineProperty({__proto__:null,validateInitialState:T,validateModule:b,validateModuleOperation:_,validateModules:x,validateStateSchemaName:R},Symbol.toStringTag,{value:"Module"})),M={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
2
2
  "id": "",
3
3
  "name": "",
4
4
  "extension": "",
@@ -1,4 +1,4 @@
1
- import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-CrDRbO7a.js";
1
+ import { j as e, f as a, b as s, a as o, c as t, k as r, m as i, n, o as c, p as l, i as p, q as d, r as u, t as m, l as O, e as y, u as b, v as D, w as S, x as _, s as f, d as g, y as F, z as v, A as h, B as j, h as x, g as z, C as R, D as A, E as B } from "./object-BsCssWq4.js";
2
2
  const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  calculateSkipsLeft: e,
@@ -0,0 +1,20 @@
1
+ "use strict";var se=Object.defineProperty;var ae=(e,t,i)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var ot=(e,t,i)=>(ae(e,typeof t!="symbol"?t+"":t,i),i);const U=require("immer"),u=require("zod"),pe=require("crypto"),lt=require("fs"),ce=require("https"),le=require("path"),zt=require("jszip"),Et=e=>e!=null,me=u.z.any().refine(e=>Et(e)),vt=u.z.enum(["LOAD_STATE"]),Tt=u.z.enum(["PRUNE"]),kt=u.z.enum(["REDO"]),_t=u.z.enum(["SET_NAME"]),Dt=u.z.enum(["UNDO"]);function ue(){return u.z.object({__typename:u.z.literal("Action").optional(),type:u.z.string()})}function X(){return u.z.literal("global").or(u.z.literal("local"))}function At(){return u.z.union([Nt(),Pt(),Ft(),It(),Rt()])}function fe(){return u.z.object({__typename:u.z.literal("DocumentFile").optional(),data:u.z.string(),extension:u.z.string().nullable(),fileName:u.z.string().nullable(),mimeType:u.z.string()})}function Nt(){return u.z.object({input:u.z.lazy(()=>gt()),type:vt,scope:X()})}function gt(){return u.z.object({operations:u.z.number(),state:u.z.lazy(()=>Mt())})}function Mt(){return u.z.object({data:u.z.unknown().nullish(),name:u.z.string()})}function de(){return u.z.object({__typename:u.z.literal("Operation").optional(),hash:u.z.string(),index:u.z.number(),timestamp:u.z.string().datetime(),type:u.z.string()})}function Pt(){return u.z.object({input:u.z.lazy(()=>ht()),type:Tt,scope:X()})}function ht(){return u.z.object({end:u.z.number().nullish(),start:u.z.number().nullish()})}const xt=u.z.number;function Ft(){return u.z.object({input:xt(),type:kt,scope:X()})}const yt=u.z.string;function It(){return u.z.object({input:yt(),type:_t,scope:u.z.literal("global")})}function ge(){return u.z.object({__typename:u.z.literal("SetNameOperation").optional(),hash:u.z.string(),index:u.z.number(),input:u.z.string(),timestamp:u.z.string().datetime(),type:u.z.string()})}const bt=u.z.number;function Rt(){return u.z.object({input:bt(),type:Dt,scope:X()})}const he=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:ue,BaseActionSchema:At,DocumentFileSchema:fe,LoadStateActionInputSchema:gt,LoadStateActionSchema:Nt,LoadStateActionStateInputSchema:Mt,Load_StateSchema:vt,OperationSchema:de,OperationScopeSchema:X,PruneActionInputSchema:ht,PruneActionSchema:Pt,PruneSchema:Tt,RedoActionInputSchema:xt,RedoActionSchema:Ft,RedoSchema:kt,SetNameActionInputSchema:yt,SetNameActionSchema:It,SetNameOperationSchema:ge,Set_NameSchema:_t,UndoActionInputSchema:bt,UndoActionSchema:Rt,UndoSchema:Dt,definedNonNullAnySchema:me,isDefinedNonNullAny:Et},Symbol.toStringTag,{value:"Module"}));function xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mt={exports:{}};(function(e,t){const{hasOwnProperty:i}=Object.prototype,n=_();n.configure=_,n.stringify=n,n.default=n,t.stringify=n,t.configure=_,e.exports=n;const a=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function p(s){return s.length<5e3&&!a.test(s)?`"${s}"`:JSON.stringify(s)}function r(s){if(s.length>200)return s.sort();for(let m=1;m<s.length;m++){const y=s[m];let A=m;for(;A!==0&&s[A-1]>y;)s[A]=s[A-1],A--;s[A]=y}return s}const l=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(s){return l.call(s)!==void 0&&s.length!==0}function x(s,m,y){s.length<y&&(y=s.length);const A=m===","?"":" ";let V=`"0":${A}${s[0]}`;for(let R=1;R<y;R++)V+=`${m}"${R}":${A}${s[R]}`;return V}function j(s){if(i.call(s,"circularValue")){const m=s.circularValue;if(typeof m=="string")return`"${m}"`;if(m==null)return m;if(m===Error||m===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 z(s,m){let y;if(i.call(s,m)&&(y=s[m],typeof y!="boolean"))throw new TypeError(`The "${m}" argument must be of type boolean`);return y===void 0?!0:y}function g(s,m){let y;if(i.call(s,m)){if(y=s[m],typeof y!="number")throw new TypeError(`The "${m}" argument must be of type number`);if(!Number.isInteger(y))throw new TypeError(`The "${m}" argument must be an integer`);if(y<1)throw new RangeError(`The "${m}" argument must be >= 1`)}return y===void 0?1/0:y}function S(s){return s===1?"1 item":`${s} items`}function I(s){const m=new Set;for(const y of s)(typeof y=="string"||typeof y=="number")&&m.add(String(y));return m}function k(s){if(i.call(s,"strict")){const m=s.strict;if(typeof m!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(m)return y=>{let A=`Object can not safely be stringified. Received type ${typeof y}`;throw typeof y!="function"&&(A+=` (${y.toString()})`),new Error(A)}}}function _(s){s={...s};const m=k(s);m&&(s.bigint===void 0&&(s.bigint=!1),"circularValue"in s||(s.circularValue=Error));const y=j(s),A=z(s,"bigint"),V=z(s,"deterministic"),R=g(s,"maximumDepth"),v=g(s,"maximumBreadth");function et(M,o,f,b,h,O){let d=o[M];switch(typeof d=="object"&&d!==null&&typeof d.toJSON=="function"&&(d=d.toJSON(M)),d=b.call(o,M,d),typeof d){case"string":return p(d);case"object":{if(d===null)return"null";if(f.indexOf(d)!==-1)return y;let w="",E=",";const T=O;if(Array.isArray(d)){if(d.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(d),h!==""&&(O+=h,w+=`
2
+ ${O}`,E=`,
3
+ ${O}`);const F=Math.min(d.length,v);let J=0;for(;J<F-1;J++){const nt=et(String(J),d,f,b,h,O);w+=nt!==void 0?nt:"null",w+=E}const C=et(String(J),d,f,b,h,O);if(w+=C!==void 0?C:"null",d.length-1>v){const nt=d.length-v-1;w+=`${E}"... ${S(nt)} not stringified"`}return h!==""&&(w+=`
4
+ ${T}`),f.pop(),`[${w}]`}let D=Object.keys(d);const N=D.length;if(N===0)return"{}";if(R<f.length+1)return'"[Object]"';let $="",P="";h!==""&&(O+=h,E=`,
5
+ ${O}`,$=" ");const L=Math.min(N,v);V&&!c(d)&&(D=r(D)),f.push(d);for(let F=0;F<L;F++){const J=D[F],C=et(J,d,f,b,h,O);C!==void 0&&(w+=`${P}${p(J)}:${$}${C}`,P=E)}if(N>v){const F=N-v;w+=`${P}"...":${$}"${S(F)} not stringified"`,P=E}return h!==""&&P.length>1&&(w=`
6
+ ${O}${w}
7
+ ${T}`),f.pop(),`{${w}}`}case"number":return isFinite(d)?String(d):m?m(d):"null";case"boolean":return d===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(d);default:return m?m(d):void 0}}function it(M,o,f,b,h,O){switch(typeof o=="object"&&o!==null&&typeof o.toJSON=="function"&&(o=o.toJSON(M)),typeof o){case"string":return p(o);case"object":{if(o===null)return"null";if(f.indexOf(o)!==-1)return y;const d=O;let w="",E=",";if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o),h!==""&&(O+=h,w+=`
8
+ ${O}`,E=`,
9
+ ${O}`);const N=Math.min(o.length,v);let $=0;for(;$<N-1;$++){const L=it(String($),o[$],f,b,h,O);w+=L!==void 0?L:"null",w+=E}const P=it(String($),o[$],f,b,h,O);if(w+=P!==void 0?P:"null",o.length-1>v){const L=o.length-v-1;w+=`${E}"... ${S(L)} not stringified"`}return h!==""&&(w+=`
10
+ ${d}`),f.pop(),`[${w}]`}f.push(o);let T="";h!==""&&(O+=h,E=`,
11
+ ${O}`,T=" ");let D="";for(const N of b){const $=it(N,o[N],f,b,h,O);$!==void 0&&(w+=`${D}${p(N)}:${T}${$}`,D=E)}return h!==""&&D.length>1&&(w=`
12
+ ${O}${w}
13
+ ${d}`),f.pop(),`{${w}}`}case"number":return isFinite(o)?String(o):m?m(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(o);default:return m?m(o):void 0}}function W(M,o,f,b,h){switch(typeof o){case"string":return p(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(M),typeof o!="object")return W(M,o,f,b,h);if(o===null)return"null"}if(f.indexOf(o)!==-1)return y;const O=h;if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o),h+=b;let $=`
14
+ ${h}`;const P=`,
15
+ ${h}`,L=Math.min(o.length,v);let F=0;for(;F<L-1;F++){const C=W(String(F),o[F],f,b,h);$+=C!==void 0?C:"null",$+=P}const J=W(String(F),o[F],f,b,h);if($+=J!==void 0?J:"null",o.length-1>v){const C=o.length-v-1;$+=`${P}"... ${S(C)} not stringified"`}return $+=`
16
+ ${O}`,f.pop(),`[${$}]`}let d=Object.keys(o);const w=d.length;if(w===0)return"{}";if(R<f.length+1)return'"[Object]"';h+=b;const E=`,
17
+ ${h}`;let T="",D="",N=Math.min(w,v);c(o)&&(T+=x(o,E,v),d=d.slice(o.length),N-=o.length,D=E),V&&(d=r(d)),f.push(o);for(let $=0;$<N;$++){const P=d[$],L=W(P,o[P],f,b,h);L!==void 0&&(T+=`${D}${p(P)}: ${L}`,D=E)}if(w>v){const $=w-v;T+=`${D}"...": "${S($)} not stringified"`,D=E}return D!==""&&(T=`
18
+ ${h}${T}
19
+ ${O}`),f.pop(),`{${T}}`}case"number":return isFinite(o)?String(o):m?m(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(o);default:return m?m(o):void 0}}function Z(M,o,f){switch(typeof o){case"string":return p(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(M),typeof o!="object")return Z(M,o,f);if(o===null)return"null"}if(f.indexOf(o)!==-1)return y;let b="";if(Array.isArray(o)){if(o.length===0)return"[]";if(R<f.length+1)return'"[Array]"';f.push(o);const E=Math.min(o.length,v);let T=0;for(;T<E-1;T++){const N=Z(String(T),o[T],f);b+=N!==void 0?N:"null",b+=","}const D=Z(String(T),o[T],f);if(b+=D!==void 0?D:"null",o.length-1>v){const N=o.length-v-1;b+=`,"... ${S(N)} not stringified"`}return f.pop(),`[${b}]`}let h=Object.keys(o);const O=h.length;if(O===0)return"{}";if(R<f.length+1)return'"[Object]"';let d="",w=Math.min(O,v);c(o)&&(b+=x(o,",",v),h=h.slice(o.length),w-=o.length,d=","),V&&(h=r(h)),f.push(o);for(let E=0;E<w;E++){const T=h[E],D=Z(T,o[T],f);D!==void 0&&(b+=`${d}${p(T)}:${D}`,d=",")}if(O>v){const E=O-v;b+=`${d}"...":"${S(E)} not stringified"`}return f.pop(),`{${b}}`}case"number":return isFinite(o)?String(o):m?m(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(A)return String(o);default:return m?m(o):void 0}}function re(M,o,f){if(arguments.length>1){let b="";if(typeof f=="number"?b=" ".repeat(Math.min(f,10)):typeof f=="string"&&(b=f.slice(0,10)),o!=null){if(typeof o=="function")return et("",{"":M},[],o,b,"");if(Array.isArray(o))return it("",M,[],I(o),b,"")}if(b.length!==0)return W("",M,[],b,"")}return Z("",M,[])}return re}})(mt,mt.exports);var ye=mt.exports;const rt=xe(ye);rt.configure;function be(e,t){return{...e,name:t}}function we(e,t,i){const n={skip:i,document:e},{scope:a}=t;return!a||t.skip===void 0?n:U.produce(n,p=>{const[r]=p.document.operations[a].slice(-1);t.skip&&t.skip>0&&(p.skip=t.skip),r.type==="NOOP"&&t.index===r.index&&p.skip>r.skip&&p.document.operations[a].pop()})}function je(e,t,i){const{scope:n,input:a}=t,p={document:e,action:t,skip:i};return U.produce(p,r=>{if(r.document.operations[n].length<1)throw new Error(`Cannot undo: no operations in history for scope "${n}"`);if(a<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[l]=r.document.operations[n].slice(-1),c=l.type==="NOOP"&&l.skip>0;if(r.skip+=a,c){r.skip+=l.skip;const g=r.document.operations[n][r.document.operations[n].length-2];g&&l.index-g.index===1&&r.document.operations[n].pop()}if(r.document.operations[n].length<r.skip)throw new Error("Cannot undo: you can't undo more operations than the ones in the scope history");const x=r.document.operations[n].length-1;let j=a,z=c?x-l.skip:x;for(;j>0&&z>=0;){const g=r.document.operations[n][z];if(!g){j--,z--;continue}g.type==="NOOP"&&g.skip>0?(z=z-(g.skip+1),r.skip+=g.skip+1):(r.document.clipboard.push({...g}),j--,z--)}r.action=St(n)})}function Oe(e,t,i){const{scope:n,input:a}=t,p={document:e,action:t,skip:i};return U.produce(p,r=>{if(r.skip>0)throw new Error("Cannot redo: skip value from reducer cannot be used with REDO action");if(a>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(a<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 l=r.document.clipboard.findLastIndex(x=>x.scope===n);if(l<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${n}"`);const c=r.document.clipboard.splice(l,1)[0];r.action=U.castDraft({type:c.type,scope:c.scope,input:c.input})})}function Se(e,t,i){const{scope:n}=t,a=e.operations[n];let{input:{start:p,end:r}}=t;p=p||0,r=r||a.length;const l=a.slice(p,r),c=a.slice(0,p),x=a.slice(r),j=st(e.initialState,{...e.operations,[n]:c.concat(l)},i),{name:z,state:g}=j,S=c.length,I=c.length?c[c.length-1].timestamp:x.length?x[0].timestamp:new Date().toISOString();return st(e.initialState,{...e.operations,[n]:[...c,{...Ot({name:z,state:g},l.length),timestamp:I,index:S,hash:ct({state:g},"global")},...x.map((k,_)=>({...k,index:S+_+1}))]},i)}function $e(e,t){return{...e,name:t.name,state:t.state??{global:{},local:{}}}}const qt="SET_NAME",Y="UNDO",tt="REDO",at="PRUNE",Lt="LOAD_STATE",ze="NOOP";function Ee(e,t){let i;return"index"in t?i={...t}:i=e.operations[t.scope].slice(-1)[0],((i==null?void 0:i.index)??-1)+1}function ve(e,t){return{...e,revision:{...e.revision,[t.scope]:Ee(e,t)},lastModified:new Date().toISOString()}}function Te(e,t,i=0){if([Y,tt,at].includes(t.type))return e;const{scope:n}=t,a=e.operations[n].slice(0,e.revision[n]),p=[...a].pop();let r=((p==null?void 0:p.index)??-1)+1;if("index"in t){if(t.index>r+i)throw new Error(`Missing operations: expected ${r} with skip 0 or equivalent, got index ${t.index} with skip ${i}`);r=t.index}return a.push({...t,index:r,timestamp:new Date().toISOString(),hash:"",scope:n,skip:i}),{...e,operations:{...e.operations,[n]:a}}}function ke(e,t,i=0){let n=Te(e,t,i);return n=ve(n,t),n}function _e(e,t,i){switch(At().parse(t),t.type){case qt:return be(e,t.input);case at:return Se(e,t,i);case Lt:return $e(e,t.input.state);default:return e}}function Jt(e,t,i){switch(t.type){case Y:return je(e,t,i);case tt:return Oe(e,t,i);default:return{document:e,action:t,skip:i}}}function wt(e,t,i,n,a={}){const{skip:p,ignoreSkipOperations:r=!1,reuseHash:l=!1}=a;let c={...t},x=p||0,j=e,z=[...e.clipboard];if(Ut(c)){const{document:g,skip:S}=we(j,c,x);x=S,j=g}if(ut(c)){const{skip:g,action:S,document:I}=Jt(e,c,x);c=S,x=g,j=I,z=[...j.clipboard]}if(ft(c)&&(j=_e(j,c,i)),x>0&&!r){let g=x;"index"in c&&(g=Wt(j.operations[c.scope],c.index,x)),j=st(j.initialState,j.operations,i,void 0,void 0,void 0,{[c.scope]:g})}return j=ke(j,c,x),j=U.produce(j,g=>{const S=i(g.state,c,n),I=ut(t)?[...z]:[];if(S)return U.castDraft({...j,clipboard:[...I],state:S});g.clipboard=U.castDraft([...I])}),U.produce(j,g=>{if([Y,tt,at].includes(c.type))return g;const S=c.scope||"global";console.time("hash");const I=l&&Object.prototype.hasOwnProperty.call(c,"hash")?c.hash:ct(g,S);console.timeEnd("hash"),g.operations[S][g.operations[S].length-1].hash=I,!ft(c)&&c.attachments&&c.attachments.forEach(k=>{const{hash:_,...s}=k;g.attachments[_]={...s}})})}function De(e,t,i){const n=le.join(e,t);return lt.mkdirSync(e,{recursive:!0}),new Promise((a,p)=>{try{lt.writeFile(n,i,{},r=>{r?p(r):a(n)})}catch(r){p(r)}})}function Ct(e){return lt.readFileSync(e)}function Ae(e){return new Promise((t,i)=>{ce.get(e,n=>{const a=[],p=n.headers["content-type"];n.on("data",r=>{a.push(r)}),n.on("end",()=>{t({buffer:Buffer.concat(a),mimeType:p})})}).on("error",n=>{i(n)})})}const Ne=async e=>Ct(e),pt=(e,t="sha1")=>pe.createHash(t).update(e).digest("base64");function Ut(e){return e.type===ze&&e.skip!==void 0&&e.skip>0&&e.hash!==void 0}function ut(e){return[Y,tt].includes(e.type)}function ft(e){return[qt,Y,tt,at,Lt].includes(e.type)}function B(e,t,i,n,a="global"){if(!e)throw new Error("Empty action type");if(typeof e!="string")throw new Error(`Invalid action type: ${JSON.stringify(e)}`);const p={type:e,input:t,scope:a};i&&(p.attachments=i);try{n==null||n().parse(p.input)}catch(r){throw new Error(`Invalid action input: ${r}`)}return p}function Vt(e,t=wt){return(i,n,a,p)=>t(i,n,e,a,p)}const Kt=(e,t)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...e,state:(t==null?void 0:t(e==null?void 0:e.state))??(e==null?void 0:e.state)??{global:{},local:{}}}),Bt=(e,t)=>{const i=Kt(e,t);return{...i,initialState:i,operations:{global:[],local:[]},clipboard:[]}},ct=(e,t="global")=>pt(rt(e.state[t]||"")),Me=(e,t=1e3)=>{const i=Math.random()*t;return pt(`${(e??new Date).toISOString()}${i}`)};function G(e){return U.castImmutable(U.freeze(e,!0))}function Ht(e,t){const i=[...e];let n=t||0,a=i.length>0?i[i.length-1].index:0;const p=[];for(const r of i.reverse()){if(n>0){const x=a-r.index;n-=x}if(n<0)throw new Error("Invalid operation index, missing operations");const l={ignore:n>0,operation:r},c=r.skip>0?r.skip+1:0;if(c>0&&c>n){const x=c-n;n=n+x}a=r.index,p.push(l)}return p.reverse()}function Wt(e,t,i){const n=e.slice().sort((l,c)=>l.skip-c.skip).sort((l,c)=>l.index-c.index);let a=i,p=0,r=t;for(const l of n.reverse()){const c=r-l.index;if(a=a-c,a>-1)p++,r=l.index;else break}return p}function Pe(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.timestamp).getTime()-new Date(i.timestamp).getTime())}function Zt(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.operation.timestamp).getTime()-new Date(i.operation.timestamp).getTime())}function st(e,t,i,n,a,p=wt,r={},l){const c=Vt(i,p);return jt(e,t,c,n,a,r,l)}function jt(e,t,i,n,a,p={},r){const l=(r==null?void 0:r.checkHashes)??!0,c=Bt(e),x=Object.keys(t).reduce((k,_)=>{const s=_;return{...k,[s]:t[s].slice(0,a==null?void 0:a.revision[s])}},{}),j=Object.keys(x).reduce((k,_)=>{const s=_;return{...k,[s]:Ht(x[s],p[s])}},{}),z=Zt(j),g=z.reduce((k,{ignore:_,operation:s},m,y)=>_?i(k,St(s.scope),n,{skip:s.skip,ignoreSkipOperations:!0}):i(k,s,n,{skip:s.skip,ignoreSkipOperations:!0,reuseHash:!l}),c);for(const k of Object.keys(g.state))for(let _=z.length-1;_>=0;_--)if(z[_].operation.scope===k){if(z[_].operation.hash!==ct(g,k))throw new Error(`Hash mismatch for scope ${k}`);break}const S=Object.keys(g.operations).reduce((k,_)=>{const s=_,m=a&&a.revision[s]<t[s].length?t[s].slice(a.revision[s]):[];return{...k,[s]:[...g.operations[s].map((y,A)=>{var V;return{...y,timestamp:((V=t[s][A])==null?void 0:V.timestamp)??y.timestamp}}),...m]}},{global:[],local:[]}),I=Object.values(S).reduce((k,_)=>{for(const s of _)s.timestamp>k&&(k=s.timestamp);return k},e.lastModified);return{...g,operations:S,lastModified:I}}function Fe(e,t){return rt(e)===rt(t)}const Gt=e=>B("SET_NAME",e,void 0,yt,void 0),Qt=(e=1,t="global")=>B("UNDO",e,void 0,bt,t),Xt=(e=1,t="global")=>B("REDO",e,void 0,xt,t),Yt=(e,t,i="global")=>B("PRUNE",{start:e,end:t},void 0,ht,i),Ot=(e,t)=>B("LOAD_STATE",{state:e,operations:t},void 0,gt),St=(e="global")=>B("NOOP",{},void 0,void 0,e),Ie=Object.freeze(Object.defineProperty({__proto__:null,loadState:Ot,noop:St,prune:Yt,redo:Xt,setName:Gt,undo:Qt},Symbol.toStringTag,{value:"Module"})),te={"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(te);var q=function(e,t,i,n){if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(e):n?n.value:t.get(e)},H,Q,K;class Re{constructor(...t){H.set(this,new Map),Q.set(this,new Map),K.set(this,new Map);for(const i of t)this.define(i)}define(t,i=!1){for(let[n,a]of Object.entries(t)){n=n.toLowerCase(),a=a.map(l=>l.toLowerCase()),q(this,K,"f").has(n)||q(this,K,"f").set(n,new Set);const p=q(this,K,"f").get(n);let r=!0;for(let l of a){const c=l.startsWith("*");if(l=c?l.slice(1):l,p==null||p.add(l),r&&q(this,Q,"f").set(n,l),r=!1,c)continue;const x=q(this,H,"f").get(l);if(x&&x!=n&&!i)throw new Error(`"${n} -> ${l}" conflicts with "${x} -> ${l}". Pass \`force=true\` to override this definition.`);q(this,H,"f").set(l,n)}}return this}getType(t){if(typeof t!="string")return null;const i=t.replace(/^.*[/\\]/,"").toLowerCase(),n=i.replace(/^.*\./,"").toLowerCase(),a=i.length<t.length;return!(n.length<i.length-1)&&a?null:q(this,H,"f").get(n)??null}getExtension(t){var i;return typeof t!="string"?null:(t=(i=t==null?void 0:t.split)==null?void 0:i.call(t,";")[0],(t&&q(this,Q,"f").get(t.trim().toLowerCase()))??null)}getAllExtensions(t){return typeof t!="string"?null:q(this,K,"f").get(t.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 t of q(this,K,"f").values())Object.freeze(t);return this}_getTestState(){return{types:q(this,H,"f"),extensions:q(this,Q,"f")}}}H=new WeakMap,Q=new WeakMap,K=new WeakMap;const qe=new Re(te)._freeze();function ee(e){const t=[],i=Object.keys(e);for(const n of i){const a=e[n].sort((p,r)=>p.index-r.index);for(let p=0;p<a.length;p++)a[p].index!==p&&t.push({message:`Invalid operation index ${a[p].index} at position ${p}`,details:{position:p,operation:a[p],scope:a[p].scope}})}return t}const $t=async e=>{const t=new zt,{name:i,revision:n,documentType:a,created:p,lastModified:r}=e,l={name:i,revision:n,documentType:a,created:p,lastModified:r};return t.file("header.json",JSON.stringify(l,null,2)),t.file("state.json",JSON.stringify(e.initialState||{},null,2)),t.file("operations.json",JSON.stringify(e.operations,null,2)),Object.keys(e.attachments).forEach(x=>{const{data:j,...z}=e.attachments[x];t.file(x,j,{base64:!0,createFolders:!0,comment:JSON.stringify(z)})}),t},ie=async(e,t,i,n)=>{const p=await(await $t(e)).generateAsync({type:"uint8array",streamFiles:!0}),r=n??e.name,l=`.${i}.zip`;return De(t,r.endsWith(l)?r:`${r}${l}`,p)},Le=async(e,t)=>{const n=await(await $t(e)).generateAsync({type:"blob"}),a=await t.createWritable();await a.write(n),await a.close()},dt=async(e,t,i)=>{const n=Ct(e);return ne(n,t)},ne=async(e,t,i)=>{const n=new zt;return await n.loadAsync(e),Je(n,t)};async function Je(e,t,i){const n=e.file("state.json");if(!n)throw new Error("Initial state not found");const a=await n.async("string"),p=JSON.parse(a),r=e.file("header.json");let l;r&&(l=JSON.parse(await r.async("string")));const c=e.file("operations.json");if(!c)throw new Error("Operations history not found");const x=JSON.parse(await c.async("string")),j=ee(x);if(j.length){const g=j.map(S=>S.message);throw new Error(g.join(`
20
+ `))}let z=jt(p,x,t,void 0,l);return l&&(z={...z,...l}),z}function oe(e){const t=e.replace(/^.*\./,"")||void 0,i=e.replace(/^.*[/\\]/,"")||void 0;return{extension:t,fileName:i}}async function Ce(e){const{buffer:t,mimeType:i="application/octet-stream"}=await Ae(e),n=oe(e),a=t.toString("base64");return{data:a,hash:pt(a),mimeType:i,...n}}async function Ue(e){const t=await Ne(e),i=qe.getType(e)||"application/octet-stream",n=oe(e),a=t.toString("base64");return{data:a,hash:pt(a),mimeType:i,...n}}class Ve{constructor(t,i,n){ot(this,"_document");ot(this,"_reducer");ot(this,"_signalDispatch");this._reducer=t,this._document=i,this._signalDispatch=n}dispatch(t,i){return this._document=this._reducer(this._document,t,this._signalDispatch,i),this}saveToFile(t,i,n){return ie(this._document,t,i,n)}async loadFromFile(t){this._document=await dt(t,this._reducer)}static async stateFromFile(t,i){return await dt(t,i)}get state(){return G(this._document.state)}get operations(){return G(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(t){return this._document.revision[t]}get initialState(){return G(this._document.initialState)}toDocument(){return G(this._document)}getAttachment(t){return this._document.attachments[t]}setName(t){return this.dispatch(Gt(t)),this}undo(t){return this.dispatch(Qt(t)),this}redo(t){return this.dispatch(Xt(t)),this}prune(t,i){return this.dispatch(Yt(t,i)),this}loadState(t,i){return this.dispatch(Ot(t,i)),this}}function Ke(e,t){t.forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(i.prototype,n)||Object.create(null))})})}exports.BaseActions=Ie;exports.BaseDocument=Ve;exports.applyMixins=Ke;exports.baseReducer=wt;exports.calculateSkipsLeft=Wt;exports.createAction=B;exports.createDocument=Bt;exports.createExtendedState=Kt;exports.createReducer=Vt;exports.createZip=$t;exports.getLocalFile=Ue;exports.getRemoteFile=Ce;exports.hashDocument=ct;exports.hashKey=Me;exports.isBaseAction=ft;exports.isNoopOperation=Ut;exports.isSameDocument=Fe;exports.isUndoRedo=ut;exports.loadFromFile=dt;exports.loadFromInput=ne;exports.mapSkippedOperations=Ht;exports.processUndoRedo=Jt;exports.readOnly=G;exports.replayDocument=jt;exports.replayOperations=st;exports.saveToFile=ie;exports.saveToFileHandle=Le;exports.sortMappedOperations=Zt;exports.sortOperations=Pe;exports.validateOperations=ee;exports.zod=he;