document-model 1.0.27 → 1.0.28

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 (31) hide show
  1. package/dist/browser/document-model.cjs +1 -1
  2. package/dist/browser/document-model.js +7 -8
  3. package/dist/browser/document.cjs +1 -1
  4. package/dist/browser/document.js +9 -13
  5. package/dist/browser/index.cjs +1 -1
  6. package/dist/browser/index.js +8 -13
  7. package/dist/{node/internal/index-2d55ed8c.js → browser/internal/index-FBdtB-Z0.js} +1 -1
  8. package/dist/{node/internal/index-78c035e1.js → browser/internal/index-MQO6aDba.js} +1 -1
  9. package/dist/browser/internal/{index-ff67644b.js → index-oR1tzXEU.js} +1 -1
  10. package/dist/browser/internal/{index-99f8b333.js → index-qiOnVXbI.js} +1 -1
  11. package/dist/browser/internal/object-P7bHOWu_.js +1912 -0
  12. package/dist/browser/internal/object-RV2GJjkF.js +6 -0
  13. package/dist/browser/vitest.config.d.ts +1 -1
  14. package/dist/node/document-model.cjs +1 -1
  15. package/dist/node/document-model.js +10 -11
  16. package/dist/node/document.cjs +1 -1
  17. package/dist/node/document.js +9 -17
  18. package/dist/node/index.cjs +1 -1
  19. package/dist/node/index.js +8 -17
  20. package/dist/{browser/internal/index-e019b5aa.js → node/internal/index-E6Dehju3.js} +1 -1
  21. package/dist/{browser/internal/index-df4df518.js → node/internal/index-Rc3pWGDQ.js} +1 -1
  22. package/dist/node/internal/{index-433d6a9b.js → index-r_Cve_NX.js} +1 -1
  23. package/dist/node/internal/{index-a46dcf07.js → index-uFGJxYP7.js} +1 -1
  24. package/dist/node/internal/object-51-uoy0f.js +1 -0
  25. package/dist/node/internal/object-qR4Tf50L.js +911 -0
  26. package/dist/node/vitest.config.d.ts +1 -1
  27. package/package.json +2 -2
  28. package/dist/browser/internal/object-4b5800c0.js +0 -1891
  29. package/dist/browser/internal/object-be1b0c52.js +0 -6
  30. package/dist/node/internal/object-305e4c59.js +0 -893
  31. package/dist/node/internal/object-ff6617a2.js +0 -1
@@ -0,0 +1,6 @@
1
+ "use strict";var De=Object.defineProperty;var Me=(o,i,p)=>i in o?De(o,i,{enumerable:!0,configurable:!0,writable:!0,value:p}):o[i]=p;var X=(o,i,p)=>(Me(o,typeof i!="symbol"?i+"":i,p),p);const D=require("immer"),Ne=require("json-stringify-deterministic"),w=require("zod"),Dt=require("jszip"),Mt=o=>o!=null,Re=w.z.any().refine(o=>Mt(o)),Nt=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 Ce(){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 $t(){return w.z.union([Pt(),Jt(),Ht(),Zt(),Kt()])}function Le(){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 Pt(){return w.z.object({input:w.z.lazy(()=>ut()),type:Nt,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 qe(){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 Pe=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Ce,BaseActionSchema:$t,DocumentFileSchema:Le,LoadStateActionInputSchema:ut,LoadStateActionSchema:Pt,LoadStateActionStateInputSchema:Wt,Load_StateSchema:Nt,OperationSchema:qe,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:Re,isDefinedNonNullAny:Mt},Symbol.toStringTag,{value:"Module"}));function We(o,i){return{...o,name:i}}function Je(o,i,p){const{scope:c,input:f}=i,m={document:o,action:i,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(f<1)throw new Error("Invalid UNDO action: input value must be greater than 0");if(l.skip>0)throw new Error("Cannot undo: skip value from reducer cannot be used with UNDO action");const[a]=l.document.operations[c].slice(-1),x=a.type==="NOOP"&&a.skip>0;if(l.skip+=f,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=f,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 He(o,i,p){const{scope:c,input:f}=i,m={document:o,action:i,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(f>1)throw new Error("Cannot redo: you can only redo one operation at a time");if(f<1)throw new Error("Invalid REDO action: invalid redo input value");if(l.document.clipboard.length<1)throw new Error("Cannot redo: no operations in the clipboard");const a=l.document.clipboard.findLastIndex(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 Ze(o,i,p){const{scope:c}=i,f=o.operations[c];let{input:{start:m,end:l}}=i;m=m||0,l=l||f.length;const a=f.slice(m,l),x=f.slice(0,m),d=f.slice(l),E=Q(o.initialState,{...o.operations,[c]:x.concat(a)},p),{name:g,state:v}=E,y=x.length,O=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:O,index:y,hash:yt({state:v},"global")},...d.map((j,W)=>({...j,index:y+W+1}))]},p)}function Ke(o,i){return{...o,name:i.name,state:i.state??{global:{},local:{}}}}const Yt="SET_NAME",$="UNDO",P="REDO",K="PRUNE",Gt="LOAD_STATE";function Ye(o,i){const p=o.revision[i.scope];return[$,P,K].includes(i.type)?p:p+1}function Ge(o,i){return{...o,revision:{...o.revision,[i.scope]:Ye(o,i)},lastModified:new Date().toISOString()}}function Ve(o,i,p=0){if([$,P,K].includes(i.type))return o;const{scope:c}=i,f=o.operations[c].slice(0,o.revision[c]);return f.push({...i,index:f.length,timestamp:new Date().toISOString(),hash:"",scope:c,skip:p}),{...o,operations:{...o.operations,[c]:f}}}function Xe(o,i,p=0){let c=Ve(o,i,p);return c=Ge(c,i),c}function Qe(o,i,p){switch($t().parse(i),i.type){case Yt:return We(o,i.input);case K:return Ze(o,i,p);case Gt:return Ke(o,i.input.state);default:return o}}function Vt(o,i,p){switch(i.type){case $:return Je(o,i,p);case P:return He(o,i,p);default:return{document:o,action:i,skip:p}}}function dt(o,i,p,c,f={}){const{skip:m,ignoreSkipOperations:l=!1}=f;let a={...i},x=m||0,d=o,E=[...o.clipboard];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=Qe(d,a,p)),x>0&&!l&&(d=Q(d.initialState,d.operations,p,void 0,void 0,void 0,{[a.scope]:x})),d=Xe(d,a,x),d=D.produce(d,g=>{const v=p(g.state,a,c),y=st(i)?[...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:O,...j}=y;g.attachments[O]={...j}})})}function tr(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var at={exports:{}};typeof Object.create=="function"?at.exports=function(i,p){p&&(i.super_=p,i.prototype=Object.create(p.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}))}:at.exports=function(i,p){if(p){i.super_=p;var c=function(){};c.prototype=p.prototype,i.prototype=new c,i.prototype.constructor=i}};var er=at.exports,pt={exports:{}},Xt={},tt={};tt.byteLength=nr;tt.toByteArray=ar;tt.fromByteArray=cr;var z=[],U=[],rr=typeof Uint8Array<"u"?Uint8Array:Array,ot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var L=0,ir=ot.length;L<ir;++L)z[L]=ot[L],U[ot.charCodeAt(L)]=L;U[45]=62;U[95]=63;function Qt(o){var i=o.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var p=o.indexOf("=");p===-1&&(p=i);var c=p===i?0:4-p%4;return[p,c]}function nr(o){var i=Qt(o),p=i[0],c=i[1];return(p+c)*3/4-c}function or(o,i,p){return(i+p)*3/4-p}function ar(o){var i,p=Qt(o),c=p[0],f=p[1],m=new rr(or(o,c,f)),l=0,a=f>0?c-4:c,x;for(x=0;x<a;x+=4)i=U[o.charCodeAt(x)]<<18|U[o.charCodeAt(x+1)]<<12|U[o.charCodeAt(x+2)]<<6|U[o.charCodeAt(x+3)],m[l++]=i>>16&255,m[l++]=i>>8&255,m[l++]=i&255;return f===2&&(i=U[o.charCodeAt(x)]<<2|U[o.charCodeAt(x+1)]>>4,m[l++]=i&255),f===1&&(i=U[o.charCodeAt(x)]<<10|U[o.charCodeAt(x+1)]<<4|U[o.charCodeAt(x+2)]>>2,m[l++]=i>>8&255,m[l++]=i&255),m}function pr(o){return z[o>>18&63]+z[o>>12&63]+z[o>>6&63]+z[o&63]}function sr(o,i,p){for(var c,f=[],m=i;m<p;m+=3)c=(o[m]<<16&16711680)+(o[m+1]<<8&65280)+(o[m+2]&255),f.push(pr(c));return f.join("")}function cr(o){for(var i,p=o.length,c=p%3,f=[],m=16383,l=0,a=p-c;l<a;l+=m)f.push(sr(o,l,l+m>a?a:l+m));return c===1?(i=o[p-1],f.push(z[i>>2]+z[i<<4&63]+"==")):c===2&&(i=(o[p-2]<<8)+o[p-1],f.push(z[i>>10]+z[i>>4&63]+z[i<<2&63]+"=")),f.join("")}var wt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */wt.read=function(o,i,p,c,f){var m,l,a=f*8-c-1,x=(1<<a)-1,d=x>>1,E=-7,g=p?f-1:0,v=p?-1:1,y=o[i+g];for(g+=v,m=y&(1<<-E)-1,y>>=-E,E+=a;E>0;m=m*256+o[i+g],g+=v,E-=8);for(l=m&(1<<-E)-1,m>>=-E,E+=c;E>0;l=l*256+o[i+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,i,p,c,f,m){var l,a,x,d=m*8-f-1,E=(1<<d)-1,g=E>>1,v=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=c?0:m-1,O=c?1:-1,j=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(a=isNaN(i)?1:0,l=E):(l=Math.floor(Math.log(i)/Math.LN2),i*(x=Math.pow(2,-l))<1&&(l--,x*=2),l+g>=1?i+=v/x:i+=v*Math.pow(2,1-g),i*x>=2&&(l++,x/=2),l+g>=E?(a=0,l=E):l+g>=1?(a=(i*x-1)*Math.pow(2,f),l=l+g):(a=i*Math.pow(2,g-1)*Math.pow(2,f),l=0));f>=8;o[p+y]=a&255,y+=O,a/=256,f-=8);for(l=l<<f|a,d+=f;d>0;o[p+y]=l&255,y+=O,l/=256,d-=8);o[p+y-O]|=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 i=tt,p=wt,c=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;o.Buffer=a,o.SlowBuffer=we,o.INSPECT_MAX_BYTES=50;var f=2147483647;o.kMaxLength=f,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 r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.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(r){if(r>f)throw new RangeError('The value "'+r+'" is invalid for option "size"');var t=new Uint8Array(r);return Object.setPrototypeOf(t,a.prototype),t}function a(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(r)}return x(r,t,e)}a.poolSize=8192;function x(r,t,e){if(typeof r=="string")return v(r,t);if(ArrayBuffer.isView(r))return O(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(T(r,ArrayBuffer)||r&&T(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(T(r,SharedArrayBuffer)||r&&T(r.buffer,SharedArrayBuffer)))return j(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return a.from(n,t,e);var s=W(r);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return a.from(r[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 r)}a.from=function(r,t,e){return x(r,t,e)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function d(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function E(r,t,e){return d(r),r<=0?l(r):t!==void 0?typeof e=="string"?l(r).fill(t,e):l(r).fill(t):l(r)}a.alloc=function(r,t,e){return E(r,t,e)};function g(r){return d(r),l(r<0?0:C(r)|0)}a.allocUnsafe=function(r){return g(r)},a.allocUnsafeSlow=function(r){return g(r)};function v(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var e=_t(r,t)|0,n=l(e),s=n.write(r,t);return s!==e&&(n=n.slice(0,s)),n}function y(r){for(var t=r.length<0?0:C(r.length)|0,e=l(t),n=0;n<t;n+=1)e[n]=r[n]&255;return e}function O(r){if(T(r,Uint8Array)){var t=new Uint8Array(r);return j(t.buffer,t.byteOffset,t.byteLength)}return y(r)}function j(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.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(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,a.prototype),n}function W(r){if(a.isBuffer(r)){var t=C(r.length)|0,e=l(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||nt(r.length)?l(0):y(r);if(r.type==="Buffer"&&Array.isArray(r.data))return y(r.data)}function C(r){if(r>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return r|0}function we(r){return+r!=r&&(r=0),a.alloc(+r)}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,u=0,h=Math.min(n,s);u<h;++u)if(t[u]!==e[u]){n=t[u],s=e[u];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),u=0;for(n=0;n<t.length;++n){var h=t[n];if(T(h,Uint8Array))u+h.length>s.length?a.from(h).copy(s,u):Uint8Array.prototype.set.call(s,h,u);else if(a.isBuffer(h))h.copy(s,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=h.length}return s};function _t(r,t){if(a.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||T(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);var e=r.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 it(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ot(r).length;default:if(s)return n?-1:it(r).length;t=(""+t).toLowerCase(),s=!0}}a.byteLength=_t;function ge(r,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(r||(r="utf8");;)switch(r){case"hex":return ke(this,t,e);case"utf8":case"utf-8":return Bt(this,t,e);case"ascii":return Se(this,t,e);case"latin1":case"binary":return Be(this,t,e);case"base64":return _e(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return je(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}a.prototype._isBuffer=!0;function M(r,t,e){var n=r[t];r[t]=r[e],r[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)M(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)M(this,e,e+3),M(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)M(this,e,e+7),M(this,e+1,e+6),M(this,e+2,e+5),M(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?Bt(this,0,t):ge.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,u){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),u===void 0&&(u=this.length),e<0||n>t.length||s<0||u>this.length)throw new RangeError("out of range index");if(s>=u&&e>=n)return 0;if(s>=u)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,s>>>=0,u>>>=0,this===t)return 0;for(var h=u-s,b=n-e,F=Math.min(h,b),_=this.slice(s,u),B=t.slice(e,n),A=0;A<F;++A)if(_[A]!==B[A]){h=_[A],b=B[A];break}return h<b?-1:b<h?1:0};function At(r,t,e,n,s){if(r.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:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(s)return-1;e=r.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(r,t,e,n,s);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):St(r,[t],e,n,s);throw new TypeError("val must be string, number or Buffer")}function St(r,t,e,n,s){var u=1,h=r.length,b=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;u=2,h/=2,b/=2,e/=2}function F(Tt,zt){return u===1?Tt[zt]:Tt.readUInt16BE(zt*u)}var _;if(s){var B=-1;for(_=e;_<h;_++)if(F(r,_)===F(t,B===-1?0:_-B)){if(B===-1&&(B=_),_-B+1===b)return B*u}else B!==-1&&(_-=_-B),B=-1}else for(e+b>h&&(e=h-b),_=e;_>=0;_--){for(var A=!0,V=0;V<b;V++)if(F(r,_+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 ye(r,t,e,n){e=Number(e)||0;var s=r.length-e;n?(n=Number(n),n>s&&(n=s)):n=s;var u=t.length;n>u/2&&(n=u/2);for(var h=0;h<n;++h){var b=parseInt(t.substr(h*2,2),16);if(nt(b))return h;r[e+h]=b}return h}function ve(r,t,e,n){return G(it(t,r.length-e),r,e,n)}function be(r,t,e,n){return G(Oe(t),r,e,n)}function Ee(r,t,e,n){return G(Ot(t),r,e,n)}function Fe(r,t,e,n){return G(Te(t,r.length-e),r,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 u=this.length-e;if((n===void 0||n>u)&&(n=u),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 ye(this,t,e,n);case"utf8":case"utf-8":return ve(this,t,e,n);case"ascii":case"latin1":case"binary":return be(this,t,e,n);case"base64":return Ee(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Fe(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 _e(r,t,e){return t===0&&e===r.length?i.fromByteArray(r):i.fromByteArray(r.slice(t,e))}function Bt(r,t,e){e=Math.min(r.length,e);for(var n=[],s=t;s<e;){var u=r[s],h=null,b=u>239?4:u>223?3:u>191?2:1;if(s+b<=e){var F,_,B,A;switch(b){case 1:u<128&&(h=u);break;case 2:F=r[s+1],(F&192)===128&&(A=(u&31)<<6|F&63,A>127&&(h=A));break;case 3:F=r[s+1],_=r[s+2],(F&192)===128&&(_&192)===128&&(A=(u&15)<<12|(F&63)<<6|_&63,A>2047&&(A<55296||A>57343)&&(h=A));break;case 4:F=r[s+1],_=r[s+2],B=r[s+3],(F&192)===128&&(_&192)===128&&(B&192)===128&&(A=(u&15)<<18|(F&63)<<12|(_&63)<<6|B&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 Ae(n)}var kt=4096;function Ae(r){var t=r.length;if(t<=kt)return String.fromCharCode.apply(String,r);for(var e="",n=0;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=kt));return e}function Se(r,t,e){var n="";e=Math.min(r.length,e);for(var s=t;s<e;++s)n+=String.fromCharCode(r[s]&127);return n}function Be(r,t,e){var n="";e=Math.min(r.length,e);for(var s=t;s<e;++s)n+=String.fromCharCode(r[s]);return n}function ke(r,t,e){var n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var s="",u=t;u<e;++u)s+=ze[r[u]];return s}function je(r,t,e){for(var n=r.slice(t,e),s="",u=0;u<n.length-1;u+=2)s+=String.fromCharCode(n[u]+n[u+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(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+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],u=1,h=0;++h<e&&(u*=256);)s+=this[t+h]*u;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],u=1;e>0&&(u*=256);)s+=this[t+--e]*u;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],u=1,h=0;++h<e&&(u*=256);)s+=this[t+h]*u;return u*=128,s>=u&&(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,u=1,h=this[t+--s];s>0&&(u*=256);)h+=this[t+--s]*u;return u*=128,h>=u&&(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 k(r,t,e,n,s,u){if(!a.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<u)throw new RangeError('"value" argument is out of bounds');if(e+n>r.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 u=Math.pow(2,8*n)-1;k(this,t,e,n,u,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 u=Math.pow(2,8*n)-1;k(this,t,e,n,u,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||k(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||k(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||k(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||k(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||k(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 u=Math.pow(2,8*n-1);k(this,t,e,n,u-1,-u)}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 u=Math.pow(2,8*n-1);k(this,t,e,n,u-1,-u)}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||k(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||k(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||k(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||k(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||k(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(r,t,e,n,s,u){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function It(r,t,e,n,s){return t=+t,e=e>>>0,s||jt(r,t,e,4),p.write(r,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 Ut(r,t,e,n,s){return t=+t,e=e>>>0,s||jt(r,t,e,8),p.write(r,t,e,n,52,8),e+8}a.prototype.writeDoubleLE=function(t,e,n){return Ut(this,t,e,!0,n)},a.prototype.writeDoubleBE=function(t,e,n){return Ut(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 u=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),u},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 u=t.charCodeAt(0);(s==="utf8"&&u<128||s==="latin1")&&(t=u)}}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 Ie=/[^+/0-9A-Za-z-_]/g;function Ue(r){if(r=r.split("=")[0],r=r.trim().replace(Ie,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function it(r,t){t=t||1/0;for(var e,n=r.length,s=null,u=[],h=0;h<n;++h){if(e=r.charCodeAt(h),e>55295&&e<57344){if(!s){if(e>56319){(t-=3)>-1&&u.push(239,191,189);continue}else if(h+1===n){(t-=3)>-1&&u.push(239,191,189);continue}s=e;continue}if(e<56320){(t-=3)>-1&&u.push(239,191,189),s=e;continue}e=(s-55296<<10|e-56320)+65536}else s&&(t-=3)>-1&&u.push(239,191,189);if(s=null,e<128){if((t-=1)<0)break;u.push(e)}else if(e<2048){if((t-=2)<0)break;u.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;u.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;u.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return u}function Oe(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Te(r,t){for(var e,n,s,u=[],h=0;h<r.length&&!((t-=2)<0);++h)e=r.charCodeAt(h),n=e>>8,s=e%256,u.push(s),u.push(n);return u}function Ot(r){return i.toByteArray(Ue(r))}function G(r,t,e,n){for(var s=0;s<n&&!(s+e>=t.length||s>=r.length);++s)t[s+e]=r[s];return s}function T(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function nt(r){return r!==r}var ze=function(){for(var r="0123456789abcdef",t=new Array(256),e=0;e<16;++e)for(var n=e*16,s=0;s<16;++s)t[n+s]=r[e]+r[s];return t}()})(Xt);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(o,i){var p=Xt,c=p.Buffer;function f(l,a){for(var x in l)a[x]=l[x]}c.from&&c.alloc&&c.allocUnsafe&&c.allocUnsafeSlow?o.exports=p:(f(p,i),i.Buffer=m);function m(l,a,x){return c(l,a,x)}m.prototype=Object.create(c.prototype),f(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,i){this._block=ee.alloc(o),this._finalSize=i,this._blockSize=o,this._len=0}et.prototype.update=function(o,i){typeof o=="string"&&(i=i||"utf8",o=ee.from(o,i));for(var p=this._block,c=this._blockSize,f=o.length,m=this._len,l=0;l<f;){for(var a=m%c,x=Math.min(f-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+=f,this};et.prototype.digest=function(o){var i=this._len%this._blockSize;this._block[i]=128,this._block.fill(0,i+1),i>=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,f=(p-c)/4294967296;this._block.writeUInt32BE(f,this._blockSize-8),this._block.writeUInt32BE(c,this._blockSize-4)}this._update(this._block);var m=this._hash();return o?m.toString(o):m};et.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var lr=et,ur=er,re=lr,fr=te.Buffer,mr=[1518500249,1859775393,-1894007588,-899497514],hr=new Array(80);function Y(){this.init(),this._w=hr,re.call(this,64,56)}ur(Y,re);Y.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function xr(o){return o<<1|o>>>31}function dr(o){return o<<5|o>>>27}function wr(o){return o<<30|o>>>2}function gr(o,i,p,c){return o===0?i&p|~i&c:o===2?i&p|i&c|p&c:i^p^c}Y.prototype._update=function(o){for(var i=this._w,p=this._a|0,c=this._b|0,f=this._c|0,m=this._d|0,l=this._e|0,a=0;a<16;++a)i[a]=o.readInt32BE(a*4);for(;a<80;++a)i[a]=xr(i[a-3]^i[a-8]^i[a-14]^i[a-16]);for(var x=0;x<80;++x){var d=~~(x/20),E=dr(p)+gr(d,c,f,m)+l+i[x]+mr[d]|0;l=m,m=f,f=wr(c),c=p,p=E}this._a=p+this._a|0,this._b=c+this._b|0,this._c=f+this._c|0,this._d=m+this._d|0,this._e=l+this._e|0};Y.prototype._hash=function(){var o=fr.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 yr=Y;const vr=tr(yr),gt=new Error("File system not available.");function br(o,i,p){throw gt}function ie(o){throw gt}function Er(o){throw gt}const Fr=async o=>ie();function _r(o){let i="";for(let p=0;p<o.length;p+=2)i+=String.fromCharCode(parseInt(o.substr(p,2),16));return btoa(i)}const rt=(o,i="sha1")=>{if(i!=="sha1")throw new Error("Only sha1 algorithm is available.");const p=new vr;return _r(p.update(o).digest("hex"))};function st(o){return[$,P].includes(o.type)}function ct(o){return[Yt,$,P,K,Gt].includes(o.type)}function R(o,i,p,c,f="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:i,scope:f};p&&(m.attachments=p);try{c==null||c().parse(m.input)}catch(l){throw new Error(`Invalid action input: ${l}`)}return m}function ne(o,i=dt){return(p,c,f,m)=>i(p,c,o,f,m)}const oe=(o,i)=>({name:"",documentType:"",revision:{global:0,local:0},created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...o,state:(i==null?void 0:i(o==null?void 0:o.state))??(o==null?void 0:o.state)??{global:{},local:{}}}),ae=(o,i)=>{const p=oe(o,i);return{...p,initialState:p,operations:{global:[],local:[]},clipboard:[]}},yt=(o,i="global")=>rt(Ne(o.state[i])),Ar=(o,i=1e3)=>{const p=Math.random()*i;return rt(`${(o??new Date).toISOString()}${p}`)};function J(o){return D.castImmutable(D.freeze(o,!0))}function pe(o,i){const p=[...o];let c=i||0,f=p.length>0?p[p.length-1].index:0;const m=[];for(const l of p.reverse()){if(c>0){const d=f-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}f=l.index,m.push(a)}return m.reverse()}function Sr(o){return Object.values(o).flatMap(i=>i).sort((i,p)=>new Date(i.timestamp).getTime()-new Date(p.timestamp).getTime())}function se(o){return Object.values(o).flatMap(i=>i).sort((i,p)=>new Date(i.operation.timestamp).getTime()-new Date(p.operation.timestamp).getTime())}function Q(o,i,p,c,f,m=dt,l={}){const a=ne(p,m);return vt(o,i,a,c,f,l)}function vt(o,i,p,c,f,m={}){const l=ae(o),a=Object.keys(i).reduce((g,v)=>{const y=v;return{...g,[y]:i[y].slice(0,f==null?void 0:f.revision[y])}},{}),x=Object.keys(a).reduce((g,v)=>{const y=v;return{...g,[y]:pe(a[y],m[y])}},{}),d=se(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,O=f&&f.revision[y]<i[y].length?i[y].slice(f.revision[y]):[];return{...g,[y]:[...d.operations[y].map((j,W)=>{var C;return{...j,timestamp:((C=i[y][W])==null?void 0:C.timestamp)??j.timestamp}}),...O]}},{global:[],local:[]});return{...d,operations:E}}const ce=o=>R("SET_NAME",o,void 0,ht,void 0),le=(o=1,i="global")=>R("UNDO",o,void 0,xt,i),ue=(o=1,i="global")=>R("REDO",o,void 0,mt,i),fe=(o,i,p="global")=>R("PRUNE",{start:o,end:i},void 0,ft,p),bt=(o,i)=>R("LOAD_STATE",{state:o,operations:i},void 0,ut),Et=(o="global")=>R("NOOP",{},void 0,void 0,o),Br=Object.freeze(Object.defineProperty({__proto__:null,loadState:bt,noop:Et,prune:fe,redo:ue,setName:ce,undo:le},Symbol.toStringTag,{value:"Module"})),me={"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(me);var I=function(o,i,p,c){if(p==="a"&&!c)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?o!==i||!c:!i.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:i.get(o)},q,H,N;class kr{constructor(...i){q.set(this,new Map),H.set(this,new Map),N.set(this,new Map);for(const p of i)this.define(p)}define(i,p=!1){for(let[c,f]of Object.entries(i)){c=c.toLowerCase(),f=f.map(a=>a.toLowerCase()),I(this,N,"f").has(c)||I(this,N,"f").set(c,new Set);const m=I(this,N,"f").get(c);let l=!0;for(let a of f){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(i){if(typeof i!="string")return null;const p=i.replace(/^.*[/\\]/,"").toLowerCase(),c=p.replace(/^.*\./,"").toLowerCase(),f=p.length<i.length;return!(c.length<p.length-1)&&f?null:I(this,q,"f").get(c)??null}getExtension(i){var p;return typeof i!="string"?null:(i=(p=i==null?void 0:i.split)==null?void 0:p.call(i,";")[0],(i&&I(this,H,"f").get(i.trim().toLowerCase()))??null)}getAllExtensions(i){return typeof i!="string"?null:I(this,N,"f").get(i.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 i of I(this,N,"f").values())Object.freeze(i);return this}_getTestState(){return{types:I(this,q,"f"),extensions:I(this,H,"f")}}}q=new WeakMap,H=new WeakMap,N=new WeakMap;const jr=new kr(me)._freeze(),Ft=async o=>{const i=new Dt,{name:p,revision:c,documentType:f,created:m,lastModified:l}=o,a={name:p,revision:c,documentType:f,created:m,lastModified:l};return i.file("header.json",JSON.stringify(a,null,2)),i.file("state.json",JSON.stringify(o.initialState||{},null,2)),i.file("operations.json",JSON.stringify(o.operations,null,2)),Object.keys(o.attachments).forEach(d=>{const{data:E,...g}=o.attachments[d];i.file(d,E,{base64:!0,createFolders:!0,comment:JSON.stringify(g)})}),i},he=async(o,i,p,c)=>{await(await Ft(o)).generateAsync({type:"uint8array",streamFiles:!0});const m=c??o.name,l=`.${p}.zip`;return br(i,m.endsWith(l)?m:`${m}${l}`)},Ir=async(o,i)=>{const c=await(await Ft(o)).generateAsync({type:"blob"}),f=await i.createWritable();await f.write(c),await f.close()},lt=async(o,i)=>{const p=ie();return xe(p,i)},xe=async(o,i)=>{const p=new Dt;return await p.loadAsync(o),Ur(p,i)};async function Ur(o,i){const p=o.file("state.json");if(!p)throw new Error("Initial state not found");const c=await p.async("string"),f=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(f,x,i,void 0,l);return l&&(d={...d,...l}),d}function de(o){const i=o.replace(/^.*\./,"")||void 0,p=o.replace(/^.*[/\\]/,"")||void 0;return{extension:i,fileName:p}}async function Or(o){const{buffer:i,mimeType:p="application/octet-stream"}=await Er(),c=de(o),f=i.toString("base64");return{data:f,hash:rt(f),mimeType:p,...c}}async function Tr(o){const i=await Fr(),p=jr.getType(o)||"application/octet-stream",c=de(o),f=i.toString("base64");return{data:f,hash:rt(f),mimeType:p,...c}}class zr{constructor(i,p,c){X(this,"_document");X(this,"_reducer");X(this,"_signalDispatch");this._reducer=i,this._document=p,this._signalDispatch=c}dispatch(i,p){return this._document=this._reducer(this._document,i,this._signalDispatch,p),this}saveToFile(i,p,c){return he(this._document,i,p,c)}async loadFromFile(i){this._document=await lt(i,this._reducer)}static async stateFromFile(i,p){return await lt(i,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(i){return this._document.revision[i]}get initialState(){return J(this._document.initialState)}toDocument(){return J(this._document)}getAttachment(i){return this._document.attachments[i]}setName(i){return this.dispatch(ce(i)),this}undo(i){return this.dispatch(le(i)),this}redo(i){return this.dispatch(ue(i)),this}prune(i,p){return this.dispatch(fe(i,p)),this}loadState(i,p){return this.dispatch(bt(i,p)),this}}function Dr(o,i){i.forEach(p=>{Object.getOwnPropertyNames(p.prototype).forEach(c=>{Object.defineProperty(o.prototype,c,Object.getOwnPropertyDescriptor(p.prototype,c)||Object.create(null))})})}exports.BaseActions=Br;exports.BaseDocument=zr;exports.applyMixins=Dr;exports.baseReducer=dt;exports.createAction=R;exports.createDocument=ae;exports.createExtendedState=oe;exports.createReducer=ne;exports.createZip=Ft;exports.getLocalFile=Tr;exports.getRemoteFile=Or;exports.hashDocument=yt;exports.hashKey=Ar;exports.isBaseAction=ct;exports.isUndoRedo=st;exports.loadFromFile=lt;exports.loadFromInput=xe;exports.mapSkippedOperations=pe;exports.processUndoRedo=Vt;exports.readOnly=J;exports.replayDocument=vt;exports.replayOperations=Q;exports.saveToFile=he;exports.saveToFileHandle=Ir;exports.sortMappedOperations=se;exports.sortOperations=Sr;exports.zod=Pe;
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: import("vite").UserConfig;
2
2
  export default _default;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-ff6617a2.js");require("immer");require("json-stringify-deterministic");require("crypto");require("fs");require("https");require("path");require("jszip");const e=require("./internal/index-433d6a9b.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-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,4 +1,4 @@
1
- import "./internal/object-305e4c59.js";
1
+ import "./internal/object-qR4Tf50L.js";
2
2
  import "immer";
3
3
  import "json-stringify-deterministic";
4
4
  import "crypto";
@@ -6,15 +6,14 @@ import "fs";
6
6
  import "https";
7
7
  import "path";
8
8
  import "jszip";
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-a46dcf07.js";
10
- import "zod";
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";
11
10
  export {
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
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
20
19
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-ff6617a2.js"),r=require("./internal/index-78c035e1.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
+ "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,19 +1,11 @@
1
- import { B as n, h as x, g as d, x as u, y as f, z as l } from "./internal/object-305e4c59.js";
2
- import { i as B } from "./internal/index-2d55ed8c.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";
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";
11
3
  export {
12
- n as BaseDocument,
13
- x as actions,
14
- d as applyMixins,
15
- u as baseReducer,
16
- f as processUndoRedo,
17
- B as utils,
18
- l as z
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
19
11
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-78c035e1.js"),o=require("./internal/index-433d6a9b.js");require("./internal/object-ff6617a2.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
+ "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,21 +1,12 @@
1
- import { D as o } from "./internal/index-2d55ed8c.js";
2
- import { D as t } from "./internal/index-a46dcf07.js";
3
- import "./internal/object-305e4c59.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 = {
1
+ import { D as o } from "./internal/index-Rc3pWGDQ.js";
2
+ import { D as e } from "./internal/index-uFGJxYP7.js";
3
+ const n = {
13
4
  "powerhouse/document": o,
14
- "powerhouse/document-model": t
15
- }, l = { Document: o, DocumentModel: t };
5
+ "powerhouse/document-model": e
6
+ }, s = { Document: o, DocumentModel: e };
16
7
  export {
17
8
  o as Document,
18
- t as DocumentModel,
19
- a as DocumentModels,
20
- l as default
9
+ e as DocumentModel,
10
+ n as DocumentModels,
11
+ s as default
21
12
  };
@@ -1 +1 @@
1
- "use strict";const e=require("./object-be1b0c52.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,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
+ "use strict";const e=require("./object-51-uoy0f.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,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,4 +1,4 @@
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, l as d, e as u, q as m, r as y, t as O, u as b, s as _, d as g, v as F, w as f, B as D, h as S, g as h, x as j, y as v, z as x } from "./object-4b5800c0.js";
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, l as d, e as u, q as m, r as y, t as O, u as b, s as _, d as g, v as F, w as f, B as D, h as S, g as h, x as j, y as v, z as x } from "./object-qR4Tf50L.js";
2
2
  const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  createAction: e,
@@ -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-ff6617a2.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-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:`{
2
2
  "id": "",
3
3
  "name": "",
4
4
  "extension": "",
@@ -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-305e4c59.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-qR4Tf50L.js";
5
5
  import "immer";
6
6
  import "json-stringify-deterministic";
7
7
  import "crypto";
@@ -0,0 +1 @@
1
+ "use strict";var St=Object.defineProperty;var kt=(e,t,i)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var D=(e,t,i)=>(kt(e,typeof t!="symbol"?t+"":t,i),i);const g=require("immer"),_t=require("json-stringify-deterministic"),p=require("zod"),Dt=require("crypto"),A=require("fs"),Et=require("https"),Tt=require("path"),K=require("jszip"),G=e=>e!=null,Nt=p.z.any().refine(e=>G(e)),V=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 At(){return p.z.object({__typename:p.z.literal("Action").optional(),type:p.z.string()})}function k(){return p.z.literal("global").or(p.z.literal("local"))}function et(){return p.z.union([it(),nt(),ot(),st(),pt()])}function Ft(){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(()=>q()),type:V,scope:k()})}function q(){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 Mt(){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(()=>I()),type:Q,scope:k()})}function I(){return p.z.object({end:p.z.number().nullish(),start:p.z.number().nullish()})}const P=p.z.number;function ot(){return p.z.object({input:P(),type:X,scope:k()})}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:k()})}const qt=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:At,BaseActionSchema:et,DocumentFileSchema:Ft,LoadStateActionInputSchema:q,LoadStateActionSchema:it,LoadStateActionStateInputSchema:at,Load_StateSchema:V,OperationSchema:Mt,OperationScopeSchema:k,PruneActionInputSchema:I,PruneActionSchema:nt,PruneSchema:Q,RedoActionInputSchema:P,RedoActionSchema:ot,RedoSchema:X,SetNameActionInputSchema:L,SetNameActionSchema:st,SetNameOperationSchema:Rt,Set_NameSchema:Y,UndoActionInputSchema:U,UndoActionSchema:pt,UndoSchema:tt,definedNonNullAnySchema:Nt,isDefinedNonNullAny:G},Symbol.toStringTag,{value:"Module"}));function It(e,t){return{...e,name:t}}function Pt(e,t,i){const{scope:a,input:o}=t,l={document:e,action:t,skip:i};return g.produce(l,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),r=s.type==="NOOP"&&s.skip>0;if(n.skip+=o,r&&(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 c=n.document.operations[a].length-1;let f=o,d=r?c-s.skip:c;for(;f>0&&d>=0;){const u=n.document.operations[a][d];u.type==="NOOP"&&u.skip>0?(d=d-(u.skip+1),n.skip+=u.skip+1):(n.document.clipboard.push({...u}),f--,d--)}n.action=W(a)})}function Lt(e,t,i){const{scope:a,input:o}=t,l={document:e,action:t,skip:i};return g.produce(l,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(c=>c.scope===a);if(s<0)throw new Error(`Cannot redo: no operations in clipboard for scope "${a}"`);const r=n.document.clipboard.splice(s,1)[0];n.action=g.castDraft({type:r.type,scope:r.scope,input:r.input})})}function Ut(e,t,i){const{scope:a}=t,o=e.operations[a];let{input:{start:l,end:n}}=t;l=l||0,n=n||o.length;const s=o.slice(l,n),r=o.slice(0,l),c=o.slice(n),f=E(e.initialState,{...e.operations,[a]:r.concat(s)},i),{name:d,state:u}=f,m=r.length,O=r.length?r[r.length-1].timestamp:c.length?c[0].timestamp:new Date().toISOString();return E(e.initialState,{...e.operations,[a]:[...r,{...B({name:d,state:u},s.length),timestamp:O,index:m,hash:$({state:u},"global")},...c.map((w,N)=>({...w,index:m+N+1}))]},i)}function Ct(e,t){return{...e,name:t.name,state:t.state??{global:{},local:{}}}}const ct="SET_NAME",y="UNDO",j="REDO",_="PRUNE",lt="LOAD_STATE";function $t(e,t){const i=e.revision[t.scope];return[y,j,_].includes(t.type)?i:i+1}function Jt(e,t){return{...e,revision:{...e.revision,[t.scope]:$t(e,t)},lastModified:new Date().toISOString()}}function Bt(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 Wt(e,t,i=0){let a=Bt(e,t,i);return a=Jt(a,t),a}function Zt(e,t,i){switch(et().parse(t),t.type){case ct:return It(e,t.input);case _:return Ut(e,t,i);case lt:return Ct(e,t.input.state);default:return e}}function rt(e,t,i){switch(t.type){case y:return Pt(e,t,i);case j:return Lt(e,t,i);default:return{document:e,action:t,skip:i}}}function C(e,t,i,a,o={}){const{skip:l,ignoreSkipOperations:n=!1}=o;let s={...t},r=l||0,c=e,f=[...e.clipboard];if(F(s)){const{skip:d,action:u,document:m}=rt(e,s,r);s=u,r=d,c=m,f=[...c.clipboard]}return M(s)&&(c=Zt(c,s,i)),r>0&&!n&&(c=E(c.initialState,c.operations,i,void 0,void 0,void 0,{[s.scope]:r})),c=Wt(c,s,r),c=g.produce(c,d=>{const u=i(d.state,s,a),m=F(t)?[...f]:[];if(u)return g.castDraft({...c,clipboard:[...m],state:u});d.clipboard=g.castDraft([...m])}),g.produce(c,d=>{if([y,j,_].includes(s.type))return d;const u=s.scope||"global";d.operations[u][d.operations[u].length-1].hash=$(d,u),!M(s)&&s.attachments&&s.attachments.forEach(m=>{const{hash:O,...w}=m;d.attachments[O]={...w}})})}function Ht(e,t,i){const a=Tt.join(e,t);return A.mkdirSync(e,{recursive:!0}),new Promise((o,l)=>{try{A.writeFile(a,i,{},n=>{n?l(n):o(a)})}catch(n){l(n)}})}function mt(e){return A.readFileSync(e)}function Kt(e){return new Promise((t,i)=>{Et.get(e,a=>{const o=[],l=a.headers["content-type"];a.on("data",n=>{o.push(n)}),a.on("end",()=>{t({buffer:Buffer.concat(o),mimeType:l})})}).on("error",a=>{i(a)})})}const Gt=async e=>mt(e),T=(e,t="sha1")=>Dt.createHash(t).update(e).digest("base64");function F(e){return[y,j].includes(e.type)}function M(e){return[ct,y,j,_,lt].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 l={type:e,input:t,scope:o};i&&(l.attachments=i);try{a==null||a().parse(l.input)}catch(n){throw new Error(`Invalid action input: ${n}`)}return l}function dt(e,t=C){return(i,a,o,l)=>t(i,a,e,o,l)}const ut=(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:{}}}),xt=(e,t)=>{const i=ut(e,t);return{...i,initialState:i,operations:{global:[],local:[]},clipboard:[]}},$=(e,t="global")=>T(_t(e.state[t])),Vt=(e,t=1e3)=>{const i=Math.random()*t;return T(`${(e??new Date).toISOString()}${i}`)};function z(e){return g.castImmutable(g.freeze(e,!0))}function ft(e,t){const i=[...e];let a=t||0,o=i.length>0?i[i.length-1].index:0;const l=[];for(const n of i.reverse()){if(a>0){const c=o-n.index;a-=c}if(a<0)throw new Error("Invalid operation index, missing operations");const s={ignore:a>0,operation:n},r=n.skip>0?n.skip+1:0;if(r>0&&r>a){const c=r-a;a=a+c}o=n.index,l.push(s)}return l.reverse()}function Qt(e){return Object.values(e).flatMap(t=>t).sort((t,i)=>new Date(t.timestamp).getTime()-new Date(i.timestamp).getTime())}function gt(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,l=C,n={}){const s=dt(i,l);return J(e,t,s,a,o,n)}function J(e,t,i,a,o,l={}){const n=xt(e),s=Object.keys(t).reduce((d,u)=>{const m=u;return{...d,[m]:t[m].slice(0,o==null?void 0:o.revision[m])}},{}),r=Object.keys(s).reduce((d,u)=>{const m=u;return{...d,[m]:ft(s[m],l[m])}},{}),c=gt(r).reduce((d,{ignore:u,operation:m})=>u?i(d,W(m.scope),a,{skip:m.skip,ignoreSkipOperations:!0}):i(d,m,a,{skip:m.skip,ignoreSkipOperations:!0}),n),f=Object.keys(c.operations).reduce((d,u)=>{const m=u,O=o&&o.revision[m]<t[m].length?t[m].slice(o.revision[m]):[];return{...d,[m]:[...c.operations[m].map((w,N)=>{var H;return{...w,timestamp:((H=t[m][N])==null?void 0:H.timestamp)??w.timestamp}}),...O]}},{global:[],local:[]});return{...c,operations:f}}const ht=e=>b("SET_NAME",e,void 0,L,void 0),bt=(e=1,t="global")=>b("UNDO",e,void 0,U,t),wt=(e=1,t="global")=>b("REDO",e,void 0,P,t),vt=(e,t,i="global")=>b("PRUNE",{start:e,end:t},void 0,I,i),B=(e,t)=>b("LOAD_STATE",{state:e,operations:t},void 0,q),W=(e="global")=>b("NOOP",{},void 0,void 0,e),Xt=Object.freeze(Object.defineProperty({__proto__:null,loadState:B,noop:W,prune:vt,redo:wt,setName:ht,undo:bt},Symbol.toStringTag,{value:"Module"})),yt={"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(yt);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 Yt{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 l=x(this,h,"f").get(a);let n=!0;for(let s of o){const r=s.startsWith("*");if(s=r?s.slice(1):s,l==null||l.add(s),n&&x(this,S,"f").set(a,s),n=!1,r)continue;const c=x(this,v,"f").get(s);if(c&&c!=a&&!i)throw new Error(`"${a} -> ${s}" conflicts with "${c} -> ${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 te=new Yt(yt)._freeze(),Z=async e=>{const t=new K,{name:i,revision:a,documentType:o,created:l,lastModified:n}=e,s={name:i,revision:a,documentType:o,created:l,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(c=>{const{data:f,...d}=e.attachments[c];t.file(c,f,{base64:!0,createFolders:!0,comment:JSON.stringify(d)})}),t},jt=async(e,t,i,a)=>{const l=await(await Z(e)).generateAsync({type:"uint8array",streamFiles:!0}),n=a??e.name,s=`.${i}.zip`;return Ht(t,n.endsWith(s)?n:`${n}${s}`,l)},ee=async(e,t)=>{const a=await(await Z(e)).generateAsync({type:"blob"}),o=await t.createWritable();await o.write(a),await o.close()},R=async(e,t)=>{const i=mt(e);return Ot(i,t)},Ot=async(e,t)=>{const i=new K;return await i.loadAsync(e),ie(i,t)};async function ie(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),l=e.file("header.json");let n;l&&(n=JSON.parse(await l.async("string")));const s=e.file("operations.json");if(!s)throw new Error("Operations history not found");const r=JSON.parse(await s.async("string"));let c=J(o,r,t,void 0,n);return n&&(c={...c,...n}),c}function zt(e){const t=e.replace(/^.*\./,"")||void 0,i=e.replace(/^.*[/\\]/,"")||void 0;return{extension:t,fileName:i}}async function ae(e){const{buffer:t,mimeType:i="application/octet-stream"}=await Kt(e),a=zt(e),o=t.toString("base64");return{data:o,hash:T(o),mimeType:i,...a}}async function ne(e){const t=await Gt(e),i=te.getType(e)||"application/octet-stream",a=zt(e),o=t.toString("base64");return{data:o,hash:T(o),mimeType:i,...a}}class oe{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 jt(this._document,t,i,a)}async loadFromFile(t){this._document=await R(t,this._reducer)}static async stateFromFile(t,i){return await R(t,i)}get state(){return z(this._document.state)}get operations(){return z(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 z(this._document.initialState)}toDocument(){return z(this._document)}getAttachment(t){return this._document.attachments[t]}setName(t){return this.dispatch(ht(t)),this}undo(t){return this.dispatch(bt(t)),this}redo(t){return this.dispatch(wt(t)),this}prune(t,i){return this.dispatch(vt(t,i)),this}loadState(t,i){return this.dispatch(B(t,i)),this}}function se(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=Xt;exports.BaseDocument=oe;exports.applyMixins=se;exports.baseReducer=C;exports.createAction=b;exports.createDocument=xt;exports.createExtendedState=ut;exports.createReducer=dt;exports.createZip=Z;exports.getLocalFile=ne;exports.getRemoteFile=ae;exports.hashDocument=$;exports.hashKey=Vt;exports.isBaseAction=M;exports.isUndoRedo=F;exports.loadFromFile=R;exports.loadFromInput=Ot;exports.mapSkippedOperations=ft;exports.processUndoRedo=rt;exports.readOnly=z;exports.replayDocument=J;exports.replayOperations=E;exports.saveToFile=jt;exports.saveToFileHandle=ee;exports.sortMappedOperations=gt;exports.sortOperations=Qt;exports.zod=qt;