document-model 1.0.26 → 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.
- package/dist/browser/document-model.cjs +1 -1
- package/dist/browser/document-model.js +8 -9
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +9 -12
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +8 -13
- package/dist/browser/internal/index-FBdtB-Z0.js +38 -0
- package/dist/browser/internal/index-MQO6aDba.js +1 -0
- package/dist/browser/internal/{index-gREVUw-G.js → index-oR1tzXEU.js} +1 -1
- package/dist/browser/internal/{index-IVF7gvRz.js → index-qiOnVXbI.js} +2 -2
- package/dist/browser/internal/object-P7bHOWu_.js +1912 -0
- package/dist/browser/internal/object-RV2GJjkF.js +6 -0
- package/dist/browser/src/document/actions/index.d.ts +3 -3
- package/dist/browser/src/document/object.d.ts +63 -0
- package/dist/browser/src/document/reducer.d.ts +16 -0
- package/dist/browser/src/document/schema/types.d.ts +9 -12
- package/dist/browser/src/document/signal.d.ts +1 -0
- package/dist/browser/src/document/types.d.ts +9 -0
- package/dist/browser/src/document/utils/base.d.ts +7 -4
- package/dist/browser/src/document/utils/index.d.ts +1 -0
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +12 -13
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +9 -16
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +8 -17
- package/dist/node/internal/index-E6Dehju3.js +1 -0
- package/dist/node/internal/index-Rc3pWGDQ.js +38 -0
- package/dist/node/internal/{index-VzErJ06c.js → index-r_Cve_NX.js} +1 -1
- package/dist/node/internal/{index-AWkBpPdl.js → index-uFGJxYP7.js} +3 -3
- package/dist/node/internal/object-51-uoy0f.js +1 -0
- package/dist/node/internal/object-qR4Tf50L.js +911 -0
- package/dist/node/src/document/actions/index.d.ts +3 -3
- package/dist/node/src/document/object.d.ts +63 -0
- package/dist/node/src/document/reducer.d.ts +16 -0
- package/dist/node/src/document/schema/types.d.ts +9 -12
- package/dist/node/src/document/signal.d.ts +1 -0
- package/dist/node/src/document/types.d.ts +9 -0
- package/dist/node/src/document/utils/base.d.ts +7 -4
- package/dist/node/src/document/utils/index.d.ts +1 -0
- package/package.json +2 -2
- package/dist/browser/internal/index-JkTAMqR0.js +0 -36
- package/dist/browser/internal/index-ZuT5Pi3Z.js +0 -1
- package/dist/browser/internal/object-1Edh7roc.js +0 -1844
- package/dist/browser/internal/object-v0zgcnse.js +0 -6
- package/dist/browser/test/document/undo.test.d.ts +0 -1
- package/dist/jest.config.d.ts +0 -8
- package/dist/node/internal/index-8_P5_maf.js +0 -1
- package/dist/node/internal/index-y-8qoZvC.js +0 -36
- package/dist/node/internal/object-6KU11KDZ.js +0 -843
- package/dist/node/internal/object-YfG4E2oW.js +0 -1
- package/dist/node/test/document/redo.test.d.ts +0 -1
- package/dist/node/test/document/undo.test.d.ts +0 -1
- package/dist/src/document/actions/creators.d.ts +0 -47
- package/dist/src/document/actions/index.d.ts +0 -10
- package/dist/src/document/actions/types.d.ts +0 -8
- package/dist/src/document/index.d.ts +0 -6
- package/dist/src/document/object.d.ts +0 -510
- package/dist/src/document/reducer.d.ts +0 -32
- package/dist/src/document/schema/index.d.ts +0 -2
- package/dist/src/document/schema/types.d.ts +0 -177
- package/dist/src/document/schema/zod.d.ts +0 -113
- package/dist/src/document/signal.d.ts +0 -28
- package/dist/src/document/types.d.ts +0 -210
- package/dist/src/document/utils/base.d.ts +0 -77
- package/dist/src/document/utils/browser.d.ts +0 -10
- package/dist/src/document/utils/file.d.ts +0 -47
- package/dist/src/document/utils/index.d.ts +0 -3
- package/dist/src/document/utils/node.d.ts +0 -9
- package/dist/src/document-model/custom/reducers/header.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/module.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-error.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation-example.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/operation.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/state.d.ts +0 -2
- package/dist/src/document-model/custom/reducers/versioning.d.ts +0 -7
- package/dist/src/document-model/custom/utils.d.ts +0 -1
- package/dist/src/document-model/gen/actions.d.ts +0 -15
- package/dist/src/document-model/gen/creators.d.ts +0 -7
- package/dist/src/document-model/gen/document-model.d.ts +0 -2
- package/dist/src/document-model/gen/header/actions.d.ts +0 -9
- package/dist/src/document-model/gen/header/creators.d.ts +0 -8
- package/dist/src/document-model/gen/header/object.d.ts +0 -12
- package/dist/src/document-model/gen/header/operations.d.ts +0 -10
- package/dist/src/document-model/gen/index.d.ts +0 -5
- package/dist/src/document-model/gen/module/actions.d.ts +0 -8
- package/dist/src/document-model/gen/module/creators.d.ts +0 -7
- package/dist/src/document-model/gen/module/object.d.ts +0 -11
- package/dist/src/document-model/gen/module/operations.d.ts +0 -9
- package/dist/src/document-model/gen/object.d.ts +0 -28
- package/dist/src/document-model/gen/operation/actions.d.ts +0 -13
- package/dist/src/document-model/gen/operation/creators.d.ts +0 -12
- package/dist/src/document-model/gen/operation/object.d.ts +0 -16
- package/dist/src/document-model/gen/operation/operations.d.ts +0 -14
- package/dist/src/document-model/gen/operation-error/actions.d.ts +0 -10
- package/dist/src/document-model/gen/operation-error/creators.d.ts +0 -9
- package/dist/src/document-model/gen/operation-error/object.d.ts +0 -13
- package/dist/src/document-model/gen/operation-error/operations.d.ts +0 -11
- package/dist/src/document-model/gen/operation-example/actions.d.ts +0 -7
- package/dist/src/document-model/gen/operation-example/creators.d.ts +0 -6
- package/dist/src/document-model/gen/operation-example/object.d.ts +0 -10
- package/dist/src/document-model/gen/operation-example/operations.d.ts +0 -8
- package/dist/src/document-model/gen/reducer.d.ts +0 -5
- package/dist/src/document-model/gen/schema/index.d.ts +0 -2
- package/dist/src/document-model/gen/schema/types.d.ts +0 -453
- package/dist/src/document-model/gen/schema/zod.d.ts +0 -453
- package/dist/src/document-model/gen/state/actions.d.ts +0 -9
- package/dist/src/document-model/gen/state/creators.d.ts +0 -8
- package/dist/src/document-model/gen/state/object.d.ts +0 -12
- package/dist/src/document-model/gen/state/operations.d.ts +0 -10
- package/dist/src/document-model/gen/types.d.ts +0 -8
- package/dist/src/document-model/gen/utils.d.ts +0 -6
- package/dist/src/document-model/gen/versioning/actions.d.ts +0 -8
- package/dist/src/document-model/gen/versioning/creators.d.ts +0 -7
- package/dist/src/document-model/gen/versioning/object.d.ts +0 -11
- package/dist/src/document-model/gen/versioning/operations.d.ts +0 -9
- package/dist/src/document-model/index.d.ts +0 -75
- package/dist/src/index.d.ts +0 -25
- package/dist/test/document/local.test.d.ts +0 -1
- package/dist/test/document/object.test.d.ts +0 -1
- package/dist/test/document/prune.test.d.ts +0 -1
- package/dist/test/document/redo.test.d.ts +0 -1
- package/dist/test/document/reducer.test.d.ts +0 -1
- package/dist/test/document/skip-operations.test.d.ts +0 -1
- package/dist/test/document/undo.test.d.ts +0 -1
- package/dist/test/document/utils.test.d.ts +0 -1
- package/dist/test/document-model/object.test.d.ts +0 -1
- package/dist/test/document-model/skip-operations.test.d.ts +0 -1
- package/dist/test/document-model/zip.test.d.ts +0 -1
- package/dist/test/helpers.d.ts +0 -32
- package/dist/vite.config.d.ts +0 -2
- package/dist/vitest.config.d.ts +0 -2
- /package/dist/{test → browser/test}/document/undo-redo.test.d.ts +0 -0
- /package/dist/{browser/test/document/redo.test.d.ts → node/test/document/undo-redo.test.d.ts} +0 -0
|
@@ -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,7 +1,7 @@
|
|
|
1
|
-
import { Action, Document, ImmutableStateReducer, PruneAction, RedoAction, State, UndoAction } from '../types';
|
|
1
|
+
import { Action, Document, ImmutableStateReducer, PruneAction, RedoAction, State, UndoAction, UndoRedoProcessResult } from '../types';
|
|
2
2
|
export declare function setNameOperation<T>(document: T, name: string): T;
|
|
3
|
-
export declare function undoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: UndoAction,
|
|
4
|
-
export declare function redoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: RedoAction,
|
|
3
|
+
export declare function undoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: UndoAction, skip: number): UndoRedoProcessResult<T, A, L>;
|
|
4
|
+
export declare function redoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: RedoAction, skip: number): UndoRedoProcessResult<T, A, L>;
|
|
5
5
|
export declare function pruneOperation<T, A extends Action, L>(document: Document<T, A, L>, action: PruneAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
|
|
6
6
|
export declare function loadStateOperation<T, A extends Action, L>(oldDocument: Document<T, A, L>, newDocument: {
|
|
7
7
|
name: string;
|
|
@@ -400,6 +400,69 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
400
400
|
};
|
|
401
401
|
};
|
|
402
402
|
};
|
|
403
|
+
readonly clipboard: readonly ({
|
|
404
|
+
readonly input: {
|
|
405
|
+
readonly operations: number;
|
|
406
|
+
readonly state: {
|
|
407
|
+
readonly data?: unknown;
|
|
408
|
+
readonly name: string;
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
readonly type: "LOAD_STATE";
|
|
412
|
+
readonly scope: OperationScope;
|
|
413
|
+
readonly index: number;
|
|
414
|
+
readonly timestamp: string;
|
|
415
|
+
readonly hash: string;
|
|
416
|
+
readonly skip: number;
|
|
417
|
+
} | {
|
|
418
|
+
readonly input: {
|
|
419
|
+
readonly end?: import("./types").InputMaybe<number>;
|
|
420
|
+
readonly start?: import("./types").InputMaybe<number>;
|
|
421
|
+
};
|
|
422
|
+
readonly type: "PRUNE";
|
|
423
|
+
readonly scope: OperationScope;
|
|
424
|
+
readonly index: number;
|
|
425
|
+
readonly timestamp: string;
|
|
426
|
+
readonly hash: string;
|
|
427
|
+
readonly skip: number;
|
|
428
|
+
} | {
|
|
429
|
+
readonly input: number;
|
|
430
|
+
readonly type: "REDO";
|
|
431
|
+
readonly scope: OperationScope;
|
|
432
|
+
readonly index: number;
|
|
433
|
+
readonly timestamp: string;
|
|
434
|
+
readonly hash: string;
|
|
435
|
+
readonly skip: number;
|
|
436
|
+
} | {
|
|
437
|
+
readonly input: string;
|
|
438
|
+
readonly type: "SET_NAME";
|
|
439
|
+
readonly scope: "global";
|
|
440
|
+
readonly index: number;
|
|
441
|
+
readonly timestamp: string;
|
|
442
|
+
readonly hash: string;
|
|
443
|
+
readonly skip: number;
|
|
444
|
+
} | {
|
|
445
|
+
readonly input: number;
|
|
446
|
+
readonly type: "UNDO";
|
|
447
|
+
readonly scope: OperationScope;
|
|
448
|
+
readonly index: number;
|
|
449
|
+
readonly timestamp: string;
|
|
450
|
+
readonly hash: string;
|
|
451
|
+
readonly skip: number;
|
|
452
|
+
} | {
|
|
453
|
+
readonly input: unknown;
|
|
454
|
+
readonly type: "NOOP";
|
|
455
|
+
readonly scope: OperationScope;
|
|
456
|
+
readonly index: number;
|
|
457
|
+
readonly timestamp: string;
|
|
458
|
+
readonly hash: string;
|
|
459
|
+
readonly skip: number;
|
|
460
|
+
} | import("immer").Immutable<A & {
|
|
461
|
+
index: number;
|
|
462
|
+
timestamp: string;
|
|
463
|
+
hash: string;
|
|
464
|
+
skip: number;
|
|
465
|
+
}>)[];
|
|
403
466
|
};
|
|
404
467
|
/**
|
|
405
468
|
* Gets the attachment associated with the given key.
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { BaseAction } from './actions/types';
|
|
2
|
+
import { UndoRedoAction } from './schema';
|
|
2
3
|
import { Action, Document, ImmutableStateReducer, ReducerOptions } from './types';
|
|
3
4
|
import { SignalDispatch } from './signal';
|
|
5
|
+
type UndoRedoProcessResult<T, A extends Action, L> = {
|
|
6
|
+
document: Document<T, A, L>;
|
|
7
|
+
action: A | BaseAction;
|
|
8
|
+
skip: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Processes an UNDO or REDO action.
|
|
12
|
+
*
|
|
13
|
+
* @param document The current state of the document.
|
|
14
|
+
* @param action The action being applied to the document.
|
|
15
|
+
* @param skip The number of operations to skip before applying the action.
|
|
16
|
+
* @returns The updated document, calculated skip value and transformed action (if apply).
|
|
17
|
+
*/
|
|
18
|
+
export declare function processUndoRedo<T, A extends Action, L>(document: Document<T, A, L>, action: UndoRedoAction, skip: number): UndoRedoProcessResult<T, A, L>;
|
|
4
19
|
/**
|
|
5
20
|
* Base document reducer that wraps a custom document reducer and handles
|
|
6
21
|
* document-level actions such as undo, redo, prune, and set name.
|
|
@@ -14,3 +29,4 @@ import { SignalDispatch } from './signal';
|
|
|
14
29
|
* @returns The new state of the document.
|
|
15
30
|
*/
|
|
16
31
|
export declare function baseReducer<T, A extends Action, L>(document: Document<T, A, L>, action: A | BaseAction, customReducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, options?: ReducerOptions): Document<T, A, L>;
|
|
32
|
+
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { OperationScope } from '..';
|
|
2
2
|
export type Maybe<T> = T | null;
|
|
3
3
|
export type InputMaybe<T> = T | null | undefined;
|
|
4
|
-
export type Exact<T extends {
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
}> = {
|
|
4
|
+
export type Exact<T extends Record<string, unknown>> = {
|
|
7
5
|
[K in keyof T]: T[K];
|
|
8
6
|
};
|
|
9
7
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
@@ -12,9 +10,7 @@ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
|
12
10
|
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
13
11
|
[SubKey in K]: Maybe<T[SubKey]>;
|
|
14
12
|
};
|
|
15
|
-
export type MakeEmpty<T extends {
|
|
16
|
-
[key: string]: unknown;
|
|
17
|
-
}, K extends keyof T> = {
|
|
13
|
+
export type MakeEmpty<T extends Record<string, unknown>, K extends keyof T> = {
|
|
18
14
|
[_ in K]?: never;
|
|
19
15
|
};
|
|
20
16
|
export type Incremental<T> = T | {
|
|
@@ -64,6 +60,7 @@ export type Action = IAction & {
|
|
|
64
60
|
type: Scalars['String']['output'];
|
|
65
61
|
};
|
|
66
62
|
export type BaseAction = LoadStateAction | PruneAction | RedoAction | SetNameAction | UndoAction | NOOPAction;
|
|
63
|
+
export type UndoRedoAction = RedoAction | UndoAction;
|
|
67
64
|
export type DocumentFile = {
|
|
68
65
|
__typename?: 'DocumentFile';
|
|
69
66
|
data: Scalars['String']['output'];
|
|
@@ -91,7 +88,7 @@ export type IOperation = {
|
|
|
91
88
|
export type Load_State = 'LOAD_STATE';
|
|
92
89
|
export type LoadStateAction = {
|
|
93
90
|
input: LoadStateActionInput;
|
|
94
|
-
type: Load_State
|
|
91
|
+
type: Load_State;
|
|
95
92
|
scope: OperationScope;
|
|
96
93
|
};
|
|
97
94
|
export type LoadStateActionInput = {
|
|
@@ -135,7 +132,7 @@ export type Operation = IOperation & {
|
|
|
135
132
|
export type Prune = 'PRUNE';
|
|
136
133
|
export type PruneAction = {
|
|
137
134
|
input: PruneActionInput;
|
|
138
|
-
type: Prune
|
|
135
|
+
type: Prune;
|
|
139
136
|
scope: OperationScope;
|
|
140
137
|
};
|
|
141
138
|
export type PruneActionInput = {
|
|
@@ -149,13 +146,13 @@ export type Query = {
|
|
|
149
146
|
export type Redo = 'REDO';
|
|
150
147
|
export type RedoAction = {
|
|
151
148
|
input: Scalars['Int']['input'];
|
|
152
|
-
type: Redo
|
|
149
|
+
type: Redo;
|
|
153
150
|
scope: OperationScope;
|
|
154
151
|
};
|
|
155
152
|
export type Set_Name = 'SET_NAME';
|
|
156
153
|
export type SetNameAction = {
|
|
157
154
|
input: Scalars['String']['input'];
|
|
158
|
-
type: Set_Name
|
|
155
|
+
type: Set_Name;
|
|
159
156
|
scope: 'global';
|
|
160
157
|
};
|
|
161
158
|
export type SetNameOperation = IOperation & {
|
|
@@ -169,12 +166,12 @@ export type SetNameOperation = IOperation & {
|
|
|
169
166
|
export type Undo = 'UNDO';
|
|
170
167
|
export type UndoAction = {
|
|
171
168
|
input: Scalars['Int']['input'];
|
|
172
|
-
type: Undo
|
|
169
|
+
type: Undo;
|
|
173
170
|
scope: OperationScope;
|
|
174
171
|
};
|
|
175
172
|
export type NOOP = 'NOOP';
|
|
176
173
|
export type NOOPAction = {
|
|
177
174
|
input: Scalars['Unknown']['input'];
|
|
178
|
-
type: NOOP
|
|
175
|
+
type: NOOP;
|
|
179
176
|
scope: OperationScope;
|
|
180
177
|
};
|
|
@@ -22,6 +22,7 @@ export type DeleteChildDocumentSignal = ISignal<'DELETE_CHILD_DOCUMENT', DeleteC
|
|
|
22
22
|
export type CopyChildDocumentInput = {
|
|
23
23
|
id: string;
|
|
24
24
|
newId: string;
|
|
25
|
+
synchronizationUnits: SynchronizationUnit[];
|
|
25
26
|
};
|
|
26
27
|
export type CopyChildDocumentSignal = ISignal<'COPY_CHILD_DOCUMENT', CopyChildDocumentInput>;
|
|
27
28
|
export type Signal = CreateChildDocumentSignal | DeleteChildDocumentSignal | CopyChildDocumentSignal;
|
|
@@ -30,6 +30,8 @@ export type ActionWithAttachment<T extends string = string, I = unknown, S exten
|
|
|
30
30
|
export type ReducerOptions = {
|
|
31
31
|
/** The number of operations to skip before this new action is applied */
|
|
32
32
|
skip?: number;
|
|
33
|
+
/** When true the skip count is ignored and the action is applied regardless of the skip count */
|
|
34
|
+
ignoreSkipOperations?: boolean;
|
|
33
35
|
};
|
|
34
36
|
/**
|
|
35
37
|
* A pure function that takes an action and the previous state
|
|
@@ -151,6 +153,8 @@ ExtendedState<GlobalState, LocalState> & {
|
|
|
151
153
|
operations: DocumentOperations<A>;
|
|
152
154
|
/** The initial state of the document, enabling replaying operations. */
|
|
153
155
|
initialState: ExtendedState<GlobalState, LocalState>;
|
|
156
|
+
/** A list of undone operations */
|
|
157
|
+
clipboard: Operation<BaseAction | A>[];
|
|
154
158
|
};
|
|
155
159
|
/**
|
|
156
160
|
* String type representing an attachment in a Document.
|
|
@@ -199,3 +203,8 @@ export type DocumentModelLib = {
|
|
|
199
203
|
documentModels: DocumentModel[];
|
|
200
204
|
editors: Editor[];
|
|
201
205
|
};
|
|
206
|
+
export type UndoRedoProcessResult<T, A extends Action, L> = {
|
|
207
|
+
document: Document<T, A, L>;
|
|
208
|
+
action: A | BaseAction;
|
|
209
|
+
skip: number;
|
|
210
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { baseReducer } from '../reducer';
|
|
2
|
-
import { Action, BaseAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader, DocumentOperationsIgnoreMap, Operation, MappedOperation } from '../types';
|
|
2
|
+
import { Action, BaseAction, UndoRedoAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader, DocumentOperationsIgnoreMap, Operation, MappedOperation } from '../types';
|
|
3
3
|
import { SignalDispatch } from '../signal';
|
|
4
|
+
export declare function isUndoRedo(action: Action): action is UndoRedoAction;
|
|
4
5
|
export declare function isBaseAction(action: Action): action is BaseAction;
|
|
5
6
|
/**
|
|
6
7
|
* Helper function to be used by action creators.
|
|
@@ -64,11 +65,13 @@ export declare function readOnly<T>(value: T): Immutable<T>;
|
|
|
64
65
|
* Maps skipped operations in an array of operations.
|
|
65
66
|
* Skipped operations are operations that are ignored during processing.
|
|
66
67
|
* @param operations - The array of operations to map.
|
|
68
|
+
* @param skippedHeadOperations - The number of operations to skip at the head of the array of operations.
|
|
67
69
|
* @returns An array of mapped operations with ignore flag indicating if the operation is skipped.
|
|
68
70
|
* @throws Error if the operation index is invalid and there are missing operations.
|
|
69
71
|
*/
|
|
70
|
-
export declare function mapSkippedOperations<A extends Action>(operations: Operation<BaseAction | A>[]): MappedOperation<A>[];
|
|
72
|
+
export declare function mapSkippedOperations<A extends Action>(operations: Operation<BaseAction | A>[], skippedHeadOperations?: number): MappedOperation<A>[];
|
|
71
73
|
export declare function sortOperations<A extends Action>(operations: DocumentOperations<A>): Operation<BaseAction | A>[];
|
|
72
74
|
export declare function sortMappedOperations<A extends Action>(operations: DocumentOperationsIgnoreMap<A>): MappedOperation<A>[];
|
|
73
|
-
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer): Document<T, A, L>;
|
|
74
|
-
export
|
|
75
|
+
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer, skipHeaderOperations?: SkipHeaderOperations): Document<T, A, L>;
|
|
76
|
+
export type SkipHeaderOperations = Partial<Record<OperationScope, number>>;
|
|
77
|
+
export declare function replayDocument<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: Reducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, skipHeaderOperations?: SkipHeaderOperations): Document<T, A, L>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export * from './base';
|
|
2
|
+
export { createAction, createDocument, createExtendedState, createReducer, hashDocument, hashKey, isBaseAction, mapSkippedOperations, readOnly, replayDocument, replayOperations, sortMappedOperations, sortOperations, } from './base';
|
|
2
3
|
export * from './file';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-
|
|
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,20 +1,19 @@
|
|
|
1
|
-
import "./internal/object-
|
|
2
|
-
import "json-stringify-deterministic";
|
|
1
|
+
import "./internal/object-qR4Tf50L.js";
|
|
3
2
|
import "immer";
|
|
4
|
-
import "
|
|
3
|
+
import "json-stringify-deterministic";
|
|
5
4
|
import "crypto";
|
|
6
5
|
import "fs";
|
|
7
6
|
import "https";
|
|
8
7
|
import "path";
|
|
9
|
-
import
|
|
10
|
-
import "
|
|
8
|
+
import "jszip";
|
|
9
|
+
import { b as c, a as d, c as l, d as n, m as D, r as M, u as b, z as f } from "./internal/index-uFGJxYP7.js";
|
|
11
10
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
};
|
package/dist/node/document.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-
|
|
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;
|
package/dist/node/document.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
import { i as
|
|
3
|
-
import "json-stringify-deterministic";
|
|
4
|
-
import "immer";
|
|
5
|
-
import "zod";
|
|
6
|
-
import "jszip";
|
|
7
|
-
import "crypto";
|
|
8
|
-
import "fs";
|
|
9
|
-
import "https";
|
|
10
|
-
import "path";
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
18
11
|
};
|
package/dist/node/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-
|
|
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;
|
package/dist/node/index.js
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { D as o } from "./internal/index-
|
|
2
|
-
import { D as
|
|
3
|
-
|
|
4
|
-
import "json-stringify-deterministic";
|
|
5
|
-
import "immer";
|
|
6
|
-
import "zod";
|
|
7
|
-
import "jszip";
|
|
8
|
-
import "crypto";
|
|
9
|
-
import "fs";
|
|
10
|
-
import "https";
|
|
11
|
-
import "path";
|
|
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":
|
|
15
|
-
},
|
|
5
|
+
"powerhouse/document-model": e
|
|
6
|
+
}, s = { Document: o, DocumentModel: e };
|
|
16
7
|
export {
|
|
17
8
|
o as Document,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
e as DocumentModel,
|
|
10
|
+
n as DocumentModels,
|
|
11
|
+
s as default
|
|
21
12
|
};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
|
+
__proto__: null,
|
|
4
|
+
createAction: e,
|
|
5
|
+
createDocument: a,
|
|
6
|
+
createExtendedState: s,
|
|
7
|
+
createReducer: o,
|
|
8
|
+
createZip: t,
|
|
9
|
+
getLocalFile: r,
|
|
10
|
+
getRemoteFile: n,
|
|
11
|
+
hashDocument: i,
|
|
12
|
+
hashKey: c,
|
|
13
|
+
isBaseAction: l,
|
|
14
|
+
isUndoRedo: p,
|
|
15
|
+
loadFromFile: d,
|
|
16
|
+
loadFromInput: u,
|
|
17
|
+
mapSkippedOperations: m,
|
|
18
|
+
readOnly: y,
|
|
19
|
+
replayDocument: O,
|
|
20
|
+
replayOperations: b,
|
|
21
|
+
saveToFile: _,
|
|
22
|
+
saveToFileHandle: g,
|
|
23
|
+
sortMappedOperations: F,
|
|
24
|
+
sortOperations: f
|
|
25
|
+
}, Symbol.toStringTag, { value: "Module" })), B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
26
|
+
__proto__: null,
|
|
27
|
+
BaseDocument: D,
|
|
28
|
+
actions: S,
|
|
29
|
+
applyMixins: h,
|
|
30
|
+
baseReducer: j,
|
|
31
|
+
processUndoRedo: v,
|
|
32
|
+
utils: z,
|
|
33
|
+
z: x
|
|
34
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
35
|
+
export {
|
|
36
|
+
B as D,
|
|
37
|
+
z as i
|
|
38
|
+
};
|
|
@@ -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-
|
|
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": "",
|