document-model 1.0.28 → 1.0.30

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