@iebh/tera-fy 2.0.20 → 2.0.21
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/CHANGELOG.md +39 -1
- package/dist/plugin.vue2.es2019.js +1 -1
- package/dist/terafy.es2019.js +1 -1
- package/dist/terafy.js +1 -1
- package/eslint.config.js +0 -5
- package/lib/syncro/entities.js +1 -1
- package/lib/syncro/syncro.js +80 -9
- package/lib/terafy.client.js +6 -2
- package/lib/terafy.server.js +71 -50
- package/package.json +5 -4
- package/utils/pathTools.js +3 -5
package/dist/terafy.es2019.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var uo=Object.defineProperty;var co=(t,e,r)=>e in t?uo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var p=(t,e,r)=>co(t,typeof e!="symbol"?e+"":e,r);var ho=typeof global=="object"&&global&&global.Object===Object&&global,dt=ho;var xo=typeof self=="object"&&self&&self.Object===Object&&self,go=dt||xo||Function("return this")(),c=go;var bo=c.Symbol,b=bo;var Yt=Object.prototype,yo=Yt.hasOwnProperty,vo=Yt.toString,st=b?b.toStringTag:void 0;function wo(t){var e=yo.call(t,st),r=t[st];try{t[st]=void 0;var o=!0}catch{}var a=vo.call(t);return o&&(e?t[st]=r:delete t[st]),a}var Zt=wo;var To=Object.prototype,Oo=To.toString;function jo(t){return Oo.call(t)}var Jt=jo;var Ao="[object Null]",Po="[object Undefined]",Xt=b?b.toStringTag:void 0;function So(t){return t==null?t===void 0?Po:Ao:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var O=So;function Io(t){return t!=null&&typeof t=="object"}var T=Io;var _o="[object Symbol]";function Eo(t){return typeof t=="symbol"||T(t)&&O(t)==_o}var k=Eo;function Co(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Qt=Co;var Fo=Array.isArray,g=Fo;var No=1/0,te=b?b.prototype:void 0,ee=te?te.toString:void 0;function re(t){if(typeof t=="string")return t;if(g(t))return Qt(t,re)+"";if(k(t))return ee?ee.call(t):"";var e=t+"";return e=="0"&&1/t==-No?"-0":e}var oe=re;function Mo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var w=Mo;function Ro(t){return t}var ae=Ro;var Bo="[object AsyncFunction]",Lo="[object Function]",ko="[object GeneratorFunction]",Uo="[object Proxy]";function Do(t){if(!w(t))return!1;var e=O(t);return e==Lo||e==ko||e==Bo||e==Uo}var ct=Do;var zo=c["__core-js_shared__"],ht=zo;var ie=function(){var t=/[^.]+$/.exec(ht&&ht.keys&&ht.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Go(t){return!!ie&&ie in t}var se=Go;var Wo=Function.prototype,Ko=Wo.toString;function $o(t){if(t!=null){try{return Ko.call(t)}catch{}try{return t+""}catch{}}return""}var A=$o;var Ho=/[\\^$.*+?()[\]{}|]/g,Vo=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Zo=qo.toString,Jo=Yo.hasOwnProperty,Xo=RegExp("^"+Zo.call(Jo).replace(Ho,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Qo(t){if(!w(t)||se(t))return!1;var e=ct(t)?Xo:Vo;return e.test(A(t))}var ne=Qo;function ta(t,e){return t==null?void 0:t[e]}var fe=ta;function ea(t,e){var r=fe(t,e);return ne(r)?r:void 0}var y=ea;var ra=y(c,"WeakMap"),xt=ra;var pe=Object.create,oa=function(){function t(){}return function(e){if(!w(e))return{};if(pe)return pe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),le=oa;function aa(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var me=aa;function ia(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=ia;var sa=800,na=16,fa=Date.now;function pa(t){var e=0,r=0;return function(){var o=fa(),a=na-(o-r);if(r=o,a>0){if(++e>=sa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var de=pa;function la(t){return function(){return t}}var ce=la;var ma=function(){try{var t=y(Object,"defineProperty");return t({},"",{}),t}catch{}}(),U=ma;var ua=U?function(t,e){return U(t,"toString",{configurable:!0,enumerable:!1,value:ce(e),writable:!0})}:ae,he=ua;var da=de(he),xe=da;function ca(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ge=ca;var ha=9007199254740991,xa=/^(?:0|[1-9]\d*)$/;function ga(t,e){var r=typeof t;return e=e==null?ha:e,!!e&&(r=="number"||r!="symbol"&&xa.test(t))&&t>-1&&t%1==0&&t<e}var D=ga;function ba(t,e,r){e=="__proto__"&&U?U(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var gt=ba;function ya(t,e){return t===e||t!==t&&e!==e}var bt=ya;var va=Object.prototype,wa=va.hasOwnProperty;function Ta(t,e,r){var o=t[e];(!(wa.call(t,e)&&bt(o,r))||r===void 0&&!(e in t))&>(t,e,r)}var z=Ta;function Oa(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],d=o?o(r[n],t[n],n,r,t):void 0;d===void 0&&(d=t[n]),a?gt(r,n,d):z(r,n,d)}return r}var I=Oa;var be=Math.max;function ja(t,e,r){return e=be(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=be(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),me(t,this,n)}}var ye=ja;var Aa=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Aa}var G=Pa;function Sa(t){return t!=null&&G(t.length)&&!ct(t)}var yt=Sa;var Ia=Object.prototype;function _a(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ia;return t===r}var W=_a;function Ea(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=Ea;var Ca="[object Arguments]";function Fa(t){return T(t)&&O(t)==Ca}var Nt=Fa;var we=Object.prototype,Na=we.hasOwnProperty,Ma=we.propertyIsEnumerable,Ra=Nt(function(){return arguments}())?Nt:function(t){return T(t)&&Na.call(t,"callee")&&!Ma.call(t,"callee")},K=Ra;function Ba(){return!1}var Te=Ba;var Ae=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Ae&&typeof module=="object"&&module&&!module.nodeType&&module,La=Oe&&Oe.exports===Ae,je=La?c.Buffer:void 0,ka=je?je.isBuffer:void 0,Ua=ka||Te,vt=Ua;var Da="[object Arguments]",za="[object Array]",Ga="[object Boolean]",Wa="[object Date]",Ka="[object Error]",$a="[object Function]",Ha="[object Map]",Va="[object Number]",qa="[object Object]",Ya="[object RegExp]",Za="[object Set]",Ja="[object String]",Xa="[object WeakMap]",Qa="[object ArrayBuffer]",ti="[object DataView]",ei="[object Float32Array]",ri="[object Float64Array]",oi="[object Int8Array]",ai="[object Int16Array]",ii="[object Int32Array]",si="[object Uint8Array]",ni="[object Uint8ClampedArray]",fi="[object Uint16Array]",pi="[object Uint32Array]",u={};u[ei]=u[ri]=u[oi]=u[ai]=u[ii]=u[si]=u[ni]=u[fi]=u[pi]=!0;u[Da]=u[za]=u[Qa]=u[Ga]=u[ti]=u[Wa]=u[Ka]=u[$a]=u[Ha]=u[Va]=u[qa]=u[Ya]=u[Za]=u[Ja]=u[Xa]=!1;function li(t){return T(t)&&G(t.length)&&!!u[O(t)]}var Pe=li;function mi(t){return function(e){return t(e)}}var $=mi;var Se=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nt=Se&&typeof module=="object"&&module&&!module.nodeType&&module,ui=nt&&nt.exports===Se,Mt=ui&&dt.process,di=function(){try{var t=nt&&nt.require&&nt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch{}}(),P=di;var Ie=P&&P.isTypedArray,ci=Ie?$(Ie):Pe,_e=ci;var hi=Object.prototype,xi=hi.hasOwnProperty;function gi(t,e){var r=g(t),o=!r&&K(t),a=!r&&!o&&vt(t),s=!r&&!o&&!a&&_e(t),i=r||o||a||s,n=i?ve(t.length,String):[],d=n.length;for(var h in t)(e||xi.call(t,h))&&!(i&&(h=="length"||a&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||D(h,d)))&&n.push(h);return n}var wt=gi;function bi(t,e){return function(r){return t(e(r))}}var Tt=bi;var yi=Tt(Object.keys,Object),Ee=yi;var vi=Object.prototype,wi=vi.hasOwnProperty;function Ti(t){if(!W(t))return Ee(t);var e=[];for(var r in Object(t))wi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ce=Ti;function Oi(t){return yt(t)?wt(t):Ce(t)}var H=Oi;function ji(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Fe=ji;var Ai=Object.prototype,Pi=Ai.hasOwnProperty;function Si(t){if(!w(t))return Fe(t);var e=W(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Ne=Si;function Ii(t){return yt(t)?wt(t,!0):Ne(t)}var V=Ii;var _i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ei=/^\w*$/;function Ci(t,e){if(g(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||k(t)?!0:Ei.test(t)||!_i.test(t)||e!=null&&t in Object(e)}var Me=Ci;var Fi=y(Object,"create"),S=Fi;function Ni(){this.__data__=S?S(null):{},this.size=0}var Re=Ni;function Mi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Mi;var Ri="__lodash_hash_undefined__",Bi=Object.prototype,Li=Bi.hasOwnProperty;function ki(t){var e=this.__data__;if(S){var r=e[t];return r===Ri?void 0:r}return Li.call(e,t)?e[t]:void 0}var Le=ki;var Ui=Object.prototype,Di=Ui.hasOwnProperty;function zi(t){var e=this.__data__;return S?e[t]!==void 0:Di.call(e,t)}var ke=zi;var Gi="__lodash_hash_undefined__";function Wi(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=S&&e===void 0?Gi:e,this}var Ue=Wi;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=Re;q.prototype.delete=Be;q.prototype.get=Le;q.prototype.has=ke;q.prototype.set=Ue;var Rt=q;function Ki(){this.__data__=[],this.size=0}var De=Ki;function $i(t,e){for(var r=t.length;r--;)if(bt(t[r][0],e))return r;return-1}var _=$i;var Hi=Array.prototype,Vi=Hi.splice;function qi(t){var e=this.__data__,r=_(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Vi.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=_(e,t);return r<0?void 0:e[r][1]}var Ge=Yi;function Zi(t){return _(this.__data__,t)>-1}var We=Zi;function Ji(t,e){var r=this.__data__,o=_(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Ke=Ji;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=De;Y.prototype.delete=ze;Y.prototype.get=Ge;Y.prototype.has=We;Y.prototype.set=Ke;var E=Y;var Xi=y(c,"Map"),C=Xi;function Qi(){this.size=0,this.__data__={hash:new Rt,map:new(C||E),string:new Rt}}var $e=Qi;function ts(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var He=ts;function es(t,e){var r=t.__data__;return He(e)?r[typeof e=="string"?"string":"hash"]:r.map}var F=es;function rs(t){var e=F(this,t).delete(t);return this.size-=e?1:0,e}var Ve=rs;function os(t){return F(this,t).get(t)}var qe=os;function as(t){return F(this,t).has(t)}var Ye=as;function is(t,e){var r=F(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=is;function Z(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Z.prototype.clear=$e;Z.prototype.delete=Ve;Z.prototype.get=qe;Z.prototype.has=Ye;Z.prototype.set=Ze;var ft=Z;var ss="Expected a function";function Bt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(ss);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Bt.Cache||ft),r}Bt.Cache=ft;var Je=Bt;var ns=500;function fs(t){var e=Je(t,function(o){return r.size===ns&&r.clear(),o}),r=e.cache;return e}var Xe=fs;var ps=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ls=/\\(\\)?/g,ms=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ps,function(r,o,a,s){e.push(a?s.replace(ls,"$1"):o||r)}),e}),Qe=ms;function us(t){return t==null?"":oe(t)}var tr=us;function ds(t,e){return g(t)?t:Me(t,e)?[t]:Qe(tr(t))}var N=ds;var cs=1/0;function hs(t){if(typeof t=="string"||k(t))return t;var e=t+"";return e=="0"&&1/t==-cs?"-0":e}var J=hs;function xs(t,e){e=N(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[J(e[r++])];return r&&r==o?t:void 0}var er=xs;function gs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var X=gs;var rr=b?b.isConcatSpreadable:void 0;function bs(t){return g(t)||K(t)||!!(rr&&t&&t[rr])}var or=bs;function ar(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=or),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?ar(n,e-1,r,o,a):X(a,n):o||(a[a.length]=n)}return a}var ir=ar;function ys(t){var e=t==null?0:t.length;return e?ir(t,1):[]}var sr=ys;function vs(t){return xe(ye(t,void 0,sr),t+"")}var nr=vs;var ws=Tt(Object.getPrototypeOf,Object),Ot=ws;function Ts(){this.__data__=new E,this.size=0}var fr=Ts;function Os(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Os;function js(t){return this.__data__.get(t)}var lr=js;function As(t){return this.__data__.has(t)}var mr=As;var Ps=200;function Ss(t,e){var r=this.__data__;if(r instanceof E){var o=r.__data__;if(!C||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ft(o)}return r.set(t,e),this.size=r.size,this}var ur=Ss;function Q(t){var e=this.__data__=new E(t);this.size=e.size}Q.prototype.clear=fr;Q.prototype.delete=pr;Q.prototype.get=lr;Q.prototype.has=mr;Q.prototype.set=ur;var dr=Q;function Is(t,e){return t&&I(e,H(e),t)}var cr=Is;function _s(t,e){return t&&I(e,V(e),t)}var hr=_s;var yr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=yr&&typeof module=="object"&&module&&!module.nodeType&&module,Es=xr&&xr.exports===yr,gr=Es?c.Buffer:void 0,br=gr?gr.allocUnsafe:void 0;function Cs(t,e){if(e)return t.slice();var r=t.length,o=br?br(r):new t.constructor(r);return t.copy(o),o}var vr=Cs;function Fs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var wr=Fs;function Ns(){return[]}var jt=Ns;var Ms=Object.prototype,Rs=Ms.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Bs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Rs.call(t,e)}))}:jt,tt=Bs;function Ls(t,e){return I(t,tt(t),e)}var Or=Ls;var ks=Object.getOwnPropertySymbols,Us=ks?function(t){for(var e=[];t;)X(e,tt(t)),t=Ot(t);return e}:jt,At=Us;function Ds(t,e){return I(t,At(t),e)}var jr=Ds;function zs(t,e,r){var o=e(t);return g(t)?o:X(o,r(t))}var Pt=zs;function Gs(t){return Pt(t,H,tt)}var Ar=Gs;function Ws(t){return Pt(t,V,At)}var Pr=Ws;var Ks=y(c,"DataView"),St=Ks;var $s=y(c,"Promise"),It=$s;var Hs=y(c,"Set"),_t=Hs;var Sr="[object Map]",Vs="[object Object]",Ir="[object Promise]",_r="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=A(St),Ys=A(C),Zs=A(It),Js=A(_t),Xs=A(xt),B=O;(St&&B(new St(new ArrayBuffer(1)))!=Cr||C&&B(new C)!=Sr||It&&B(It.resolve())!=Ir||_t&&B(new _t)!=_r||xt&&B(new xt)!=Er)&&(B=function(t){var e=O(t),r=e==Vs?t.constructor:void 0,o=r?A(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Sr;case Zs:return Ir;case Js:return _r;case Xs:return Er}return e});var et=B;var Qs=Object.prototype,tn=Qs.hasOwnProperty;function en(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&tn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Fr=en;var rn=c.Uint8Array,Lt=rn;function on(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var rt=on;function an(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Nr=an;var sn=/\w*$/;function nn(t){var e=new t.constructor(t.source,sn.exec(t));return e.lastIndex=t.lastIndex,e}var Mr=nn;var Rr=b?b.prototype:void 0,Br=Rr?Rr.valueOf:void 0;function fn(t){return Br?Object(Br.call(t)):{}}var Lr=fn;function pn(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var kr=pn;var ln="[object Boolean]",mn="[object Date]",un="[object Map]",dn="[object Number]",cn="[object RegExp]",hn="[object Set]",xn="[object String]",gn="[object Symbol]",bn="[object ArrayBuffer]",yn="[object DataView]",vn="[object Float32Array]",wn="[object Float64Array]",Tn="[object Int8Array]",On="[object Int16Array]",jn="[object Int32Array]",An="[object Uint8Array]",Pn="[object Uint8ClampedArray]",Sn="[object Uint16Array]",In="[object Uint32Array]";function _n(t,e,r){var o=t.constructor;switch(e){case bn:return rt(t);case ln:case mn:return new o(+t);case yn:return Nr(t,r);case vn:case wn:case Tn:case On:case jn:case An:case Pn:case Sn:case In:return kr(t,r);case un:return new o;case dn:case xn:return new o(t);case cn:return Mr(t);case hn:return new o;case gn:return Lr(t)}}var Ur=_n;function En(t){return typeof t.constructor=="function"&&!W(t)?le(Ot(t)):{}}var Dr=En;var Cn="[object Map]";function Fn(t){return T(t)&&et(t)==Cn}var zr=Fn;var Gr=P&&P.isMap,Nn=Gr?$(Gr):zr,Wr=Nn;var Mn="[object Set]";function Rn(t){return T(t)&&et(t)==Mn}var Kr=Rn;var $r=P&&P.isSet,Bn=$r?$($r):Kr,Hr=Bn;var Ln=1,kn=2,Un=4,Vr="[object Arguments]",Dn="[object Array]",zn="[object Boolean]",Gn="[object Date]",Wn="[object Error]",qr="[object Function]",Kn="[object GeneratorFunction]",$n="[object Map]",Hn="[object Number]",Yr="[object Object]",Vn="[object RegExp]",qn="[object Set]",Yn="[object String]",Zn="[object Symbol]",Jn="[object WeakMap]",Xn="[object ArrayBuffer]",Qn="[object DataView]",tf="[object Float32Array]",ef="[object Float64Array]",rf="[object Int8Array]",of="[object Int16Array]",af="[object Int32Array]",sf="[object Uint8Array]",nf="[object Uint8ClampedArray]",ff="[object Uint16Array]",pf="[object Uint32Array]",m={};m[Vr]=m[Dn]=m[Xn]=m[Qn]=m[zn]=m[Gn]=m[tf]=m[ef]=m[rf]=m[of]=m[af]=m[$n]=m[Hn]=m[Yr]=m[Vn]=m[qn]=m[Yn]=m[Zn]=m[sf]=m[nf]=m[ff]=m[pf]=!0;m[Wn]=m[qr]=m[Jn]=!1;function Et(t,e,r,o,a,s){var i,n=e&Ln,d=e&kn,h=e&Un;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!w(t))return t;var x=g(t);if(x){if(i=Fr(t),!n)return ue(t,i)}else{var j=et(t),pt=j==qr||j==Kn;if(vt(t))return vr(t,n);if(j==Yr||j==Vr||pt&&!a){if(i=d||pt?{}:Dr(t),!n)return d?jr(t,hr(i,t)):Or(t,cr(i,t))}else{if(!m[j])return a?t:{};i=Ur(t,j,n)}}s||(s=new dr);var at=s.get(t);if(at)return at;s.set(t,i),Hr(t)?t.forEach(function(v){i.add(Et(v,e,r,v,t,s))}):Wr(t)&&t.forEach(function(v,f){i.set(f,Et(v,e,r,f,t,s))});var lt=h?d?Pr:Ar:d?V:H,mt=x?void 0:lt(t);return ge(mt||t,function(v,f){mt&&(f=v,v=t[f]),z(i,f,Et(v,e,r,f,t,s))}),i}var Zr=Et;var lf=1,mf=4;function uf(t){return Zr(t,lf|mf)}var kt=uf;function df(t,e){return t!=null&&e in Object(t)}var Jr=df;function cf(t,e,r){e=N(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=J(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&G(a)&&D(i,a)&&(g(t)||K(t)))}var Xr=cf;function hf(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=hf;function xf(t,e,r,o){if(!w(t))return t;e=N(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var d=J(e[a]),h=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(a!=i){var x=n[d];h=o?o(x,d,n):void 0,h===void 0&&(h=w(x)?x:D(e[a+1])?[]:{})}z(n,d,h),n=n[d]}return t}var to=xf;function gf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=er(t,i);r(n,i)&&to(s,N(i,t),n)}return s}var eo=gf;function bf(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=bf;var yf=nr(function(t,e){return t==null?{}:ro(t,e)}),Ct=yf;function oo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var ao="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Ut=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ao[r[t]&63];return e};var vf="array",wf="bit",io="bits",Tf="byte",so="bytes",ot="",Of="exponent",jf="function",no="iec",Af="Invalid number",Pf="Invalid rounding method",Dt="jedec",Sf="object",fo=".",If="round",_f="s",Ef="si",Cf="kbit",Ff="kB",Nf=" ",Mf="string",Rf="0",zt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function po(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=ot,localeOptions:i={},separator:n=ot,spacer:d=Nf,symbols:h={},standard:x=ot,output:j=Mf,fullform:pt=!1,fullforms:at=[],exponent:lt=-1,roundingMethod:mt=If,precision:v=0}={}){let f=lt,L=Number(t),l=[],R=0,Ft=ot;x===Ef?(o=10,x=Dt):x===no||x===Dt?o=2:o===2?x=no:(o=10,x=Dt);let ut=o===10?1e3:1024,lo=pt===!0,Wt=L<0,Kt=Math[mt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Af);if(typeof Kt!==jf)throw new TypeError(Pf);if(Wt&&(L=-L),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(L)/Math.log(ut)),f<0&&(f=0)),f>8&&(v>0&&(v+=8-f),f=8),j===Of)return f;if(L===0)l[0]=0,Ft=l[1]=zt.symbol[x][e?io:so][f];else{R=L/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(R=R*8,R>=ut&&f<8&&(R=R/ut,f++));let it=Math.pow(10,f>0?a:0);l[0]=Kt(R*it)/it,l[0]===ut&&f<8&<===-1&&(l[0]=1,f++),Ft=l[1]=o===10&&f===1?e?Cf:Ff:zt.symbol[x][e?io:so][f]}if(Wt&&(l[0]=-l[0]),v>0&&(l[0]=l[0].toPrecision(v)),l[1]=h[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,i):n.length>0&&(l[0]=l[0].toString().replace(fo,n)),r&&a>0){let it=l[0].toString(),$t=n||(it.match(/(\D)/g)||[]).pop()||fo,Ht=it.toString().split($t),Vt=Ht[1]||ot,qt=Vt.length,mo=a-qt;l[0]=`${Ht[0]}${$t}${Vt.padEnd(qt+mo,Rf)}`}return lo&&(l[1]=at[f]?at[f]:zt.fullform[x][f]+(e?wf:Tf)+(l[0]===1?ot:_f)),j===vf?l:j===Sf?{value:l[0],symbol:l[1],exponent:f,unit:Ft}:l.join(d)}var M=class t{constructor(e){p(this,"_tera");p(this,"id");p(this,"sbId");p(this,"name");p(this,"icon");p(this,"path");p(this,"url");p(this,"teraUrl");p(this,"parsedName");p(this,"created");p(this,"createdFormatted");p(this,"modified");p(this,"modifiedFormatted");p(this,"accessed");p(this,"accessedFormatted");p(this,"size");p(this,"sizeFormatted");p(this,"mime");p(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=po(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Ct(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Ct(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var Gt=class{constructor(e){p(this,"settings",{session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null});p(this,"events",oo());p(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});p(this,"methods",["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"]);p(this,"plugins",[]);p(this,"namespaces",{});p(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Ut();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||Ut(),...kt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):(r==null?void 0:r.action)=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):(r==null?void 0:r.action)=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r!=null&&r.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>{var o;return(o=this.settings).session||(o.session="tfy-"+this.getEntropicString(16))}).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).catch(o=>this.debug("WARN",0,"Init process fault",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),d=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(d,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o()).catch(a)};d()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
1
|
+
var uo=Object.defineProperty;var co=(t,e,r)=>e in t?uo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var p=(t,e,r)=>co(t,typeof e!="symbol"?e+"":e,r);var ho=typeof global=="object"&&global&&global.Object===Object&&global,dt=ho;var xo=typeof self=="object"&&self&&self.Object===Object&&self,go=dt||xo||Function("return this")(),c=go;var bo=c.Symbol,b=bo;var Yt=Object.prototype,yo=Yt.hasOwnProperty,vo=Yt.toString,st=b?b.toStringTag:void 0;function wo(t){var e=yo.call(t,st),r=t[st];try{t[st]=void 0;var o=!0}catch{}var a=vo.call(t);return o&&(e?t[st]=r:delete t[st]),a}var Zt=wo;var To=Object.prototype,Oo=To.toString;function jo(t){return Oo.call(t)}var Jt=jo;var Ao="[object Null]",Po="[object Undefined]",Xt=b?b.toStringTag:void 0;function So(t){return t==null?t===void 0?Po:Ao:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var O=So;function Io(t){return t!=null&&typeof t=="object"}var T=Io;var _o="[object Symbol]";function Eo(t){return typeof t=="symbol"||T(t)&&O(t)==_o}var k=Eo;function Co(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Qt=Co;var Fo=Array.isArray,g=Fo;var No=1/0,te=b?b.prototype:void 0,ee=te?te.toString:void 0;function re(t){if(typeof t=="string")return t;if(g(t))return Qt(t,re)+"";if(k(t))return ee?ee.call(t):"";var e=t+"";return e=="0"&&1/t==-No?"-0":e}var oe=re;function Mo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var w=Mo;function Ro(t){return t}var ae=Ro;var Bo="[object AsyncFunction]",Lo="[object Function]",ko="[object GeneratorFunction]",Uo="[object Proxy]";function Do(t){if(!w(t))return!1;var e=O(t);return e==Lo||e==ko||e==Bo||e==Uo}var ct=Do;var zo=c["__core-js_shared__"],ht=zo;var ie=function(){var t=/[^.]+$/.exec(ht&&ht.keys&&ht.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Go(t){return!!ie&&ie in t}var se=Go;var Wo=Function.prototype,Ko=Wo.toString;function $o(t){if(t!=null){try{return Ko.call(t)}catch{}try{return t+""}catch{}}return""}var A=$o;var Ho=/[\\^$.*+?()[\]{}|]/g,Vo=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Zo=qo.toString,Jo=Yo.hasOwnProperty,Xo=RegExp("^"+Zo.call(Jo).replace(Ho,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Qo(t){if(!w(t)||se(t))return!1;var e=ct(t)?Xo:Vo;return e.test(A(t))}var ne=Qo;function ta(t,e){return t==null?void 0:t[e]}var fe=ta;function ea(t,e){var r=fe(t,e);return ne(r)?r:void 0}var y=ea;var ra=y(c,"WeakMap"),xt=ra;var pe=Object.create,oa=function(){function t(){}return function(e){if(!w(e))return{};if(pe)return pe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),le=oa;function aa(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var me=aa;function ia(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=ia;var sa=800,na=16,fa=Date.now;function pa(t){var e=0,r=0;return function(){var o=fa(),a=na-(o-r);if(r=o,a>0){if(++e>=sa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var de=pa;function la(t){return function(){return t}}var ce=la;var ma=function(){try{var t=y(Object,"defineProperty");return t({},"",{}),t}catch{}}(),U=ma;var ua=U?function(t,e){return U(t,"toString",{configurable:!0,enumerable:!1,value:ce(e),writable:!0})}:ae,he=ua;var da=de(he),xe=da;function ca(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ge=ca;var ha=9007199254740991,xa=/^(?:0|[1-9]\d*)$/;function ga(t,e){var r=typeof t;return e=e==null?ha:e,!!e&&(r=="number"||r!="symbol"&&xa.test(t))&&t>-1&&t%1==0&&t<e}var D=ga;function ba(t,e,r){e=="__proto__"&&U?U(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var gt=ba;function ya(t,e){return t===e||t!==t&&e!==e}var bt=ya;var va=Object.prototype,wa=va.hasOwnProperty;function Ta(t,e,r){var o=t[e];(!(wa.call(t,e)&&bt(o,r))||r===void 0&&!(e in t))&>(t,e,r)}var z=Ta;function Oa(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],d=o?o(r[n],t[n],n,r,t):void 0;d===void 0&&(d=t[n]),a?gt(r,n,d):z(r,n,d)}return r}var I=Oa;var be=Math.max;function ja(t,e,r){return e=be(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=be(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),me(t,this,n)}}var ye=ja;var Aa=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Aa}var G=Pa;function Sa(t){return t!=null&&G(t.length)&&!ct(t)}var yt=Sa;var Ia=Object.prototype;function _a(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ia;return t===r}var W=_a;function Ea(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=Ea;var Ca="[object Arguments]";function Fa(t){return T(t)&&O(t)==Ca}var Nt=Fa;var we=Object.prototype,Na=we.hasOwnProperty,Ma=we.propertyIsEnumerable,Ra=Nt(function(){return arguments}())?Nt:function(t){return T(t)&&Na.call(t,"callee")&&!Ma.call(t,"callee")},K=Ra;function Ba(){return!1}var Te=Ba;var Ae=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Ae&&typeof module=="object"&&module&&!module.nodeType&&module,La=Oe&&Oe.exports===Ae,je=La?c.Buffer:void 0,ka=je?je.isBuffer:void 0,Ua=ka||Te,vt=Ua;var Da="[object Arguments]",za="[object Array]",Ga="[object Boolean]",Wa="[object Date]",Ka="[object Error]",$a="[object Function]",Ha="[object Map]",Va="[object Number]",qa="[object Object]",Ya="[object RegExp]",Za="[object Set]",Ja="[object String]",Xa="[object WeakMap]",Qa="[object ArrayBuffer]",ti="[object DataView]",ei="[object Float32Array]",ri="[object Float64Array]",oi="[object Int8Array]",ai="[object Int16Array]",ii="[object Int32Array]",si="[object Uint8Array]",ni="[object Uint8ClampedArray]",fi="[object Uint16Array]",pi="[object Uint32Array]",u={};u[ei]=u[ri]=u[oi]=u[ai]=u[ii]=u[si]=u[ni]=u[fi]=u[pi]=!0;u[Da]=u[za]=u[Qa]=u[Ga]=u[ti]=u[Wa]=u[Ka]=u[$a]=u[Ha]=u[Va]=u[qa]=u[Ya]=u[Za]=u[Ja]=u[Xa]=!1;function li(t){return T(t)&&G(t.length)&&!!u[O(t)]}var Pe=li;function mi(t){return function(e){return t(e)}}var $=mi;var Se=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nt=Se&&typeof module=="object"&&module&&!module.nodeType&&module,ui=nt&&nt.exports===Se,Mt=ui&&dt.process,di=function(){try{var t=nt&&nt.require&&nt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch{}}(),P=di;var Ie=P&&P.isTypedArray,ci=Ie?$(Ie):Pe,_e=ci;var hi=Object.prototype,xi=hi.hasOwnProperty;function gi(t,e){var r=g(t),o=!r&&K(t),a=!r&&!o&&vt(t),s=!r&&!o&&!a&&_e(t),i=r||o||a||s,n=i?ve(t.length,String):[],d=n.length;for(var h in t)(e||xi.call(t,h))&&!(i&&(h=="length"||a&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||D(h,d)))&&n.push(h);return n}var wt=gi;function bi(t,e){return function(r){return t(e(r))}}var Tt=bi;var yi=Tt(Object.keys,Object),Ee=yi;var vi=Object.prototype,wi=vi.hasOwnProperty;function Ti(t){if(!W(t))return Ee(t);var e=[];for(var r in Object(t))wi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ce=Ti;function Oi(t){return yt(t)?wt(t):Ce(t)}var H=Oi;function ji(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Fe=ji;var Ai=Object.prototype,Pi=Ai.hasOwnProperty;function Si(t){if(!w(t))return Fe(t);var e=W(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Ne=Si;function Ii(t){return yt(t)?wt(t,!0):Ne(t)}var V=Ii;var _i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ei=/^\w*$/;function Ci(t,e){if(g(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||k(t)?!0:Ei.test(t)||!_i.test(t)||e!=null&&t in Object(e)}var Me=Ci;var Fi=y(Object,"create"),S=Fi;function Ni(){this.__data__=S?S(null):{},this.size=0}var Re=Ni;function Mi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Mi;var Ri="__lodash_hash_undefined__",Bi=Object.prototype,Li=Bi.hasOwnProperty;function ki(t){var e=this.__data__;if(S){var r=e[t];return r===Ri?void 0:r}return Li.call(e,t)?e[t]:void 0}var Le=ki;var Ui=Object.prototype,Di=Ui.hasOwnProperty;function zi(t){var e=this.__data__;return S?e[t]!==void 0:Di.call(e,t)}var ke=zi;var Gi="__lodash_hash_undefined__";function Wi(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=S&&e===void 0?Gi:e,this}var Ue=Wi;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=Re;q.prototype.delete=Be;q.prototype.get=Le;q.prototype.has=ke;q.prototype.set=Ue;var Rt=q;function Ki(){this.__data__=[],this.size=0}var De=Ki;function $i(t,e){for(var r=t.length;r--;)if(bt(t[r][0],e))return r;return-1}var _=$i;var Hi=Array.prototype,Vi=Hi.splice;function qi(t){var e=this.__data__,r=_(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Vi.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=_(e,t);return r<0?void 0:e[r][1]}var Ge=Yi;function Zi(t){return _(this.__data__,t)>-1}var We=Zi;function Ji(t,e){var r=this.__data__,o=_(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Ke=Ji;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=De;Y.prototype.delete=ze;Y.prototype.get=Ge;Y.prototype.has=We;Y.prototype.set=Ke;var E=Y;var Xi=y(c,"Map"),C=Xi;function Qi(){this.size=0,this.__data__={hash:new Rt,map:new(C||E),string:new Rt}}var $e=Qi;function ts(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var He=ts;function es(t,e){var r=t.__data__;return He(e)?r[typeof e=="string"?"string":"hash"]:r.map}var F=es;function rs(t){var e=F(this,t).delete(t);return this.size-=e?1:0,e}var Ve=rs;function os(t){return F(this,t).get(t)}var qe=os;function as(t){return F(this,t).has(t)}var Ye=as;function is(t,e){var r=F(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=is;function Z(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Z.prototype.clear=$e;Z.prototype.delete=Ve;Z.prototype.get=qe;Z.prototype.has=Ye;Z.prototype.set=Ze;var ft=Z;var ss="Expected a function";function Bt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(ss);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Bt.Cache||ft),r}Bt.Cache=ft;var Je=Bt;var ns=500;function fs(t){var e=Je(t,function(o){return r.size===ns&&r.clear(),o}),r=e.cache;return e}var Xe=fs;var ps=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ls=/\\(\\)?/g,ms=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ps,function(r,o,a,s){e.push(a?s.replace(ls,"$1"):o||r)}),e}),Qe=ms;function us(t){return t==null?"":oe(t)}var tr=us;function ds(t,e){return g(t)?t:Me(t,e)?[t]:Qe(tr(t))}var N=ds;var cs=1/0;function hs(t){if(typeof t=="string"||k(t))return t;var e=t+"";return e=="0"&&1/t==-cs?"-0":e}var J=hs;function xs(t,e){e=N(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[J(e[r++])];return r&&r==o?t:void 0}var er=xs;function gs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var X=gs;var rr=b?b.isConcatSpreadable:void 0;function bs(t){return g(t)||K(t)||!!(rr&&t&&t[rr])}var or=bs;function ar(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=or),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?ar(n,e-1,r,o,a):X(a,n):o||(a[a.length]=n)}return a}var ir=ar;function ys(t){var e=t==null?0:t.length;return e?ir(t,1):[]}var sr=ys;function vs(t){return xe(ye(t,void 0,sr),t+"")}var nr=vs;var ws=Tt(Object.getPrototypeOf,Object),Ot=ws;function Ts(){this.__data__=new E,this.size=0}var fr=Ts;function Os(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Os;function js(t){return this.__data__.get(t)}var lr=js;function As(t){return this.__data__.has(t)}var mr=As;var Ps=200;function Ss(t,e){var r=this.__data__;if(r instanceof E){var o=r.__data__;if(!C||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ft(o)}return r.set(t,e),this.size=r.size,this}var ur=Ss;function Q(t){var e=this.__data__=new E(t);this.size=e.size}Q.prototype.clear=fr;Q.prototype.delete=pr;Q.prototype.get=lr;Q.prototype.has=mr;Q.prototype.set=ur;var dr=Q;function Is(t,e){return t&&I(e,H(e),t)}var cr=Is;function _s(t,e){return t&&I(e,V(e),t)}var hr=_s;var yr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=yr&&typeof module=="object"&&module&&!module.nodeType&&module,Es=xr&&xr.exports===yr,gr=Es?c.Buffer:void 0,br=gr?gr.allocUnsafe:void 0;function Cs(t,e){if(e)return t.slice();var r=t.length,o=br?br(r):new t.constructor(r);return t.copy(o),o}var vr=Cs;function Fs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var wr=Fs;function Ns(){return[]}var jt=Ns;var Ms=Object.prototype,Rs=Ms.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Bs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Rs.call(t,e)}))}:jt,tt=Bs;function Ls(t,e){return I(t,tt(t),e)}var Or=Ls;var ks=Object.getOwnPropertySymbols,Us=ks?function(t){for(var e=[];t;)X(e,tt(t)),t=Ot(t);return e}:jt,At=Us;function Ds(t,e){return I(t,At(t),e)}var jr=Ds;function zs(t,e,r){var o=e(t);return g(t)?o:X(o,r(t))}var Pt=zs;function Gs(t){return Pt(t,H,tt)}var Ar=Gs;function Ws(t){return Pt(t,V,At)}var Pr=Ws;var Ks=y(c,"DataView"),St=Ks;var $s=y(c,"Promise"),It=$s;var Hs=y(c,"Set"),_t=Hs;var Sr="[object Map]",Vs="[object Object]",Ir="[object Promise]",_r="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=A(St),Ys=A(C),Zs=A(It),Js=A(_t),Xs=A(xt),B=O;(St&&B(new St(new ArrayBuffer(1)))!=Cr||C&&B(new C)!=Sr||It&&B(It.resolve())!=Ir||_t&&B(new _t)!=_r||xt&&B(new xt)!=Er)&&(B=function(t){var e=O(t),r=e==Vs?t.constructor:void 0,o=r?A(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Sr;case Zs:return Ir;case Js:return _r;case Xs:return Er}return e});var et=B;var Qs=Object.prototype,tn=Qs.hasOwnProperty;function en(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&tn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Fr=en;var rn=c.Uint8Array,Lt=rn;function on(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var rt=on;function an(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Nr=an;var sn=/\w*$/;function nn(t){var e=new t.constructor(t.source,sn.exec(t));return e.lastIndex=t.lastIndex,e}var Mr=nn;var Rr=b?b.prototype:void 0,Br=Rr?Rr.valueOf:void 0;function fn(t){return Br?Object(Br.call(t)):{}}var Lr=fn;function pn(t,e){var r=e?rt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var kr=pn;var ln="[object Boolean]",mn="[object Date]",un="[object Map]",dn="[object Number]",cn="[object RegExp]",hn="[object Set]",xn="[object String]",gn="[object Symbol]",bn="[object ArrayBuffer]",yn="[object DataView]",vn="[object Float32Array]",wn="[object Float64Array]",Tn="[object Int8Array]",On="[object Int16Array]",jn="[object Int32Array]",An="[object Uint8Array]",Pn="[object Uint8ClampedArray]",Sn="[object Uint16Array]",In="[object Uint32Array]";function _n(t,e,r){var o=t.constructor;switch(e){case bn:return rt(t);case ln:case mn:return new o(+t);case yn:return Nr(t,r);case vn:case wn:case Tn:case On:case jn:case An:case Pn:case Sn:case In:return kr(t,r);case un:return new o;case dn:case xn:return new o(t);case cn:return Mr(t);case hn:return new o;case gn:return Lr(t)}}var Ur=_n;function En(t){return typeof t.constructor=="function"&&!W(t)?le(Ot(t)):{}}var Dr=En;var Cn="[object Map]";function Fn(t){return T(t)&&et(t)==Cn}var zr=Fn;var Gr=P&&P.isMap,Nn=Gr?$(Gr):zr,Wr=Nn;var Mn="[object Set]";function Rn(t){return T(t)&&et(t)==Mn}var Kr=Rn;var $r=P&&P.isSet,Bn=$r?$($r):Kr,Hr=Bn;var Ln=1,kn=2,Un=4,Vr="[object Arguments]",Dn="[object Array]",zn="[object Boolean]",Gn="[object Date]",Wn="[object Error]",qr="[object Function]",Kn="[object GeneratorFunction]",$n="[object Map]",Hn="[object Number]",Yr="[object Object]",Vn="[object RegExp]",qn="[object Set]",Yn="[object String]",Zn="[object Symbol]",Jn="[object WeakMap]",Xn="[object ArrayBuffer]",Qn="[object DataView]",tf="[object Float32Array]",ef="[object Float64Array]",rf="[object Int8Array]",of="[object Int16Array]",af="[object Int32Array]",sf="[object Uint8Array]",nf="[object Uint8ClampedArray]",ff="[object Uint16Array]",pf="[object Uint32Array]",m={};m[Vr]=m[Dn]=m[Xn]=m[Qn]=m[zn]=m[Gn]=m[tf]=m[ef]=m[rf]=m[of]=m[af]=m[$n]=m[Hn]=m[Yr]=m[Vn]=m[qn]=m[Yn]=m[Zn]=m[sf]=m[nf]=m[ff]=m[pf]=!0;m[Wn]=m[qr]=m[Jn]=!1;function Et(t,e,r,o,a,s){var i,n=e&Ln,d=e&kn,h=e&Un;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!w(t))return t;var x=g(t);if(x){if(i=Fr(t),!n)return ue(t,i)}else{var j=et(t),pt=j==qr||j==Kn;if(vt(t))return vr(t,n);if(j==Yr||j==Vr||pt&&!a){if(i=d||pt?{}:Dr(t),!n)return d?jr(t,hr(i,t)):Or(t,cr(i,t))}else{if(!m[j])return a?t:{};i=Ur(t,j,n)}}s||(s=new dr);var at=s.get(t);if(at)return at;s.set(t,i),Hr(t)?t.forEach(function(v){i.add(Et(v,e,r,v,t,s))}):Wr(t)&&t.forEach(function(v,f){i.set(f,Et(v,e,r,f,t,s))});var lt=h?d?Pr:Ar:d?V:H,mt=x?void 0:lt(t);return ge(mt||t,function(v,f){mt&&(f=v,v=t[f]),z(i,f,Et(v,e,r,f,t,s))}),i}var Zr=Et;var lf=1,mf=4;function uf(t){return Zr(t,lf|mf)}var kt=uf;function df(t,e){return t!=null&&e in Object(t)}var Jr=df;function cf(t,e,r){e=N(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=J(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&G(a)&&D(i,a)&&(g(t)||K(t)))}var Xr=cf;function hf(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=hf;function xf(t,e,r,o){if(!w(t))return t;e=N(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var d=J(e[a]),h=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(a!=i){var x=n[d];h=o?o(x,d,n):void 0,h===void 0&&(h=w(x)?x:D(e[a+1])?[]:{})}z(n,d,h),n=n[d]}return t}var to=xf;function gf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=er(t,i);r(n,i)&&to(s,N(i,t),n)}return s}var eo=gf;function bf(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=bf;var yf=nr(function(t,e){return t==null?{}:ro(t,e)}),Ct=yf;function oo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var ao="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Ut=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=ao[r[t]&63];return e};var vf="array",wf="bit",io="bits",Tf="byte",so="bytes",ot="",Of="exponent",jf="function",no="iec",Af="Invalid number",Pf="Invalid rounding method",Dt="jedec",Sf="object",fo=".",If="round",_f="s",Ef="si",Cf="kbit",Ff="kB",Nf=" ",Mf="string",Rf="0",zt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function po(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=ot,localeOptions:i={},separator:n=ot,spacer:d=Nf,symbols:h={},standard:x=ot,output:j=Mf,fullform:pt=!1,fullforms:at=[],exponent:lt=-1,roundingMethod:mt=If,precision:v=0}={}){let f=lt,L=Number(t),l=[],R=0,Ft=ot;x===Ef?(o=10,x=Dt):x===no||x===Dt?o=2:o===2?x=no:(o=10,x=Dt);let ut=o===10?1e3:1024,lo=pt===!0,Wt=L<0,Kt=Math[mt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Af);if(typeof Kt!==jf)throw new TypeError(Pf);if(Wt&&(L=-L),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(L)/Math.log(ut)),f<0&&(f=0)),f>8&&(v>0&&(v+=8-f),f=8),j===Of)return f;if(L===0)l[0]=0,Ft=l[1]=zt.symbol[x][e?io:so][f];else{R=L/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(R=R*8,R>=ut&&f<8&&(R=R/ut,f++));let it=Math.pow(10,f>0?a:0);l[0]=Kt(R*it)/it,l[0]===ut&&f<8&<===-1&&(l[0]=1,f++),Ft=l[1]=o===10&&f===1?e?Cf:Ff:zt.symbol[x][e?io:so][f]}if(Wt&&(l[0]=-l[0]),v>0&&(l[0]=l[0].toPrecision(v)),l[1]=h[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,i):n.length>0&&(l[0]=l[0].toString().replace(fo,n)),r&&a>0){let it=l[0].toString(),$t=n||(it.match(/(\D)/g)||[]).pop()||fo,Ht=it.toString().split($t),Vt=Ht[1]||ot,qt=Vt.length,mo=a-qt;l[0]=`${Ht[0]}${$t}${Vt.padEnd(qt+mo,Rf)}`}return lo&&(l[1]=at[f]?at[f]:zt.fullform[x][f]+(e?wf:Tf)+(l[0]===1?ot:_f)),j===vf?l:j===Sf?{value:l[0],symbol:l[1],exponent:f,unit:Ft}:l.join(d)}var M=class t{constructor(e){p(this,"_tera");p(this,"id");p(this,"sbId");p(this,"name");p(this,"icon");p(this,"path");p(this,"url");p(this,"teraUrl");p(this,"parsedName");p(this,"created");p(this,"createdFormatted");p(this,"modified");p(this,"modifiedFormatted");p(this,"accessed");p(this,"accessedFormatted");p(this,"size");p(this,"sizeFormatted");p(this,"mime");p(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=po(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Ct(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Ct(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var Gt=class{constructor(e){p(this,"settings",{session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null});p(this,"events",oo());p(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});p(this,"methods",["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"]);p(this,"plugins",[]);p(this,"namespaces",{});p(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Ut();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||Ut(),...kt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):(r==null?void 0:r.action)=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):(r==null?void 0:r.action)=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r!=null&&r.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>{var o;return(o=this.settings).session||(o.session="tfy-"+this.getEntropicString(16))}).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).then(()=>r).catch(o=>(this.debug("WARN",0,"Init process fault",o),r))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),d=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(d,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o()).catch(a)};d()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
2
2
|
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){let o=typeof e=="function"?new e(this,r):typeof e=="object"?e:typeof e=="string"?(()=>{throw new Error("use(String) is not yet supported")})():(()=>{throw new Error("Expected use() call to be provided with a class initalizer")})();return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){let o=[],a=r;do o.unshift(a);while(a=Object.getPrototypeOf(a));o.forEach(s=>Object.getOwnPropertyNames(s).filter(i=>!["constructor","init","prototype","name"].includes(i)&&!i.startsWith("__")).forEach(i=>{typeof r[i]=="function"?Object.defineProperty(e,i,{enumerable:!1,value:r[i].bind(e)}):e[i]=r[i]}))}toggleDevMode(e="toggle"){var r;return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.settings.devMode&&(this.settings.restrictOrigin="*"),(r=this.dom)!=null&&r.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}getEntropicString(e=32){let r=new Uint32Array(4);return window.crypto.getRandomValues(r),btoa(String.fromCharCode(...new Uint8Array(r.buffer))).replace(/[+/]/g,"").slice(0,e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new M({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new M({tera:this,...o})))}getProjectFile(e,r){return this.rpc("getProjectFile",e,r).then(o=>o&&new M({tera:this,...o}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new M({tera:this,...r}))}};export{Gt as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
package/dist/terafy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var mo=typeof global=="object"&&global&&global.Object===Object&&global,ut=mo;var uo=typeof self=="object"&&self&&self.Object===Object&&self,co=ut||uo||Function("return this")(),d=co;var ho=d.Symbol,g=ho;var qt=Object.prototype,xo=qt.hasOwnProperty,go=qt.toString,it=g?g.toStringTag:void 0;function bo(t){var e=xo.call(t,it),r=t[it];try{t[it]=void 0;var o=!0}catch{}var a=go.call(t);return o&&(e?t[it]=r:delete t[it]),a}var Yt=bo;var yo=Object.prototype,vo=yo.toString;function wo(t){return vo.call(t)}var Zt=wo;var To="[object Null]",Oo="[object Undefined]",Jt=g?g.toStringTag:void 0;function jo(t){return t==null?t===void 0?Oo:To:Jt&&Jt in Object(t)?Yt(t):Zt(t)}var T=jo;function Ao(t){return t!=null&&typeof t=="object"}var w=Ao;var Po="[object Symbol]";function So(t){return typeof t=="symbol"||w(t)&&T(t)==Po}var L=So;function Io(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Xt=Io;var _o=Array.isArray,x=_o;var Eo=1/0,Qt=g?g.prototype:void 0,te=Qt?Qt.toString:void 0;function ee(t){if(typeof t=="string")return t;if(x(t))return Xt(t,ee)+"";if(L(t))return te?te.call(t):"";var e=t+"";return e=="0"&&1/t==-Eo?"-0":e}var re=ee;function Co(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v=Co;function Fo(t){return t}var oe=Fo;var No="[object AsyncFunction]",Mo="[object Function]",Ro="[object GeneratorFunction]",Bo="[object Proxy]";function Lo(t){if(!v(t))return!1;var e=T(t);return e==Mo||e==Ro||e==No||e==Bo}var dt=Lo;var ko=d["__core-js_shared__"],ct=ko;var ae=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Uo(t){return!!ae&&ae in t}var ie=Uo;var Do=Function.prototype,zo=Do.toString;function Go(t){if(t!=null){try{return zo.call(t)}catch{}try{return t+""}catch{}}return""}var j=Go;var Wo=/[\\^$.*+?()[\]{}|]/g,Ko=/^\[object .+?Constructor\]$/,$o=Function.prototype,Ho=Object.prototype,Vo=$o.toString,qo=Ho.hasOwnProperty,Yo=RegExp("^"+Vo.call(qo).replace(Wo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zo(t){if(!v(t)||ie(t))return!1;var e=dt(t)?Yo:Ko;return e.test(j(t))}var se=Zo;function Jo(t,e){return t?.[e]}var ne=Jo;function Xo(t,e){var r=ne(t,e);return se(r)?r:void 0}var b=Xo;var Qo=b(d,"WeakMap"),ht=Qo;var fe=Object.create,ta=function(){function t(){}return function(e){if(!v(e))return{};if(fe)return fe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),pe=ta;function ea(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var le=ea;function ra(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var me=ra;var oa=800,aa=16,ia=Date.now;function sa(t){var e=0,r=0;return function(){var o=ia(),a=aa-(o-r);if(r=o,a>0){if(++e>=oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ue=sa;function na(t){return function(){return t}}var de=na;var fa=function(){try{var t=b(Object,"defineProperty");return t({},"",{}),t}catch{}}(),k=fa;var pa=k?function(t,e){return k(t,"toString",{configurable:!0,enumerable:!1,value:de(e),writable:!0})}:oe,ce=pa;var la=ue(ce),he=la;function ma(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var xe=ma;var ua=9007199254740991,da=/^(?:0|[1-9]\d*)$/;function ca(t,e){var r=typeof t;return e=e??ua,!!e&&(r=="number"||r!="symbol"&&da.test(t))&&t>-1&&t%1==0&&t<e}var U=ca;function ha(t,e,r){e=="__proto__"&&k?k(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ha;function xa(t,e){return t===e||t!==t&&e!==e}var gt=xa;var ga=Object.prototype,ba=ga.hasOwnProperty;function ya(t,e,r){var o=t[e];(!(ba.call(t,e)&>(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var D=ya;function va(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],u=o?o(r[n],t[n],n,r,t):void 0;u===void 0&&(u=t[n]),a?xt(r,n,u):D(r,n,u)}return r}var S=va;var ge=Math.max;function wa(t,e,r){return e=ge(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ge(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),le(t,this,n)}}var be=wa;var Ta=9007199254740991;function Oa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ta}var z=Oa;function ja(t){return t!=null&&z(t.length)&&!dt(t)}var bt=ja;var Aa=Object.prototype;function Pa(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var G=Pa;function Sa(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ye=Sa;var Ia="[object Arguments]";function _a(t){return w(t)&&T(t)==Ia}var Ft=_a;var ve=Object.prototype,Ea=ve.hasOwnProperty,Ca=ve.propertyIsEnumerable,Fa=Ft(function(){return arguments}())?Ft:function(t){return w(t)&&Ea.call(t,"callee")&&!Ca.call(t,"callee")},W=Fa;function Na(){return!1}var we=Na;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=je&&typeof module=="object"&&module&&!module.nodeType&&module,Ma=Te&&Te.exports===je,Oe=Ma?d.Buffer:void 0,Ra=Oe?Oe.isBuffer:void 0,Ba=Ra||we,yt=Ba;var La="[object Arguments]",ka="[object Array]",Ua="[object Boolean]",Da="[object Date]",za="[object Error]",Ga="[object Function]",Wa="[object Map]",Ka="[object Number]",$a="[object Object]",Ha="[object RegExp]",Va="[object Set]",qa="[object String]",Ya="[object WeakMap]",Za="[object ArrayBuffer]",Ja="[object DataView]",Xa="[object Float32Array]",Qa="[object Float64Array]",ti="[object Int8Array]",ei="[object Int16Array]",ri="[object Int32Array]",oi="[object Uint8Array]",ai="[object Uint8ClampedArray]",ii="[object Uint16Array]",si="[object Uint32Array]",m={};m[Xa]=m[Qa]=m[ti]=m[ei]=m[ri]=m[oi]=m[ai]=m[ii]=m[si]=!0;m[La]=m[ka]=m[Za]=m[Ua]=m[Ja]=m[Da]=m[za]=m[Ga]=m[Wa]=m[Ka]=m[$a]=m[Ha]=m[Va]=m[qa]=m[Ya]=!1;function ni(t){return w(t)&&z(t.length)&&!!m[T(t)]}var Ae=ni;function fi(t){return function(e){return t(e)}}var K=fi;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,pi=st&&st.exports===Pe,Nt=pi&&ut.process,li=function(){try{var t=st&&st.require&&st.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch{}}(),A=li;var Se=A&&A.isTypedArray,mi=Se?K(Se):Ae,Ie=mi;var ui=Object.prototype,di=ui.hasOwnProperty;function ci(t,e){var r=x(t),o=!r&&W(t),a=!r&&!o&&yt(t),s=!r&&!o&&!a&&Ie(t),i=r||o||a||s,n=i?ye(t.length,String):[],u=n.length;for(var c in t)(e||di.call(t,c))&&!(i&&(c=="length"||a&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||U(c,u)))&&n.push(c);return n}var vt=ci;function hi(t,e){return function(r){return t(e(r))}}var wt=hi;var xi=wt(Object.keys,Object),_e=xi;var gi=Object.prototype,bi=gi.hasOwnProperty;function yi(t){if(!G(t))return _e(t);var e=[];for(var r in Object(t))bi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ee=yi;function vi(t){return bt(t)?vt(t):Ee(t)}var $=vi;function wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ce=wi;var Ti=Object.prototype,Oi=Ti.hasOwnProperty;function ji(t){if(!v(t))return Ce(t);var e=G(t),r=[];for(var o in t)o=="constructor"&&(e||!Oi.call(t,o))||r.push(o);return r}var Fe=ji;function Ai(t){return bt(t)?vt(t,!0):Fe(t)}var H=Ai;var Pi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Si=/^\w*$/;function Ii(t,e){if(x(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||L(t)?!0:Si.test(t)||!Pi.test(t)||e!=null&&t in Object(e)}var Ne=Ii;var _i=b(Object,"create"),P=_i;function Ei(){this.__data__=P?P(null):{},this.size=0}var Me=Ei;function Ci(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Re=Ci;var Fi="__lodash_hash_undefined__",Ni=Object.prototype,Mi=Ni.hasOwnProperty;function Ri(t){var e=this.__data__;if(P){var r=e[t];return r===Fi?void 0:r}return Mi.call(e,t)?e[t]:void 0}var Be=Ri;var Bi=Object.prototype,Li=Bi.hasOwnProperty;function ki(t){var e=this.__data__;return P?e[t]!==void 0:Li.call(e,t)}var Le=ki;var Ui="__lodash_hash_undefined__";function Di(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=P&&e===void 0?Ui:e,this}var ke=Di;function V(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}V.prototype.clear=Me;V.prototype.delete=Re;V.prototype.get=Be;V.prototype.has=Le;V.prototype.set=ke;var Mt=V;function zi(){this.__data__=[],this.size=0}var Ue=zi;function Gi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var I=Gi;var Wi=Array.prototype,Ki=Wi.splice;function $i(t){var e=this.__data__,r=I(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ki.call(e,r,1),--this.size,!0}var De=$i;function Hi(t){var e=this.__data__,r=I(e,t);return r<0?void 0:e[r][1]}var ze=Hi;function Vi(t){return I(this.__data__,t)>-1}var Ge=Vi;function qi(t,e){var r=this.__data__,o=I(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=qi;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=Ue;q.prototype.delete=De;q.prototype.get=ze;q.prototype.has=Ge;q.prototype.set=We;var _=q;var Yi=b(d,"Map"),E=Yi;function Zi(){this.size=0,this.__data__={hash:new Mt,map:new(E||_),string:new Mt}}var Ke=Zi;function Ji(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Ji;function Xi(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var C=Xi;function Qi(t){var e=C(this,t).delete(t);return this.size-=e?1:0,e}var He=Qi;function ts(t){return C(this,t).get(t)}var Ve=ts;function es(t){return C(this,t).has(t)}var qe=es;function rs(t,e){var r=C(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ye=rs;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=Ke;Y.prototype.delete=He;Y.prototype.get=Ve;Y.prototype.has=qe;Y.prototype.set=Ye;var nt=Y;var os="Expected a function";function Rt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(os);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Rt.Cache||nt),r}Rt.Cache=nt;var Ze=Rt;var as=500;function is(t){var e=Ze(t,function(o){return r.size===as&&r.clear(),o}),r=e.cache;return e}var Je=is;var ss=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ns=/\\(\\)?/g,fs=Je(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ss,function(r,o,a,s){e.push(a?s.replace(ns,"$1"):o||r)}),e}),Xe=fs;function ps(t){return t==null?"":re(t)}var Qe=ps;function ls(t,e){return x(t)?t:Ne(t,e)?[t]:Xe(Qe(t))}var F=ls;var ms=1/0;function us(t){if(typeof t=="string"||L(t))return t;var e=t+"";return e=="0"&&1/t==-ms?"-0":e}var Z=us;function ds(t,e){e=F(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[Z(e[r++])];return r&&r==o?t:void 0}var tr=ds;function cs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var J=cs;var er=g?g.isConcatSpreadable:void 0;function hs(t){return x(t)||W(t)||!!(er&&t&&t[er])}var rr=hs;function or(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=rr),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?or(n,e-1,r,o,a):J(a,n):o||(a[a.length]=n)}return a}var ar=or;function xs(t){var e=t==null?0:t.length;return e?ar(t,1):[]}var ir=xs;function gs(t){return he(be(t,void 0,ir),t+"")}var sr=gs;var bs=wt(Object.getPrototypeOf,Object),Tt=bs;function ys(){this.__data__=new _,this.size=0}var nr=ys;function vs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var fr=vs;function ws(t){return this.__data__.get(t)}var pr=ws;function Ts(t){return this.__data__.has(t)}var lr=Ts;var Os=200;function js(t,e){var r=this.__data__;if(r instanceof _){var o=r.__data__;if(!E||o.length<Os-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new nt(o)}return r.set(t,e),this.size=r.size,this}var mr=js;function X(t){var e=this.__data__=new _(t);this.size=e.size}X.prototype.clear=nr;X.prototype.delete=fr;X.prototype.get=pr;X.prototype.has=lr;X.prototype.set=mr;var ur=X;function As(t,e){return t&&S(e,$(e),t)}var dr=As;function Ps(t,e){return t&&S(e,H(e),t)}var cr=Ps;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hr=br&&typeof module=="object"&&module&&!module.nodeType&&module,Ss=hr&&hr.exports===br,xr=Ss?d.Buffer:void 0,gr=xr?xr.allocUnsafe:void 0;function Is(t,e){if(e)return t.slice();var r=t.length,o=gr?gr(r):new t.constructor(r);return t.copy(o),o}var yr=Is;function _s(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var vr=_s;function Es(){return[]}var Ot=Es;var Cs=Object.prototype,Fs=Cs.propertyIsEnumerable,wr=Object.getOwnPropertySymbols,Ns=wr?function(t){return t==null?[]:(t=Object(t),vr(wr(t),function(e){return Fs.call(t,e)}))}:Ot,Q=Ns;function Ms(t,e){return S(t,Q(t),e)}var Tr=Ms;var Rs=Object.getOwnPropertySymbols,Bs=Rs?function(t){for(var e=[];t;)J(e,Q(t)),t=Tt(t);return e}:Ot,jt=Bs;function Ls(t,e){return S(t,jt(t),e)}var Or=Ls;function ks(t,e,r){var o=e(t);return x(t)?o:J(o,r(t))}var At=ks;function Us(t){return At(t,$,Q)}var jr=Us;function Ds(t){return At(t,H,jt)}var Ar=Ds;var zs=b(d,"DataView"),Pt=zs;var Gs=b(d,"Promise"),St=Gs;var Ws=b(d,"Set"),It=Ws;var Pr="[object Map]",Ks="[object Object]",Sr="[object Promise]",Ir="[object Set]",_r="[object WeakMap]",Er="[object DataView]",$s=j(Pt),Hs=j(E),Vs=j(St),qs=j(It),Ys=j(ht),R=T;(Pt&&R(new Pt(new ArrayBuffer(1)))!=Er||E&&R(new E)!=Pr||St&&R(St.resolve())!=Sr||It&&R(new It)!=Ir||ht&&R(new ht)!=_r)&&(R=function(t){var e=T(t),r=e==Ks?t.constructor:void 0,o=r?j(r):"";if(o)switch(o){case $s:return Er;case Hs:return Pr;case Vs:return Sr;case qs:return Ir;case Ys:return _r}return e});var tt=R;var Zs=Object.prototype,Js=Zs.hasOwnProperty;function Xs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Js.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Cr=Xs;var Qs=d.Uint8Array,Bt=Qs;function tn(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var et=tn;function en(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Fr=en;var rn=/\w*$/;function on(t){var e=new t.constructor(t.source,rn.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=on;var Mr=g?g.prototype:void 0,Rr=Mr?Mr.valueOf:void 0;function an(t){return Rr?Object(Rr.call(t)):{}}var Br=an;function sn(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Lr=sn;var nn="[object Boolean]",fn="[object Date]",pn="[object Map]",ln="[object Number]",mn="[object RegExp]",un="[object Set]",dn="[object String]",cn="[object Symbol]",hn="[object ArrayBuffer]",xn="[object DataView]",gn="[object Float32Array]",bn="[object Float64Array]",yn="[object Int8Array]",vn="[object Int16Array]",wn="[object Int32Array]",Tn="[object Uint8Array]",On="[object Uint8ClampedArray]",jn="[object Uint16Array]",An="[object Uint32Array]";function Pn(t,e,r){var o=t.constructor;switch(e){case hn:return et(t);case nn:case fn:return new o(+t);case xn:return Fr(t,r);case gn:case bn:case yn:case vn:case wn:case Tn:case On:case jn:case An:return Lr(t,r);case pn:return new o;case ln:case dn:return new o(t);case mn:return Nr(t);case un:return new o;case cn:return Br(t)}}var kr=Pn;function Sn(t){return typeof t.constructor=="function"&&!G(t)?pe(Tt(t)):{}}var Ur=Sn;var In="[object Map]";function _n(t){return w(t)&&tt(t)==In}var Dr=_n;var zr=A&&A.isMap,En=zr?K(zr):Dr,Gr=En;var Cn="[object Set]";function Fn(t){return w(t)&&tt(t)==Cn}var Wr=Fn;var Kr=A&&A.isSet,Nn=Kr?K(Kr):Wr,$r=Nn;var Mn=1,Rn=2,Bn=4,Hr="[object Arguments]",Ln="[object Array]",kn="[object Boolean]",Un="[object Date]",Dn="[object Error]",Vr="[object Function]",zn="[object GeneratorFunction]",Gn="[object Map]",Wn="[object Number]",qr="[object Object]",Kn="[object RegExp]",$n="[object Set]",Hn="[object String]",Vn="[object Symbol]",qn="[object WeakMap]",Yn="[object ArrayBuffer]",Zn="[object DataView]",Jn="[object Float32Array]",Xn="[object Float64Array]",Qn="[object Int8Array]",tf="[object Int16Array]",ef="[object Int32Array]",rf="[object Uint8Array]",of="[object Uint8ClampedArray]",af="[object Uint16Array]",sf="[object Uint32Array]",l={};l[Hr]=l[Ln]=l[Yn]=l[Zn]=l[kn]=l[Un]=l[Jn]=l[Xn]=l[Qn]=l[tf]=l[ef]=l[Gn]=l[Wn]=l[qr]=l[Kn]=l[$n]=l[Hn]=l[Vn]=l[rf]=l[of]=l[af]=l[sf]=!0;l[Dn]=l[Vr]=l[qn]=!1;function _t(t,e,r,o,a,s){var i,n=e&Mn,u=e&Rn,c=e&Bn;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!v(t))return t;var h=x(t);if(h){if(i=Cr(t),!n)return me(t,i)}else{var O=tt(t),ft=O==Vr||O==zn;if(yt(t))return yr(t,n);if(O==qr||O==Hr||ft&&!a){if(i=u||ft?{}:Ur(t),!n)return u?Or(t,cr(i,t)):Tr(t,dr(i,t))}else{if(!l[O])return a?t:{};i=kr(t,O,n)}}s||(s=new ur);var ot=s.get(t);if(ot)return ot;s.set(t,i),$r(t)?t.forEach(function(y){i.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,f){i.set(f,_t(y,e,r,f,t,s))});var pt=c?u?Ar:jr:u?H:$,lt=h?void 0:pt(t);return xe(lt||t,function(y,f){lt&&(f=y,y=t[f]),D(i,f,_t(y,e,r,f,t,s))}),i}var Yr=_t;var nf=1,ff=4;function pf(t){return Yr(t,nf|ff)}var Lt=pf;function lf(t,e){return t!=null&&e in Object(t)}var Zr=lf;function mf(t,e,r){e=F(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=Z(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&z(a)&&U(i,a)&&(x(t)||W(t)))}var Jr=mf;function uf(t,e){return t!=null&&Jr(t,e,Zr)}var Xr=uf;function df(t,e,r,o){if(!v(t))return t;e=F(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var u=Z(e[a]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=i){var h=n[u];c=o?o(h,u,n):void 0,c===void 0&&(c=v(h)?h:U(e[a+1])?[]:{})}D(n,u,c),n=n[u]}return t}var Qr=df;function cf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=tr(t,i);r(n,i)&&Qr(s,F(i,t),n)}return s}var to=cf;function hf(t,e){return to(t,e,function(r,o){return Xr(t,o)})}var eo=hf;var xf=sr(function(t,e){return t==null?{}:eo(t,e)}),Et=xf;function ro(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var oo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var kt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=oo[r[t]&63];return e};var gf="array",bf="bit",ao="bits",yf="byte",io="bytes",rt="",vf="exponent",wf="function",so="iec",Tf="Invalid number",Of="Invalid rounding method",Ut="jedec",jf="object",no=".",Af="round",Pf="s",Sf="si",If="kbit",_f="kB",Ef=" ",Cf="string",Ff="0",Dt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=rt,localeOptions:i={},separator:n=rt,spacer:u=Ef,symbols:c={},standard:h=rt,output:O=Cf,fullform:ft=!1,fullforms:ot=[],exponent:pt=-1,roundingMethod:lt=Af,precision:y=0}={}){let f=pt,B=Number(t),p=[],M=0,Ct=rt;h===Sf?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=ft===!0,Gt=B<0,Wt=Math[lt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Tf);if(typeof Wt!==wf)throw new TypeError(Of);if(Gt&&(B=-B),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(B)/Math.log(mt)),f<0&&(f=0)),f>8&&(y>0&&(y+=8-f),f=8),O===vf)return f;if(B===0)p[0]=0,Ct=p[1]=Dt.symbol[h][e?ao:io][f];else{M=B/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(M=M*8,M>=mt&&f<8&&(M=M/mt,f++));let at=Math.pow(10,f>0?a:0);p[0]=Wt(M*at)/at,p[0]===mt&&f<8&&pt===-1&&(p[0]=1,f++),Ct=p[1]=o===10&&f===1?e?If:_f:Dt.symbol[h][e?ao:io][f]}if(Gt&&(p[0]=-p[0]),y>0&&(p[0]=p[0].toPrecision(y)),p[1]=c[p[1]]||p[1],s===!0?p[0]=p[0].toLocaleString():s.length>0?p[0]=p[0].toLocaleString(s,i):n.length>0&&(p[0]=p[0].toString().replace(no,n)),r&&a>0){let at=p[0].toString(),Kt=n||(at.match(/(\D)/g)||[]).pop()||no,$t=at.toString().split(Kt),Ht=$t[1]||rt,Vt=Ht.length,lo=a-Vt;p[0]=`${$t[0]}${Kt}${Ht.padEnd(Vt+lo,Ff)}`}return po&&(p[1]=ot[f]?ot[f]:Dt.fullform[h][f]+(e?bf:yf)+(p[0]===1?rt:Pf)),O===gf?p:O===jf?{value:p[0],symbol:p[1],exponent:f,unit:Ct}:p.join(u)}var N=class t{_tera;id;sbId;name;icon;path;url;teraUrl;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;meta={};constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};events=ro();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"];plugins=[];namespaces={};send(e){let r=kt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||kt(),...Lt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),r?.action=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):r?.action=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):r?.action=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r?.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}acceptPostboxes={};mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}constructor(e){e&&this.set(e)}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.settings.session||="tfy-"+this.getEntropicString(16)).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).catch(o=>this.debug("WARN",0,"Init process fault",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),u=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(u,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o()).catch(a)};u()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
1
|
+
var mo=typeof global=="object"&&global&&global.Object===Object&&global,ut=mo;var uo=typeof self=="object"&&self&&self.Object===Object&&self,co=ut||uo||Function("return this")(),d=co;var ho=d.Symbol,g=ho;var qt=Object.prototype,xo=qt.hasOwnProperty,go=qt.toString,it=g?g.toStringTag:void 0;function bo(t){var e=xo.call(t,it),r=t[it];try{t[it]=void 0;var o=!0}catch{}var a=go.call(t);return o&&(e?t[it]=r:delete t[it]),a}var Yt=bo;var yo=Object.prototype,vo=yo.toString;function wo(t){return vo.call(t)}var Zt=wo;var To="[object Null]",Oo="[object Undefined]",Jt=g?g.toStringTag:void 0;function jo(t){return t==null?t===void 0?Oo:To:Jt&&Jt in Object(t)?Yt(t):Zt(t)}var T=jo;function Ao(t){return t!=null&&typeof t=="object"}var w=Ao;var Po="[object Symbol]";function So(t){return typeof t=="symbol"||w(t)&&T(t)==Po}var L=So;function Io(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Xt=Io;var _o=Array.isArray,x=_o;var Eo=1/0,Qt=g?g.prototype:void 0,te=Qt?Qt.toString:void 0;function ee(t){if(typeof t=="string")return t;if(x(t))return Xt(t,ee)+"";if(L(t))return te?te.call(t):"";var e=t+"";return e=="0"&&1/t==-Eo?"-0":e}var re=ee;function Co(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v=Co;function Fo(t){return t}var oe=Fo;var No="[object AsyncFunction]",Mo="[object Function]",Ro="[object GeneratorFunction]",Bo="[object Proxy]";function Lo(t){if(!v(t))return!1;var e=T(t);return e==Mo||e==Ro||e==No||e==Bo}var dt=Lo;var ko=d["__core-js_shared__"],ct=ko;var ae=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Uo(t){return!!ae&&ae in t}var ie=Uo;var Do=Function.prototype,zo=Do.toString;function Go(t){if(t!=null){try{return zo.call(t)}catch{}try{return t+""}catch{}}return""}var j=Go;var Wo=/[\\^$.*+?()[\]{}|]/g,Ko=/^\[object .+?Constructor\]$/,$o=Function.prototype,Ho=Object.prototype,Vo=$o.toString,qo=Ho.hasOwnProperty,Yo=RegExp("^"+Vo.call(qo).replace(Wo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zo(t){if(!v(t)||ie(t))return!1;var e=dt(t)?Yo:Ko;return e.test(j(t))}var se=Zo;function Jo(t,e){return t?.[e]}var ne=Jo;function Xo(t,e){var r=ne(t,e);return se(r)?r:void 0}var b=Xo;var Qo=b(d,"WeakMap"),ht=Qo;var fe=Object.create,ta=function(){function t(){}return function(e){if(!v(e))return{};if(fe)return fe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),pe=ta;function ea(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var le=ea;function ra(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var me=ra;var oa=800,aa=16,ia=Date.now;function sa(t){var e=0,r=0;return function(){var o=ia(),a=aa-(o-r);if(r=o,a>0){if(++e>=oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ue=sa;function na(t){return function(){return t}}var de=na;var fa=function(){try{var t=b(Object,"defineProperty");return t({},"",{}),t}catch{}}(),k=fa;var pa=k?function(t,e){return k(t,"toString",{configurable:!0,enumerable:!1,value:de(e),writable:!0})}:oe,ce=pa;var la=ue(ce),he=la;function ma(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var xe=ma;var ua=9007199254740991,da=/^(?:0|[1-9]\d*)$/;function ca(t,e){var r=typeof t;return e=e??ua,!!e&&(r=="number"||r!="symbol"&&da.test(t))&&t>-1&&t%1==0&&t<e}var U=ca;function ha(t,e,r){e=="__proto__"&&k?k(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ha;function xa(t,e){return t===e||t!==t&&e!==e}var gt=xa;var ga=Object.prototype,ba=ga.hasOwnProperty;function ya(t,e,r){var o=t[e];(!(ba.call(t,e)&>(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var D=ya;function va(t,e,r,o){var a=!r;r||(r={});for(var s=-1,i=e.length;++s<i;){var n=e[s],u=o?o(r[n],t[n],n,r,t):void 0;u===void 0&&(u=t[n]),a?xt(r,n,u):D(r,n,u)}return r}var S=va;var ge=Math.max;function wa(t,e,r){return e=ge(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ge(o.length-e,0),i=Array(s);++a<s;)i[a]=o[e+a];a=-1;for(var n=Array(e+1);++a<e;)n[a]=o[a];return n[e]=r(i),le(t,this,n)}}var be=wa;var Ta=9007199254740991;function Oa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ta}var z=Oa;function ja(t){return t!=null&&z(t.length)&&!dt(t)}var bt=ja;var Aa=Object.prototype;function Pa(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var G=Pa;function Sa(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ye=Sa;var Ia="[object Arguments]";function _a(t){return w(t)&&T(t)==Ia}var Ft=_a;var ve=Object.prototype,Ea=ve.hasOwnProperty,Ca=ve.propertyIsEnumerable,Fa=Ft(function(){return arguments}())?Ft:function(t){return w(t)&&Ea.call(t,"callee")&&!Ca.call(t,"callee")},W=Fa;function Na(){return!1}var we=Na;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Te=je&&typeof module=="object"&&module&&!module.nodeType&&module,Ma=Te&&Te.exports===je,Oe=Ma?d.Buffer:void 0,Ra=Oe?Oe.isBuffer:void 0,Ba=Ra||we,yt=Ba;var La="[object Arguments]",ka="[object Array]",Ua="[object Boolean]",Da="[object Date]",za="[object Error]",Ga="[object Function]",Wa="[object Map]",Ka="[object Number]",$a="[object Object]",Ha="[object RegExp]",Va="[object Set]",qa="[object String]",Ya="[object WeakMap]",Za="[object ArrayBuffer]",Ja="[object DataView]",Xa="[object Float32Array]",Qa="[object Float64Array]",ti="[object Int8Array]",ei="[object Int16Array]",ri="[object Int32Array]",oi="[object Uint8Array]",ai="[object Uint8ClampedArray]",ii="[object Uint16Array]",si="[object Uint32Array]",m={};m[Xa]=m[Qa]=m[ti]=m[ei]=m[ri]=m[oi]=m[ai]=m[ii]=m[si]=!0;m[La]=m[ka]=m[Za]=m[Ua]=m[Ja]=m[Da]=m[za]=m[Ga]=m[Wa]=m[Ka]=m[$a]=m[Ha]=m[Va]=m[qa]=m[Ya]=!1;function ni(t){return w(t)&&z(t.length)&&!!m[T(t)]}var Ae=ni;function fi(t){return function(e){return t(e)}}var K=fi;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,st=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,pi=st&&st.exports===Pe,Nt=pi&&ut.process,li=function(){try{var t=st&&st.require&&st.require("util").types;return t||Nt&&Nt.binding&&Nt.binding("util")}catch{}}(),A=li;var Se=A&&A.isTypedArray,mi=Se?K(Se):Ae,Ie=mi;var ui=Object.prototype,di=ui.hasOwnProperty;function ci(t,e){var r=x(t),o=!r&&W(t),a=!r&&!o&&yt(t),s=!r&&!o&&!a&&Ie(t),i=r||o||a||s,n=i?ye(t.length,String):[],u=n.length;for(var c in t)(e||di.call(t,c))&&!(i&&(c=="length"||a&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||U(c,u)))&&n.push(c);return n}var vt=ci;function hi(t,e){return function(r){return t(e(r))}}var wt=hi;var xi=wt(Object.keys,Object),_e=xi;var gi=Object.prototype,bi=gi.hasOwnProperty;function yi(t){if(!G(t))return _e(t);var e=[];for(var r in Object(t))bi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ee=yi;function vi(t){return bt(t)?vt(t):Ee(t)}var $=vi;function wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ce=wi;var Ti=Object.prototype,Oi=Ti.hasOwnProperty;function ji(t){if(!v(t))return Ce(t);var e=G(t),r=[];for(var o in t)o=="constructor"&&(e||!Oi.call(t,o))||r.push(o);return r}var Fe=ji;function Ai(t){return bt(t)?vt(t,!0):Fe(t)}var H=Ai;var Pi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Si=/^\w*$/;function Ii(t,e){if(x(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||L(t)?!0:Si.test(t)||!Pi.test(t)||e!=null&&t in Object(e)}var Ne=Ii;var _i=b(Object,"create"),P=_i;function Ei(){this.__data__=P?P(null):{},this.size=0}var Me=Ei;function Ci(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Re=Ci;var Fi="__lodash_hash_undefined__",Ni=Object.prototype,Mi=Ni.hasOwnProperty;function Ri(t){var e=this.__data__;if(P){var r=e[t];return r===Fi?void 0:r}return Mi.call(e,t)?e[t]:void 0}var Be=Ri;var Bi=Object.prototype,Li=Bi.hasOwnProperty;function ki(t){var e=this.__data__;return P?e[t]!==void 0:Li.call(e,t)}var Le=ki;var Ui="__lodash_hash_undefined__";function Di(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=P&&e===void 0?Ui:e,this}var ke=Di;function V(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}V.prototype.clear=Me;V.prototype.delete=Re;V.prototype.get=Be;V.prototype.has=Le;V.prototype.set=ke;var Mt=V;function zi(){this.__data__=[],this.size=0}var Ue=zi;function Gi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var I=Gi;var Wi=Array.prototype,Ki=Wi.splice;function $i(t){var e=this.__data__,r=I(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ki.call(e,r,1),--this.size,!0}var De=$i;function Hi(t){var e=this.__data__,r=I(e,t);return r<0?void 0:e[r][1]}var ze=Hi;function Vi(t){return I(this.__data__,t)>-1}var Ge=Vi;function qi(t,e){var r=this.__data__,o=I(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=qi;function q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}q.prototype.clear=Ue;q.prototype.delete=De;q.prototype.get=ze;q.prototype.has=Ge;q.prototype.set=We;var _=q;var Yi=b(d,"Map"),E=Yi;function Zi(){this.size=0,this.__data__={hash:new Mt,map:new(E||_),string:new Mt}}var Ke=Zi;function Ji(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Ji;function Xi(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var C=Xi;function Qi(t){var e=C(this,t).delete(t);return this.size-=e?1:0,e}var He=Qi;function ts(t){return C(this,t).get(t)}var Ve=ts;function es(t){return C(this,t).has(t)}var qe=es;function rs(t,e){var r=C(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ye=rs;function Y(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Y.prototype.clear=Ke;Y.prototype.delete=He;Y.prototype.get=Ve;Y.prototype.has=qe;Y.prototype.set=Ye;var nt=Y;var os="Expected a function";function Rt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(os);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var i=t.apply(this,o);return r.cache=s.set(a,i)||s,i};return r.cache=new(Rt.Cache||nt),r}Rt.Cache=nt;var Ze=Rt;var as=500;function is(t){var e=Ze(t,function(o){return r.size===as&&r.clear(),o}),r=e.cache;return e}var Je=is;var ss=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ns=/\\(\\)?/g,fs=Je(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ss,function(r,o,a,s){e.push(a?s.replace(ns,"$1"):o||r)}),e}),Xe=fs;function ps(t){return t==null?"":re(t)}var Qe=ps;function ls(t,e){return x(t)?t:Ne(t,e)?[t]:Xe(Qe(t))}var F=ls;var ms=1/0;function us(t){if(typeof t=="string"||L(t))return t;var e=t+"";return e=="0"&&1/t==-ms?"-0":e}var Z=us;function ds(t,e){e=F(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[Z(e[r++])];return r&&r==o?t:void 0}var tr=ds;function cs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var J=cs;var er=g?g.isConcatSpreadable:void 0;function hs(t){return x(t)||W(t)||!!(er&&t&&t[er])}var rr=hs;function or(t,e,r,o,a){var s=-1,i=t.length;for(r||(r=rr),a||(a=[]);++s<i;){var n=t[s];e>0&&r(n)?e>1?or(n,e-1,r,o,a):J(a,n):o||(a[a.length]=n)}return a}var ar=or;function xs(t){var e=t==null?0:t.length;return e?ar(t,1):[]}var ir=xs;function gs(t){return he(be(t,void 0,ir),t+"")}var sr=gs;var bs=wt(Object.getPrototypeOf,Object),Tt=bs;function ys(){this.__data__=new _,this.size=0}var nr=ys;function vs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var fr=vs;function ws(t){return this.__data__.get(t)}var pr=ws;function Ts(t){return this.__data__.has(t)}var lr=Ts;var Os=200;function js(t,e){var r=this.__data__;if(r instanceof _){var o=r.__data__;if(!E||o.length<Os-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new nt(o)}return r.set(t,e),this.size=r.size,this}var mr=js;function X(t){var e=this.__data__=new _(t);this.size=e.size}X.prototype.clear=nr;X.prototype.delete=fr;X.prototype.get=pr;X.prototype.has=lr;X.prototype.set=mr;var ur=X;function As(t,e){return t&&S(e,$(e),t)}var dr=As;function Ps(t,e){return t&&S(e,H(e),t)}var cr=Ps;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,hr=br&&typeof module=="object"&&module&&!module.nodeType&&module,Ss=hr&&hr.exports===br,xr=Ss?d.Buffer:void 0,gr=xr?xr.allocUnsafe:void 0;function Is(t,e){if(e)return t.slice();var r=t.length,o=gr?gr(r):new t.constructor(r);return t.copy(o),o}var yr=Is;function _s(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var i=t[r];e(i,r,t)&&(s[a++]=i)}return s}var vr=_s;function Es(){return[]}var Ot=Es;var Cs=Object.prototype,Fs=Cs.propertyIsEnumerable,wr=Object.getOwnPropertySymbols,Ns=wr?function(t){return t==null?[]:(t=Object(t),vr(wr(t),function(e){return Fs.call(t,e)}))}:Ot,Q=Ns;function Ms(t,e){return S(t,Q(t),e)}var Tr=Ms;var Rs=Object.getOwnPropertySymbols,Bs=Rs?function(t){for(var e=[];t;)J(e,Q(t)),t=Tt(t);return e}:Ot,jt=Bs;function Ls(t,e){return S(t,jt(t),e)}var Or=Ls;function ks(t,e,r){var o=e(t);return x(t)?o:J(o,r(t))}var At=ks;function Us(t){return At(t,$,Q)}var jr=Us;function Ds(t){return At(t,H,jt)}var Ar=Ds;var zs=b(d,"DataView"),Pt=zs;var Gs=b(d,"Promise"),St=Gs;var Ws=b(d,"Set"),It=Ws;var Pr="[object Map]",Ks="[object Object]",Sr="[object Promise]",Ir="[object Set]",_r="[object WeakMap]",Er="[object DataView]",$s=j(Pt),Hs=j(E),Vs=j(St),qs=j(It),Ys=j(ht),R=T;(Pt&&R(new Pt(new ArrayBuffer(1)))!=Er||E&&R(new E)!=Pr||St&&R(St.resolve())!=Sr||It&&R(new It)!=Ir||ht&&R(new ht)!=_r)&&(R=function(t){var e=T(t),r=e==Ks?t.constructor:void 0,o=r?j(r):"";if(o)switch(o){case $s:return Er;case Hs:return Pr;case Vs:return Sr;case qs:return Ir;case Ys:return _r}return e});var tt=R;var Zs=Object.prototype,Js=Zs.hasOwnProperty;function Xs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Js.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Cr=Xs;var Qs=d.Uint8Array,Bt=Qs;function tn(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var et=tn;function en(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Fr=en;var rn=/\w*$/;function on(t){var e=new t.constructor(t.source,rn.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=on;var Mr=g?g.prototype:void 0,Rr=Mr?Mr.valueOf:void 0;function an(t){return Rr?Object(Rr.call(t)):{}}var Br=an;function sn(t,e){var r=e?et(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Lr=sn;var nn="[object Boolean]",fn="[object Date]",pn="[object Map]",ln="[object Number]",mn="[object RegExp]",un="[object Set]",dn="[object String]",cn="[object Symbol]",hn="[object ArrayBuffer]",xn="[object DataView]",gn="[object Float32Array]",bn="[object Float64Array]",yn="[object Int8Array]",vn="[object Int16Array]",wn="[object Int32Array]",Tn="[object Uint8Array]",On="[object Uint8ClampedArray]",jn="[object Uint16Array]",An="[object Uint32Array]";function Pn(t,e,r){var o=t.constructor;switch(e){case hn:return et(t);case nn:case fn:return new o(+t);case xn:return Fr(t,r);case gn:case bn:case yn:case vn:case wn:case Tn:case On:case jn:case An:return Lr(t,r);case pn:return new o;case ln:case dn:return new o(t);case mn:return Nr(t);case un:return new o;case cn:return Br(t)}}var kr=Pn;function Sn(t){return typeof t.constructor=="function"&&!G(t)?pe(Tt(t)):{}}var Ur=Sn;var In="[object Map]";function _n(t){return w(t)&&tt(t)==In}var Dr=_n;var zr=A&&A.isMap,En=zr?K(zr):Dr,Gr=En;var Cn="[object Set]";function Fn(t){return w(t)&&tt(t)==Cn}var Wr=Fn;var Kr=A&&A.isSet,Nn=Kr?K(Kr):Wr,$r=Nn;var Mn=1,Rn=2,Bn=4,Hr="[object Arguments]",Ln="[object Array]",kn="[object Boolean]",Un="[object Date]",Dn="[object Error]",Vr="[object Function]",zn="[object GeneratorFunction]",Gn="[object Map]",Wn="[object Number]",qr="[object Object]",Kn="[object RegExp]",$n="[object Set]",Hn="[object String]",Vn="[object Symbol]",qn="[object WeakMap]",Yn="[object ArrayBuffer]",Zn="[object DataView]",Jn="[object Float32Array]",Xn="[object Float64Array]",Qn="[object Int8Array]",tf="[object Int16Array]",ef="[object Int32Array]",rf="[object Uint8Array]",of="[object Uint8ClampedArray]",af="[object Uint16Array]",sf="[object Uint32Array]",l={};l[Hr]=l[Ln]=l[Yn]=l[Zn]=l[kn]=l[Un]=l[Jn]=l[Xn]=l[Qn]=l[tf]=l[ef]=l[Gn]=l[Wn]=l[qr]=l[Kn]=l[$n]=l[Hn]=l[Vn]=l[rf]=l[of]=l[af]=l[sf]=!0;l[Dn]=l[Vr]=l[qn]=!1;function _t(t,e,r,o,a,s){var i,n=e&Mn,u=e&Rn,c=e&Bn;if(r&&(i=a?r(t,o,a,s):r(t)),i!==void 0)return i;if(!v(t))return t;var h=x(t);if(h){if(i=Cr(t),!n)return me(t,i)}else{var O=tt(t),ft=O==Vr||O==zn;if(yt(t))return yr(t,n);if(O==qr||O==Hr||ft&&!a){if(i=u||ft?{}:Ur(t),!n)return u?Or(t,cr(i,t)):Tr(t,dr(i,t))}else{if(!l[O])return a?t:{};i=kr(t,O,n)}}s||(s=new ur);var ot=s.get(t);if(ot)return ot;s.set(t,i),$r(t)?t.forEach(function(y){i.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,f){i.set(f,_t(y,e,r,f,t,s))});var pt=c?u?Ar:jr:u?H:$,lt=h?void 0:pt(t);return xe(lt||t,function(y,f){lt&&(f=y,y=t[f]),D(i,f,_t(y,e,r,f,t,s))}),i}var Yr=_t;var nf=1,ff=4;function pf(t){return Yr(t,nf|ff)}var Lt=pf;function lf(t,e){return t!=null&&e in Object(t)}var Zr=lf;function mf(t,e,r){e=F(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var i=Z(e[o]);if(!(s=t!=null&&r(t,i)))break;t=t[i]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&z(a)&&U(i,a)&&(x(t)||W(t)))}var Jr=mf;function uf(t,e){return t!=null&&Jr(t,e,Zr)}var Xr=uf;function df(t,e,r,o){if(!v(t))return t;e=F(e,t);for(var a=-1,s=e.length,i=s-1,n=t;n!=null&&++a<s;){var u=Z(e[a]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(a!=i){var h=n[u];c=o?o(h,u,n):void 0,c===void 0&&(c=v(h)?h:U(e[a+1])?[]:{})}D(n,u,c),n=n[u]}return t}var Qr=df;function cf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var i=e[o],n=tr(t,i);r(n,i)&&Qr(s,F(i,t),n)}return s}var to=cf;function hf(t,e){return to(t,e,function(r,o){return Xr(t,o)})}var eo=hf;var xf=sr(function(t,e){return t==null?{}:eo(t,e)}),Et=xf;function ro(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var oo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var kt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=oo[r[t]&63];return e};var gf="array",bf="bit",ao="bits",yf="byte",io="bytes",rt="",vf="exponent",wf="function",so="iec",Tf="Invalid number",Of="Invalid rounding method",Ut="jedec",jf="object",no=".",Af="round",Pf="s",Sf="si",If="kbit",_f="kB",Ef=" ",Cf="string",Ff="0",Dt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=rt,localeOptions:i={},separator:n=rt,spacer:u=Ef,symbols:c={},standard:h=rt,output:O=Cf,fullform:ft=!1,fullforms:ot=[],exponent:pt=-1,roundingMethod:lt=Af,precision:y=0}={}){let f=pt,B=Number(t),p=[],M=0,Ct=rt;h===Sf?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=ft===!0,Gt=B<0,Wt=Math[lt];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Tf);if(typeof Wt!==wf)throw new TypeError(Of);if(Gt&&(B=-B),(f===-1||isNaN(f))&&(f=Math.floor(Math.log(B)/Math.log(mt)),f<0&&(f=0)),f>8&&(y>0&&(y+=8-f),f=8),O===vf)return f;if(B===0)p[0]=0,Ct=p[1]=Dt.symbol[h][e?ao:io][f];else{M=B/(o===2?Math.pow(2,f*10):Math.pow(1e3,f)),e&&(M=M*8,M>=mt&&f<8&&(M=M/mt,f++));let at=Math.pow(10,f>0?a:0);p[0]=Wt(M*at)/at,p[0]===mt&&f<8&&pt===-1&&(p[0]=1,f++),Ct=p[1]=o===10&&f===1?e?If:_f:Dt.symbol[h][e?ao:io][f]}if(Gt&&(p[0]=-p[0]),y>0&&(p[0]=p[0].toPrecision(y)),p[1]=c[p[1]]||p[1],s===!0?p[0]=p[0].toLocaleString():s.length>0?p[0]=p[0].toLocaleString(s,i):n.length>0&&(p[0]=p[0].toString().replace(no,n)),r&&a>0){let at=p[0].toString(),Kt=n||(at.match(/(\D)/g)||[]).pop()||no,$t=at.toString().split(Kt),Ht=$t[1]||rt,Vt=Ht.length,lo=a-Vt;p[0]=`${$t[0]}${Kt}${Ht.padEnd(Vt+lo,Ff)}`}return po&&(p[1]=ot[f]?ot[f]:Dt.fullform[h][f]+(e?bf:yf)+(p[0]===1?rt:Pf)),O===gf?p:O===jf?{value:p[0],symbol:p[1],exponent:f,unit:Ct}:p.join(u)}var N=class t{_tera;id;sbId;name;icon;path;url;teraUrl;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;meta={};constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e,{})}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","sbId","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={session:null,devMode:!1,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child(e){e.siteUrl=="https://tera-tools.com/embed"&&(e.siteUrl="https://dev.tera-tools.com/embed")}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};events=ro();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","setServerVerbosity","getUser","requireUser","getCredentials","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getNamespace","setNamespace","listNamespaces","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateRefresh","getProjectFileContents","deleteProjectFile","setProjectFileContents","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiPanic","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"];plugins=[];namespaces={};send(e){let r=kt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||kt(),...Lt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return Promise.resolve();let r=e.data;return!r.TERA||!r.id?Promise.resolve():(this.debug("INFO",3,"Recieved message",r),r?.action=="response"&&this.acceptPostboxes[r.id]?(r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response),Promise.resolve()):r?.action=="rpc"?Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})}):r?.action=="event"?Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o}):r?.id?(this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`),Promise.resolve()):(this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r}),Promise.resolve()))}acceptPostboxes={};mountNamespace(e){if(!/^[\w-]+$/.test(e))throw new Error("Namespaces must be alphanumeric + hyphens + underscores");return this.namespaces[e]?Promise.resolve(this.namespaces[e]):Promise.resolve().then(()=>this._mountNamespace(e)).then(()=>this.namespaces[e]||Promise.reject(`teraFy.mountNamespace('${e}') resolved but no namespace has been mounted`))}_mountNamespace(e){throw console.warn("teraFy._mountNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework"),new Error("teraFy._mountNamespace() is not supported")}unmountNamespace(e){return this.namespaces[e]?this._unmountNamespace(e):Promise.resolve()}_unmountNamespace(e){console.warn("teraFy.unbindNamespace() has not been overriden by a TERA-fy plugin, load one to add this functionality for your preferred framework")}constructor(e){e&&this.set(e)}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.settings.session||="tfy-"+this.getEntropicString(16)).then(()=>this.debug("INFO",4,"[0/6] Init","Session",this.settings.session,"against",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{if(this.debug("INFO",4,"[1/6] Setting client mode to",o),this.settings.mode=o,this.settings.modeOverrides[o])return this.debug("INFO",4,"[1/6] Applying specific config overrides for mode",o),this.settings.modeOverrides[o](this.settings)}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).then(()=>r).catch(o=>(this.debug("WARN",0,"Init process fault",o),r))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r("TIMEOUT"),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":return this.debug("INFO",2,"Using TERA window parent"),Promise.resolve();case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,i,n=setTimeout(()=>{clearTimeout(i),a("TIMEOUT")},r.handshakeTimeout),u=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(i),i=setTimeout(u,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(n),clearTimeout(i)}).then(()=>o()).catch(a)};u()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
2
2
|
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){let o=typeof e=="function"?new e(this,r):typeof e=="object"?e:typeof e=="string"?(()=>{throw new Error("use(String) is not yet supported")})():(()=>{throw new Error("Expected use() call to be provided with a class initalizer")})();return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){let o=[],a=r;do o.unshift(a);while(a=Object.getPrototypeOf(a));o.forEach(s=>Object.getOwnPropertyNames(s).filter(i=>!["constructor","init","prototype","name"].includes(i)&&!i.startsWith("__")).forEach(i=>{typeof r[i]=="function"?Object.defineProperty(e,i,{enumerable:!1,value:r[i].bind(e)}):e[i]=r[i]}))}toggleDevMode(e="toggle"){return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.settings.devMode&&(this.settings.restrictOrigin="*"),this.dom?.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}getEntropicString(e=32){let r=new Uint32Array(4);return window.crypto.getRandomValues(r),btoa(String.fromCharCode(...new Uint8Array(r.buffer))).replace(/[+/]/g,"").slice(0,e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new N({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new N({tera:this,...o})))}getProjectFile(e,r){return this.rpc("getProjectFile",e,r).then(o=>o&&new N({tera:this,...o}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new N({tera:this,...r}))}};export{zt as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
package/eslint.config.js
CHANGED
package/lib/syncro/entities.js
CHANGED
package/lib/syncro/syncro.js
CHANGED
|
@@ -270,7 +270,9 @@ export default class Syncro {
|
|
|
270
270
|
if (Syncro.SyncroEntities && !(extracted.entity in SyncroEntities)) throw new Error(`Unsupported entity "${path}" -> Entity="${extracted.entity}"`);
|
|
271
271
|
|
|
272
272
|
return {
|
|
273
|
-
|
|
273
|
+
entity: extracted.entity,
|
|
274
|
+
id: extracted.id,
|
|
275
|
+
relation: extracted.relation,
|
|
274
276
|
fsCollection: extracted.entity,
|
|
275
277
|
fsId: extracted.relation
|
|
276
278
|
? `${extracted.id}::${extracted.relation}`
|
|
@@ -346,7 +348,9 @@ export default class Syncro {
|
|
|
346
348
|
} else if (value === null) {
|
|
347
349
|
result[key] = { nullValue: null };
|
|
348
350
|
} else if (Array.isArray(value)) {
|
|
349
|
-
result[key] = { arrayValue: { values:
|
|
351
|
+
result[key] = { arrayValue: { values:
|
|
352
|
+
value.map(item => Syncro.toFirestoreFields({item}).item)
|
|
353
|
+
}};
|
|
350
354
|
} else if (type === 'object') {
|
|
351
355
|
result[key] = { mapValue: { fields: Syncro.toFirestoreFields(value) } };
|
|
352
356
|
}
|
|
@@ -371,7 +375,7 @@ export default class Syncro {
|
|
|
371
375
|
let value = fields[key];
|
|
372
376
|
let isDocumentType = [
|
|
373
377
|
'stringValue', 'booleanValue', 'doubleValue',
|
|
374
|
-
'integerValue', 'timestampValue', 'mapValue', 'arrayValue',
|
|
378
|
+
'integerValue', 'timestampValue', 'mapValue', 'arrayValue', 'nullValue',
|
|
375
379
|
].find(t => t === key);
|
|
376
380
|
|
|
377
381
|
if (isDocumentType) {
|
|
@@ -387,6 +391,7 @@ export default class Syncro {
|
|
|
387
391
|
return !!list ? list.map(l => Syncro.fromFirestoreFields(l)) : [];
|
|
388
392
|
}
|
|
389
393
|
} else {
|
|
394
|
+
// This case might not be standard Firestore field structure, but handle recursively
|
|
390
395
|
result[key] = Syncro.fromFirestoreFields(value)
|
|
391
396
|
}
|
|
392
397
|
}
|
|
@@ -460,7 +465,7 @@ export default class Syncro {
|
|
|
460
465
|
...options,
|
|
461
466
|
};
|
|
462
467
|
|
|
463
|
-
let {fsCollection, fsId, entity
|
|
468
|
+
let {fsCollection, fsId, entity} = Syncro.pathSplit(this.path);
|
|
464
469
|
let reactive; // Eventual response from reactive() with the intitial value
|
|
465
470
|
let doc; // Eventual Firebase document
|
|
466
471
|
|
|
@@ -522,12 +527,75 @@ export default class Syncro {
|
|
|
522
527
|
minTimeout: settings.retryMinTime,
|
|
523
528
|
randomize: true,
|
|
524
529
|
factor: 3,
|
|
525
|
-
onFailedAttempt: e =>
|
|
530
|
+
onFailedAttempt: async (e) => {
|
|
531
|
+
this.debugError(`[Attempt ${e.attemptNumber}/${e.attemptNumber + e.retriesLeft - 1}] to mount syncro`, e);
|
|
532
|
+
await this.destroy(); // Ensure cleanup on failed attempt before retry
|
|
533
|
+
},
|
|
526
534
|
},
|
|
527
535
|
);
|
|
528
536
|
}
|
|
529
537
|
|
|
530
538
|
|
|
539
|
+
/**
|
|
540
|
+
* Merge a single or multiple values into a Syncro data object
|
|
541
|
+
*
|
|
542
|
+
* @param {String|Object} key Either the single named key to set OR the object to merge
|
|
543
|
+
* @param {*} [value] The value to set if `key` is a string
|
|
544
|
+
*
|
|
545
|
+
* @param {Object} [options] Additional options to mutate behaviour
|
|
546
|
+
* @param {Boolean} [options.delta=true] Only merge keys that differ, skipping flush if no changes are made
|
|
547
|
+
* @param {Boolean} [options.flush=false] Send a flush signal that Firebase should sync to Supabase on changes
|
|
548
|
+
* @param {Boolean} [options.forceFlush=false] Flush even if no changes were made
|
|
549
|
+
* @param {Boolean} [options.flushDestroy=false] Destroy the Syncro after flushing
|
|
550
|
+
*
|
|
551
|
+
* @returns {Promise<Syncro>} A promise which resolves with this Syncro instance on completion
|
|
552
|
+
*/
|
|
553
|
+
async set(key, value, options) {
|
|
554
|
+
// Argument mangling - [key, value, settings] -> changes{}, settings {{{
|
|
555
|
+
let changes;
|
|
556
|
+
if (typeof key == 'string') { // Called as (key:String, value:*, options?:Object)
|
|
557
|
+
changes[key] = value;
|
|
558
|
+
} else if (typeof key == 'object') { // Called as (changes:Object, options?:Object)
|
|
559
|
+
[changes, options] = [key, value];
|
|
560
|
+
} else {
|
|
561
|
+
throw new Error('Unknown call signature for set() - call with string+value or object');
|
|
562
|
+
}
|
|
563
|
+
// }}}
|
|
564
|
+
|
|
565
|
+
let settings = {
|
|
566
|
+
delta: true,
|
|
567
|
+
flush: false,
|
|
568
|
+
forceFlush: false,
|
|
569
|
+
flushDestroy: false,
|
|
570
|
+
...options,
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
// Perform merge
|
|
574
|
+
let hasChanges = false;
|
|
575
|
+
if (settings.delta) { // Merge changes lazily
|
|
576
|
+
Object.entries(changes)
|
|
577
|
+
.filter(([k, v]) => !isEqual(this.value[k], v))
|
|
578
|
+
.forEach(([k, v]) => {
|
|
579
|
+
hasChanges = true;
|
|
580
|
+
this.value[k] = v;
|
|
581
|
+
})
|
|
582
|
+
} else {
|
|
583
|
+
hasChanges = true;
|
|
584
|
+
Object.assign(this.value, changes);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// Optionally perform flush
|
|
588
|
+
if (
|
|
589
|
+
(settings.forceFlush || hasChanges)
|
|
590
|
+
&& settings.flush
|
|
591
|
+
) {
|
|
592
|
+
await this.flush({destroy: settings.flushDestroy});
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
return this;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
|
|
531
599
|
/**
|
|
532
600
|
* Schedule Syncro heartbeats
|
|
533
601
|
* This populates the `sync` presence meta-information
|
|
@@ -552,7 +620,7 @@ export default class Syncro {
|
|
|
552
620
|
await this.heartbeat();
|
|
553
621
|
|
|
554
622
|
// If we're enabled - schedule the next heartbeat timer
|
|
555
|
-
enable
|
|
623
|
+
if (enable) this.setHeartbeat(true);
|
|
556
624
|
}, this.config.heartbeatInterval);
|
|
557
625
|
|
|
558
626
|
if (settings.immediate) this.heartbeat();
|
|
@@ -620,7 +688,7 @@ export default class Syncro {
|
|
|
620
688
|
if (!this.docRef) throw new Error('mount() must be called before getting Firestore state');
|
|
621
689
|
|
|
622
690
|
return FirestoreGetDoc(this.docRef)
|
|
623
|
-
.then(doc => Syncro.fromFirestore(doc.data()))
|
|
691
|
+
.then(doc => Syncro.fromFirestore(doc.data() ?? {})); // Handle undefined data with default {}
|
|
624
692
|
}
|
|
625
693
|
|
|
626
694
|
|
|
@@ -652,7 +720,10 @@ export default class Syncro {
|
|
|
652
720
|
};
|
|
653
721
|
|
|
654
722
|
return fetch(`${this.config.syncroRegistryUrl}/${this.path}/flush` + (settings.destroy ? '?destroy=1' : ''))
|
|
655
|
-
.then(response => response.ok
|
|
723
|
+
.then(response => response.ok
|
|
724
|
+
? null
|
|
725
|
+
: Promise.reject(response.statusText || 'An error occured')
|
|
726
|
+
)
|
|
656
727
|
}
|
|
657
728
|
|
|
658
729
|
|
|
@@ -712,7 +783,7 @@ const marshalFlattenArrays = {
|
|
|
712
783
|
|
|
713
784
|
Object.entries(v)
|
|
714
785
|
.filter(([k]) => k !== '_')
|
|
715
|
-
.forEach(([k,
|
|
786
|
+
.forEach(([k, w]) => arr[+k] = w);
|
|
716
787
|
|
|
717
788
|
return arr;
|
|
718
789
|
},
|
package/lib/terafy.client.js
CHANGED
|
@@ -460,7 +460,11 @@ export default class TeraFy {
|
|
|
460
460
|
)
|
|
461
461
|
))
|
|
462
462
|
.then(()=> this.debug('INFO', 4, '[6/6] Init complete'))
|
|
463
|
-
.
|
|
463
|
+
.then(()=> context)
|
|
464
|
+
.catch(e => {
|
|
465
|
+
this.debug('WARN', 0, 'Init process fault', e);
|
|
466
|
+
return context;
|
|
467
|
+
})
|
|
464
468
|
}
|
|
465
469
|
|
|
466
470
|
|
|
@@ -480,7 +484,7 @@ export default class TeraFy {
|
|
|
480
484
|
return Promise.resolve()
|
|
481
485
|
.then(()=> this.settings.mode = 'parent') // Switch to parent mode...
|
|
482
486
|
.then(()=> new Promise((resolve, reject) => { // And try messaging with a timeout
|
|
483
|
-
let timeoutHandle = setTimeout(()=> reject(), this.settings.modeTimeout);
|
|
487
|
+
let timeoutHandle = setTimeout(()=> reject('TIMEOUT'), this.settings.modeTimeout);
|
|
484
488
|
|
|
485
489
|
this.rpc('handshake')
|
|
486
490
|
.then(()=> clearTimeout(timeoutHandle))
|