xrfragment-haxe/src/3rd/js/plugin/matrix/matrix-crdt.js

2 lines
1.1 MiB
JavaScript
Raw Normal View History

2023-12-27 17:26:21 +00:00
/*! For license information please see matrix-crdt.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Matrix=t():e.Matrix=t()}(self,(()=>(()=>{var e={9141:e=>{"use strict";for(var t=/[\\\"\x00-\x1F]/g,n={},r=0;r<32;++r)n[String.fromCharCode(r)]="\\U"+("0000"+r.toString(16)).slice(-4).toUpperCase();function i(e){return t.lastIndex=0,e.replace(t,(function(e){return n[e]}))}n["\b"]="\\b",n["\t"]="\\t",n["\n"]="\\n",n["\f"]="\\f",n["\r"]="\\r",n['"']='\\"',n["\\"]="\\\\",e.exports={stringify:function e(t){switch(typeof t){case"string":return'"'+i(t)+'"';case"number":return isFinite(t)?t:"null";case"boolean":return t;case"object":return null===t?"null":Array.isArray(t)?function(t){for(var n="[",r="",i=0;i<t.length;++i)r+=n,n=",",r+=e(t[i]);return","!=n?"[]":r+"]"}(t):function(t){var n="{",r="",s=Object.keys(t);s.sort();for(var o=0;o<s.length;++o){var a=s[o];r+=n+'"'+i(a)+'":',n=",",r+=e(t[a])}return","!=n?"{}":r+"}"}(t);default:throw new Error("Cannot stringify: "+typeof t)}}}},8162:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var r=0;r<e.length;r++){var i=e.charAt(r),s=i.charCodeAt(0);if(255!==t[s])throw new TypeError(i+" is ambiguous");t[s]=r}var o=e.length,a=e.charAt(0),c=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);function d(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var n=0,r=0,i=0;e[n]===a;)r++,n++;for(var s=(e.length-n)*c+1>>>0,l=new Uint8Array(s);e[n];){var d=t[e.charCodeAt(n)];if(255===d)return;for(var u=0,h=s-1;(0!==d||u<i)&&-1!==h;h--,u++)d+=o*l[h]>>>0,l[h]=d%256>>>0,d=d/256>>>0;if(0!==d)throw new Error("Non-zero carry");i=u,n++}for(var f=s-i;f!==s&&0===l[f];)f++;for(var g=new Uint8Array(r+(s-f)),p=r;f!==s;)g[p++]=l[f++];return g}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var n=0,r=0,i=0,s=t.length;i!==s&&0===t[i];)i++,n++;for(var c=(s-i)*l+1>>>0,d=new Uint8Array(c);i!==s;){for(var u=t[i],h=0,f=c-1;(0!==u||h<r)&&-1!==f;f--,h++)u+=256*d[f]>>>0,d[f]=u%o>>>0,u=u/o>>>0;if(0!==u)throw new Error("Non-zero carry");r=h,i++}for(var g=c-r;g!==c&&0===d[g];)g++;for(var p=a.repeat(n);g<c;++g)p+=e.charAt(d[g]);return p},decodeUnsafe:d,decode:function(e){var t=d(e);if(t)return t;throw new Error("Non-base"+o+" character")}}}},9742:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,s=a(e),o=s[0],c=s[1],l=new i(function(e,t,n){return 3*(t+n)/4-n}(0,o,c)),d=0,u=c>0?o-4:o;for(n=0;n<u;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],l[d++]=t>>16&255,l[d++]=t>>8&255,l[d++]=255&t;return 2===c&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,l[d++]=255&t),1===c&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,l[d++]=t>>8&255,l[d++]=255&t),l},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,s=[],o=16383,a=0,l=r-i;a<l;a+=o)s.push(c(e,a,a+o>l?l:a+o));return 1===i?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),s.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)n[o]=s[o],r[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function c(e,t,r){for(var i,s,o=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(n[(s=i)>>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},4770:function(e,t){var n,r;n=function(){var e=XMLHttpRequest;if(!e)thr