document-model 1.0.15 → 1.0.17
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/actions/creators.d.ts +1 -1
- package/dist/browser/document/actions/index.d.ts +8 -8
- package/dist/browser/document/object.d.ts +123 -99
- package/dist/browser/document/reducer.d.ts +1 -1
- package/dist/browser/document/schema/types.d.ts +5 -0
- package/dist/browser/document/schema/zod.d.ts +39 -0
- package/dist/browser/document/types.d.ts +41 -31
- package/dist/browser/document/utils/base.d.ts +6 -6
- package/dist/browser/document/utils/file.d.ts +2 -2
- package/dist/browser/document-model/gen/object.d.ts +1 -1
- package/dist/browser/document-model/gen/reducer.d.ts +1 -1
- package/dist/browser/document-model/gen/schema/types.d.ts +13 -3
- package/dist/browser/document-model/gen/schema/zod.d.ts +20 -1
- package/dist/browser/document-model/index.d.ts +9 -9
- package/dist/browser/document-model.cjs +1 -1
- package/dist/browser/document-model.js +2 -2
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +2 -2
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +3 -3
- package/dist/browser/internal/index-01030c3f.js +22 -0
- package/dist/{node/internal/index-c9d178be.js → browser/internal/index-2aee8ea9.js} +1 -1
- package/dist/browser/internal/{index-8142b58e.js → index-5f1909ad.js} +513 -435
- package/dist/{node/internal/index-0b0cb8c2.js → browser/internal/index-a1282d5c.js} +1 -1
- package/dist/browser/internal/object-24df9d92.js +6 -0
- package/dist/browser/internal/{object-4ec03a36.js → object-7e8eaff4.js} +777 -731
- package/dist/node/document/actions/creators.d.ts +1 -1
- package/dist/node/document/actions/index.d.ts +8 -8
- package/dist/node/document/object.d.ts +123 -99
- package/dist/node/document/reducer.d.ts +1 -1
- package/dist/node/document/schema/types.d.ts +5 -0
- package/dist/node/document/schema/zod.d.ts +39 -0
- package/dist/node/document/types.d.ts +41 -31
- package/dist/node/document/utils/base.d.ts +6 -6
- package/dist/node/document/utils/file.d.ts +2 -2
- package/dist/node/document-model/gen/object.d.ts +1 -1
- package/dist/node/document-model/gen/reducer.d.ts +1 -1
- package/dist/node/document-model/gen/schema/types.d.ts +13 -3
- package/dist/node/document-model/gen/schema/zod.d.ts +20 -1
- package/dist/node/document-model/index.d.ts +9 -9
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +2 -2
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +2 -2
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +3 -3
- package/dist/node/internal/{index-0c87fbed.js → index-0db636da.js} +513 -435
- package/dist/{browser/internal/index-cb990484.js → node/internal/index-2d4783d9.js} +1 -1
- package/dist/{browser/internal/index-9f1cf811.js → node/internal/index-5ef0c6b0.js} +1 -1
- package/dist/node/internal/index-cddc9dfd.js +22 -0
- package/dist/node/internal/object-21f3d2ee.js +1 -0
- package/dist/node/internal/{object-89d9b82f.js → object-c32ea0a0.js} +400 -356
- package/package.json +3 -3
- package/dist/browser/internal/index-cbe39f72.js +0 -22
- package/dist/browser/internal/object-5f03095e.js +0 -6
- package/dist/node/internal/index-63db4708.js +0 -22
- package/dist/node/internal/object-397a9b23.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as e, b as a, a as s, c as t, j as o, k as r, m as c, n as l, o as n, i, l as d, e as u, r as m, s as p, d as b, B as _, h as g, g as y, p as F, z as f } from "./object-
|
|
1
|
+
import { f as e, b as a, a as s, c as t, j as o, k as r, m as c, n as l, o as n, i, l as d, e as u, r as m, s as p, d as b, B as _, h as g, g as y, p as F, z as f } from "./object-7e8eaff4.js";
|
|
2
2
|
const h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
createAction: e,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";var Ar=Object.defineProperty;var Br=(i,a,s)=>a in i?Ar(i,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[a]=s;var J=(i,a,s)=>(Br(i,typeof a!="symbol"?a+"":a,s),s);const Sr=require("json-stringify-deterministic"),R=require("immer"),Bt=require("jszip"),g=require("zod"),St=i=>i!=null,jr=g.z.any().refine(i=>St(i)),jt=g.z.enum(["LOAD_STATE"]),It=g.z.enum(["PRUNE"]),Ut=g.z.enum(["REDO"]),zt=g.z.enum(["SET_NAME"]),Tt=g.z.enum(["UNDO"]);function Ir(){return g.z.object({__typename:g.z.literal("Action").optional(),type:g.z.string()})}function kt(){return g.z.union([Dt(),Nt(),Mt(),Rt(),Ct()])}function Ur(){return g.z.object({__typename:g.z.literal("DocumentFile").optional(),data:g.z.string(),extension:g.z.string().nullable(),fileName:g.z.string().nullable(),mimeType:g.z.string()})}function Dt(){return g.z.object({input:g.z.lazy(()=>ot()),type:jt,scope:g.z.literal("global")})}function ot(){return g.z.object({operations:g.z.number(),state:g.z.lazy(()=>Ot())})}function Ot(){return g.z.object({data:g.z.unknown().nullish(),name:g.z.string()})}function zr(){return g.z.object({__typename:g.z.literal("Operation").optional(),hash:g.z.string(),index:g.z.number(),timestamp:g.z.string().datetime(),type:g.z.string()})}function Nt(){return g.z.object({input:g.z.lazy(()=>pt()),type:It,scope:g.z.literal("global")})}function pt(){return g.z.object({end:g.z.number().nullish(),start:g.z.number().nullish()})}const st=g.z.number;function Mt(){return g.z.object({input:st(),type:Ut,scope:g.z.literal("global")})}const lt=g.z.string;function Rt(){return g.z.object({input:lt(),type:zt,scope:g.z.literal("global")})}function Tr(){return g.z.object({__typename:g.z.literal("SetNameOperation").optional(),hash:g.z.string(),index:g.z.number(),input:g.z.string(),timestamp:g.z.string().datetime(),type:g.z.string()})}const ct=g.z.number;function Ct(){return g.z.object({input:ct(),type:Tt,scope:g.z.literal("global")})}const kr=Object.freeze(Object.defineProperty({__proto__:null,ActionSchema:Ir,BaseActionSchema:kt,DocumentFileSchema:Ur,LoadStateActionInputSchema:ot,LoadStateActionSchema:Dt,LoadStateActionStateInputSchema:Ot,Load_StateSchema:jt,OperationSchema:zr,PruneActionInputSchema:pt,PruneActionSchema:Nt,PruneSchema:It,RedoActionInputSchema:st,RedoActionSchema:Mt,RedoSchema:Ut,SetNameActionInputSchema:lt,SetNameActionSchema:Rt,SetNameOperationSchema:Tr,Set_NameSchema:zt,UndoActionInputSchema:ct,UndoActionSchema:Ct,UndoSchema:Tt,definedNonNullAnySchema:jr,isDefinedNonNullAny:St},Symbol.toStringTag,{value:"Module"}));function Lt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function W(){this._types=Object.create(null),this._extensions=Object.create(null);for(let i=0;i<arguments.length;i++)this.define(arguments[i]);this.define=this.define.bind(this),this.getType=this.getType.bind(this),this.getExtension=this.getExtension.bind(this)}W.prototype.define=function(i,a){for(let s in i){let l=i[s].map(function(h){return h.toLowerCase()});s=s.toLowerCase();for(let h=0;h<l.length;h++){const f=l[h];if(f[0]!=="*"){if(!a&&f in this._types)throw new Error('Attempt to change mapping for "'+f+'" extension from "'+this._types[f]+'" to "'+s+'". Pass `force=true` to allow this, otherwise remove "'+f+'" from the list of extensions for "'+s+'".');this._types[f]=s}}if(a||!this._extensions[s]){const h=l[0];this._extensions[s]=h[0]!=="*"?h:h.substr(1)}}};W.prototype.getType=function(i){i=String(i);let a=i.replace(/^.*[/\\]/,"").toLowerCase(),s=a.replace(/^.*\./,"").toLowerCase(),l=a.length<i.length;return(s.length<a.length-1||!l)&&this._types[s]||null};W.prototype.getExtension=function(i){return i=/^\s*([^;\s]*)/.test(i)&&RegExp.$1,i&&this._extensions[i.toLowerCase()]||null};var Dr=W,Or={"application/andrew-inset":["ez"],"application/applixware":["aw"],"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/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/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"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","mjs"],"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/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":["mp4s","m4p"],"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-signature":["asc","sig"],"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/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/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/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/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/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"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"],"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/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"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/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"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/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"]};let Nr=Dr;var Mr=new Nr(Or);const Rr=Lt(Mr);var rt={exports:{}};typeof Object.create=="function"?rt.exports=function(a,s){s&&(a.super_=s,a.prototype=Object.create(s.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:rt.exports=function(a,s){if(s){a.super_=s;var l=function(){};l.prototype=s.prototype,a.prototype=new l,a.prototype.constructor=a}};var Cr=rt.exports,et={exports:{}},qt={},H={};H.byteLength=$r;H.toByteArray=Pr;H.fromByteArray=Zr;var z=[],j=[],Lr=typeof Uint8Array<"u"?Uint8Array:Array,tt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var k=0,qr=tt.length;k<qr;++k)z[k]=tt[k],j[tt.charCodeAt(k)]=k;j["-".charCodeAt(0)]=62;j["_".charCodeAt(0)]=63;function $t(i){var a=i.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var s=i.indexOf("=");s===-1&&(s=a);var l=s===a?0:4-s%4;return[s,l]}function $r(i){var a=$t(i),s=a[0],l=a[1];return(s+l)*3/4-l}function Jr(i,a,s){return(a+s)*3/4-s}function Pr(i){var a,s=$t(i),l=s[0],h=s[1],f=new Lr(Jr(i,l,h)),c=0,o=h>0?l-4:l,x;for(x=0;x<o;x+=4)a=j[i.charCodeAt(x)]<<18|j[i.charCodeAt(x+1)]<<12|j[i.charCodeAt(x+2)]<<6|j[i.charCodeAt(x+3)],f[c++]=a>>16&255,f[c++]=a>>8&255,f[c++]=a&255;return h===2&&(a=j[i.charCodeAt(x)]<<2|j[i.charCodeAt(x+1)]>>4,f[c++]=a&255),h===1&&(a=j[i.charCodeAt(x)]<<10|j[i.charCodeAt(x+1)]<<4|j[i.charCodeAt(x+2)]>>2,f[c++]=a>>8&255,f[c++]=a&255),f}function Wr(i){return z[i>>18&63]+z[i>>12&63]+z[i>>6&63]+z[i&63]}function Hr(i,a,s){for(var l,h=[],f=a;f<s;f+=3)l=(i[f]<<16&16711680)+(i[f+1]<<8&65280)+(i[f+2]&255),h.push(Wr(l));return h.join("")}function Zr(i){for(var a,s=i.length,l=s%3,h=[],f=16383,c=0,o=s-l;c<o;c+=f)h.push(Hr(i,c,c+f>o?o:c+f));return l===1?(a=i[s-1],h.push(z[a>>2]+z[a<<4&63]+"==")):l===2&&(a=(i[s-2]<<8)+i[s-1],h.push(z[a>>10]+z[a>>4&63]+z[a<<2&63]+"=")),h.join("")}var ut={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ut.read=function(i,a,s,l,h){var f,c,o=h*8-l-1,x=(1<<o)-1,y=x>>1,w=-7,F=s?h-1:0,I=s?-1:1,B=i[a+F];for(F+=I,f=B&(1<<-w)-1,B>>=-w,w+=o;w>0;f=f*256+i[a+F],F+=I,w-=8);for(c=f&(1<<-w)-1,f>>=-w,w+=l;w>0;c=c*256+i[a+F],F+=I,w-=8);if(f===0)f=1-y;else{if(f===x)return c?NaN:(B?-1:1)*(1/0);c=c+Math.pow(2,l),f=f-y}return(B?-1:1)*c*Math.pow(2,f-l)};ut.write=function(i,a,s,l,h,f){var c,o,x,y=f*8-h-1,w=(1<<y)-1,F=w>>1,I=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,B=l?0:f-1,O=l?1:-1,N=a<0||a===0&&1/a<0?1:0;for(a=Math.abs(a),isNaN(a)||a===1/0?(o=isNaN(a)?1:0,c=w):(c=Math.floor(Math.log(a)/Math.LN2),a*(x=Math.pow(2,-c))<1&&(c--,x*=2),c+F>=1?a+=I/x:a+=I*Math.pow(2,1-F),a*x>=2&&(c++,x/=2),c+F>=w?(o=0,c=w):c+F>=1?(o=(a*x-1)*Math.pow(2,h),c=c+F):(o=a*Math.pow(2,F-1)*Math.pow(2,h),c=0));h>=8;i[s+B]=o&255,B+=O,o/=256,h-=8);for(c=c<<h|o,y+=h;y>0;i[s+B]=c&255,B+=O,c/=256,y-=8);i[s+B-O]|=N*128};/*!
|
|
2
|
+
* The buffer module from node.js, for the browser.
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/(function(i){var a=H,s=ut,l=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=o,i.SlowBuffer=pr,i.INSPECT_MAX_BYTES=50;var h=2147483647;i.kMaxLength=h,o.TYPED_ARRAY_SUPPORT=f(),!o.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 f(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function c(e){if(e>h)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return F(e)}return x(e,t,r)}o.poolSize=8192;function x(e,t,r){if(typeof e=="string")return I(e,t);if(ArrayBuffer.isView(e))return O(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(U(e,SharedArrayBuffer)||e&&U(e.buffer,SharedArrayBuffer)))return N(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return o.from(n,t,r);var p=or(e);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return o.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}o.from=function(e,t,r){return x(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function y(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function w(e,t,r){return y(e),e<=0?c(e):t!==void 0?typeof r=="string"?c(e).fill(t,r):c(e).fill(t):c(e)}o.alloc=function(e,t,r){return w(e,t,r)};function F(e){return y(e),c(e<0?0:G(e)|0)}o.allocUnsafe=function(e){return F(e)},o.allocUnsafeSlow=function(e){return F(e)};function I(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=xt(e,t)|0,n=c(r),p=n.write(e,t);return p!==r&&(n=n.slice(0,p)),n}function B(e){for(var t=e.length<0?0:G(e.length)|0,r=c(t),n=0;n<t;n+=1)r[n]=e[n]&255;return r}function O(e){if(U(e,Uint8Array)){var t=new Uint8Array(e);return N(t.buffer,t.byteOffset,t.byteLength)}return B(e)}function N(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,o.prototype),n}function or(e){if(o.isBuffer(e)){var t=G(e.length)|0,r=c(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Q(e.length)?c(0):B(e);if(e.type==="Buffer"&&Array.isArray(e.data))return B(e.data)}function G(e){if(e>=h)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+h.toString(16)+" bytes");return e|0}function pr(e){return+e!=e&&(e=0),o.alloc(+e)}o.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==o.prototype},o.compare=function(t,r){if(U(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),U(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(t)||!o.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;for(var n=t.length,p=r.length,u=0,m=Math.min(n,p);u<m;++u)if(t[u]!==r[u]){n=t[u],p=r[u];break}return n<p?-1:p<n?1:0},o.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}},o.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return o.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var p=o.allocUnsafe(r),u=0;for(n=0;n<t.length;++n){var m=t[n];if(U(m,Uint8Array))u+m.length>p.length?o.from(m).copy(p,u):Uint8Array.prototype.set.call(p,m,u);else if(o.isBuffer(m))m.copy(p,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=m.length}return p};function xt(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;for(var p=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ft(e).length;default:if(p)return n?-1:V(e).length;t=(""+t).toLowerCase(),p=!0}}o.byteLength=xt;function sr(e,t,r){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return yr(this,t,r);case"utf8":case"utf-8":return yt(this,t,r);case"ascii":return gr(this,t,r);case"latin1":case"binary":return dr(this,t,r);case"base64":return mr(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wr(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}o.prototype._isBuffer=!0;function T(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}o.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 r=0;r<t;r+=2)T(this,r,r+1);return this},o.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 r=0;r<t;r+=4)T(this,r,r+3),T(this,r+1,r+2);return this},o.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 r=0;r<t;r+=8)T(this,r,r+7),T(this,r+1,r+6),T(this,r+2,r+5),T(this,r+3,r+4);return this},o.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?yt(this,0,t):sr.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:o.compare(this,t)===0},o.prototype.inspect=function(){var t="",r=i.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},l&&(o.prototype[l]=o.prototype.inspect),o.prototype.compare=function(t,r,n,p,u){if(U(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),p===void 0&&(p=0),u===void 0&&(u=this.length),r<0||n>t.length||p<0||u>this.length)throw new RangeError("out of range index");if(p>=u&&r>=n)return 0;if(p>=u)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,p>>>=0,u>>>=0,this===t)return 0;for(var m=u-p,d=n-r,v=Math.min(m,d),b=this.slice(p,u),A=t.slice(r,n),E=0;E<v;++E)if(b[E]!==A[E]){m=b[E],d=A[E];break}return m<d?-1:d<m?1:0};function gt(e,t,r,n,p){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Q(r)&&(r=p?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(p)return-1;r=e.length-1}else if(r<0)if(p)r=0;else return-1;if(typeof t=="string"&&(t=o.from(t,n)),o.isBuffer(t))return t.length===0?-1:dt(e,t,r,n,p);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):dt(e,[t],r,n,p);throw new TypeError("val must be string, number or Buffer")}function dt(e,t,r,n,p){var u=1,m=e.length,d=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;u=2,m/=2,d/=2,r/=2}function v(_t,At){return u===1?_t[At]:_t.readUInt16BE(At*u)}var b;if(p){var A=-1;for(b=r;b<m;b++)if(v(e,b)===v(t,A===-1?0:b-A)){if(A===-1&&(A=b),b-A+1===d)return A*u}else A!==-1&&(b-=b-A),A=-1}else for(r+d>m&&(r=m-d),b=r;b>=0;b--){for(var E=!0,$=0;$<d;$++)if(v(e,b+$)!==v(t,$)){E=!1;break}if(E)return b}return-1}o.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1},o.prototype.indexOf=function(t,r,n){return gt(this,t,r,n,!0)},o.prototype.lastIndexOf=function(t,r,n){return gt(this,t,r,n,!1)};function lr(e,t,r,n){r=Number(r)||0;var p=e.length-r;n?(n=Number(n),n>p&&(n=p)):n=p;var u=t.length;n>u/2&&(n=u/2);for(var m=0;m<n;++m){var d=parseInt(t.substr(m*2,2),16);if(Q(d))return m;e[r+m]=d}return m}function cr(e,t,r,n){return q(V(t,e.length-r),e,r,n)}function ur(e,t,r,n){return q(Er(t),e,r,n)}function hr(e,t,r,n){return q(Ft(t),e,r,n)}function fr(e,t,r,n){return q(Fr(t,e.length-r),e,r,n)}o.prototype.write=function(t,r,n,p){if(r===void 0)p="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")p=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,p===void 0&&(p="utf8")):(p=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var u=this.length-r;if((n===void 0||n>u)&&(n=u),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");for(var m=!1;;)switch(p){case"hex":return lr(this,t,r,n);case"utf8":case"utf-8":return cr(this,t,r,n);case"ascii":case"latin1":case"binary":return ur(this,t,r,n);case"base64":return hr(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fr(this,t,r,n);default:if(m)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),m=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function mr(e,t,r){return t===0&&r===e.length?a.fromByteArray(e):a.fromByteArray(e.slice(t,r))}function yt(e,t,r){r=Math.min(e.length,r);for(var n=[],p=t;p<r;){var u=e[p],m=null,d=u>239?4:u>223?3:u>191?2:1;if(p+d<=r){var v,b,A,E;switch(d){case 1:u<128&&(m=u);break;case 2:v=e[p+1],(v&192)===128&&(E=(u&31)<<6|v&63,E>127&&(m=E));break;case 3:v=e[p+1],b=e[p+2],(v&192)===128&&(b&192)===128&&(E=(u&15)<<12|(v&63)<<6|b&63,E>2047&&(E<55296||E>57343)&&(m=E));break;case 4:v=e[p+1],b=e[p+2],A=e[p+3],(v&192)===128&&(b&192)===128&&(A&192)===128&&(E=(u&15)<<18|(v&63)<<12|(b&63)<<6|A&63,E>65535&&E<1114112&&(m=E))}}m===null?(m=65533,d=1):m>65535&&(m-=65536,n.push(m>>>10&1023|55296),m=56320|m&1023),n.push(m),p+=d}return xr(n)}var wt=4096;function xr(e){var t=e.length;if(t<=wt)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=wt));return r}function gr(e,t,r){var n="";r=Math.min(e.length,r);for(var p=t;p<r;++p)n+=String.fromCharCode(e[p]&127);return n}function dr(e,t,r){var n="";r=Math.min(e.length,r);for(var p=t;p<r;++p)n+=String.fromCharCode(e[p]);return n}function yr(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var p="",u=t;u<r;++u)p+=_r[e[u]];return p}function wr(e,t,r){for(var n=e.slice(t,r),p="",u=0;u<n.length-1;u+=2)p+=String.fromCharCode(n[u]+n[u+1]*256);return p}o.prototype.slice=function(t,r){var n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);var p=this.subarray(t,r);return Object.setPrototypeOf(p,o.prototype),p};function _(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||_(t,r,this.length);for(var p=this[t],u=1,m=0;++m<r&&(u*=256);)p+=this[t+m]*u;return p},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||_(t,r,this.length);for(var p=this[t+--r],u=1;r>0&&(u*=256);)p+=this[t+--r]*u;return p},o.prototype.readUint8=o.prototype.readUInt8=function(t,r){return t=t>>>0,r||_(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||_(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||_(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||_(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||_(t,r,this.length);for(var p=this[t],u=1,m=0;++m<r&&(u*=256);)p+=this[t+m]*u;return u*=128,p>=u&&(p-=Math.pow(2,8*r)),p},o.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||_(t,r,this.length);for(var p=r,u=1,m=this[t+--p];p>0&&(u*=256);)m+=this[t+--p]*u;return u*=128,m>=u&&(m-=Math.pow(2,8*r)),m},o.prototype.readInt8=function(t,r){return t=t>>>0,r||_(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,r){t=t>>>0,r||_(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},o.prototype.readInt16BE=function(t,r){t=t>>>0,r||_(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},o.prototype.readInt32LE=function(t,r){return t=t>>>0,r||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,r){return t=t>>>0,r||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,r){return t=t>>>0,r||_(t,4,this.length),s.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,r){return t=t>>>0,r||_(t,4,this.length),s.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||_(t,8,this.length),s.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||_(t,8,this.length),s.read(this,t,!1,52,8)};function S(e,t,r,n,p,u){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>p||t<u)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,r,n,p){if(t=+t,r=r>>>0,n=n>>>0,!p){var u=Math.pow(2,8*n)-1;S(this,t,r,n,u,0)}var m=1,d=0;for(this[r]=t&255;++d<n&&(m*=256);)this[r+d]=t/m&255;return r+n},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,r,n,p){if(t=+t,r=r>>>0,n=n>>>0,!p){var u=Math.pow(2,8*n)-1;S(this,t,r,n,u,0)}var m=n-1,d=1;for(this[r+m]=t&255;--m>=0&&(d*=256);)this[r+m]=t/d&255;return r+n},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,1,255,0),this[r]=t&255,r+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4},o.prototype.writeIntLE=function(t,r,n,p){if(t=+t,r=r>>>0,!p){var u=Math.pow(2,8*n-1);S(this,t,r,n,u-1,-u)}var m=0,d=1,v=0;for(this[r]=t&255;++m<n&&(d*=256);)t<0&&v===0&&this[r+m-1]!==0&&(v=1),this[r+m]=(t/d>>0)-v&255;return r+n},o.prototype.writeIntBE=function(t,r,n,p){if(t=+t,r=r>>>0,!p){var u=Math.pow(2,8*n-1);S(this,t,r,n,u-1,-u)}var m=n-1,d=1,v=0;for(this[r+m]=t&255;--m>=0&&(d*=256);)t<0&&v===0&&this[r+m+1]!==0&&(v=1),this[r+m]=(t/d>>0)-v&255;return r+n},o.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1},o.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2},o.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2},o.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},o.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||S(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function vt(e,t,r,n,p,u){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function bt(e,t,r,n,p){return t=+t,r=r>>>0,p||vt(e,t,r,4),s.write(e,t,r,n,23,4),r+4}o.prototype.writeFloatLE=function(t,r,n){return bt(this,t,r,!0,n)},o.prototype.writeFloatBE=function(t,r,n){return bt(this,t,r,!1,n)};function Et(e,t,r,n,p){return t=+t,r=r>>>0,p||vt(e,t,r,8),s.write(e,t,r,n,52,8),r+8}o.prototype.writeDoubleLE=function(t,r,n){return Et(this,t,r,!0,n)},o.prototype.writeDoubleBE=function(t,r,n){return Et(this,t,r,!1,n)},o.prototype.copy=function(t,r,n,p){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!p&&p!==0&&(p=this.length),r>=t.length&&(r=t.length),r||(r=0),p>0&&p<n&&(p=n),p===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),t.length-r<p-n&&(p=t.length-r+n);var u=p-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,p):Uint8Array.prototype.set.call(t,this.subarray(n,p),r),u},o.prototype.fill=function(t,r,n,p){if(typeof t=="string"){if(typeof r=="string"?(p=r,r=0,n=this.length):typeof n=="string"&&(p=n,n=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!o.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(t.length===1){var u=t.charCodeAt(0);(p==="utf8"&&u<128||p==="latin1")&&(t=u)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var m;if(typeof t=="number")for(m=r;m<n;++m)this[m]=t;else{var d=o.isBuffer(t)?t:o.from(t,p),v=d.length;if(v===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(m=0;m<n-r;++m)this[m+r]=d[m%v]}return this};var vr=/[^+/0-9A-Za-z-_]/g;function br(e){if(e=e.split("=")[0],e=e.trim().replace(vr,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function V(e,t){t=t||1/0;for(var r,n=e.length,p=null,u=[],m=0;m<n;++m){if(r=e.charCodeAt(m),r>55295&&r<57344){if(!p){if(r>56319){(t-=3)>-1&&u.push(239,191,189);continue}else if(m+1===n){(t-=3)>-1&&u.push(239,191,189);continue}p=r;continue}if(r<56320){(t-=3)>-1&&u.push(239,191,189),p=r;continue}r=(p-55296<<10|r-56320)+65536}else p&&(t-=3)>-1&&u.push(239,191,189);if(p=null,r<128){if((t-=1)<0)break;u.push(r)}else if(r<2048){if((t-=2)<0)break;u.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;u.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;u.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return u}function Er(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Fr(e,t){for(var r,n,p,u=[],m=0;m<e.length&&!((t-=2)<0);++m)r=e.charCodeAt(m),n=r>>8,p=r%256,u.push(p),u.push(n);return u}function Ft(e){return a.toByteArray(br(e))}function q(e,t,r,n){for(var p=0;p<n&&!(p+r>=t.length||p>=e.length);++p)t[p+r]=e[p];return p}function U(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Q(e){return e!==e}var _r=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var n=r*16,p=0;p<16;++p)t[n+p]=e[r]+e[p];return t}()})(qt);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(i,a){var s=qt,l=s.Buffer;function h(c,o){for(var x in c)o[x]=c[x]}l.from&&l.alloc&&l.allocUnsafe&&l.allocUnsafeSlow?i.exports=s:(h(s,a),a.Buffer=f);function f(c,o,x){return l(c,o,x)}f.prototype=Object.create(l.prototype),h(l,f),f.from=function(c,o,x){if(typeof c=="number")throw new TypeError("Argument must not be a number");return l(c,o,x)},f.alloc=function(c,o,x){if(typeof c!="number")throw new TypeError("Argument must be a number");var y=l(c);return o!==void 0?typeof x=="string"?y.fill(o,x):y.fill(o):y.fill(0),y},f.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return l(c)},f.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return s.SlowBuffer(c)}})(et,et.exports);var Jt=et.exports,Pt=Jt.Buffer;function Z(i,a){this._block=Pt.alloc(i),this._finalSize=a,this._blockSize=i,this._len=0}Z.prototype.update=function(i,a){typeof i=="string"&&(a=a||"utf8",i=Pt.from(i,a));for(var s=this._block,l=this._blockSize,h=i.length,f=this._len,c=0;c<h;){for(var o=f%l,x=Math.min(h-c,l-o),y=0;y<x;y++)s[o+y]=i[c+y];f+=x,c+=x,f%l===0&&this._update(s)}return this._len+=h,this};Z.prototype.digest=function(i){var a=this._len%this._blockSize;this._block[a]=128,this._block.fill(0,a+1),a>=this._finalSize&&(this._update(this._block),this._block.fill(0));var s=this._len*8;if(s<=4294967295)this._block.writeUInt32BE(s,this._blockSize-4);else{var l=(s&4294967295)>>>0,h=(s-l)/4294967296;this._block.writeUInt32BE(h,this._blockSize-8),this._block.writeUInt32BE(l,this._blockSize-4)}this._update(this._block);var f=this._hash();return i?f.toString(i):f};Z.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Kr=Z,Yr=Cr,Wt=Kr,Xr=Jt.Buffer,Gr=[1518500249,1859775393,-1894007588,-899497514],Vr=new Array(80);function L(){this.init(),this._w=Vr,Wt.call(this,64,56)}Yr(L,Wt);L.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Qr(i){return i<<1|i>>>31}function te(i){return i<<5|i>>>27}function re(i){return i<<30|i>>>2}function ee(i,a,s,l){return i===0?a&s|~a&l:i===2?a&s|a&l|s&l:a^s^l}L.prototype._update=function(i){for(var a=this._w,s=this._a|0,l=this._b|0,h=this._c|0,f=this._d|0,c=this._e|0,o=0;o<16;++o)a[o]=i.readInt32BE(o*4);for(;o<80;++o)a[o]=Qr(a[o-3]^a[o-8]^a[o-14]^a[o-16]);for(var x=0;x<80;++x){var y=~~(x/20),w=te(s)+ee(y,l,h,f)+c+a[x]+Gr[y]|0;c=f,f=h,h=re(l),l=s,s=w}this._a=s+this._a|0,this._b=l+this._b|0,this._c=h+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0};L.prototype._hash=function(){var i=Xr.allocUnsafe(20);return i.writeInt32BE(this._a|0,0),i.writeInt32BE(this._b|0,4),i.writeInt32BE(this._c|0,8),i.writeInt32BE(this._d|0,12),i.writeInt32BE(this._e|0,16),i};var ie=L;const ne=Lt(ie),ht=new Error("File system not available.");function ae(i,a,s){throw ht}function Ht(i){throw ht}function oe(i){throw ht}const pe=async i=>Ht();function se(i){let a="";for(let s=0;s<i.length;s+=2)a+=String.fromCharCode(parseInt(i.substr(s,2),16));return btoa(a)}const K=(i,a="sha1")=>{if(a!=="sha1")throw new Error("Only sha1 algorithm is available.");const s=new ne;return se(s.update(i).digest("hex"))},ft=async i=>{const a=new Bt,{name:s,revision:l,documentType:h,created:f,lastModified:c}=i,o={name:s,revision:l,documentType:h,created:f,lastModified:c};return a.file("header.json",JSON.stringify(o,null,2)),a.file("state.json",JSON.stringify(i.initialState||{},null,2)),a.file("operations.json",JSON.stringify(i.operations,null,2)),Object.keys(i.attachments).forEach(y=>{const{data:w,...F}=i.attachments[y];a.file(y,w,{base64:!0,createFolders:!0,comment:JSON.stringify(F)})}),a},Zt=async(i,a,s,l)=>{await(await ft(i)).generateAsync({type:"uint8array",streamFiles:!0});const f=l??i.name,c=`.${s}.zip`;return ae(a,f.endsWith(c)?f:`${f}${c}`)},le=async(i,a)=>{const l=await(await ft(i)).generateAsync({type:"blob"}),h=await a.createWritable();await h.write(l),await h.close()},it=async(i,a)=>{const s=Ht();return Kt(s,a)},Kt=async(i,a)=>{const s=new Bt;return await s.loadAsync(i),ce(s,a)};async function ce(i,a){const s=i.file("state.json");if(!s)throw new Error("Initial state not found");const l=await s.async("string"),h=JSON.parse(l),f=i.file("header.json");let c=null;f&&(c=JSON.parse(await f.async("string")));const o=i.file("operations.json");if(!o)throw new Error("Operations history not found");const x=JSON.parse(await o.async("string")),y={...h,...c,initialState:h,operations:{global:[],local:[]},attachments:{...h.attachments}};let w=x.global.concat(x.local).slice(0,c==null?void 0:c.revision).reduce((F,I)=>a(F,I),y);return c&&(w={...w,...c,operations:{global:[...w.operations.global,...x.global.slice(c.revision)],local:w.operations.local}}),w}function Yt(i){const a=i.replace(/^.*\./,"")||void 0,s=i.replace(/^.*[/\\]/,"")||void 0;return{extension:a,fileName:s}}async function ue(i){const{buffer:a,mimeType:s="application/octet-stream"}=await oe(),l=Yt(i),h=a.toString("base64");return{data:h,hash:K(h),mimeType:s,...l}}async function he(i){const a=await pe(),s=Rr.getType(i)||"application/octet-stream",l=Yt(i),h=a.toString("base64");return{data:h,hash:K(h),mimeType:s,...l}}function P(i,a,s,l){const h=rr(i),f=Qt(s);return a.global.concat(a.local).reduce((c,o)=>f(c,o,l),h)}function fe(i,a){return{...i,name:a}}function me(i,a,s){const l=Math.min(a,i.revision),h=i.operations.global.slice(0,i.revision-l);return{...P(i.initialState,{global:h,local:i.operations.local},s),operations:i.operations,revision:i.revision-l}}function xe(i,a,s){const l=i.operations.global.length-i.revision;if(!l)throw new Error("There is no UNDO operation to REDO");const h=a<l?a:l,f=i.operations.global.slice(0,i.revision+h);return{...P(i.initialState,{global:f,local:i.operations.local},s),operations:i.operations,revision:i.revision+h}}function ge(i,a,s,l){a=a||0,s=s||i.operations.global.length;const h=i.operations.global.slice(a,s),f=i.operations.global.slice(0,a),c=i.operations.global.slice(s),o=P(i.initialState,{global:f.concat(h),local:i.operations.local},l),{name:x,state:y}=o;return P(i.initialState,{global:[...f,mt({name:x,state:y},h.length),...c],local:i.operations.local},l)}function de(i,a){return{...i,name:a.name,state:a.state??{global:{},local:{}}}}const Xt="SET_NAME",Y="UNDO",X="REDO",C="PRUNE",Gt="LOAD_STATE";function ye(i,a){return[Y,X,C].includes(a.type)?i.revision:i.revision+1}function we(i,a){return{...i,revision:ye(i,a),lastModified:new Date().toISOString()}}function ve(i,a){if([Y,X,C,C].includes(a.type))return i;const s=i.operations.global.slice(0,i.revision),l=i.operations.local.slice();return!a.scope||a.scope==="global"?s.push({...a,index:s.length,timestamp:new Date().toISOString(),hash:"",scope:"global"}):a.scope==="local"&&l.push({...a,index:l.length,timestamp:new Date().toISOString(),hash:"",scope:"local"}),{...i,operations:{global:s,local:l}}}function be(i,a){let s=ve(i,a);return(!a.scope||a.scope==="global")&&(s=we(s,a)),s}function Ee(i,a,s){switch(kt().parse(a),a.type){case Xt:return fe(i,a.input);case Y:return me(i,a.input,s);case X:return xe(i,a.input,s);case C:return ge(i,a.input.start,a.input.end,s);case Gt:return de(i,a.input.state);default:return i}}function Vt(i,a,s,l){let h=i;return nt(a)&&(h=Ee(h,a,s)),h=be(h,a),h=R.produce(h,f=>{const c=s(f.state,a,l);if(c)return R.castDraft({...h,state:c})}),R.produce(h,f=>{!a.scope||a.scope==="global"?f.operations.global[f.operations.global.length-1].hash=at(f,"global"):a.scope==="local"&&(f.operations.local[f.operations.local.length-1].hash=at(f,"local")),!nt(a)&&a.attachments&&a.attachments.forEach(c=>{const{hash:o,...x}=c;f.attachments[o]={...x}})})}function nt(i){return[Xt,Y,X,C,Gt].includes(i.type)}function D(i,a,s,l,h="global"){if(!i)throw new Error("Empty action type");if(typeof i!="string")throw new Error(`Invalid action type: ${i}`);const f={type:i,input:a,scope:h};s&&(f.attachments=s);try{l==null||l().parse(f.input)}catch(c){throw new Error(`Invalid action input: ${c}`)}return f}function Qt(i,a=Vt){return(s,l,h)=>a(s,l,i,h)}const tr=(i,a)=>({name:"",documentType:"",revision:0,created:new Date().toISOString(),lastModified:new Date().toISOString(),attachments:{},...i,state:(a==null?void 0:a(i==null?void 0:i.state))??(i==null?void 0:i.state)??{global:{},local:{}}}),rr=(i,a)=>{const s=tr(i,a);return{...s,initialState:s,operations:{global:[],local:[]}}},at=(i,a="global")=>K(Sr(a==="local"?i.state.local:i.state.global)),Fe=(i,a=1e3)=>{const s=Math.random()*a;return K(`${(i??new Date).toISOString()}${s}`)};function M(i){return R.castImmutable(R.freeze(i,!0))}const er=i=>D("SET_NAME",i,void 0,lt),ir=(i=1)=>D("UNDO",i,void 0,ct),nr=(i=1)=>D("REDO",i,void 0,st),ar=(i,a)=>D("PRUNE",{start:i,end:a},void 0,pt),mt=(i,a)=>D("LOAD_STATE",{state:i,operations:a},void 0,ot),_e=Object.freeze(Object.defineProperty({__proto__:null,loadState:mt,prune:ar,redo:nr,setName:er,undo:ir},Symbol.toStringTag,{value:"Module"}));class Ae{constructor(a,s,l){J(this,"_document");J(this,"_reducer");J(this,"_signalDispatch");this._reducer=a,this._document=s,this._signalDispatch=l}dispatch(a){return this._document=this._reducer(this._document,a,this._signalDispatch),this}saveToFile(a,s,l){return Zt(this._document,a,s,l)}async loadFromFile(a){this._document=await it(a,this._reducer)}static async stateFromFile(a,s){return await it(a,s)}get state(){return M(this._document.state)}get operations(){return M(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}get initialState(){return M(this._document.initialState)}toDocument(){return M(this._document)}getAttachment(a){return this._document.attachments[a]}setName(a){return this.dispatch(er(a)),this}undo(a){return this.dispatch(ir(a)),this}redo(a){return this.dispatch(nr(a)),this}prune(a,s){return this.dispatch(ar(a,s)),this}loadState(a,s){return this.dispatch(mt(a,s)),this}}function Be(i,a){a.forEach(s=>{Object.getOwnPropertyNames(s.prototype).forEach(l=>{Object.defineProperty(i.prototype,l,Object.getOwnPropertyDescriptor(s.prototype,l)||Object.create(null))})})}exports.BaseActions=_e;exports.BaseDocument=Ae;exports.applyMixins=Be;exports.baseReducer=Vt;exports.createAction=D;exports.createDocument=rr;exports.createExtendedState=tr;exports.createReducer=Qt;exports.createZip=ft;exports.getLocalFile=he;exports.getRemoteFile=ue;exports.hashDocument=at;exports.hashKey=Fe;exports.isBaseAction=nt;exports.loadFromFile=it;exports.loadFromInput=Kt;exports.readOnly=M;exports.saveToFile=Zt;exports.saveToFileHandle=le;exports.zod=kr;
|