@iebh/tera-fy 1.4.0 → 1.4.1
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 +2 -0
- package/api.md +3 -1
- package/dist/plugin.vue2.es2019.js +1 -1
- package/dist/terafy.es2019.js +2 -2
- package/dist/terafy.js +2 -2
- package/lib/terafy.client.js +26 -19
- package/lib/terafy.server.js +32 -23
- package/package.json +1 -1
- package/plugins/vue2.js +4 -3
- package/plugins/vue3.js +3 -4
package/CHANGELOG.md
CHANGED
package/api.md
CHANGED
|
@@ -309,6 +309,7 @@ Type: [Object][125]
|
|
|
309
309
|
#### Properties
|
|
310
310
|
|
|
311
311
|
* `devMode` **[Boolean][133]** Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance
|
|
312
|
+
* `verbosity` **[Number][127]** Verbosity level, the higher the more chatty TeraFY will be. Set to zero to disable all `debug()` call output
|
|
312
313
|
* `mode` **(`"detect"` | `"parent"` | `"child"` | `"popup"`)** How to communicate with TERA. 'parent' assumes that the parent of the current document is TERA, 'child' spawns an iFrame and uses TERA there, 'detect' tries parent and switches to `modeFallback` if communication fails
|
|
313
314
|
* `modeFallback` **[String][124]** Method to use when all method detection fails
|
|
314
315
|
* `modeTimeout` **[Number][127]** How long entities have in 'detect' mode to identify themselves
|
|
@@ -459,7 +460,8 @@ This function will only act if `settings.devMode` is truthy
|
|
|
459
460
|
#### Parameters
|
|
460
461
|
|
|
461
462
|
* `msg` **...any** 
|
|
462
|
-
* `
|
|
463
|
+
* `method` **(`"INFO"` | `"LOG"` | `"WARN"` | `"ERROR"`)** Logging method to use (optional, default `'LOG'`)
|
|
464
|
+
* `verboseLevel` **[Number][127]** The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored (optional, default `1`)
|
|
463
465
|
|
|
464
466
|
### set
|
|
465
467
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var fr=Object.defineProperty;var sr=(t,e,r)=>e in t?fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var k=(t,e,r)=>(sr(t,typeof e!="symbol"?e+"":e,r),r);var pr=typeof global=="object"&&global&&global.Object===Object&&global,q=pr;var ir=typeof self=="object"&&self&&self.Object===Object&&self,nr=q||ir||Function("return this")(),u=nr;var ur=u.Symbol,g=ur;var _t=Object.prototype,mr=_t.hasOwnProperty,lr=_t.toString,V=g?g.toStringTag:void 0;function dr(t){var e=mr.call(t,V),r=t[V];try{t[V]=void 0;var o=!0}catch{}var a=lr.call(t);return o&&(e?t[V]=r:delete t[V]),a}var At=dr;var cr=Object.prototype,xr=cr.toString;function gr(t){return xr.call(t)}var wt=gr;var hr="[object Null]",yr="[object Undefined]",St=g?g.toStringTag:void 0;function br(t){return t==null?t===void 0?yr:hr:St&&St in Object(t)?At(t):wt(t)}var h=br;function vr(t){return t!=null&&typeof t=="object"}var c=vr;var jr=Array.isArray,C=jr;function Tr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var x=Tr;var Or="[object AsyncFunction]",_r="[object Function]",Ar="[object GeneratorFunction]",wr="[object Proxy]";function Sr(t){if(!x(t))return!1;var e=h(t);return e==_r||e==Ar||e==Or||e==wr}var H=Sr;var Ir=u["__core-js_shared__"],$=Ir;var It=function(){var t=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Pr(t){return!!It&&It in t}var Pt=Pr;var Cr=Function.prototype,Er=Cr.toString;function Br(t){if(t!=null){try{return Er.call(t)}catch{}try{return t+""}catch{}}return""}var y=Br;var Lr=/[\\^$.*+?()[\]{}|]/g,Mr=/^\[object .+?Constructor\]$/,Dr=Function.prototype,Fr=Object.prototype,Nr=Dr.toString,Rr=Fr.hasOwnProperty,Ur=RegExp("^"+Nr.call(Rr).replace(Lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Gr(t){if(!x(t)||Pt(t))return!1;var e=H(t)?Ur:Mr;return e.test(y(t))}var Ct=Gr;function Wr(t,e){return t==null?void 0:t[e]}var Et=Wr;function Vr(t,e){var r=Et(t,e);return Ct(r)?r:void 0}var m=Vr;var Kr=m(u,"WeakMap"),J=Kr;var Bt=Object.create,zr=function(){function t(){}return function(e){if(!x(e))return{};if(Bt)return Bt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Lt=zr;function kr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Mt=kr;var qr=function(){try{var t=m(Object,"defineProperty");return t({},"",{}),t}catch{}}(),ct=qr;function Hr(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Dt=Hr;var $r=9007199254740991,Jr=/^(?:0|[1-9]\d*)$/;function Yr(t,e){var r=typeof t;return e=e==null?$r:e,!!e&&(r=="number"||r!="symbol"&&Jr.test(t))&&t>-1&&t%1==0&&t<e}var Ft=Yr;function Xr(t,e,r){e=="__proto__"&&ct?ct(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Y=Xr;function Zr(t,e){return t===e||t!==t&&e!==e}var X=Zr;var Qr=Object.prototype,to=Qr.hasOwnProperty;function eo(t,e,r){var o=t[e];(!(to.call(t,e)&&X(o,r))||r===void 0&&!(e in t))&&Y(t,e,r)}var Z=eo;function ro(t,e,r,o){var a=!r;r||(r={});for(var f=-1,s=e.length;++f<s;){var n=e[f],l=o?o(r[n],t[n],n,r,t):void 0;l===void 0&&(l=t[n]),a?Y(r,n,l):Z(r,n,l)}return r}var T=ro;var oo=9007199254740991;function ao(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=oo}var Q=ao;function fo(t){return t!=null&&Q(t.length)&&!H(t)}var tt=fo;var so=Object.prototype;function po(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||so;return t===r}var E=po;function io(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Nt=io;var no="[object Arguments]";function uo(t){return c(t)&&h(t)==no}var xt=uo;var Rt=Object.prototype,mo=Rt.hasOwnProperty,lo=Rt.propertyIsEnumerable,co=xt(function(){return arguments}())?xt:function(t){return c(t)&&mo.call(t,"callee")&&!lo.call(t,"callee")},Ut=co;function xo(){return!1}var Gt=xo;var Kt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wt=Kt&&typeof module=="object"&&module&&!module.nodeType&&module,go=Wt&&Wt.exports===Kt,Vt=go?u.Buffer:void 0,ho=Vt?Vt.isBuffer:void 0,yo=ho||Gt,et=yo;var bo="[object Arguments]",vo="[object Array]",jo="[object Boolean]",To="[object Date]",Oo="[object Error]",_o="[object Function]",Ao="[object Map]",wo="[object Number]",So="[object Object]",Io="[object RegExp]",Po="[object Set]",Co="[object String]",Eo="[object WeakMap]",Bo="[object ArrayBuffer]",Lo="[object DataView]",Mo="[object Float32Array]",Do="[object Float64Array]",Fo="[object Int8Array]",No="[object Int16Array]",Ro="[object Int32Array]",Uo="[object Uint8Array]",Go="[object Uint8ClampedArray]",Wo="[object Uint16Array]",Vo="[object Uint32Array]",i={};i[Mo]=i[Do]=i[Fo]=i[No]=i[Ro]=i[Uo]=i[Go]=i[Wo]=i[Vo]=!0;i[bo]=i[vo]=i[Bo]=i[jo]=i[Lo]=i[To]=i[Oo]=i[_o]=i[Ao]=i[wo]=i[So]=i[Io]=i[Po]=i[Co]=i[Eo]=!1;function Ko(t){return c(t)&&Q(t.length)&&!!i[h(t)]}var zt=Ko;function zo(t){return function(e){return t(e)}}var B=zo;var kt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,K=kt&&typeof module=="object"&&module&&!module.nodeType&&module,ko=K&&K.exports===kt,gt=ko&&q.process,qo=function(){try{var t=K&&K.require&&K.require("util").types;return t||gt&>.binding&>.binding("util")}catch{}}(),b=qo;var qt=b&&b.isTypedArray,Ho=qt?B(qt):zt,Ht=Ho;var $o=Object.prototype,Jo=$o.hasOwnProperty;function Yo(t,e){var r=C(t),o=!r&&Ut(t),a=!r&&!o&&et(t),f=!r&&!o&&!a&&Ht(t),s=r||o||a||f,n=s?Nt(t.length,String):[],l=n.length;for(var d in t)(e||Jo.call(t,d))&&!(s&&(d=="length"||a&&(d=="offset"||d=="parent")||f&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||Ft(d,l)))&&n.push(d);return n}var rt=Yo;function Xo(t,e){return function(r){return t(e(r))}}var ot=Xo;var Zo=ot(Object.keys,Object),$t=Zo;var Qo=Object.prototype,ta=Qo.hasOwnProperty;function ea(t){if(!E(t))return $t(t);var e=[];for(var r in Object(t))ta.call(t,r)&&r!="constructor"&&e.push(r);return e}var Jt=ea;function ra(t){return tt(t)?rt(t):Jt(t)}var L=ra;function oa(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Yt=oa;var aa=Object.prototype,fa=aa.hasOwnProperty;function sa(t){if(!x(t))return Yt(t);var e=E(t),r=[];for(var o in t)o=="constructor"&&(e||!fa.call(t,o))||r.push(o);return r}var Xt=sa;function pa(t){return tt(t)?rt(t,!0):Xt(t)}var M=pa;var ia=m(Object,"create"),v=ia;function na(){this.__data__=v?v(null):{},this.size=0}var Zt=na;function ua(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Qt=ua;var ma="__lodash_hash_undefined__",la=Object.prototype,da=la.hasOwnProperty;function ca(t){var e=this.__data__;if(v){var r=e[t];return r===ma?void 0:r}return da.call(e,t)?e[t]:void 0}var te=ca;var xa=Object.prototype,ga=xa.hasOwnProperty;function ha(t){var e=this.__data__;return v?e[t]!==void 0:ga.call(e,t)}var ee=ha;var ya="__lodash_hash_undefined__";function ba(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=v&&e===void 0?ya:e,this}var re=ba;function D(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])}}D.prototype.clear=Zt;D.prototype.delete=Qt;D.prototype.get=te;D.prototype.has=ee;D.prototype.set=re;var ht=D;function va(){this.__data__=[],this.size=0}var oe=va;function ja(t,e){for(var r=t.length;r--;)if(X(t[r][0],e))return r;return-1}var O=ja;var Ta=Array.prototype,Oa=Ta.splice;function _a(t){var e=this.__data__,r=O(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Oa.call(e,r,1),--this.size,!0}var ae=_a;function Aa(t){var e=this.__data__,r=O(e,t);return r<0?void 0:e[r][1]}var fe=Aa;function wa(t){return O(this.__data__,t)>-1}var se=wa;function Sa(t,e){var r=this.__data__,o=O(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var pe=Sa;function F(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])}}F.prototype.clear=oe;F.prototype.delete=ae;F.prototype.get=fe;F.prototype.has=se;F.prototype.set=pe;var _=F;var Ia=m(u,"Map"),A=Ia;function Pa(){this.size=0,this.__data__={hash:new ht,map:new(A||_),string:new ht}}var ie=Pa;function Ca(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ne=Ca;function Ea(t,e){var r=t.__data__;return ne(e)?r[typeof e=="string"?"string":"hash"]:r.map}var w=Ea;function Ba(t){var e=w(this,t).delete(t);return this.size-=e?1:0,e}var ue=Ba;function La(t){return w(this,t).get(t)}var me=La;function Ma(t){return w(this,t).has(t)}var le=Ma;function Da(t,e){var r=w(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var de=Da;function N(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])}}N.prototype.clear=ie;N.prototype.delete=ue;N.prototype.get=me;N.prototype.has=le;N.prototype.set=de;var ce=N;function Fa(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var at=Fa;var Na=ot(Object.getPrototypeOf,Object),ft=Na;function Ra(){this.__data__=new _,this.size=0}var xe=Ra;function Ua(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ge=Ua;function Ga(t){return this.__data__.get(t)}var he=Ga;function Wa(t){return this.__data__.has(t)}var ye=Wa;var Va=200;function Ka(t,e){var r=this.__data__;if(r instanceof _){var o=r.__data__;if(!A||o.length<Va-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ce(o)}return r.set(t,e),this.size=r.size,this}var be=Ka;function R(t){var e=this.__data__=new _(t);this.size=e.size}R.prototype.clear=xe;R.prototype.delete=ge;R.prototype.get=he;R.prototype.has=ye;R.prototype.set=be;var ve=R;function za(t,e){return t&&T(e,L(e),t)}var je=za;function ka(t,e){return t&&T(e,M(e),t)}var Te=ka;var we=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=we&&typeof module=="object"&&module&&!module.nodeType&&module,qa=Oe&&Oe.exports===we,_e=qa?u.Buffer:void 0,Ae=_e?_e.allocUnsafe:void 0;function Ha(t,e){if(e)return t.slice();var r=t.length,o=Ae?Ae(r):new t.constructor(r);return t.copy(o),o}var Se=Ha;function $a(t,e){for(var r=-1,o=t==null?0:t.length,a=0,f=[];++r<o;){var s=t[r];e(s,r,t)&&(f[a++]=s)}return f}var Ie=$a;function Ja(){return[]}var st=Ja;var Ya=Object.prototype,Xa=Ya.propertyIsEnumerable,Pe=Object.getOwnPropertySymbols,Za=Pe?function(t){return t==null?[]:(t=Object(t),Ie(Pe(t),function(e){return Xa.call(t,e)}))}:st,U=Za;function Qa(t,e){return T(t,U(t),e)}var Ce=Qa;var tf=Object.getOwnPropertySymbols,ef=tf?function(t){for(var e=[];t;)at(e,U(t)),t=ft(t);return e}:st,pt=ef;function rf(t,e){return T(t,pt(t),e)}var Ee=rf;function of(t,e,r){var o=e(t);return C(t)?o:at(o,r(t))}var it=of;function af(t){return it(t,L,U)}var Be=af;function ff(t){return it(t,M,pt)}var Le=ff;var sf=m(u,"DataView"),nt=sf;var pf=m(u,"Promise"),ut=pf;var nf=m(u,"Set"),mt=nf;var Me="[object Map]",uf="[object Object]",De="[object Promise]",Fe="[object Set]",Ne="[object WeakMap]",Re="[object DataView]",mf=y(nt),lf=y(A),df=y(ut),cf=y(mt),xf=y(J),I=h;(nt&&I(new nt(new ArrayBuffer(1)))!=Re||A&&I(new A)!=Me||ut&&I(ut.resolve())!=De||mt&&I(new mt)!=Fe||J&&I(new J)!=Ne)&&(I=function(t){var e=h(t),r=e==uf?t.constructor:void 0,o=r?y(r):"";if(o)switch(o){case mf:return Re;case lf:return Me;case df:return De;case cf:return Fe;case xf:return Ne}return e});var G=I;var gf=Object.prototype,hf=gf.hasOwnProperty;function yf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&hf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ue=yf;var bf=u.Uint8Array,yt=bf;function vf(t){var e=new t.constructor(t.byteLength);return new yt(e).set(new yt(t)),e}var W=vf;function jf(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ge=jf;var Tf=/\w*$/;function Of(t){var e=new t.constructor(t.source,Tf.exec(t));return e.lastIndex=t.lastIndex,e}var We=Of;var Ve=g?g.prototype:void 0,Ke=Ve?Ve.valueOf:void 0;function _f(t){return Ke?Object(Ke.call(t)):{}}var ze=_f;function Af(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var ke=Af;var wf="[object Boolean]",Sf="[object Date]",If="[object Map]",Pf="[object Number]",Cf="[object RegExp]",Ef="[object Set]",Bf="[object String]",Lf="[object Symbol]",Mf="[object ArrayBuffer]",Df="[object DataView]",Ff="[object Float32Array]",Nf="[object Float64Array]",Rf="[object Int8Array]",Uf="[object Int16Array]",Gf="[object Int32Array]",Wf="[object Uint8Array]",Vf="[object Uint8ClampedArray]",Kf="[object Uint16Array]",zf="[object Uint32Array]";function kf(t,e,r){var o=t.constructor;switch(e){case Mf:return W(t);case wf:case Sf:return new o(+t);case Df:return Ge(t,r);case Ff:case Nf:case Rf:case Uf:case Gf:case Wf:case Vf:case Kf:case zf:return ke(t,r);case If:return new o;case Pf:case Bf:return new o(t);case Cf:return We(t);case Ef:return new o;case Lf:return ze(t)}}var qe=kf;function qf(t){return typeof t.constructor=="function"&&!E(t)?Lt(ft(t)):{}}var He=qf;var Hf="[object Map]";function $f(t){return c(t)&&G(t)==Hf}var $e=$f;var Je=b&&b.isMap,Jf=Je?B(Je):$e,Ye=Jf;var Yf="[object Set]";function Xf(t){return c(t)&&G(t)==Yf}var Xe=Xf;var Ze=b&&b.isSet,Zf=Ze?B(Ze):Xe,Qe=Zf;var Qf=1,ts=2,es=4,tr="[object Arguments]",rs="[object Array]",os="[object Boolean]",as="[object Date]",fs="[object Error]",er="[object Function]",ss="[object GeneratorFunction]",ps="[object Map]",is="[object Number]",rr="[object Object]",ns="[object RegExp]",us="[object Set]",ms="[object String]",ls="[object Symbol]",ds="[object WeakMap]",cs="[object ArrayBuffer]",xs="[object DataView]",gs="[object Float32Array]",hs="[object Float64Array]",ys="[object Int8Array]",bs="[object Int16Array]",vs="[object Int32Array]",js="[object Uint8Array]",Ts="[object Uint8ClampedArray]",Os="[object Uint16Array]",_s="[object Uint32Array]",p={};p[tr]=p[rs]=p[cs]=p[xs]=p[os]=p[as]=p[gs]=p[hs]=p[ys]=p[bs]=p[vs]=p[ps]=p[is]=p[rr]=p[ns]=p[us]=p[ms]=p[ls]=p[js]=p[Ts]=p[Os]=p[_s]=!0;p[fs]=p[er]=p[ds]=!1;function lt(t,e,r,o,a,f){var s,n=e&Qf,l=e&ts,d=e&es;if(r&&(s=a?r(t,o,a,f):r(t)),s!==void 0)return s;if(!x(t))return t;var vt=C(t);if(vt){if(s=Ue(t),!n)return Mt(t,s)}else{var P=G(t),jt=P==er||P==ss;if(et(t))return Se(t,n);if(P==rr||P==tr||jt&&!a){if(s=l||jt?{}:He(t),!n)return l?Ee(t,Te(s,t)):Ce(t,je(s,t))}else{if(!p[P])return a?t:{};s=qe(t,P,n)}}f||(f=new ve);var Tt=f.get(t);if(Tt)return Tt;f.set(t,s),Qe(t)?t.forEach(function(j){s.add(lt(j,e,r,j,t,f))}):Ye(t)&&t.forEach(function(j,S){s.set(S,lt(j,e,r,S,t,f))});var ar=d?l?Le:Be:l?M:L,Ot=vt?void 0:ar(t);return Dt(Ot||t,function(j,S){Ot&&(S=j,j=t[S]),Z(s,S,lt(j,e,r,S,t,f))}),s}var or=lt;var As=1,ws=4;function Ss(t){return or(t,As|ws)}var dt=Ss;var z=class{init(){}constructor(e,r){}};var bt=class extends z{constructor(){super(...arguments);k(this,"Vue");k(this,"projects");k(this,"state",null)}bindProjectState(r){let o={component:null,componentKey:null,autoRequire:!0,write:!0,...r};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:o.autoRequire}),(()=>{if(!o.componentKey){for(let a=0;a<50;a++){let f=`terafy_${a}`;if(!Object.hasOwnProperty(o.component,f)){o.componentKey=f;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([a])=>{this.debug("Got project snapshot",a);let f=this.Vue.observable(a);o.component[o.componentKey]=f;let s=0;if(o.read&&this.events.on(`update:projects/${f.id}`,n=>{s++,this.merge(f,n)}),o.write){if(!o.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let n=dt(a);o.component.$watch(o.componentKey,l=>{if(s>0){s--;return}this.createProjectStatePatch(l,n),n=dt(a)},{deep:!0})}return f})}merge(r,...o){return o.forEach(a=>Object.keys(a).forEach(f=>this.Vue.set(r,f,a[f]))),r}init(r){let o={app:null,Vue:null,globalName:"$tera",requireProject:!0,subscribeState:!0,subscribeProjects:!0,stateOptions:{read:!0,write:!0},...r};if(!o.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=r.Vue,!this.settings.app)throw new Error("Need to specify the root level Vue2 app during init");return o.stateOptions.app=this.settings.app,this.projects=this.Vue.observable([]),o.globalName&&(this.Vue.prototype[o.globalName]=this),this.state=null,Promise.resolve().then(()=>o.requireProject&&this.requireProject()).then(()=>Promise.all([o.subscribeState&&this.bindProjectState({...o.stateOptions,component:this.settings.app.$root}).then(a=>this.state=a).then(()=>this.debug("INFO","Loaded project state",this.state)),o.subscribeProjects&&this.getProjects().then(a=>this.projects=this.Vue.observable(a)).then(()=>this.debug("INFO","Loaded projects",this.projects))]))}};export{bt as default};
|
|
1
|
+
var fr=Object.defineProperty;var sr=(t,e,r)=>e in t?fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var k=(t,e,r)=>(sr(t,typeof e!="symbol"?e+"":e,r),r);var pr=typeof global=="object"&&global&&global.Object===Object&&global,q=pr;var ir=typeof self=="object"&&self&&self.Object===Object&&self,nr=q||ir||Function("return this")(),u=nr;var ur=u.Symbol,g=ur;var _t=Object.prototype,mr=_t.hasOwnProperty,lr=_t.toString,V=g?g.toStringTag:void 0;function dr(t){var e=mr.call(t,V),r=t[V];try{t[V]=void 0;var o=!0}catch{}var a=lr.call(t);return o&&(e?t[V]=r:delete t[V]),a}var At=dr;var cr=Object.prototype,xr=cr.toString;function gr(t){return xr.call(t)}var wt=gr;var hr="[object Null]",yr="[object Undefined]",St=g?g.toStringTag:void 0;function br(t){return t==null?t===void 0?yr:hr:St&&St in Object(t)?At(t):wt(t)}var h=br;function vr(t){return t!=null&&typeof t=="object"}var c=vr;var jr=Array.isArray,C=jr;function Tr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var x=Tr;var Or="[object AsyncFunction]",_r="[object Function]",Ar="[object GeneratorFunction]",wr="[object Proxy]";function Sr(t){if(!x(t))return!1;var e=h(t);return e==_r||e==Ar||e==Or||e==wr}var H=Sr;var Ir=u["__core-js_shared__"],$=Ir;var It=function(){var t=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Pr(t){return!!It&&It in t}var Pt=Pr;var Cr=Function.prototype,Er=Cr.toString;function Br(t){if(t!=null){try{return Er.call(t)}catch{}try{return t+""}catch{}}return""}var y=Br;var Lr=/[\\^$.*+?()[\]{}|]/g,Mr=/^\[object .+?Constructor\]$/,Dr=Function.prototype,Fr=Object.prototype,Nr=Dr.toString,Rr=Fr.hasOwnProperty,Ur=RegExp("^"+Nr.call(Rr).replace(Lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Gr(t){if(!x(t)||Pt(t))return!1;var e=H(t)?Ur:Mr;return e.test(y(t))}var Ct=Gr;function Wr(t,e){return t==null?void 0:t[e]}var Et=Wr;function Vr(t,e){var r=Et(t,e);return Ct(r)?r:void 0}var m=Vr;var Kr=m(u,"WeakMap"),J=Kr;var Bt=Object.create,zr=function(){function t(){}return function(e){if(!x(e))return{};if(Bt)return Bt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Lt=zr;function kr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Mt=kr;var qr=function(){try{var t=m(Object,"defineProperty");return t({},"",{}),t}catch{}}(),ct=qr;function Hr(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Dt=Hr;var $r=9007199254740991,Jr=/^(?:0|[1-9]\d*)$/;function Yr(t,e){var r=typeof t;return e=e==null?$r:e,!!e&&(r=="number"||r!="symbol"&&Jr.test(t))&&t>-1&&t%1==0&&t<e}var Ft=Yr;function Xr(t,e,r){e=="__proto__"&&ct?ct(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Y=Xr;function Zr(t,e){return t===e||t!==t&&e!==e}var X=Zr;var Qr=Object.prototype,to=Qr.hasOwnProperty;function eo(t,e,r){var o=t[e];(!(to.call(t,e)&&X(o,r))||r===void 0&&!(e in t))&&Y(t,e,r)}var Z=eo;function ro(t,e,r,o){var a=!r;r||(r={});for(var f=-1,s=e.length;++f<s;){var n=e[f],l=o?o(r[n],t[n],n,r,t):void 0;l===void 0&&(l=t[n]),a?Y(r,n,l):Z(r,n,l)}return r}var T=ro;var oo=9007199254740991;function ao(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=oo}var Q=ao;function fo(t){return t!=null&&Q(t.length)&&!H(t)}var tt=fo;var so=Object.prototype;function po(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||so;return t===r}var E=po;function io(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Nt=io;var no="[object Arguments]";function uo(t){return c(t)&&h(t)==no}var xt=uo;var Rt=Object.prototype,mo=Rt.hasOwnProperty,lo=Rt.propertyIsEnumerable,co=xt(function(){return arguments}())?xt:function(t){return c(t)&&mo.call(t,"callee")&&!lo.call(t,"callee")},Ut=co;function xo(){return!1}var Gt=xo;var Kt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wt=Kt&&typeof module=="object"&&module&&!module.nodeType&&module,go=Wt&&Wt.exports===Kt,Vt=go?u.Buffer:void 0,ho=Vt?Vt.isBuffer:void 0,yo=ho||Gt,et=yo;var bo="[object Arguments]",vo="[object Array]",jo="[object Boolean]",To="[object Date]",Oo="[object Error]",_o="[object Function]",Ao="[object Map]",wo="[object Number]",So="[object Object]",Io="[object RegExp]",Po="[object Set]",Co="[object String]",Eo="[object WeakMap]",Bo="[object ArrayBuffer]",Lo="[object DataView]",Mo="[object Float32Array]",Do="[object Float64Array]",Fo="[object Int8Array]",No="[object Int16Array]",Ro="[object Int32Array]",Uo="[object Uint8Array]",Go="[object Uint8ClampedArray]",Wo="[object Uint16Array]",Vo="[object Uint32Array]",i={};i[Mo]=i[Do]=i[Fo]=i[No]=i[Ro]=i[Uo]=i[Go]=i[Wo]=i[Vo]=!0;i[bo]=i[vo]=i[Bo]=i[jo]=i[Lo]=i[To]=i[Oo]=i[_o]=i[Ao]=i[wo]=i[So]=i[Io]=i[Po]=i[Co]=i[Eo]=!1;function Ko(t){return c(t)&&Q(t.length)&&!!i[h(t)]}var zt=Ko;function zo(t){return function(e){return t(e)}}var B=zo;var kt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,K=kt&&typeof module=="object"&&module&&!module.nodeType&&module,ko=K&&K.exports===kt,gt=ko&&q.process,qo=function(){try{var t=K&&K.require&&K.require("util").types;return t||gt&>.binding&>.binding("util")}catch{}}(),b=qo;var qt=b&&b.isTypedArray,Ho=qt?B(qt):zt,Ht=Ho;var $o=Object.prototype,Jo=$o.hasOwnProperty;function Yo(t,e){var r=C(t),o=!r&&Ut(t),a=!r&&!o&&et(t),f=!r&&!o&&!a&&Ht(t),s=r||o||a||f,n=s?Nt(t.length,String):[],l=n.length;for(var d in t)(e||Jo.call(t,d))&&!(s&&(d=="length"||a&&(d=="offset"||d=="parent")||f&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||Ft(d,l)))&&n.push(d);return n}var rt=Yo;function Xo(t,e){return function(r){return t(e(r))}}var ot=Xo;var Zo=ot(Object.keys,Object),$t=Zo;var Qo=Object.prototype,ta=Qo.hasOwnProperty;function ea(t){if(!E(t))return $t(t);var e=[];for(var r in Object(t))ta.call(t,r)&&r!="constructor"&&e.push(r);return e}var Jt=ea;function ra(t){return tt(t)?rt(t):Jt(t)}var L=ra;function oa(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Yt=oa;var aa=Object.prototype,fa=aa.hasOwnProperty;function sa(t){if(!x(t))return Yt(t);var e=E(t),r=[];for(var o in t)o=="constructor"&&(e||!fa.call(t,o))||r.push(o);return r}var Xt=sa;function pa(t){return tt(t)?rt(t,!0):Xt(t)}var M=pa;var ia=m(Object,"create"),v=ia;function na(){this.__data__=v?v(null):{},this.size=0}var Zt=na;function ua(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Qt=ua;var ma="__lodash_hash_undefined__",la=Object.prototype,da=la.hasOwnProperty;function ca(t){var e=this.__data__;if(v){var r=e[t];return r===ma?void 0:r}return da.call(e,t)?e[t]:void 0}var te=ca;var xa=Object.prototype,ga=xa.hasOwnProperty;function ha(t){var e=this.__data__;return v?e[t]!==void 0:ga.call(e,t)}var ee=ha;var ya="__lodash_hash_undefined__";function ba(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=v&&e===void 0?ya:e,this}var re=ba;function D(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])}}D.prototype.clear=Zt;D.prototype.delete=Qt;D.prototype.get=te;D.prototype.has=ee;D.prototype.set=re;var ht=D;function va(){this.__data__=[],this.size=0}var oe=va;function ja(t,e){for(var r=t.length;r--;)if(X(t[r][0],e))return r;return-1}var O=ja;var Ta=Array.prototype,Oa=Ta.splice;function _a(t){var e=this.__data__,r=O(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Oa.call(e,r,1),--this.size,!0}var ae=_a;function Aa(t){var e=this.__data__,r=O(e,t);return r<0?void 0:e[r][1]}var fe=Aa;function wa(t){return O(this.__data__,t)>-1}var se=wa;function Sa(t,e){var r=this.__data__,o=O(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var pe=Sa;function F(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])}}F.prototype.clear=oe;F.prototype.delete=ae;F.prototype.get=fe;F.prototype.has=se;F.prototype.set=pe;var _=F;var Ia=m(u,"Map"),A=Ia;function Pa(){this.size=0,this.__data__={hash:new ht,map:new(A||_),string:new ht}}var ie=Pa;function Ca(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ne=Ca;function Ea(t,e){var r=t.__data__;return ne(e)?r[typeof e=="string"?"string":"hash"]:r.map}var w=Ea;function Ba(t){var e=w(this,t).delete(t);return this.size-=e?1:0,e}var ue=Ba;function La(t){return w(this,t).get(t)}var me=La;function Ma(t){return w(this,t).has(t)}var le=Ma;function Da(t,e){var r=w(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var de=Da;function N(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])}}N.prototype.clear=ie;N.prototype.delete=ue;N.prototype.get=me;N.prototype.has=le;N.prototype.set=de;var ce=N;function Fa(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var at=Fa;var Na=ot(Object.getPrototypeOf,Object),ft=Na;function Ra(){this.__data__=new _,this.size=0}var xe=Ra;function Ua(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ge=Ua;function Ga(t){return this.__data__.get(t)}var he=Ga;function Wa(t){return this.__data__.has(t)}var ye=Wa;var Va=200;function Ka(t,e){var r=this.__data__;if(r instanceof _){var o=r.__data__;if(!A||o.length<Va-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ce(o)}return r.set(t,e),this.size=r.size,this}var be=Ka;function R(t){var e=this.__data__=new _(t);this.size=e.size}R.prototype.clear=xe;R.prototype.delete=ge;R.prototype.get=he;R.prototype.has=ye;R.prototype.set=be;var ve=R;function za(t,e){return t&&T(e,L(e),t)}var je=za;function ka(t,e){return t&&T(e,M(e),t)}var Te=ka;var we=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=we&&typeof module=="object"&&module&&!module.nodeType&&module,qa=Oe&&Oe.exports===we,_e=qa?u.Buffer:void 0,Ae=_e?_e.allocUnsafe:void 0;function Ha(t,e){if(e)return t.slice();var r=t.length,o=Ae?Ae(r):new t.constructor(r);return t.copy(o),o}var Se=Ha;function $a(t,e){for(var r=-1,o=t==null?0:t.length,a=0,f=[];++r<o;){var s=t[r];e(s,r,t)&&(f[a++]=s)}return f}var Ie=$a;function Ja(){return[]}var st=Ja;var Ya=Object.prototype,Xa=Ya.propertyIsEnumerable,Pe=Object.getOwnPropertySymbols,Za=Pe?function(t){return t==null?[]:(t=Object(t),Ie(Pe(t),function(e){return Xa.call(t,e)}))}:st,U=Za;function Qa(t,e){return T(t,U(t),e)}var Ce=Qa;var tf=Object.getOwnPropertySymbols,ef=tf?function(t){for(var e=[];t;)at(e,U(t)),t=ft(t);return e}:st,pt=ef;function rf(t,e){return T(t,pt(t),e)}var Ee=rf;function of(t,e,r){var o=e(t);return C(t)?o:at(o,r(t))}var it=of;function af(t){return it(t,L,U)}var Be=af;function ff(t){return it(t,M,pt)}var Le=ff;var sf=m(u,"DataView"),nt=sf;var pf=m(u,"Promise"),ut=pf;var nf=m(u,"Set"),mt=nf;var Me="[object Map]",uf="[object Object]",De="[object Promise]",Fe="[object Set]",Ne="[object WeakMap]",Re="[object DataView]",mf=y(nt),lf=y(A),df=y(ut),cf=y(mt),xf=y(J),I=h;(nt&&I(new nt(new ArrayBuffer(1)))!=Re||A&&I(new A)!=Me||ut&&I(ut.resolve())!=De||mt&&I(new mt)!=Fe||J&&I(new J)!=Ne)&&(I=function(t){var e=h(t),r=e==uf?t.constructor:void 0,o=r?y(r):"";if(o)switch(o){case mf:return Re;case lf:return Me;case df:return De;case cf:return Fe;case xf:return Ne}return e});var G=I;var gf=Object.prototype,hf=gf.hasOwnProperty;function yf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&hf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ue=yf;var bf=u.Uint8Array,yt=bf;function vf(t){var e=new t.constructor(t.byteLength);return new yt(e).set(new yt(t)),e}var W=vf;function jf(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ge=jf;var Tf=/\w*$/;function Of(t){var e=new t.constructor(t.source,Tf.exec(t));return e.lastIndex=t.lastIndex,e}var We=Of;var Ve=g?g.prototype:void 0,Ke=Ve?Ve.valueOf:void 0;function _f(t){return Ke?Object(Ke.call(t)):{}}var ze=_f;function Af(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var ke=Af;var wf="[object Boolean]",Sf="[object Date]",If="[object Map]",Pf="[object Number]",Cf="[object RegExp]",Ef="[object Set]",Bf="[object String]",Lf="[object Symbol]",Mf="[object ArrayBuffer]",Df="[object DataView]",Ff="[object Float32Array]",Nf="[object Float64Array]",Rf="[object Int8Array]",Uf="[object Int16Array]",Gf="[object Int32Array]",Wf="[object Uint8Array]",Vf="[object Uint8ClampedArray]",Kf="[object Uint16Array]",zf="[object Uint32Array]";function kf(t,e,r){var o=t.constructor;switch(e){case Mf:return W(t);case wf:case Sf:return new o(+t);case Df:return Ge(t,r);case Ff:case Nf:case Rf:case Uf:case Gf:case Wf:case Vf:case Kf:case zf:return ke(t,r);case If:return new o;case Pf:case Bf:return new o(t);case Cf:return We(t);case Ef:return new o;case Lf:return ze(t)}}var qe=kf;function qf(t){return typeof t.constructor=="function"&&!E(t)?Lt(ft(t)):{}}var He=qf;var Hf="[object Map]";function $f(t){return c(t)&&G(t)==Hf}var $e=$f;var Je=b&&b.isMap,Jf=Je?B(Je):$e,Ye=Jf;var Yf="[object Set]";function Xf(t){return c(t)&&G(t)==Yf}var Xe=Xf;var Ze=b&&b.isSet,Zf=Ze?B(Ze):Xe,Qe=Zf;var Qf=1,ts=2,es=4,tr="[object Arguments]",rs="[object Array]",os="[object Boolean]",as="[object Date]",fs="[object Error]",er="[object Function]",ss="[object GeneratorFunction]",ps="[object Map]",is="[object Number]",rr="[object Object]",ns="[object RegExp]",us="[object Set]",ms="[object String]",ls="[object Symbol]",ds="[object WeakMap]",cs="[object ArrayBuffer]",xs="[object DataView]",gs="[object Float32Array]",hs="[object Float64Array]",ys="[object Int8Array]",bs="[object Int16Array]",vs="[object Int32Array]",js="[object Uint8Array]",Ts="[object Uint8ClampedArray]",Os="[object Uint16Array]",_s="[object Uint32Array]",p={};p[tr]=p[rs]=p[cs]=p[xs]=p[os]=p[as]=p[gs]=p[hs]=p[ys]=p[bs]=p[vs]=p[ps]=p[is]=p[rr]=p[ns]=p[us]=p[ms]=p[ls]=p[js]=p[Ts]=p[Os]=p[_s]=!0;p[fs]=p[er]=p[ds]=!1;function lt(t,e,r,o,a,f){var s,n=e&Qf,l=e&ts,d=e&es;if(r&&(s=a?r(t,o,a,f):r(t)),s!==void 0)return s;if(!x(t))return t;var vt=C(t);if(vt){if(s=Ue(t),!n)return Mt(t,s)}else{var P=G(t),jt=P==er||P==ss;if(et(t))return Se(t,n);if(P==rr||P==tr||jt&&!a){if(s=l||jt?{}:He(t),!n)return l?Ee(t,Te(s,t)):Ce(t,je(s,t))}else{if(!p[P])return a?t:{};s=qe(t,P,n)}}f||(f=new ve);var Tt=f.get(t);if(Tt)return Tt;f.set(t,s),Qe(t)?t.forEach(function(j){s.add(lt(j,e,r,j,t,f))}):Ye(t)&&t.forEach(function(j,S){s.set(S,lt(j,e,r,S,t,f))});var ar=d?l?Le:Be:l?M:L,Ot=vt?void 0:ar(t);return Dt(Ot||t,function(j,S){Ot&&(S=j,j=t[S]),Z(s,S,lt(j,e,r,S,t,f))}),s}var or=lt;var As=1,ws=4;function Ss(t){return or(t,As|ws)}var dt=Ss;var z=class{init(){}constructor(e,r){}};var bt=class extends z{constructor(){super(...arguments);k(this,"Vue");k(this,"projects");k(this,"state",null)}bindProjectState(r){let o={component:null,componentKey:null,autoRequire:!0,write:!0,...r};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:o.autoRequire}),(()=>{if(!o.componentKey){for(let a=0;a<50;a++){let f=`terafy_${a}`;if(!Object.hasOwnProperty(o.component,f)){o.componentKey=f;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([a])=>{this.debug("INFO",2,"Got project snapshot",a);let f=this.Vue.observable(a);o.component[o.componentKey]=f;let s=0;if(o.read&&this.events.on(`update:projects/${f.id}`,n=>{s++,this.merge(f,n)}),o.write){if(!o.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let n=dt(a);o.component.$watch(o.componentKey,l=>{if(s>0){s--;return}this.createProjectStatePatch(l,n),n=dt(a)},{deep:!0})}return f})}merge(r,...o){return o.forEach(a=>Object.keys(a).forEach(f=>this.Vue.set(r,f,a[f]))),r}init(r){let o={app:null,Vue:null,globalName:"$tera",requireProject:!0,subscribeState:!0,subscribeProjects:!0,stateOptions:{read:!0,write:!0},...r};if(!o.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=r.Vue,!this.settings.app)throw new Error("Need to specify the root level Vue2 app during init");return o.stateOptions.app=this.settings.app,this.projects=this.Vue.observable([]),o.globalName&&(this.Vue.prototype[o.globalName]=this),this.state=null,Promise.resolve().then(()=>o.requireProject&&this.requireProject()).then(()=>Promise.all([o.subscribeState&&this.bindProjectState({...o.stateOptions,component:this.settings.app.$root}).then(a=>this.state=a).then(()=>this.debug("INFO",1,"Loaded initial project state",this.state)),o.subscribeProjects&&this.getProjects().then(a=>this.projects=this.Vue.observable(a)).then(()=>this.debug("INFO",2,"Loaded project list",this.projects))])).then(()=>this.debug("INFO",1,"Ready"))}};export{bt as default};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
lodash-es/lodash.js:
|
package/dist/terafy.es2019.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var bo=Object.defineProperty;var vo=(t,e,r)=>e in t?bo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var x=(t,e,r)=>(vo(t,typeof e!="symbol"?e+"":e,r),r),Jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var lt=(t,e,r)=>(Jt(t,e,"read from private field"),r?r.call(t):e.get(t)),Xt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Qt=(t,e,r,o)=>(Jt(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r);function te(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:v}){var P=Object.keys(i),A=P.length,y=Object.keys(n),I=y.length,b,p=i.length-n.length;if(To(i,n)){for(var u=0;u<A;u++){var l=Array.isArray(i)?Number(P[u]):P[u];l in n||(b=h.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<I;u++){var l=Array.isArray(n)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=h.concat(u),v.remove.push({op:"remove",path:r(b)});for(var E=i.slice(p),u=0;u<I;u++)s({key:u,obj1:E,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:v})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:v,diffs:P}){var A=n[i],y=m[i];if(!(i in n)&&i in m){var I=y;P.add.push({op:"add",path:r(h),value:I})}else A!==y&&(Object(A)!==A||Object(y)!==y||wo(A,y)||!Object.keys(A).length&&!Object.keys(y).length&&String(A)!=String(y)?f(h,P,y):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:v,diffs:P}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function ee(t){return[""].concat(t).join("/")}function wo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function To(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var Ao=typeof global=="object"&&global&&global.Object===Object&&global,ht=Ao;var So=typeof self=="object"&&self&&self.Object===Object&&self,Po=ht||So||Function("return this")(),g=Po;var jo=g.Symbol,T=jo;var re=Object.prototype,Oo=re.hasOwnProperty,_o=re.toString,mt=T?T.toStringTag:void 0;function Io(t){var e=Oo.call(t,mt),r=t[mt];try{t[mt]=void 0;var o=!0}catch{}var a=_o.call(t);return o&&(e?t[mt]=r:delete t[mt]),a}var oe=Io;var Eo=Object.prototype,Co=Eo.toString;function Mo(t){return Co.call(t)}var ae=Mo;var Ro="[object Null]",Bo="[object Undefined]",ie=T?T.toStringTag:void 0;function Fo(t){return t==null?t===void 0?Bo:Ro:ie&&ie in Object(t)?oe(t):ae(t)}var _=Fo;function Lo(t){return t!=null&&typeof t=="object"}var O=Lo;var No="[object Symbol]";function Do(t){return typeof t=="symbol"||O(t)&&_(t)==No}var G=Do;function ko(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 se=ko;var Uo=Array.isArray,w=Uo;var zo=1/0,fe=T?T.prototype:void 0,ne=fe?fe.toString:void 0;function pe(t){if(typeof t=="string")return t;if(w(t))return se(t,pe)+"";if(G(t))return ne?ne.call(t):"";var e=t+"";return e=="0"&&1/t==-zo?"-0":e}var le=pe;function Ko(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var j=Ko;function Go(t){return t}var me=Go;var Wo="[object AsyncFunction]",Ho="[object Function]",$o="[object GeneratorFunction]",qo="[object Proxy]";function Yo(t){if(!j(t))return!1;var e=_(t);return e==Ho||e==$o||e==Wo||e==qo}var xt=Yo;var Vo=g["__core-js_shared__"],gt=Vo;var ue=function(){var t=/[^.]+$/.exec(gt&>.keys&>.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Zo(t){return!!ue&&ue in t}var de=Zo;var Jo=Function.prototype,Xo=Jo.toString;function Qo(t){if(t!=null){try{return Xo.call(t)}catch{}try{return t+""}catch{}}return""}var C=Qo;var ta=/[\\^$.*+?()[\]{}|]/g,ea=/^\[object .+?Constructor\]$/,ra=Function.prototype,oa=Object.prototype,aa=ra.toString,ia=oa.hasOwnProperty,sa=RegExp("^"+aa.call(ia).replace(ta,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fa(t){if(!j(t)||de(t))return!1;var e=xt(t)?sa:ea;return e.test(C(t))}var ce=fa;function na(t,e){return t==null?void 0:t[e]}var he=na;function pa(t,e){var r=he(t,e);return ce(r)?r:void 0}var S=pa;var la=S(g,"WeakMap"),yt=la;var xe=Object.create,ma=function(){function t(){}return function(e){if(!j(e))return{};if(xe)return xe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ge=ma;function ua(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 ye=ua;function da(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var be=da;var ca=800,ha=16,xa=Date.now;function ga(t){var e=0,r=0;return function(){var o=xa(),a=ha-(o-r);if(r=o,a>0){if(++e>=ca)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ve=ga;function ya(t){return function(){return t}}var we=ya;var ba=function(){try{var t=S(Object,"defineProperty");return t({},"",{}),t}catch{}}(),W=ba;var va=W?function(t,e){return W(t,"toString",{configurable:!0,enumerable:!1,value:we(e),writable:!0})}:me,Te=va;var wa=ve(Te),Ae=wa;function Ta(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Se=Ta;var Aa=9007199254740991,Sa=/^(?:0|[1-9]\d*)$/;function Pa(t,e){var r=typeof t;return e=e==null?Aa:e,!!e&&(r=="number"||r!="symbol"&&Sa.test(t))&&t>-1&&t%1==0&&t<e}var H=Pa;function ja(t,e,r){e=="__proto__"&&W?W(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var bt=ja;function Oa(t,e){return t===e||t!==t&&e!==e}var vt=Oa;var _a=Object.prototype,Ia=_a.hasOwnProperty;function Ea(t,e,r){var o=t[e];(!(Ia.call(t,e)&&vt(o,r))||r===void 0&&!(e in t))&&bt(t,e,r)}var $=Ea;function Ca(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?bt(r,i,n):$(r,i,n)}return r}var B=Ca;var Pe=Math.max;function Ma(t,e,r){return e=Pe(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=Pe(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),ye(t,this,i)}}var je=Ma;var Ra=9007199254740991;function Ba(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ra}var q=Ba;function Fa(t){return t!=null&&q(t.length)&&!xt(t)}var wt=Fa;var La=Object.prototype;function Na(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||La;return t===r}var Y=Na;function Da(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Oe=Da;var ka="[object Arguments]";function Ua(t){return O(t)&&_(t)==ka}var Ft=Ua;var _e=Object.prototype,za=_e.hasOwnProperty,Ka=_e.propertyIsEnumerable,Ga=Ft(function(){return arguments}())?Ft:function(t){return O(t)&&za.call(t,"callee")&&!Ka.call(t,"callee")},V=Ga;function Wa(){return!1}var Ie=Wa;var Me=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ee=Me&&typeof module=="object"&&module&&!module.nodeType&&module,Ha=Ee&&Ee.exports===Me,Ce=Ha?g.Buffer:void 0,$a=Ce?Ce.isBuffer:void 0,qa=$a||Ie,Tt=qa;var Ya="[object Arguments]",Va="[object Array]",Za="[object Boolean]",Ja="[object Date]",Xa="[object Error]",Qa="[object Function]",ti="[object Map]",ei="[object Number]",ri="[object Object]",oi="[object RegExp]",ai="[object Set]",ii="[object String]",si="[object WeakMap]",fi="[object ArrayBuffer]",ni="[object DataView]",pi="[object Float32Array]",li="[object Float64Array]",mi="[object Int8Array]",ui="[object Int16Array]",di="[object Int32Array]",ci="[object Uint8Array]",hi="[object Uint8ClampedArray]",xi="[object Uint16Array]",gi="[object Uint32Array]",c={};c[pi]=c[li]=c[mi]=c[ui]=c[di]=c[ci]=c[hi]=c[xi]=c[gi]=!0;c[Ya]=c[Va]=c[fi]=c[Za]=c[ni]=c[Ja]=c[Xa]=c[Qa]=c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=!1;function yi(t){return O(t)&&q(t.length)&&!!c[_(t)]}var Re=yi;function bi(t){return function(e){return t(e)}}var Z=bi;var Be=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ut=Be&&typeof module=="object"&&module&&!module.nodeType&&module,vi=ut&&ut.exports===Be,Lt=vi&&ht.process,wi=function(){try{var t=ut&&ut.require&&ut.require("util").types;return t||Lt&&Lt.binding&&Lt.binding("util")}catch{}}(),M=wi;var Fe=M&&M.isTypedArray,Ti=Fe?Z(Fe):Re,Le=Ti;var Ai=Object.prototype,Si=Ai.hasOwnProperty;function Pi(t,e){var r=w(t),o=!r&&V(t),a=!r&&!o&&Tt(t),s=!r&&!o&&!a&&Le(t),f=r||o||a||s,i=f?Oe(t.length,String):[],n=i.length;for(var m in t)(e||Si.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||H(m,n)))&&i.push(m);return i}var At=Pi;function ji(t,e){return function(r){return t(e(r))}}var St=ji;var Oi=St(Object.keys,Object),Ne=Oi;var _i=Object.prototype,Ii=_i.hasOwnProperty;function Ei(t){if(!Y(t))return Ne(t);var e=[];for(var r in Object(t))Ii.call(t,r)&&r!="constructor"&&e.push(r);return e}var De=Ei;function Ci(t){return wt(t)?At(t):De(t)}var J=Ci;function Mi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var ke=Mi;var Ri=Object.prototype,Bi=Ri.hasOwnProperty;function Fi(t){if(!j(t))return ke(t);var e=Y(t),r=[];for(var o in t)o=="constructor"&&(e||!Bi.call(t,o))||r.push(o);return r}var Ue=Fi;function Li(t){return wt(t)?At(t,!0):Ue(t)}var X=Li;var Ni=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Di=/^\w*$/;function ki(t,e){if(w(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||G(t)?!0:Di.test(t)||!Ni.test(t)||e!=null&&t in Object(e)}var ze=ki;var Ui=S(Object,"create"),R=Ui;function zi(){this.__data__=R?R(null):{},this.size=0}var Ke=zi;function Ki(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ge=Ki;var Gi="__lodash_hash_undefined__",Wi=Object.prototype,Hi=Wi.hasOwnProperty;function $i(t){var e=this.__data__;if(R){var r=e[t];return r===Gi?void 0:r}return Hi.call(e,t)?e[t]:void 0}var We=$i;var qi=Object.prototype,Yi=qi.hasOwnProperty;function Vi(t){var e=this.__data__;return R?e[t]!==void 0:Yi.call(e,t)}var He=Vi;var Zi="__lodash_hash_undefined__";function Ji(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=R&&e===void 0?Zi:e,this}var $e=Ji;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=Ke;Q.prototype.delete=Ge;Q.prototype.get=We;Q.prototype.has=He;Q.prototype.set=$e;var Nt=Q;function Xi(){this.__data__=[],this.size=0}var qe=Xi;function Qi(t,e){for(var r=t.length;r--;)if(vt(t[r][0],e))return r;return-1}var F=Qi;var ts=Array.prototype,es=ts.splice;function rs(t){var e=this.__data__,r=F(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():es.call(e,r,1),--this.size,!0}var Ye=rs;function os(t){var e=this.__data__,r=F(e,t);return r<0?void 0:e[r][1]}var Ve=os;function as(t){return F(this.__data__,t)>-1}var Ze=as;function is(t,e){var r=this.__data__,o=F(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Je=is;function tt(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])}}tt.prototype.clear=qe;tt.prototype.delete=Ye;tt.prototype.get=Ve;tt.prototype.has=Ze;tt.prototype.set=Je;var L=tt;var ss=S(g,"Map"),N=ss;function fs(){this.size=0,this.__data__={hash:new Nt,map:new(N||L),string:new Nt}}var Xe=fs;function ns(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Qe=ns;function ps(t,e){var r=t.__data__;return Qe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var D=ps;function ls(t){var e=D(this,t).delete(t);return this.size-=e?1:0,e}var tr=ls;function ms(t){return D(this,t).get(t)}var er=ms;function us(t){return D(this,t).has(t)}var rr=us;function ds(t,e){var r=D(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var or=ds;function et(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])}}et.prototype.clear=Xe;et.prototype.delete=tr;et.prototype.get=er;et.prototype.has=rr;et.prototype.set=or;var dt=et;var cs="Expected a function";function Dt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(cs);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 f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Dt.Cache||dt),r}Dt.Cache=dt;var ar=Dt;var hs=500;function xs(t){var e=ar(t,function(o){return r.size===hs&&r.clear(),o}),r=e.cache;return e}var ir=xs;var gs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ys=/\\(\\)?/g,bs=ir(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(gs,function(r,o,a,s){e.push(a?s.replace(ys,"$1"):o||r)}),e}),sr=bs;function vs(t){return t==null?"":le(t)}var fr=vs;function ws(t,e){return w(t)?t:ze(t,e)?[t]:sr(fr(t))}var k=ws;var Ts=1/0;function As(t){if(typeof t=="string"||G(t))return t;var e=t+"";return e=="0"&&1/t==-Ts?"-0":e}var rt=As;function Ss(t,e){e=k(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[rt(e[r++])];return r&&r==o?t:void 0}var nr=Ss;function Ps(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ot=Ps;var pr=T?T.isConcatSpreadable:void 0;function js(t){return w(t)||V(t)||!!(pr&&t&&t[pr])}var lr=js;function mr(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=lr),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?mr(i,e-1,r,o,a):ot(a,i):o||(a[a.length]=i)}return a}var ur=mr;function Os(t){var e=t==null?0:t.length;return e?ur(t,1):[]}var dr=Os;function _s(t){return Ae(je(t,void 0,dr),t+"")}var cr=_s;var Is=St(Object.getPrototypeOf,Object),Pt=Is;function Es(){this.__data__=new L,this.size=0}var hr=Es;function Cs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var xr=Cs;function Ms(t){return this.__data__.get(t)}var gr=Ms;function Rs(t){return this.__data__.has(t)}var yr=Rs;var Bs=200;function Fs(t,e){var r=this.__data__;if(r instanceof L){var o=r.__data__;if(!N||o.length<Bs-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new dt(o)}return r.set(t,e),this.size=r.size,this}var br=Fs;function at(t){var e=this.__data__=new L(t);this.size=e.size}at.prototype.clear=hr;at.prototype.delete=xr;at.prototype.get=gr;at.prototype.has=yr;at.prototype.set=br;var vr=at;function Ls(t,e){return t&&B(e,J(e),t)}var wr=Ls;function Ns(t,e){return t&&B(e,X(e),t)}var Tr=Ns;var jr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ar=jr&&typeof module=="object"&&module&&!module.nodeType&&module,Ds=Ar&&Ar.exports===jr,Sr=Ds?g.Buffer:void 0,Pr=Sr?Sr.allocUnsafe:void 0;function ks(t,e){if(e)return t.slice();var r=t.length,o=Pr?Pr(r):new t.constructor(r);return t.copy(o),o}var Or=ks;function Us(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var _r=Us;function zs(){return[]}var jt=zs;var Ks=Object.prototype,Gs=Ks.propertyIsEnumerable,Ir=Object.getOwnPropertySymbols,Ws=Ir?function(t){return t==null?[]:(t=Object(t),_r(Ir(t),function(e){return Gs.call(t,e)}))}:jt,it=Ws;function Hs(t,e){return B(t,it(t),e)}var Er=Hs;var $s=Object.getOwnPropertySymbols,qs=$s?function(t){for(var e=[];t;)ot(e,it(t)),t=Pt(t);return e}:jt,Ot=qs;function Ys(t,e){return B(t,Ot(t),e)}var Cr=Ys;function Vs(t,e,r){var o=e(t);return w(t)?o:ot(o,r(t))}var _t=Vs;function Zs(t){return _t(t,J,it)}var Mr=Zs;function Js(t){return _t(t,X,Ot)}var Rr=Js;var Xs=S(g,"DataView"),It=Xs;var Qs=S(g,"Promise"),Et=Qs;var tf=S(g,"Set"),Ct=tf;var Br="[object Map]",ef="[object Object]",Fr="[object Promise]",Lr="[object Set]",Nr="[object WeakMap]",Dr="[object DataView]",rf=C(It),of=C(N),af=C(Et),sf=C(Ct),ff=C(yt),z=_;(It&&z(new It(new ArrayBuffer(1)))!=Dr||N&&z(new N)!=Br||Et&&z(Et.resolve())!=Fr||Ct&&z(new Ct)!=Lr||yt&&z(new yt)!=Nr)&&(z=function(t){var e=_(t),r=e==ef?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case rf:return Dr;case of:return Br;case af:return Fr;case sf:return Lr;case ff:return Nr}return e});var st=z;var nf=Object.prototype,pf=nf.hasOwnProperty;function lf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&pf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var kr=lf;var mf=g.Uint8Array,kt=mf;function uf(t){var e=new t.constructor(t.byteLength);return new kt(e).set(new kt(t)),e}var ft=uf;function df(t,e){var r=e?ft(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ur=df;var cf=/\w*$/;function hf(t){var e=new t.constructor(t.source,cf.exec(t));return e.lastIndex=t.lastIndex,e}var zr=hf;var Kr=T?T.prototype:void 0,Gr=Kr?Kr.valueOf:void 0;function xf(t){return Gr?Object(Gr.call(t)):{}}var Wr=xf;function gf(t,e){var r=e?ft(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Hr=gf;var yf="[object Boolean]",bf="[object Date]",vf="[object Map]",wf="[object Number]",Tf="[object RegExp]",Af="[object Set]",Sf="[object String]",Pf="[object Symbol]",jf="[object ArrayBuffer]",Of="[object DataView]",_f="[object Float32Array]",If="[object Float64Array]",Ef="[object Int8Array]",Cf="[object Int16Array]",Mf="[object Int32Array]",Rf="[object Uint8Array]",Bf="[object Uint8ClampedArray]",Ff="[object Uint16Array]",Lf="[object Uint32Array]";function Nf(t,e,r){var o=t.constructor;switch(e){case jf:return ft(t);case yf:case bf:return new o(+t);case Of:return Ur(t,r);case _f:case If:case Ef:case Cf:case Mf:case Rf:case Bf:case Ff:case Lf:return Hr(t,r);case vf:return new o;case wf:case Sf:return new o(t);case Tf:return zr(t);case Af:return new o;case Pf:return Wr(t)}}var $r=Nf;function Df(t){return typeof t.constructor=="function"&&!Y(t)?ge(Pt(t)):{}}var qr=Df;var kf="[object Map]";function Uf(t){return O(t)&&st(t)==kf}var Yr=Uf;var Vr=M&&M.isMap,zf=Vr?Z(Vr):Yr,Zr=zf;var Kf="[object Set]";function Gf(t){return O(t)&&st(t)==Kf}var Jr=Gf;var Xr=M&&M.isSet,Wf=Xr?Z(Xr):Jr,Qr=Wf;var Hf=1,$f=2,qf=4,to="[object Arguments]",Yf="[object Array]",Vf="[object Boolean]",Zf="[object Date]",Jf="[object Error]",eo="[object Function]",Xf="[object GeneratorFunction]",Qf="[object Map]",tn="[object Number]",ro="[object Object]",en="[object RegExp]",rn="[object Set]",on="[object String]",an="[object Symbol]",sn="[object WeakMap]",fn="[object ArrayBuffer]",nn="[object DataView]",pn="[object Float32Array]",ln="[object Float64Array]",mn="[object Int8Array]",un="[object Int16Array]",dn="[object Int32Array]",cn="[object Uint8Array]",hn="[object Uint8ClampedArray]",xn="[object Uint16Array]",gn="[object Uint32Array]",d={};d[to]=d[Yf]=d[fn]=d[nn]=d[Vf]=d[Zf]=d[pn]=d[ln]=d[mn]=d[un]=d[dn]=d[Qf]=d[tn]=d[ro]=d[en]=d[rn]=d[on]=d[an]=d[cn]=d[hn]=d[xn]=d[gn]=!0;d[Jf]=d[eo]=d[sn]=!1;function Mt(t,e,r,o,a,s){var f,i=e&Hf,n=e&$f,m=e&qf;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!j(t))return t;var h=w(t);if(h){if(f=kr(t),!i)return be(t,f)}else{var v=st(t),P=v==eo||v==Xf;if(Tt(t))return Or(t,i);if(v==ro||v==to||P&&!a){if(f=n||P?{}:qr(t),!i)return n?Cr(t,Tr(f,t)):Er(t,wr(f,t))}else{if(!d[v])return a?t:{};f=$r(t,v,i)}}s||(s=new vr);var A=s.get(t);if(A)return A;s.set(t,f),Qr(t)?t.forEach(function(b){f.add(Mt(b,e,r,b,t,s))}):Zr(t)&&t.forEach(function(b,p){f.set(p,Mt(b,e,r,p,t,s))});var y=m?n?Rr:Mr:n?X:J,I=h?void 0:y(t);return Se(I||t,function(b,p){I&&(p=b,b=t[p]),$(f,p,Mt(b,e,r,p,t,s))}),f}var oo=Mt;var yn=1,bn=4;function vn(t){return oo(t,yn|bn)}var Ut=vn;function wn(t,e){return t!=null&&e in Object(t)}var ao=wn;function Tn(t,e,r){e=k(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=rt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&q(a)&&H(f,a)&&(w(t)||V(t)))}var io=Tn;function An(t,e){return t!=null&&io(t,e,ao)}var so=An;function Sn(t,e,r,o){if(!j(t))return t;e=k(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=rt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=j(h)?h:H(e[a+1])?[]:{})}$(i,n,m),i=i[n]}return t}var fo=Sn;function Pn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=nr(t,f);r(i,f)&&fo(s,k(f,t),i)}return s}var no=Pn;function jn(t,e){return no(t,e,function(r,o){return so(t,o)})}var po=jn;var On=cr(function(t,e){return t==null?{}:po(t,e)}),Rt=On;function lo(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 zt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var _n="array",In="bit",mo="bits",En="byte",uo="bytes",nt="",Cn="exponent",Mn="function",co="iec",Rn="Invalid number",Bn="Invalid rounding method",Kt="jedec",Fn="object",ho=".",Ln="round",Nn="s",Dn="si",kn="kbit",Un="kB",zn=" ",Kn="string",Gn="0",Gt={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 xo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=nt,localeOptions:f={},separator:i=nt,spacer:n=zn,symbols:m={},standard:h=nt,output:v=Kn,fullform:P=!1,fullforms:A=[],exponent:y=-1,roundingMethod:I=Ln,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Bt=nt;h===Dn?(o=10,h=Kt):h===co||h===Kt?o=2:o===2?h=co:(o=10,h=Kt);let ct=o===10?1e3:1024,go=P===!0,$t=u<0,qt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Rn);if(typeof qt!==Mn)throw new TypeError(Bn);if($t&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(ct)),p<0&&(p=0)),p>8&&(b>0&&(b+=8-p),p=8),v===Cn)return p;if(u===0)l[0]=0,Bt=l[1]=Gt.symbol[h][e?mo:uo][p];else{E=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(E=E*8,E>=ct&&p<8&&(E=E/ct,p++));let pt=Math.pow(10,p>0?a:0);l[0]=qt(E*pt)/pt,l[0]===ct&&p<8&&y===-1&&(l[0]=1,p++),Bt=l[1]=o===10&&p===1?e?kn:Un:Gt.symbol[h][e?mo:uo][p]}if($t&&(l[0]=-l[0]),b>0&&(l[0]=l[0].toPrecision(b)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(ho,i)),r&&Number.isInteger(l[0])===!1&&a>0){let pt=i||ho,Yt=l[0].toString().split(pt),Vt=Yt[1]||nt,Zt=Vt.length,yo=a-Zt;l[0]=`${Yt[0]}${pt}${Vt.padEnd(Zt+yo,Gn)}`}return go&&(l[1]=A[p]?A[p]:Gt.fullform[h][p]+(e?In:En)+(l[0]===1?nt:Nn)),v===_n?l:v===Fn?{value:l[0],symbol:l[1],exponent:p,unit:Bt}:l.join(n)}var U,Wt=class Wt{constructor(e){Xt(this,U,void 0);x(this,"id");x(this,"name");x(this,"icon");x(this,"path");x(this,"parsedName");x(this,"created");x(this,"createdFormatted");x(this,"modified");x(this,"modifiedFormatted");x(this,"accessed");x(this,"accessedFormatted");x(this,"size");x(this,"sizeFormatted");x(this,"mime");x(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),delete this.tera,Qt(this,U,e.tera),this.sizeFormatted=xo(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(){return lt(this,U).getProjectFile(this.path)}setContents(e){return lt(this,U).setProjectFile(this.path,e)}getRefs(){return lt(this,U).getProjectLibrary(this.path)}setRefs(e){return lt(this,U).setProjectLibrary(this.path,e)}serialize(){return Rt(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new Wt(Rt(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};U=new WeakMap;var K=Wt;var Ht=class{constructor(e){x(this,"settings",{devMode:!0,mode:"detect",modeTimeout:300,modeFallback:"child",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});x(this,"events",lo());x(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});x(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"]);x(this,"plugins",[]);x(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=zt();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||zt(),...Ut(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","Message compose client->server:",o),this.debug("ERROR","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;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",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);else{if((r==null?void 0:r.action)=="rpc")return 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()})});if((r==null?void 0:r.action)=="event")return 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(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=te(r,e,ee);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}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.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).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(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}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(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("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),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA window parent"),e();break;case"popup":this.debug("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"),(()=>{let r=0,o,a=()=>{this.debug("Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}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;","&.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
|
-
`),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){let r="log";typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase())
|
|
1
|
+
var bo=Object.defineProperty;var vo=(t,e,r)=>e in t?bo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var x=(t,e,r)=>(vo(t,typeof e!="symbol"?e+"":e,r),r),Jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var lt=(t,e,r)=>(Jt(t,e,"read from private field"),r?r.call(t):e.get(t)),Xt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Qt=(t,e,r,o)=>(Jt(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r);function te(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:v}){var S=Object.keys(i),O=S.length,y=Object.keys(n),_=y.length,b,p=i.length-n.length;if(To(i,n)){for(var u=0;u<O;u++){var l=Array.isArray(i)?Number(S[u]):S[u];l in n||(b=h.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<_;u++){var l=Array.isArray(n)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=h.concat(u),v.remove.push({op:"remove",path:r(b)});for(var E=i.slice(p),u=0;u<_;u++)s({key:u,obj1:E,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:v})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:v,diffs:S}){var O=n[i],y=m[i];if(!(i in n)&&i in m){var _=y;S.add.push({op:"add",path:r(h),value:_})}else O!==y&&(Object(O)!==O||Object(y)!==y||wo(O,y)||!Object.keys(O).length&&!Object.keys(y).length&&String(O)!=String(y)?f(h,S,y):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:v,diffs:S}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function ee(t){return[""].concat(t).join("/")}function wo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function To(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var Oo=typeof global=="object"&&global&&global.Object===Object&&global,ht=Oo;var Ao=typeof self=="object"&&self&&self.Object===Object&&self,So=ht||Ao||Function("return this")(),g=So;var Po=g.Symbol,T=Po;var re=Object.prototype,jo=re.hasOwnProperty,Io=re.toString,mt=T?T.toStringTag:void 0;function _o(t){var e=jo.call(t,mt),r=t[mt];try{t[mt]=void 0;var o=!0}catch{}var a=Io.call(t);return o&&(e?t[mt]=r:delete t[mt]),a}var oe=_o;var Eo=Object.prototype,Co=Eo.toString;function Mo(t){return Co.call(t)}var ae=Mo;var Fo="[object Null]",Ro="[object Undefined]",ie=T?T.toStringTag:void 0;function No(t){return t==null?t===void 0?Ro:Fo:ie&&ie in Object(t)?oe(t):ae(t)}var I=No;function Bo(t){return t!=null&&typeof t=="object"}var j=Bo;var Lo="[object Symbol]";function Do(t){return typeof t=="symbol"||j(t)&&I(t)==Lo}var G=Do;function ko(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 se=ko;var Uo=Array.isArray,w=Uo;var zo=1/0,fe=T?T.prototype:void 0,ne=fe?fe.toString:void 0;function pe(t){if(typeof t=="string")return t;if(w(t))return se(t,pe)+"";if(G(t))return ne?ne.call(t):"";var e=t+"";return e=="0"&&1/t==-zo?"-0":e}var le=pe;function Ko(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Ko;function Go(t){return t}var me=Go;var Wo="[object AsyncFunction]",Ho="[object Function]",$o="[object GeneratorFunction]",qo="[object Proxy]";function Yo(t){if(!P(t))return!1;var e=I(t);return e==Ho||e==$o||e==Wo||e==qo}var xt=Yo;var Vo=g["__core-js_shared__"],gt=Vo;var ue=function(){var t=/[^.]+$/.exec(gt&>.keys&>.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Zo(t){return!!ue&&ue in t}var de=Zo;var Jo=Function.prototype,Xo=Jo.toString;function Qo(t){if(t!=null){try{return Xo.call(t)}catch{}try{return t+""}catch{}}return""}var C=Qo;var ta=/[\\^$.*+?()[\]{}|]/g,ea=/^\[object .+?Constructor\]$/,ra=Function.prototype,oa=Object.prototype,aa=ra.toString,ia=oa.hasOwnProperty,sa=RegExp("^"+aa.call(ia).replace(ta,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fa(t){if(!P(t)||de(t))return!1;var e=xt(t)?sa:ea;return e.test(C(t))}var ce=fa;function na(t,e){return t==null?void 0:t[e]}var he=na;function pa(t,e){var r=he(t,e);return ce(r)?r:void 0}var A=pa;var la=A(g,"WeakMap"),yt=la;var xe=Object.create,ma=function(){function t(){}return function(e){if(!P(e))return{};if(xe)return xe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ge=ma;function ua(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 ye=ua;function da(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var be=da;var ca=800,ha=16,xa=Date.now;function ga(t){var e=0,r=0;return function(){var o=xa(),a=ha-(o-r);if(r=o,a>0){if(++e>=ca)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ve=ga;function ya(t){return function(){return t}}var we=ya;var ba=function(){try{var t=A(Object,"defineProperty");return t({},"",{}),t}catch{}}(),W=ba;var va=W?function(t,e){return W(t,"toString",{configurable:!0,enumerable:!1,value:we(e),writable:!0})}:me,Te=va;var wa=ve(Te),Oe=wa;function Ta(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Ae=Ta;var Oa=9007199254740991,Aa=/^(?:0|[1-9]\d*)$/;function Sa(t,e){var r=typeof t;return e=e==null?Oa:e,!!e&&(r=="number"||r!="symbol"&&Aa.test(t))&&t>-1&&t%1==0&&t<e}var H=Sa;function Pa(t,e,r){e=="__proto__"&&W?W(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var bt=Pa;function ja(t,e){return t===e||t!==t&&e!==e}var vt=ja;var Ia=Object.prototype,_a=Ia.hasOwnProperty;function Ea(t,e,r){var o=t[e];(!(_a.call(t,e)&&vt(o,r))||r===void 0&&!(e in t))&&bt(t,e,r)}var $=Ea;function Ca(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?bt(r,i,n):$(r,i,n)}return r}var R=Ca;var Se=Math.max;function Ma(t,e,r){return e=Se(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=Se(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),ye(t,this,i)}}var Pe=Ma;var Fa=9007199254740991;function Ra(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Fa}var q=Ra;function Na(t){return t!=null&&q(t.length)&&!xt(t)}var wt=Na;var Ba=Object.prototype;function La(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ba;return t===r}var Y=La;function Da(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var je=Da;var ka="[object Arguments]";function Ua(t){return j(t)&&I(t)==ka}var Nt=Ua;var Ie=Object.prototype,za=Ie.hasOwnProperty,Ka=Ie.propertyIsEnumerable,Ga=Nt(function(){return arguments}())?Nt:function(t){return j(t)&&za.call(t,"callee")&&!Ka.call(t,"callee")},V=Ga;function Wa(){return!1}var _e=Wa;var Me=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ee=Me&&typeof module=="object"&&module&&!module.nodeType&&module,Ha=Ee&&Ee.exports===Me,Ce=Ha?g.Buffer:void 0,$a=Ce?Ce.isBuffer:void 0,qa=$a||_e,Tt=qa;var Ya="[object Arguments]",Va="[object Array]",Za="[object Boolean]",Ja="[object Date]",Xa="[object Error]",Qa="[object Function]",ti="[object Map]",ei="[object Number]",ri="[object Object]",oi="[object RegExp]",ai="[object Set]",ii="[object String]",si="[object WeakMap]",fi="[object ArrayBuffer]",ni="[object DataView]",pi="[object Float32Array]",li="[object Float64Array]",mi="[object Int8Array]",ui="[object Int16Array]",di="[object Int32Array]",ci="[object Uint8Array]",hi="[object Uint8ClampedArray]",xi="[object Uint16Array]",gi="[object Uint32Array]",c={};c[pi]=c[li]=c[mi]=c[ui]=c[di]=c[ci]=c[hi]=c[xi]=c[gi]=!0;c[Ya]=c[Va]=c[fi]=c[Za]=c[ni]=c[Ja]=c[Xa]=c[Qa]=c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=!1;function yi(t){return j(t)&&q(t.length)&&!!c[I(t)]}var Fe=yi;function bi(t){return function(e){return t(e)}}var Z=bi;var Re=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ut=Re&&typeof module=="object"&&module&&!module.nodeType&&module,vi=ut&&ut.exports===Re,Bt=vi&&ht.process,wi=function(){try{var t=ut&&ut.require&&ut.require("util").types;return t||Bt&&Bt.binding&&Bt.binding("util")}catch{}}(),M=wi;var Ne=M&&M.isTypedArray,Ti=Ne?Z(Ne):Fe,Be=Ti;var Oi=Object.prototype,Ai=Oi.hasOwnProperty;function Si(t,e){var r=w(t),o=!r&&V(t),a=!r&&!o&&Tt(t),s=!r&&!o&&!a&&Be(t),f=r||o||a||s,i=f?je(t.length,String):[],n=i.length;for(var m in t)(e||Ai.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||H(m,n)))&&i.push(m);return i}var Ot=Si;function Pi(t,e){return function(r){return t(e(r))}}var At=Pi;var ji=At(Object.keys,Object),Le=ji;var Ii=Object.prototype,_i=Ii.hasOwnProperty;function Ei(t){if(!Y(t))return Le(t);var e=[];for(var r in Object(t))_i.call(t,r)&&r!="constructor"&&e.push(r);return e}var De=Ei;function Ci(t){return wt(t)?Ot(t):De(t)}var J=Ci;function Mi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var ke=Mi;var Fi=Object.prototype,Ri=Fi.hasOwnProperty;function Ni(t){if(!P(t))return ke(t);var e=Y(t),r=[];for(var o in t)o=="constructor"&&(e||!Ri.call(t,o))||r.push(o);return r}var Ue=Ni;function Bi(t){return wt(t)?Ot(t,!0):Ue(t)}var X=Bi;var Li=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Di=/^\w*$/;function ki(t,e){if(w(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||G(t)?!0:Di.test(t)||!Li.test(t)||e!=null&&t in Object(e)}var ze=ki;var Ui=A(Object,"create"),F=Ui;function zi(){this.__data__=F?F(null):{},this.size=0}var Ke=zi;function Ki(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ge=Ki;var Gi="__lodash_hash_undefined__",Wi=Object.prototype,Hi=Wi.hasOwnProperty;function $i(t){var e=this.__data__;if(F){var r=e[t];return r===Gi?void 0:r}return Hi.call(e,t)?e[t]:void 0}var We=$i;var qi=Object.prototype,Yi=qi.hasOwnProperty;function Vi(t){var e=this.__data__;return F?e[t]!==void 0:Yi.call(e,t)}var He=Vi;var Zi="__lodash_hash_undefined__";function Ji(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=F&&e===void 0?Zi:e,this}var $e=Ji;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=Ke;Q.prototype.delete=Ge;Q.prototype.get=We;Q.prototype.has=He;Q.prototype.set=$e;var Lt=Q;function Xi(){this.__data__=[],this.size=0}var qe=Xi;function Qi(t,e){for(var r=t.length;r--;)if(vt(t[r][0],e))return r;return-1}var N=Qi;var ts=Array.prototype,es=ts.splice;function rs(t){var e=this.__data__,r=N(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():es.call(e,r,1),--this.size,!0}var Ye=rs;function os(t){var e=this.__data__,r=N(e,t);return r<0?void 0:e[r][1]}var Ve=os;function as(t){return N(this.__data__,t)>-1}var Ze=as;function is(t,e){var r=this.__data__,o=N(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Je=is;function tt(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])}}tt.prototype.clear=qe;tt.prototype.delete=Ye;tt.prototype.get=Ve;tt.prototype.has=Ze;tt.prototype.set=Je;var B=tt;var ss=A(g,"Map"),L=ss;function fs(){this.size=0,this.__data__={hash:new Lt,map:new(L||B),string:new Lt}}var Xe=fs;function ns(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Qe=ns;function ps(t,e){var r=t.__data__;return Qe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var D=ps;function ls(t){var e=D(this,t).delete(t);return this.size-=e?1:0,e}var tr=ls;function ms(t){return D(this,t).get(t)}var er=ms;function us(t){return D(this,t).has(t)}var rr=us;function ds(t,e){var r=D(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var or=ds;function et(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])}}et.prototype.clear=Xe;et.prototype.delete=tr;et.prototype.get=er;et.prototype.has=rr;et.prototype.set=or;var dt=et;var cs="Expected a function";function Dt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(cs);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 f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Dt.Cache||dt),r}Dt.Cache=dt;var ar=Dt;var hs=500;function xs(t){var e=ar(t,function(o){return r.size===hs&&r.clear(),o}),r=e.cache;return e}var ir=xs;var gs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ys=/\\(\\)?/g,bs=ir(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(gs,function(r,o,a,s){e.push(a?s.replace(ys,"$1"):o||r)}),e}),sr=bs;function vs(t){return t==null?"":le(t)}var fr=vs;function ws(t,e){return w(t)?t:ze(t,e)?[t]:sr(fr(t))}var k=ws;var Ts=1/0;function Os(t){if(typeof t=="string"||G(t))return t;var e=t+"";return e=="0"&&1/t==-Ts?"-0":e}var rt=Os;function As(t,e){e=k(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[rt(e[r++])];return r&&r==o?t:void 0}var nr=As;function Ss(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ot=Ss;var pr=T?T.isConcatSpreadable:void 0;function Ps(t){return w(t)||V(t)||!!(pr&&t&&t[pr])}var lr=Ps;function mr(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=lr),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?mr(i,e-1,r,o,a):ot(a,i):o||(a[a.length]=i)}return a}var ur=mr;function js(t){var e=t==null?0:t.length;return e?ur(t,1):[]}var dr=js;function Is(t){return Oe(Pe(t,void 0,dr),t+"")}var cr=Is;var _s=At(Object.getPrototypeOf,Object),St=_s;function Es(){this.__data__=new B,this.size=0}var hr=Es;function Cs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var xr=Cs;function Ms(t){return this.__data__.get(t)}var gr=Ms;function Fs(t){return this.__data__.has(t)}var yr=Fs;var Rs=200;function Ns(t,e){var r=this.__data__;if(r instanceof B){var o=r.__data__;if(!L||o.length<Rs-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new dt(o)}return r.set(t,e),this.size=r.size,this}var br=Ns;function at(t){var e=this.__data__=new B(t);this.size=e.size}at.prototype.clear=hr;at.prototype.delete=xr;at.prototype.get=gr;at.prototype.has=yr;at.prototype.set=br;var vr=at;function Bs(t,e){return t&&R(e,J(e),t)}var wr=Bs;function Ls(t,e){return t&&R(e,X(e),t)}var Tr=Ls;var Pr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Or=Pr&&typeof module=="object"&&module&&!module.nodeType&&module,Ds=Or&&Or.exports===Pr,Ar=Ds?g.Buffer:void 0,Sr=Ar?Ar.allocUnsafe:void 0;function ks(t,e){if(e)return t.slice();var r=t.length,o=Sr?Sr(r):new t.constructor(r);return t.copy(o),o}var jr=ks;function Us(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var Ir=Us;function zs(){return[]}var Pt=zs;var Ks=Object.prototype,Gs=Ks.propertyIsEnumerable,_r=Object.getOwnPropertySymbols,Ws=_r?function(t){return t==null?[]:(t=Object(t),Ir(_r(t),function(e){return Gs.call(t,e)}))}:Pt,it=Ws;function Hs(t,e){return R(t,it(t),e)}var Er=Hs;var $s=Object.getOwnPropertySymbols,qs=$s?function(t){for(var e=[];t;)ot(e,it(t)),t=St(t);return e}:Pt,jt=qs;function Ys(t,e){return R(t,jt(t),e)}var Cr=Ys;function Vs(t,e,r){var o=e(t);return w(t)?o:ot(o,r(t))}var It=Vs;function Zs(t){return It(t,J,it)}var Mr=Zs;function Js(t){return It(t,X,jt)}var Fr=Js;var Xs=A(g,"DataView"),_t=Xs;var Qs=A(g,"Promise"),Et=Qs;var tf=A(g,"Set"),Ct=tf;var Rr="[object Map]",ef="[object Object]",Nr="[object Promise]",Br="[object Set]",Lr="[object WeakMap]",Dr="[object DataView]",rf=C(_t),of=C(L),af=C(Et),sf=C(Ct),ff=C(yt),z=I;(_t&&z(new _t(new ArrayBuffer(1)))!=Dr||L&&z(new L)!=Rr||Et&&z(Et.resolve())!=Nr||Ct&&z(new Ct)!=Br||yt&&z(new yt)!=Lr)&&(z=function(t){var e=I(t),r=e==ef?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case rf:return Dr;case of:return Rr;case af:return Nr;case sf:return Br;case ff:return Lr}return e});var st=z;var nf=Object.prototype,pf=nf.hasOwnProperty;function lf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&pf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var kr=lf;var mf=g.Uint8Array,kt=mf;function uf(t){var e=new t.constructor(t.byteLength);return new kt(e).set(new kt(t)),e}var ft=uf;function df(t,e){var r=e?ft(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ur=df;var cf=/\w*$/;function hf(t){var e=new t.constructor(t.source,cf.exec(t));return e.lastIndex=t.lastIndex,e}var zr=hf;var Kr=T?T.prototype:void 0,Gr=Kr?Kr.valueOf:void 0;function xf(t){return Gr?Object(Gr.call(t)):{}}var Wr=xf;function gf(t,e){var r=e?ft(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Hr=gf;var yf="[object Boolean]",bf="[object Date]",vf="[object Map]",wf="[object Number]",Tf="[object RegExp]",Of="[object Set]",Af="[object String]",Sf="[object Symbol]",Pf="[object ArrayBuffer]",jf="[object DataView]",If="[object Float32Array]",_f="[object Float64Array]",Ef="[object Int8Array]",Cf="[object Int16Array]",Mf="[object Int32Array]",Ff="[object Uint8Array]",Rf="[object Uint8ClampedArray]",Nf="[object Uint16Array]",Bf="[object Uint32Array]";function Lf(t,e,r){var o=t.constructor;switch(e){case Pf:return ft(t);case yf:case bf:return new o(+t);case jf:return Ur(t,r);case If:case _f:case Ef:case Cf:case Mf:case Ff:case Rf:case Nf:case Bf:return Hr(t,r);case vf:return new o;case wf:case Af:return new o(t);case Tf:return zr(t);case Of:return new o;case Sf:return Wr(t)}}var $r=Lf;function Df(t){return typeof t.constructor=="function"&&!Y(t)?ge(St(t)):{}}var qr=Df;var kf="[object Map]";function Uf(t){return j(t)&&st(t)==kf}var Yr=Uf;var Vr=M&&M.isMap,zf=Vr?Z(Vr):Yr,Zr=zf;var Kf="[object Set]";function Gf(t){return j(t)&&st(t)==Kf}var Jr=Gf;var Xr=M&&M.isSet,Wf=Xr?Z(Xr):Jr,Qr=Wf;var Hf=1,$f=2,qf=4,to="[object Arguments]",Yf="[object Array]",Vf="[object Boolean]",Zf="[object Date]",Jf="[object Error]",eo="[object Function]",Xf="[object GeneratorFunction]",Qf="[object Map]",tn="[object Number]",ro="[object Object]",en="[object RegExp]",rn="[object Set]",on="[object String]",an="[object Symbol]",sn="[object WeakMap]",fn="[object ArrayBuffer]",nn="[object DataView]",pn="[object Float32Array]",ln="[object Float64Array]",mn="[object Int8Array]",un="[object Int16Array]",dn="[object Int32Array]",cn="[object Uint8Array]",hn="[object Uint8ClampedArray]",xn="[object Uint16Array]",gn="[object Uint32Array]",d={};d[to]=d[Yf]=d[fn]=d[nn]=d[Vf]=d[Zf]=d[pn]=d[ln]=d[mn]=d[un]=d[dn]=d[Qf]=d[tn]=d[ro]=d[en]=d[rn]=d[on]=d[an]=d[cn]=d[hn]=d[xn]=d[gn]=!0;d[Jf]=d[eo]=d[sn]=!1;function Mt(t,e,r,o,a,s){var f,i=e&Hf,n=e&$f,m=e&qf;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!P(t))return t;var h=w(t);if(h){if(f=kr(t),!i)return be(t,f)}else{var v=st(t),S=v==eo||v==Xf;if(Tt(t))return jr(t,i);if(v==ro||v==to||S&&!a){if(f=n||S?{}:qr(t),!i)return n?Cr(t,Tr(f,t)):Er(t,wr(f,t))}else{if(!d[v])return a?t:{};f=$r(t,v,i)}}s||(s=new vr);var O=s.get(t);if(O)return O;s.set(t,f),Qr(t)?t.forEach(function(b){f.add(Mt(b,e,r,b,t,s))}):Zr(t)&&t.forEach(function(b,p){f.set(p,Mt(b,e,r,p,t,s))});var y=m?n?Fr:Mr:n?X:J,_=h?void 0:y(t);return Ae(_||t,function(b,p){_&&(p=b,b=t[p]),$(f,p,Mt(b,e,r,p,t,s))}),f}var oo=Mt;var yn=1,bn=4;function vn(t){return oo(t,yn|bn)}var Ut=vn;function wn(t,e){return t!=null&&e in Object(t)}var ao=wn;function Tn(t,e,r){e=k(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=rt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&q(a)&&H(f,a)&&(w(t)||V(t)))}var io=Tn;function On(t,e){return t!=null&&io(t,e,ao)}var so=On;function An(t,e,r,o){if(!P(t))return t;e=k(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=rt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=P(h)?h:H(e[a+1])?[]:{})}$(i,n,m),i=i[n]}return t}var fo=An;function Sn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=nr(t,f);r(i,f)&&fo(s,k(f,t),i)}return s}var no=Sn;function Pn(t,e){return no(t,e,function(r,o){return so(t,o)})}var po=Pn;var jn=cr(function(t,e){return t==null?{}:po(t,e)}),Ft=jn;function lo(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 zt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var In="array",_n="bit",mo="bits",En="byte",uo="bytes",nt="",Cn="exponent",Mn="function",co="iec",Fn="Invalid number",Rn="Invalid rounding method",Kt="jedec",Nn="object",ho=".",Bn="round",Ln="s",Dn="si",kn="kbit",Un="kB",zn=" ",Kn="string",Gn="0",Gt={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 xo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=nt,localeOptions:f={},separator:i=nt,spacer:n=zn,symbols:m={},standard:h=nt,output:v=Kn,fullform:S=!1,fullforms:O=[],exponent:y=-1,roundingMethod:_=Bn,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Rt=nt;h===Dn?(o=10,h=Kt):h===co||h===Kt?o=2:o===2?h=co:(o=10,h=Kt);let ct=o===10?1e3:1024,go=S===!0,$t=u<0,qt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Fn);if(typeof qt!==Mn)throw new TypeError(Rn);if($t&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(ct)),p<0&&(p=0)),p>8&&(b>0&&(b+=8-p),p=8),v===Cn)return p;if(u===0)l[0]=0,Rt=l[1]=Gt.symbol[h][e?mo:uo][p];else{E=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(E=E*8,E>=ct&&p<8&&(E=E/ct,p++));let pt=Math.pow(10,p>0?a:0);l[0]=qt(E*pt)/pt,l[0]===ct&&p<8&&y===-1&&(l[0]=1,p++),Rt=l[1]=o===10&&p===1?e?kn:Un:Gt.symbol[h][e?mo:uo][p]}if($t&&(l[0]=-l[0]),b>0&&(l[0]=l[0].toPrecision(b)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(ho,i)),r&&Number.isInteger(l[0])===!1&&a>0){let pt=i||ho,Yt=l[0].toString().split(pt),Vt=Yt[1]||nt,Zt=Vt.length,yo=a-Zt;l[0]=`${Yt[0]}${pt}${Vt.padEnd(Zt+yo,Gn)}`}return go&&(l[1]=O[p]?O[p]:Gt.fullform[h][p]+(e?_n:En)+(l[0]===1?nt:Ln)),v===In?l:v===Nn?{value:l[0],symbol:l[1],exponent:p,unit:Rt}:l.join(n)}var U,Wt=class Wt{constructor(e){Xt(this,U,void 0);x(this,"id");x(this,"name");x(this,"icon");x(this,"path");x(this,"parsedName");x(this,"created");x(this,"createdFormatted");x(this,"modified");x(this,"modifiedFormatted");x(this,"accessed");x(this,"accessedFormatted");x(this,"size");x(this,"sizeFormatted");x(this,"mime");x(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),delete this.tera,Qt(this,U,e.tera),this.sizeFormatted=xo(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(){return lt(this,U).getProjectFile(this.path)}setContents(e){return lt(this,U).setProjectFile(this.path,e)}getRefs(){return lt(this,U).getProjectLibrary(this.path)}setRefs(e){return lt(this,U).setProjectLibrary(this.path,e)}serialize(){return Ft(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new Wt(Ft(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};U=new WeakMap;var K=Wt;var Ht=class{constructor(e){x(this,"settings",{devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",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});x(this,"events",lo());x(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});x(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"]);x(this,"plugins",[]);x(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=zt();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||zt(),...Ut(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;let r=e.data;if(!(!r.TERA||!r.id))if(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);else{if((r==null?void 0:r.action)=="rpc")return 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()})});if((r==null?void 0:r.action)=="event")return 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?`):this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=te(r,e,ee);return this.debug("INFO",3,"Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}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.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).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(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}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(){return new Promise(e=>{switch(this.settings.mode){case"child":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),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":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"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}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;","&.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
|
+
`),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){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,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)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new K({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new K({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new K({tera:this,...r}))}};export{Ht as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
lodash-es/lodash.js:
|
package/dist/terafy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function qt(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:b}){var S=Object.keys(i),T=S.length,g=Object.keys(n),_=g.length,y,p=i.length-n.length;if(uo(i,n)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(S[u]):S[u];l in n||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<_;u++){var l=Array.isArray(n)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:b})}}else{for(var u=0;u<p;u++)y=h.concat(u),b.remove.push({op:"remove",path:r(y)});for(var I=i.slice(p),u=0;u<_;u++)s({key:u,obj1:I,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:b})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:b,diffs:S}){var T=n[i],g=m[i];if(!(i in n)&&i in m){var _=g;S.add.push({op:"add",path:r(h),value:_})}else T!==g&&(Object(T)!==T||Object(g)!==g||mo(T,g)||!Object.keys(T).length&&!Object.keys(g).length&&String(T)!=String(g)?f(h,S,g):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:S}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function Yt(t){return[""].concat(t).join("/")}function mo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function uo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var co=typeof global=="object"&&global&&global.Object===Object&&global,ut=co;var ho=typeof self=="object"&&self&&self.Object===Object&&self,xo=ut||ho||Function("return this")(),x=xo;var go=x.Symbol,w=go;var Vt=Object.prototype,yo=Vt.hasOwnProperty,bo=Vt.toString,nt=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,nt),r=t[nt];try{t[nt]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[nt]=r:delete t[nt]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Ao(t){return To.call(t)}var Jt=Ao;var So="[object Null]",Po="[object Undefined]",Xt=w?w.toStringTag:void 0;function jo(t){return t==null?t===void 0?Po:So:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var O=jo;function Oo(t){return t!=null&&typeof t=="object"}var j=Oo;var _o="[object Symbol]";function Io(t){return typeof t=="symbol"||j(t)&&O(t)==_o}var z=Io;function Eo(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=Eo;var Co=Array.isArray,v=Co;var Mo=1/0,te=w?w.prototype:void 0,ee=te?te.toString:void 0;function re(t){if(typeof t=="string")return t;if(v(t))return Qt(t,re)+"";if(z(t))return ee?ee.call(t):"";var e=t+"";return e=="0"&&1/t==-Mo?"-0":e}var oe=re;function Ro(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Ro;function Bo(t){return t}var ae=Bo;var Fo="[object AsyncFunction]",Lo="[object Function]",No="[object GeneratorFunction]",Do="[object Proxy]";function ko(t){if(!P(t))return!1;var e=O(t);return e==Lo||e==No||e==Fo||e==Do}var dt=ko;var Uo=x["__core-js_shared__"],ct=Uo;var ie=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function zo(t){return!!ie&&ie in t}var se=zo;var Ko=Function.prototype,Go=Ko.toString;function Wo(t){if(t!=null){try{return Go.call(t)}catch{}try{return t+""}catch{}}return""}var E=Wo;var Ho=/[\\^$.*+?()[\]{}|]/g,$o=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Vo=qo.toString,Zo=Yo.hasOwnProperty,Jo=RegExp("^"+Vo.call(Zo).replace(Ho,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xo(t){if(!P(t)||se(t))return!1;var e=dt(t)?Jo:$o;return e.test(E(t))}var fe=Xo;function Qo(t,e){return t?.[e]}var ne=Qo;function ta(t,e){var r=ne(t,e);return fe(r)?r:void 0}var A=ta;var ea=A(x,"WeakMap"),ht=ea;var pe=Object.create,ra=function(){function t(){}return function(e){if(!P(e))return{};if(pe)return pe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),le=ra;function oa(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=oa;function aa(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=aa;var ia=800,sa=16,fa=Date.now;function na(t){var e=0,r=0;return function(){var o=fa(),a=sa-(o-r);if(r=o,a>0){if(++e>=ia)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var de=na;function pa(t){return function(){return t}}var ce=pa;var la=function(){try{var t=A(Object,"defineProperty");return t({},"",{}),t}catch{}}(),K=la;var ma=K?function(t,e){return K(t,"toString",{configurable:!0,enumerable:!1,value:ce(e),writable:!0})}:ae,he=ma;var ua=de(he),xe=ua;function da(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ge=da;var ca=9007199254740991,ha=/^(?:0|[1-9]\d*)$/;function xa(t,e){var r=typeof t;return e=e??ca,!!e&&(r=="number"||r!="symbol"&&ha.test(t))&&t>-1&&t%1==0&&t<e}var G=xa;function ga(t,e,r){e=="__proto__"&&K?K(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ga;function ya(t,e){return t===e||t!==t&&e!==e}var gt=ya;var ba=Object.prototype,va=ba.hasOwnProperty;function wa(t,e,r){var o=t[e];(!(va.call(t,e)&>(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var W=wa;function Ta(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?xt(r,i,n):W(r,i,n)}return r}var R=Ta;var ye=Math.max;function Aa(t,e,r){return e=ye(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ye(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),me(t,this,i)}}var be=Aa;var Sa=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Sa}var H=Pa;function ja(t){return t!=null&&H(t.length)&&!dt(t)}var yt=ja;var Oa=Object.prototype;function _a(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Oa;return t===r}var $=_a;function Ia(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=Ia;var Ea="[object Arguments]";function Ca(t){return j(t)&&O(t)==Ea}var Mt=Ca;var we=Object.prototype,Ma=we.hasOwnProperty,Ra=we.propertyIsEnumerable,Ba=Mt(function(){return arguments}())?Mt:function(t){return j(t)&&Ma.call(t,"callee")&&!Ra.call(t,"callee")},q=Ba;function Fa(){return!1}var Te=Fa;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ae=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,La=Ae&&Ae.exports===Pe,Se=La?x.Buffer:void 0,Na=Se?Se.isBuffer:void 0,Da=Na||Te,bt=Da;var ka="[object Arguments]",Ua="[object Array]",za="[object Boolean]",Ka="[object Date]",Ga="[object Error]",Wa="[object Function]",Ha="[object Map]",$a="[object Number]",qa="[object Object]",Ya="[object RegExp]",Va="[object Set]",Za="[object String]",Ja="[object WeakMap]",Xa="[object ArrayBuffer]",Qa="[object DataView]",ti="[object Float32Array]",ei="[object Float64Array]",ri="[object Int8Array]",oi="[object Int16Array]",ai="[object Int32Array]",ii="[object Uint8Array]",si="[object Uint8ClampedArray]",fi="[object Uint16Array]",ni="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[fi]=c[ni]=!0;c[ka]=c[Ua]=c[Xa]=c[za]=c[Qa]=c[Ka]=c[Ga]=c[Wa]=c[Ha]=c[$a]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=!1;function pi(t){return j(t)&&H(t.length)&&!!c[O(t)]}var je=pi;function li(t){return function(e){return t(e)}}var Y=li;var Oe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=Oe&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===Oe,Rt=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Rt&&Rt.binding&&Rt.binding("util")}catch{}}(),C=ui;var _e=C&&C.isTypedArray,di=_e?Y(_e):je,Ie=di;var ci=Object.prototype,hi=ci.hasOwnProperty;function xi(t,e){var r=v(t),o=!r&&q(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&Ie(t),f=r||o||a||s,i=f?ve(t.length,String):[],n=i.length;for(var m in t)(e||hi.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,n)))&&i.push(m);return i}var vt=xi;function gi(t,e){return function(r){return t(e(r))}}var wt=gi;var yi=wt(Object.keys,Object),Ee=yi;var bi=Object.prototype,vi=bi.hasOwnProperty;function wi(t){if(!$(t))return Ee(t);var e=[];for(var r in Object(t))vi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ce=wi;function Ti(t){return yt(t)?vt(t):Ce(t)}var V=Ti;function Ai(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Me=Ai;var Si=Object.prototype,Pi=Si.hasOwnProperty;function ji(t){if(!P(t))return Me(t);var e=$(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Re=ji;function Oi(t){return yt(t)?vt(t,!0):Re(t)}var Z=Oi;var _i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ii=/^\w*$/;function Ei(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||z(t)?!0:Ii.test(t)||!_i.test(t)||e!=null&&t in Object(e)}var Be=Ei;var Ci=A(Object,"create"),M=Ci;function Mi(){this.__data__=M?M(null):{},this.size=0}var Fe=Mi;function Ri(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Le=Ri;var Bi="__lodash_hash_undefined__",Fi=Object.prototype,Li=Fi.hasOwnProperty;function Ni(t){var e=this.__data__;if(M){var r=e[t];return r===Bi?void 0:r}return Li.call(e,t)?e[t]:void 0}var Ne=Ni;var Di=Object.prototype,ki=Di.hasOwnProperty;function Ui(t){var e=this.__data__;return M?e[t]!==void 0:ki.call(e,t)}var De=Ui;var zi="__lodash_hash_undefined__";function Ki(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?zi:e,this}var ke=Ki;function J(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])}}J.prototype.clear=Fe;J.prototype.delete=Le;J.prototype.get=Ne;J.prototype.has=De;J.prototype.set=ke;var Bt=J;function Gi(){this.__data__=[],this.size=0}var Ue=Gi;function Wi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var B=Wi;var Hi=Array.prototype,$i=Hi.splice;function qi(t){var e=this.__data__,r=B(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():$i.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=B(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return B(this.__data__,t)>-1}var Ge=Vi;function Zi(t,e){var r=this.__data__,o=B(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=Zi;function X(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])}}X.prototype.clear=Ue;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var F=X;var Ji=A(x,"Map"),L=Ji;function Xi(){this.size=0,this.__data__={hash:new Bt,map:new(L||F),string:new Bt}}var He=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Qi;function ts(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var N=ts;function es(t){var e=N(this,t).delete(t);return this.size-=e?1:0,e}var qe=es;function rs(t){return N(this,t).get(t)}var Ye=rs;function os(t){return N(this,t).has(t)}var Ve=os;function as(t,e){var r=N(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=as;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=He;Q.prototype.delete=qe;Q.prototype.get=Ye;Q.prototype.has=Ve;Q.prototype.set=Ze;var lt=Q;var is="Expected a function";function Ft(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(is);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 f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Ft.Cache||lt),r}Ft.Cache=lt;var Je=Ft;var ss=500;function fs(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=fs;var ns=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ns,function(r,o,a,s){e.push(a?s.replace(ps,"$1"):o||r)}),e}),Qe=ls;function ms(t){return t==null?"":oe(t)}var tr=ms;function us(t,e){return v(t)?t:Be(t,e)?[t]:Qe(tr(t))}var D=us;var ds=1/0;function cs(t){if(typeof t=="string"||z(t))return t;var e=t+"";return e=="0"&&1/t==-ds?"-0":e}var tt=cs;function hs(t,e){e=D(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[tt(e[r++])];return r&&r==o?t:void 0}var er=hs;function xs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var et=xs;var rr=w?w.isConcatSpreadable:void 0;function gs(t){return v(t)||q(t)||!!(rr&&t&&t[rr])}var or=gs;function ar(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=or),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?ar(i,e-1,r,o,a):et(a,i):o||(a[a.length]=i)}return a}var ir=ar;function ys(t){var e=t==null?0:t.length;return e?ir(t,1):[]}var sr=ys;function bs(t){return xe(be(t,void 0,sr),t+"")}var fr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new F,this.size=0}var nr=ws;function Ts(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Ts;function As(t){return this.__data__.get(t)}var lr=As;function Ss(t){return this.__data__.has(t)}var mr=Ss;var Ps=200;function js(t,e){var r=this.__data__;if(r instanceof F){var o=r.__data__;if(!L||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new lt(o)}return r.set(t,e),this.size=r.size,this}var ur=js;function rt(t){var e=this.__data__=new F(t);this.size=e.size}rt.prototype.clear=nr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function Os(t,e){return t&&R(e,V(e),t)}var cr=Os;function _s(t,e){return t&&R(e,Z(e),t)}var hr=_s;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=br&&typeof module=="object"&&module&&!module.nodeType&&module,Is=xr&&xr.exports===br,gr=Is?x.Buffer:void 0,yr=gr?gr.allocUnsafe:void 0;function Es(t,e){if(e)return t.slice();var r=t.length,o=yr?yr(r):new t.constructor(r);return t.copy(o),o}var vr=Es;function Cs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var wr=Cs;function Ms(){return[]}var At=Ms;var Rs=Object.prototype,Bs=Rs.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Fs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Bs.call(t,e)}))}:At,ot=Fs;function Ls(t,e){return R(t,ot(t),e)}var Ar=Ls;var Ns=Object.getOwnPropertySymbols,Ds=Ns?function(t){for(var e=[];t;)et(e,ot(t)),t=Tt(t);return e}:At,St=Ds;function ks(t,e){return R(t,St(t),e)}var Sr=ks;function Us(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var Pt=Us;function zs(t){return Pt(t,V,ot)}var Pr=zs;function Ks(t){return Pt(t,Z,St)}var jr=Ks;var Gs=A(x,"DataView"),jt=Gs;var Ws=A(x,"Promise"),Ot=Ws;var Hs=A(x,"Set"),_t=Hs;var Or="[object Map]",$s="[object Object]",_r="[object Promise]",Ir="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=E(jt),Ys=E(L),Vs=E(Ot),Zs=E(_t),Js=E(ht),k=O;(jt&&k(new jt(new ArrayBuffer(1)))!=Cr||L&&k(new L)!=Or||Ot&&k(Ot.resolve())!=_r||_t&&k(new _t)!=Ir||ht&&k(new ht)!=Er)&&(k=function(t){var e=O(t),r=e==$s?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Or;case Vs:return _r;case Zs:return Ir;case Js:return Er}return e});var at=k;var Xs=Object.prototype,Qs=Xs.hasOwnProperty;function tf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Qs.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Mr=tf;var ef=x.Uint8Array,Lt=ef;function rf(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}var it=rf;function of(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Rr=of;var af=/\w*$/;function sf(t){var e=new t.constructor(t.source,af.exec(t));return e.lastIndex=t.lastIndex,e}var Br=sf;var Fr=w?w.prototype:void 0,Lr=Fr?Fr.valueOf:void 0;function ff(t){return Lr?Object(Lr.call(t)):{}}var Nr=ff;function nf(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=nf;var pf="[object Boolean]",lf="[object Date]",mf="[object Map]",uf="[object Number]",df="[object RegExp]",cf="[object Set]",hf="[object String]",xf="[object Symbol]",gf="[object ArrayBuffer]",yf="[object DataView]",bf="[object Float32Array]",vf="[object Float64Array]",wf="[object Int8Array]",Tf="[object Int16Array]",Af="[object Int32Array]",Sf="[object Uint8Array]",Pf="[object Uint8ClampedArray]",jf="[object Uint16Array]",Of="[object Uint32Array]";function _f(t,e,r){var o=t.constructor;switch(e){case gf:return it(t);case pf:case lf:return new o(+t);case yf:return Rr(t,r);case bf:case vf:case wf:case Tf:case Af:case Sf:case Pf:case jf:case Of:return Dr(t,r);case mf:return new o;case uf:case hf:return new o(t);case df:return Br(t);case cf:return new o;case xf:return Nr(t)}}var kr=_f;function If(t){return typeof t.constructor=="function"&&!$(t)?le(Tt(t)):{}}var Ur=If;var Ef="[object Map]";function Cf(t){return j(t)&&at(t)==Ef}var zr=Cf;var Kr=C&&C.isMap,Mf=Kr?Y(Kr):zr,Gr=Mf;var Rf="[object Set]";function Bf(t){return j(t)&&at(t)==Rf}var Wr=Bf;var Hr=C&&C.isSet,Ff=Hr?Y(Hr):Wr,$r=Ff;var Lf=1,Nf=2,Df=4,qr="[object Arguments]",kf="[object Array]",Uf="[object Boolean]",zf="[object Date]",Kf="[object Error]",Yr="[object Function]",Gf="[object GeneratorFunction]",Wf="[object Map]",Hf="[object Number]",Vr="[object Object]",$f="[object RegExp]",qf="[object Set]",Yf="[object String]",Vf="[object Symbol]",Zf="[object WeakMap]",Jf="[object ArrayBuffer]",Xf="[object DataView]",Qf="[object Float32Array]",tn="[object Float64Array]",en="[object Int8Array]",rn="[object Int16Array]",on="[object Int32Array]",an="[object Uint8Array]",sn="[object Uint8ClampedArray]",fn="[object Uint16Array]",nn="[object Uint32Array]",d={};d[qr]=d[kf]=d[Jf]=d[Xf]=d[Uf]=d[zf]=d[Qf]=d[tn]=d[en]=d[rn]=d[on]=d[Wf]=d[Hf]=d[Vr]=d[$f]=d[qf]=d[Yf]=d[Vf]=d[an]=d[sn]=d[fn]=d[nn]=!0;d[Kf]=d[Yr]=d[Zf]=!1;function It(t,e,r,o,a,s){var f,i=e&Lf,n=e&Nf,m=e&Df;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!P(t))return t;var h=v(t);if(h){if(f=Mr(t),!i)return ue(t,f)}else{var b=at(t),S=b==Yr||b==Gf;if(bt(t))return vr(t,i);if(b==Vr||b==qr||S&&!a){if(f=n||S?{}:Ur(t),!i)return n?Sr(t,hr(f,t)):Ar(t,cr(f,t))}else{if(!d[b])return a?t:{};f=kr(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,f),$r(t)?t.forEach(function(y){f.add(It(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){f.set(p,It(y,e,r,p,t,s))});var g=m?n?jr:Pr:n?Z:V,_=h?void 0:g(t);return ge(_||t,function(y,p){_&&(p=y,y=t[p]),W(f,p,It(y,e,r,p,t,s))}),f}var Zr=It;var pn=1,ln=4;function mn(t){return Zr(t,pn|ln)}var Nt=mn;function un(t,e){return t!=null&&e in Object(t)}var Jr=un;function dn(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=tt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&H(a)&&G(f,a)&&(v(t)||q(t)))}var Xr=dn;function cn(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cn;function hn(t,e,r,o){if(!P(t))return t;e=D(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=tt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=P(h)?h:G(e[a+1])?[]:{})}W(i,n,m),i=i[n]}return t}var to=hn;function xn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=er(t,f);r(i,f)&&to(s,D(f,t),i)}return s}var eo=xn;function gn(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gn;var yn=fr(function(t,e){return t==null?{}:ro(t,e)}),Et=yn;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 Dt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var bn="array",vn="bit",ao="bits",wn="byte",io="bytes",st="",Tn="exponent",An="function",so="iec",Sn="Invalid number",Pn="Invalid rounding method",kt="jedec",jn="object",fo=".",On="round",_n="s",In="si",En="kbit",Cn="kB",Mn=" ",Rn="string",Bn="0",Ut={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 no(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:f={},separator:i=st,spacer:n=Mn,symbols:m={},standard:h=st,output:b=Rn,fullform:S=!1,fullforms:T=[],exponent:g=-1,roundingMethod:_=On,precision:y=0}={}){let p=g,u=Number(t),l=[],I=0,Ct=st;h===In?(o=10,h=kt):h===so||h===kt?o=2:o===2?h=so:(o=10,h=kt);let mt=o===10?1e3:1024,po=S===!0,Kt=u<0,Gt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Sn);if(typeof Gt!==An)throw new TypeError(Pn);if(Kt&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(mt)),p<0&&(p=0)),p>8&&(y>0&&(y+=8-p),p=8),b===Tn)return p;if(u===0)l[0]=0,Ct=l[1]=Ut.symbol[h][e?ao:io][p];else{I=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(I=I*8,I>=mt&&p<8&&(I=I/mt,p++));let ft=Math.pow(10,p>0?a:0);l[0]=Gt(I*ft)/ft,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?En:Cn:Ut.symbol[h][e?ao:io][p]}if(Kt&&(l[0]=-l[0]),y>0&&(l[0]=l[0].toPrecision(y)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(fo,i)),r&&Number.isInteger(l[0])===!1&&a>0){let ft=i||fo,Wt=l[0].toString().split(ft),Ht=Wt[1]||st,$t=Ht.length,lo=a-$t;l[0]=`${Wt[0]}${ft}${Ht.padEnd($t+lo,Bn)}`}return po&&(l[1]=T[p]?T[p]:Ut.fullform[h][p]+(e?vn:wn)+(l[0]===1?st:_n)),b===bn?l:b===jn?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(n)}var U=class t{#t;id;name;icon;path;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),delete this.tera,this.#t=e.tera,this.sizeFormatted=no(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(){return this.#t.getProjectFile(this.path)}setContents(e){return this.#t.setProjectFile(this.path,e)}getRefs(){return this.#t.getProjectLibrary(this.path)}setRefs(e){return this.#t.setProjectLibrary(this.path,e)}serialize(){return Et(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={devMode:!0,mode:"detect",modeTimeout:300,modeFallback:"child",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};events=oo();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"];plugins=[];send(e){let r=Dt();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||Dt(),...Nt(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","Message compose client->server:",o),this.debug("ERROR","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;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",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);else{if(r?.action=="rpc")return 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()})});if(r?.action=="event")return 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(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}acceptPostboxes={};createProjectStatePatch(e,r){let o=qt(r,e,Yt);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}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.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).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(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}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(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("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),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA window parent"),e();break;case"popup":this.debug("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"),(()=>{let r=0,o,a=()=>{this.debug("Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}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;","&.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
|
-
`),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){let r="log";typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase())
|
|
1
|
+
function qt(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:b}){var A=Object.keys(i),T=A.length,g=Object.keys(n),I=g.length,y,p=i.length-n.length;if(uo(i,n)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(A[u]):A[u];l in n||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<I;u++){var l=Array.isArray(n)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:b})}}else{for(var u=0;u<p;u++)y=h.concat(u),b.remove.push({op:"remove",path:r(y)});for(var _=i.slice(p),u=0;u<I;u++)s({key:u,obj1:_,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:b})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:b,diffs:A}){var T=n[i],g=m[i];if(!(i in n)&&i in m){var I=g;A.add.push({op:"add",path:r(h),value:I})}else T!==g&&(Object(T)!==T||Object(g)!==g||mo(T,g)||!Object.keys(T).length&&!Object.keys(g).length&&String(T)!=String(g)?f(h,A,g):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:A}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function Yt(t){return[""].concat(t).join("/")}function mo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function uo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var co=typeof global=="object"&&global&&global.Object===Object&&global,ut=co;var ho=typeof self=="object"&&self&&self.Object===Object&&self,xo=ut||ho||Function("return this")(),x=xo;var go=x.Symbol,w=go;var Vt=Object.prototype,yo=Vt.hasOwnProperty,bo=Vt.toString,nt=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,nt),r=t[nt];try{t[nt]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[nt]=r:delete t[nt]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Oo(t){return To.call(t)}var Jt=Oo;var Ao="[object Null]",So="[object Undefined]",Xt=w?w.toStringTag:void 0;function Po(t){return t==null?t===void 0?So:Ao:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var j=Po;function jo(t){return t!=null&&typeof t=="object"}var P=jo;var Io="[object Symbol]";function _o(t){return typeof t=="symbol"||P(t)&&j(t)==Io}var z=_o;function Eo(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=Eo;var Co=Array.isArray,v=Co;var Mo=1/0,te=w?w.prototype:void 0,ee=te?te.toString:void 0;function re(t){if(typeof t=="string")return t;if(v(t))return Qt(t,re)+"";if(z(t))return ee?ee.call(t):"";var e=t+"";return e=="0"&&1/t==-Mo?"-0":e}var oe=re;function Fo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var S=Fo;function Ro(t){return t}var ae=Ro;var No="[object AsyncFunction]",Bo="[object Function]",Lo="[object GeneratorFunction]",Do="[object Proxy]";function ko(t){if(!S(t))return!1;var e=j(t);return e==Bo||e==Lo||e==No||e==Do}var dt=ko;var Uo=x["__core-js_shared__"],ct=Uo;var ie=function(){var t=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function zo(t){return!!ie&&ie in t}var se=zo;var Ko=Function.prototype,Go=Ko.toString;function Wo(t){if(t!=null){try{return Go.call(t)}catch{}try{return t+""}catch{}}return""}var E=Wo;var Ho=/[\\^$.*+?()[\]{}|]/g,$o=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Vo=qo.toString,Zo=Yo.hasOwnProperty,Jo=RegExp("^"+Vo.call(Zo).replace(Ho,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xo(t){if(!S(t)||se(t))return!1;var e=dt(t)?Jo:$o;return e.test(E(t))}var fe=Xo;function Qo(t,e){return t?.[e]}var ne=Qo;function ta(t,e){var r=ne(t,e);return fe(r)?r:void 0}var O=ta;var ea=O(x,"WeakMap"),ht=ea;var pe=Object.create,ra=function(){function t(){}return function(e){if(!S(e))return{};if(pe)return pe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),le=ra;function oa(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=oa;function aa(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=aa;var ia=800,sa=16,fa=Date.now;function na(t){var e=0,r=0;return function(){var o=fa(),a=sa-(o-r);if(r=o,a>0){if(++e>=ia)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var de=na;function pa(t){return function(){return t}}var ce=pa;var la=function(){try{var t=O(Object,"defineProperty");return t({},"",{}),t}catch{}}(),K=la;var ma=K?function(t,e){return K(t,"toString",{configurable:!0,enumerable:!1,value:ce(e),writable:!0})}:ae,he=ma;var ua=de(he),xe=ua;function da(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ge=da;var ca=9007199254740991,ha=/^(?:0|[1-9]\d*)$/;function xa(t,e){var r=typeof t;return e=e??ca,!!e&&(r=="number"||r!="symbol"&&ha.test(t))&&t>-1&&t%1==0&&t<e}var G=xa;function ga(t,e,r){e=="__proto__"&&K?K(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ga;function ya(t,e){return t===e||t!==t&&e!==e}var gt=ya;var ba=Object.prototype,va=ba.hasOwnProperty;function wa(t,e,r){var o=t[e];(!(va.call(t,e)&>(o,r))||r===void 0&&!(e in t))&&xt(t,e,r)}var W=wa;function Ta(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?xt(r,i,n):W(r,i,n)}return r}var F=Ta;var ye=Math.max;function Oa(t,e,r){return e=ye(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ye(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),me(t,this,i)}}var be=Oa;var Aa=9007199254740991;function Sa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Aa}var H=Sa;function Pa(t){return t!=null&&H(t.length)&&!dt(t)}var yt=Pa;var ja=Object.prototype;function Ia(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||ja;return t===r}var $=Ia;function _a(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=_a;var Ea="[object Arguments]";function Ca(t){return P(t)&&j(t)==Ea}var Mt=Ca;var we=Object.prototype,Ma=we.hasOwnProperty,Fa=we.propertyIsEnumerable,Ra=Mt(function(){return arguments}())?Mt:function(t){return P(t)&&Ma.call(t,"callee")&&!Fa.call(t,"callee")},q=Ra;function Na(){return!1}var Te=Na;var Se=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Se&&typeof module=="object"&&module&&!module.nodeType&&module,Ba=Oe&&Oe.exports===Se,Ae=Ba?x.Buffer:void 0,La=Ae?Ae.isBuffer:void 0,Da=La||Te,bt=Da;var ka="[object Arguments]",Ua="[object Array]",za="[object Boolean]",Ka="[object Date]",Ga="[object Error]",Wa="[object Function]",Ha="[object Map]",$a="[object Number]",qa="[object Object]",Ya="[object RegExp]",Va="[object Set]",Za="[object String]",Ja="[object WeakMap]",Xa="[object ArrayBuffer]",Qa="[object DataView]",ti="[object Float32Array]",ei="[object Float64Array]",ri="[object Int8Array]",oi="[object Int16Array]",ai="[object Int32Array]",ii="[object Uint8Array]",si="[object Uint8ClampedArray]",fi="[object Uint16Array]",ni="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[fi]=c[ni]=!0;c[ka]=c[Ua]=c[Xa]=c[za]=c[Qa]=c[Ka]=c[Ga]=c[Wa]=c[Ha]=c[$a]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=!1;function pi(t){return P(t)&&H(t.length)&&!!c[j(t)]}var Pe=pi;function li(t){return function(e){return t(e)}}var Y=li;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=je&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===je,Ft=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Ft&&Ft.binding&&Ft.binding("util")}catch{}}(),C=ui;var Ie=C&&C.isTypedArray,di=Ie?Y(Ie):Pe,_e=di;var ci=Object.prototype,hi=ci.hasOwnProperty;function xi(t,e){var r=v(t),o=!r&&q(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&_e(t),f=r||o||a||s,i=f?ve(t.length,String):[],n=i.length;for(var m in t)(e||hi.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,n)))&&i.push(m);return i}var vt=xi;function gi(t,e){return function(r){return t(e(r))}}var wt=gi;var yi=wt(Object.keys,Object),Ee=yi;var bi=Object.prototype,vi=bi.hasOwnProperty;function wi(t){if(!$(t))return Ee(t);var e=[];for(var r in Object(t))vi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ce=wi;function Ti(t){return yt(t)?vt(t):Ce(t)}var V=Ti;function Oi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Me=Oi;var Ai=Object.prototype,Si=Ai.hasOwnProperty;function Pi(t){if(!S(t))return Me(t);var e=$(t),r=[];for(var o in t)o=="constructor"&&(e||!Si.call(t,o))||r.push(o);return r}var Fe=Pi;function ji(t){return yt(t)?vt(t,!0):Fe(t)}var Z=ji;var Ii=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_i=/^\w*$/;function Ei(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||z(t)?!0:_i.test(t)||!Ii.test(t)||e!=null&&t in Object(e)}var Re=Ei;var Ci=O(Object,"create"),M=Ci;function Mi(){this.__data__=M?M(null):{},this.size=0}var Ne=Mi;function Fi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Fi;var Ri="__lodash_hash_undefined__",Ni=Object.prototype,Bi=Ni.hasOwnProperty;function Li(t){var e=this.__data__;if(M){var r=e[t];return r===Ri?void 0:r}return Bi.call(e,t)?e[t]:void 0}var Le=Li;var Di=Object.prototype,ki=Di.hasOwnProperty;function Ui(t){var e=this.__data__;return M?e[t]!==void 0:ki.call(e,t)}var De=Ui;var zi="__lodash_hash_undefined__";function Ki(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?zi:e,this}var ke=Ki;function J(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])}}J.prototype.clear=Ne;J.prototype.delete=Be;J.prototype.get=Le;J.prototype.has=De;J.prototype.set=ke;var Rt=J;function Gi(){this.__data__=[],this.size=0}var Ue=Gi;function Wi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var R=Wi;var Hi=Array.prototype,$i=Hi.splice;function qi(t){var e=this.__data__,r=R(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():$i.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=R(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return R(this.__data__,t)>-1}var Ge=Vi;function Zi(t,e){var r=this.__data__,o=R(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=Zi;function X(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])}}X.prototype.clear=Ue;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var N=X;var Ji=O(x,"Map"),B=Ji;function Xi(){this.size=0,this.__data__={hash:new Rt,map:new(B||N),string:new Rt}}var He=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Qi;function ts(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var L=ts;function es(t){var e=L(this,t).delete(t);return this.size-=e?1:0,e}var qe=es;function rs(t){return L(this,t).get(t)}var Ye=rs;function os(t){return L(this,t).has(t)}var Ve=os;function as(t,e){var r=L(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=as;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=He;Q.prototype.delete=qe;Q.prototype.get=Ye;Q.prototype.has=Ve;Q.prototype.set=Ze;var lt=Q;var is="Expected a function";function Nt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(is);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 f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Nt.Cache||lt),r}Nt.Cache=lt;var Je=Nt;var ss=500;function fs(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=fs;var ns=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ns,function(r,o,a,s){e.push(a?s.replace(ps,"$1"):o||r)}),e}),Qe=ls;function ms(t){return t==null?"":oe(t)}var tr=ms;function us(t,e){return v(t)?t:Re(t,e)?[t]:Qe(tr(t))}var D=us;var ds=1/0;function cs(t){if(typeof t=="string"||z(t))return t;var e=t+"";return e=="0"&&1/t==-ds?"-0":e}var tt=cs;function hs(t,e){e=D(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[tt(e[r++])];return r&&r==o?t:void 0}var er=hs;function xs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var et=xs;var rr=w?w.isConcatSpreadable:void 0;function gs(t){return v(t)||q(t)||!!(rr&&t&&t[rr])}var or=gs;function ar(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=or),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?ar(i,e-1,r,o,a):et(a,i):o||(a[a.length]=i)}return a}var ir=ar;function ys(t){var e=t==null?0:t.length;return e?ir(t,1):[]}var sr=ys;function bs(t){return xe(be(t,void 0,sr),t+"")}var fr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new N,this.size=0}var nr=ws;function Ts(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Ts;function Os(t){return this.__data__.get(t)}var lr=Os;function As(t){return this.__data__.has(t)}var mr=As;var Ss=200;function Ps(t,e){var r=this.__data__;if(r instanceof N){var o=r.__data__;if(!B||o.length<Ss-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new lt(o)}return r.set(t,e),this.size=r.size,this}var ur=Ps;function rt(t){var e=this.__data__=new N(t);this.size=e.size}rt.prototype.clear=nr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function js(t,e){return t&&F(e,V(e),t)}var cr=js;function Is(t,e){return t&&F(e,Z(e),t)}var hr=Is;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=br&&typeof module=="object"&&module&&!module.nodeType&&module,_s=xr&&xr.exports===br,gr=_s?x.Buffer:void 0,yr=gr?gr.allocUnsafe:void 0;function Es(t,e){if(e)return t.slice();var r=t.length,o=yr?yr(r):new t.constructor(r);return t.copy(o),o}var vr=Es;function Cs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var wr=Cs;function Ms(){return[]}var Ot=Ms;var Fs=Object.prototype,Rs=Fs.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Ns=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Rs.call(t,e)}))}:Ot,ot=Ns;function Bs(t,e){return F(t,ot(t),e)}var Or=Bs;var Ls=Object.getOwnPropertySymbols,Ds=Ls?function(t){for(var e=[];t;)et(e,ot(t)),t=Tt(t);return e}:Ot,At=Ds;function ks(t,e){return F(t,At(t),e)}var Ar=ks;function Us(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var St=Us;function zs(t){return St(t,V,ot)}var Sr=zs;function Ks(t){return St(t,Z,At)}var Pr=Ks;var Gs=O(x,"DataView"),Pt=Gs;var Ws=O(x,"Promise"),jt=Ws;var Hs=O(x,"Set"),It=Hs;var jr="[object Map]",$s="[object Object]",Ir="[object Promise]",_r="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=E(Pt),Ys=E(B),Vs=E(jt),Zs=E(It),Js=E(ht),k=j;(Pt&&k(new Pt(new ArrayBuffer(1)))!=Cr||B&&k(new B)!=jr||jt&&k(jt.resolve())!=Ir||It&&k(new It)!=_r||ht&&k(new ht)!=Er)&&(k=function(t){var e=j(t),r=e==$s?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case qs:return Cr;case Ys:return jr;case Vs:return Ir;case Zs:return _r;case Js:return Er}return e});var at=k;var Xs=Object.prototype,Qs=Xs.hasOwnProperty;function tf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Qs.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Mr=tf;var ef=x.Uint8Array,Bt=ef;function rf(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var it=rf;function of(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Fr=of;var af=/\w*$/;function sf(t){var e=new t.constructor(t.source,af.exec(t));return e.lastIndex=t.lastIndex,e}var Rr=sf;var Nr=w?w.prototype:void 0,Br=Nr?Nr.valueOf:void 0;function ff(t){return Br?Object(Br.call(t)):{}}var Lr=ff;function nf(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=nf;var pf="[object Boolean]",lf="[object Date]",mf="[object Map]",uf="[object Number]",df="[object RegExp]",cf="[object Set]",hf="[object String]",xf="[object Symbol]",gf="[object ArrayBuffer]",yf="[object DataView]",bf="[object Float32Array]",vf="[object Float64Array]",wf="[object Int8Array]",Tf="[object Int16Array]",Of="[object Int32Array]",Af="[object Uint8Array]",Sf="[object Uint8ClampedArray]",Pf="[object Uint16Array]",jf="[object Uint32Array]";function If(t,e,r){var o=t.constructor;switch(e){case gf:return it(t);case pf:case lf:return new o(+t);case yf:return Fr(t,r);case bf:case vf:case wf:case Tf:case Of:case Af:case Sf:case Pf:case jf:return Dr(t,r);case mf:return new o;case uf:case hf:return new o(t);case df:return Rr(t);case cf:return new o;case xf:return Lr(t)}}var kr=If;function _f(t){return typeof t.constructor=="function"&&!$(t)?le(Tt(t)):{}}var Ur=_f;var Ef="[object Map]";function Cf(t){return P(t)&&at(t)==Ef}var zr=Cf;var Kr=C&&C.isMap,Mf=Kr?Y(Kr):zr,Gr=Mf;var Ff="[object Set]";function Rf(t){return P(t)&&at(t)==Ff}var Wr=Rf;var Hr=C&&C.isSet,Nf=Hr?Y(Hr):Wr,$r=Nf;var Bf=1,Lf=2,Df=4,qr="[object Arguments]",kf="[object Array]",Uf="[object Boolean]",zf="[object Date]",Kf="[object Error]",Yr="[object Function]",Gf="[object GeneratorFunction]",Wf="[object Map]",Hf="[object Number]",Vr="[object Object]",$f="[object RegExp]",qf="[object Set]",Yf="[object String]",Vf="[object Symbol]",Zf="[object WeakMap]",Jf="[object ArrayBuffer]",Xf="[object DataView]",Qf="[object Float32Array]",tn="[object Float64Array]",en="[object Int8Array]",rn="[object Int16Array]",on="[object Int32Array]",an="[object Uint8Array]",sn="[object Uint8ClampedArray]",fn="[object Uint16Array]",nn="[object Uint32Array]",d={};d[qr]=d[kf]=d[Jf]=d[Xf]=d[Uf]=d[zf]=d[Qf]=d[tn]=d[en]=d[rn]=d[on]=d[Wf]=d[Hf]=d[Vr]=d[$f]=d[qf]=d[Yf]=d[Vf]=d[an]=d[sn]=d[fn]=d[nn]=!0;d[Kf]=d[Yr]=d[Zf]=!1;function _t(t,e,r,o,a,s){var f,i=e&Bf,n=e&Lf,m=e&Df;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!S(t))return t;var h=v(t);if(h){if(f=Mr(t),!i)return ue(t,f)}else{var b=at(t),A=b==Yr||b==Gf;if(bt(t))return vr(t,i);if(b==Vr||b==qr||A&&!a){if(f=n||A?{}:Ur(t),!i)return n?Ar(t,hr(f,t)):Or(t,cr(f,t))}else{if(!d[b])return a?t:{};f=kr(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,f),$r(t)?t.forEach(function(y){f.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){f.set(p,_t(y,e,r,p,t,s))});var g=m?n?Pr:Sr:n?Z:V,I=h?void 0:g(t);return ge(I||t,function(y,p){I&&(p=y,y=t[p]),W(f,p,_t(y,e,r,p,t,s))}),f}var Zr=_t;var pn=1,ln=4;function mn(t){return Zr(t,pn|ln)}var Lt=mn;function un(t,e){return t!=null&&e in Object(t)}var Jr=un;function dn(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=tt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&H(a)&&G(f,a)&&(v(t)||q(t)))}var Xr=dn;function cn(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cn;function hn(t,e,r,o){if(!S(t))return t;e=D(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=tt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=S(h)?h:G(e[a+1])?[]:{})}W(i,n,m),i=i[n]}return t}var to=hn;function xn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=er(t,f);r(i,f)&&to(s,D(f,t),i)}return s}var eo=xn;function gn(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gn;var yn=fr(function(t,e){return t==null?{}:ro(t,e)}),Et=yn;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 Dt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var bn="array",vn="bit",ao="bits",wn="byte",io="bytes",st="",Tn="exponent",On="function",so="iec",An="Invalid number",Sn="Invalid rounding method",kt="jedec",Pn="object",fo=".",jn="round",In="s",_n="si",En="kbit",Cn="kB",Mn=" ",Fn="string",Rn="0",Ut={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 no(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:f={},separator:i=st,spacer:n=Mn,symbols:m={},standard:h=st,output:b=Fn,fullform:A=!1,fullforms:T=[],exponent:g=-1,roundingMethod:I=jn,precision:y=0}={}){let p=g,u=Number(t),l=[],_=0,Ct=st;h===_n?(o=10,h=kt):h===so||h===kt?o=2:o===2?h=so:(o=10,h=kt);let mt=o===10?1e3:1024,po=A===!0,Kt=u<0,Gt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(An);if(typeof Gt!==On)throw new TypeError(Sn);if(Kt&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(mt)),p<0&&(p=0)),p>8&&(y>0&&(y+=8-p),p=8),b===Tn)return p;if(u===0)l[0]=0,Ct=l[1]=Ut.symbol[h][e?ao:io][p];else{_=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(_=_*8,_>=mt&&p<8&&(_=_/mt,p++));let ft=Math.pow(10,p>0?a:0);l[0]=Gt(_*ft)/ft,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?En:Cn:Ut.symbol[h][e?ao:io][p]}if(Kt&&(l[0]=-l[0]),y>0&&(l[0]=l[0].toPrecision(y)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(fo,i)),r&&Number.isInteger(l[0])===!1&&a>0){let ft=i||fo,Wt=l[0].toString().split(ft),Ht=Wt[1]||st,$t=Ht.length,lo=a-$t;l[0]=`${Wt[0]}${ft}${Ht.padEnd($t+lo,Rn)}`}return po&&(l[1]=T[p]?T[p]:Ut.fullform[h][p]+(e?vn:wn)+(l[0]===1?st:In)),b===bn?l:b===Pn?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(n)}var U=class t{#t;id;name;icon;path;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),delete this.tera,this.#t=e.tera,this.sizeFormatted=no(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(){return this.#t.getProjectFile(this.path)}setContents(e){return this.#t.setProjectFile(this.path,e)}getRefs(){return this.#t.getProjectLibrary(this.path)}setRefs(e){return this.#t.setProjectLibrary(this.path,e)}serialize(){return Et(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",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};events=oo();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"];plugins=[];send(e){let r=Dt();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||Dt(),...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;let r=e.data;if(!(!r.TERA||!r.id))if(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);else{if(r?.action=="rpc")return 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()})});if(r?.action=="event")return 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?`):this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r})}}acceptPostboxes={};createProjectStatePatch(e,r){let o=qt(r,e,Yt);return this.debug("INFO",3,"Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}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.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).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(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}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(){return new Promise(e=>{switch(this.settings.mode){case"child":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),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":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"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}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;","&.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
|
+
`),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){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,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)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new U({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new U({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new U({tera:this,...r}))}};export{zt as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
lodash-es/lodash.js:
|
package/lib/terafy.client.js
CHANGED
|
@@ -18,6 +18,7 @@ export default class TeraFy {
|
|
|
18
18
|
*
|
|
19
19
|
* @type {Object}
|
|
20
20
|
* @property {Boolean} devMode Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance
|
|
21
|
+
* @property {Number} verbosity Verbosity level, the higher the more chatty TeraFY will be. Set to zero to disable all `debug()` call output
|
|
21
22
|
* @property {'detect'|'parent'|'child'|'popup'} mode How to communicate with TERA. 'parent' assumes that the parent of the current document is TERA, 'child' spawns an iFrame and uses TERA there, 'detect' tries parent and switches to `modeFallback` if communication fails
|
|
22
23
|
* @property {String} modeFallback Method to use when all method detection fails
|
|
23
24
|
* @property {Number} modeTimeout How long entities have in 'detect' mode to identify themselves
|
|
@@ -28,6 +29,7 @@ export default class TeraFy {
|
|
|
28
29
|
*/
|
|
29
30
|
settings = {
|
|
30
31
|
devMode: true,
|
|
32
|
+
verbosity: 1,
|
|
31
33
|
mode: 'detect',
|
|
32
34
|
modeTimeout: 300,
|
|
33
35
|
modeFallback: 'child', // ENUM: 'child' (use iframes), 'popup' (use popup windows)
|
|
@@ -182,8 +184,8 @@ export default class TeraFy {
|
|
|
182
184
|
throw new Error(`Unknown TERA communication mode "${this.settings.mode}"`);
|
|
183
185
|
}
|
|
184
186
|
} catch (e) {
|
|
185
|
-
this.debug('ERROR', 'Message compose client->server:', e);
|
|
186
|
-
this.debug('ERROR', 'Attempted to dispatch payload client->server', payload);
|
|
187
|
+
this.debug('ERROR', 1, 'Message compose client->server:', e);
|
|
188
|
+
this.debug('ERROR', 1, 'Attempted to dispatch payload client->server', payload);
|
|
187
189
|
throw e;
|
|
188
190
|
}
|
|
189
191
|
}
|
|
@@ -216,7 +218,7 @@ export default class TeraFy {
|
|
|
216
218
|
|
|
217
219
|
let message = rawMessage.data;
|
|
218
220
|
if (!message.TERA || !message.id) return; // Ignore non-TERA signed messages
|
|
219
|
-
this.debug('Recieved', message);
|
|
221
|
+
this.debug('INFO', 3, 'Recieved message', message);
|
|
220
222
|
|
|
221
223
|
if (message?.action == 'response' && this.acceptPostboxes[message.id]) { // Postbox waiting for reply
|
|
222
224
|
if (message.isError === true) {
|
|
@@ -249,9 +251,9 @@ export default class TeraFy {
|
|
|
249
251
|
throw e;
|
|
250
252
|
})
|
|
251
253
|
} else if (message?.id) {
|
|
252
|
-
this.debug(`Ignoring message ID ${message.id} - was meant for someone else?`);
|
|
254
|
+
this.debug('INFO', 3, `Ignoring message ID ${message.id} - was meant for someone else?`);
|
|
253
255
|
} else {
|
|
254
|
-
this.debug('Unexpected incoming TERA-FY CLIENT message', {message});
|
|
256
|
+
this.debug('INFO', 3, 'Unexpected incoming TERA-FY CLIENT message', {message});
|
|
255
257
|
}
|
|
256
258
|
}
|
|
257
259
|
|
|
@@ -276,7 +278,7 @@ export default class TeraFy {
|
|
|
276
278
|
*/
|
|
277
279
|
createProjectStatePatch(newState, oldState) {
|
|
278
280
|
let patch = diff(oldState, newState, jsPatchConverter);
|
|
279
|
-
this.debug('INFO', 'Created project patch', {newState, oldState});
|
|
281
|
+
this.debug('INFO', 3, 'Created project patch', {newState, oldState});
|
|
280
282
|
return this.applyProjectStatePatch(patch);
|
|
281
283
|
}
|
|
282
284
|
|
|
@@ -380,7 +382,7 @@ export default class TeraFy {
|
|
|
380
382
|
injectComms() { return new Promise(resolve => {
|
|
381
383
|
switch (this.settings.mode) {
|
|
382
384
|
case 'child':
|
|
383
|
-
this.debug('Injecting TERA site as iFrame child');
|
|
385
|
+
this.debug('INFO', 2, 'Injecting TERA site as iFrame child');
|
|
384
386
|
|
|
385
387
|
this.dom.el = document.createElement('div')
|
|
386
388
|
this.dom.el.id = 'tera-fy';
|
|
@@ -392,7 +394,7 @@ export default class TeraFy {
|
|
|
392
394
|
// Queue up event chain when document loads
|
|
393
395
|
this.dom.iframe.setAttribute('sandbox', this.settings.frameSandbox.join(' '));
|
|
394
396
|
this.dom.iframe.addEventListener('load', ()=> {
|
|
395
|
-
this.debug('
|
|
397
|
+
this.debug('INFO', 2, 'Embeded iframe ready');
|
|
396
398
|
resolve();
|
|
397
399
|
});
|
|
398
400
|
|
|
@@ -401,11 +403,11 @@ export default class TeraFy {
|
|
|
401
403
|
this.dom.el.append(this.dom.iframe);
|
|
402
404
|
break;
|
|
403
405
|
case 'parent':
|
|
404
|
-
this.debug('Using TERA window parent');
|
|
406
|
+
this.debug('INFO', 2, 'Using TERA window parent');
|
|
405
407
|
resolve();
|
|
406
408
|
break;
|
|
407
409
|
case 'popup':
|
|
408
|
-
this.debug('Injecting TERA site as a popup window');
|
|
410
|
+
this.debug('INFO', 2, 'Injecting TERA site as a popup window');
|
|
409
411
|
this.dom.popup = window.open(this.settings.siteUrl, '_blank', 'popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600');
|
|
410
412
|
|
|
411
413
|
// Loop until the window context returns a handshake
|
|
@@ -414,7 +416,7 @@ export default class TeraFy {
|
|
|
414
416
|
let handshakeTimer;
|
|
415
417
|
|
|
416
418
|
const tryHandshake = ()=> {
|
|
417
|
-
this.debug('Trying handshake', ++handshakeCount);
|
|
419
|
+
this.debug('INFO', 3, 'Trying handshake', ++handshakeCount);
|
|
418
420
|
|
|
419
421
|
clearTimeout(handshakeTimer);
|
|
420
422
|
handshakeTimer = setTimeout(tryHandshake, this.settings.handshakeInterval);
|
|
@@ -422,7 +424,7 @@ export default class TeraFy {
|
|
|
422
424
|
this.rpc('handshake')
|
|
423
425
|
.then(()=> {
|
|
424
426
|
clearTimeout(handshakeTimer);
|
|
425
|
-
this.debug('Popup window accepted handshake');
|
|
427
|
+
this.debug('INFO', 3, 'Popup window accepted handshake');
|
|
426
428
|
resolve();
|
|
427
429
|
});
|
|
428
430
|
};
|
|
@@ -515,21 +517,26 @@ export default class TeraFy {
|
|
|
515
517
|
* Debugging output function
|
|
516
518
|
* This function will only act if `settings.devMode` is truthy
|
|
517
519
|
*
|
|
518
|
-
* @param {'
|
|
520
|
+
* @param {'INFO'|'LOG'|'WARN'|'ERROR'} [method='LOG'] Logging method to use
|
|
521
|
+
* @param {Number} [verboseLevel=1] The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored
|
|
519
522
|
* @param {String} [msg...] Output to show
|
|
520
523
|
*/
|
|
521
524
|
debug(...msg) {
|
|
525
|
+
if (!this.settings.devMode || this.settings.verbosity < 1) return; // Debugging is disabled
|
|
522
526
|
let method = 'log';
|
|
523
|
-
|
|
527
|
+
let verboseLevel = 1;
|
|
528
|
+
// Argument mangling for prefix method + verbosity level {{{
|
|
524
529
|
if (typeof msg[0] == 'string' && ['INFO', 'LOG', 'WARN', 'ERROR'].includes(msg[0])) {
|
|
525
530
|
method = msg.shift().toLowerCase();
|
|
526
531
|
}
|
|
532
|
+
|
|
533
|
+
if (typeof msg[0] == 'number') {
|
|
534
|
+
verboseLevel = msg[0];
|
|
535
|
+
msg.shift();
|
|
536
|
+
}
|
|
527
537
|
// }}}
|
|
528
538
|
|
|
529
|
-
if (
|
|
530
|
-
['INFO', 'LOG'].includes(method)
|
|
531
|
-
&& !this.settings.devMode
|
|
532
|
-
) return;
|
|
539
|
+
if (this.settings.verbosity < verboseLevel) return; // Called but this output is too verbose for our settings - skip
|
|
533
540
|
|
|
534
541
|
console[method](
|
|
535
542
|
'%c[TERA-FY CLIENT]',
|
|
@@ -642,7 +649,7 @@ export default class TeraFy {
|
|
|
642
649
|
* @param {String|Boolean} [isFocused='toggle'] Whether to fullscreen the embedded component
|
|
643
650
|
*/
|
|
644
651
|
toggleFocus(isFocused = 'toggle') {
|
|
645
|
-
this.debug('Request focus', {isFocused});
|
|
652
|
+
this.debug('INFO', 2, 'Request focus', {isFocused});
|
|
646
653
|
globalThis.document.body.classList.toggle('tera-fy-focus', isFocused === 'toggle' ? undefined : isFocused);
|
|
647
654
|
}
|
|
648
655
|
// }}}
|
package/lib/terafy.server.js
CHANGED
|
@@ -20,6 +20,7 @@ export default class TeraFyServer {
|
|
|
20
20
|
*
|
|
21
21
|
* @type {Object}
|
|
22
22
|
* @property {Boolean} devMode Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance
|
|
23
|
+
* @property {Number} verbosity Verbosity level, the higher the more chatty TeraFY will be. Set to zero to disable all `debug()` call output
|
|
23
24
|
* @property {Number} subscribeTimeout Acceptable timeout period for subscribers to acklowledge a project change event, failing to respond will result in the subscriber being removed from the available subscriber list
|
|
24
25
|
* @property {String} restrictOrigin URL to restrict communications to
|
|
25
26
|
* @property {String} projectId The project to use as the default reference when calling various APIs
|
|
@@ -29,6 +30,7 @@ export default class TeraFyServer {
|
|
|
29
30
|
*/
|
|
30
31
|
settings = {
|
|
31
32
|
devMode: false,
|
|
33
|
+
verbosity: 1,
|
|
32
34
|
restrictOrigin: '*',
|
|
33
35
|
subscribeTimeout: 2000,
|
|
34
36
|
projectId: null,
|
|
@@ -66,7 +68,7 @@ export default class TeraFyServer {
|
|
|
66
68
|
};
|
|
67
69
|
e.source.postMessage(payload, this.settings.restrictOrigin);
|
|
68
70
|
} catch (e) {
|
|
69
|
-
this.debug('ERROR', 'Attempted to dispatch payload server(via reply)->client', {payload, e});
|
|
71
|
+
this.debug('ERROR', 1, 'Attempted to dispatch payload server(via reply)->client', {payload, e});
|
|
70
72
|
throw e;
|
|
71
73
|
}
|
|
72
74
|
},
|
|
@@ -96,7 +98,7 @@ export default class TeraFyServer {
|
|
|
96
98
|
};
|
|
97
99
|
window.parent.postMessage(payload, this.settings.restrictOrigin);
|
|
98
100
|
} catch (e) {
|
|
99
|
-
this.debug('ERROR', 'Attempted to dispatch payload server(iframe)->cient(top level window)', {payload, e});
|
|
101
|
+
this.debug('ERROR', 1, 'Attempted to dispatch payload server(iframe)->cient(top level window)', {payload, e});
|
|
100
102
|
throw e;
|
|
101
103
|
}
|
|
102
104
|
},
|
|
@@ -116,7 +118,7 @@ export default class TeraFyServer {
|
|
|
116
118
|
};
|
|
117
119
|
iFrame.contentWindow.postMessage(payload, this.settings.restrictOrigin);
|
|
118
120
|
} catch (e) {
|
|
119
|
-
this.debug('ERROR', 'Attempted to dispatch payload server(top level window)->cient(iframe)', {payload, e});
|
|
121
|
+
this.debug('ERROR', 1, 'Attempted to dispatch payload server(top level window)->cient(iframe)', {payload, e});
|
|
120
122
|
throw e;
|
|
121
123
|
}
|
|
122
124
|
},
|
|
@@ -210,11 +212,11 @@ export default class TeraFyServer {
|
|
|
210
212
|
TERA: 1,
|
|
211
213
|
...cloneDeep(message), // Need to clone to resolve promise nasties
|
|
212
214
|
};
|
|
213
|
-
this.debug('INFO', 'Dispatch response', message, '<=>', payload);
|
|
215
|
+
this.debug('INFO', 3, 'Dispatch response', message, '<=>', payload);
|
|
214
216
|
(sendVia || globalThis.parent).postMessage(payload, this.settings.restrictOrigin);
|
|
215
217
|
} catch (e) {
|
|
216
|
-
this.debug('ERROR', 'Attempted to dispatch response server->client', payload);
|
|
217
|
-
this.debug('ERROR', 'Message compose server->client:', e);
|
|
218
|
+
this.debug('ERROR', 2, 'Attempted to dispatch response server->client', payload);
|
|
219
|
+
this.debug('ERROR', 2, 'Message compose server->client:', e);
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
222
|
|
|
@@ -251,7 +253,7 @@ export default class TeraFyServer {
|
|
|
251
253
|
|
|
252
254
|
let message = rawMessage.data;
|
|
253
255
|
if (!message.TERA) return; // Ignore non-TERA signed messages
|
|
254
|
-
this.debug('Recieved', message);
|
|
256
|
+
this.debug('INFO', 3, 'Recieved message', message);
|
|
255
257
|
|
|
256
258
|
Promise.resolve()
|
|
257
259
|
.then(()=> {
|
|
@@ -265,7 +267,7 @@ export default class TeraFyServer {
|
|
|
265
267
|
if (!this[message.method]) throw new Error(`Unknown RPC method "${message.method}"`);
|
|
266
268
|
return this[message.method].apply(this.createContext(rawMessage), message.args);
|
|
267
269
|
} else {
|
|
268
|
-
this.debug('Unexpected incoming TERA-FY SERVER message', {message});
|
|
270
|
+
this.debug('ERROR', 2, 'Unexpected incoming TERA-FY SERVER message', {message});
|
|
269
271
|
throw new Error('Unknown message format');
|
|
270
272
|
}
|
|
271
273
|
})
|
|
@@ -386,7 +388,7 @@ export default class TeraFyServer {
|
|
|
386
388
|
requireUser() {
|
|
387
389
|
return this.getUser()
|
|
388
390
|
.then(user => {
|
|
389
|
-
this.debug('Current user is', user ? user : 'Not valid');
|
|
391
|
+
this.debug('INFO', 2, 'Current user is', user ? user : 'Not valid');
|
|
390
392
|
if (user) throw 'EXIT'; // Valid user? Escape promise chain
|
|
391
393
|
})
|
|
392
394
|
.then(async ()=> { // No user present - try to validate with other methods
|
|
@@ -455,7 +457,7 @@ export default class TeraFyServer {
|
|
|
455
457
|
$auth.isLoggedIn = true;
|
|
456
458
|
$auth.user = lsState;
|
|
457
459
|
|
|
458
|
-
this.debug('Restored local user state from LocalStorage', {'$auth.user': $auth.user});
|
|
460
|
+
this.debug('INFO', 3, 'Restored local user state from LocalStorage', {'$auth.user': $auth.user});
|
|
459
461
|
|
|
460
462
|
await app.service('$projects').refresh();
|
|
461
463
|
return;
|
|
@@ -478,7 +480,7 @@ export default class TeraFyServer {
|
|
|
478
480
|
|
|
479
481
|
// Create a listener for the message from the downstream window to resolve the promise
|
|
480
482
|
let listenMessages = ({data}) => {
|
|
481
|
-
this.debug('Recieved message from popup window', {data});
|
|
483
|
+
this.debug('INFO', 3, 'Recieved message from popup window', {data});
|
|
482
484
|
if (data.TERA && data.action == 'popupUserState' && data.user) { // Signal sent from landing page - we're logged in, yey!
|
|
483
485
|
let $auth = app.service('$auth');
|
|
484
486
|
|
|
@@ -490,7 +492,7 @@ export default class TeraFyServer {
|
|
|
490
492
|
|
|
491
493
|
window.localStorage.setItem('tera.embedUser', JSON.stringify(data.user));
|
|
492
494
|
|
|
493
|
-
this.debug('Received user auth from popup window', {'$auth.user': $auth.user});
|
|
495
|
+
this.debug('INFO', 3, 'Received user auth from popup window', {'$auth.user': $auth.user});
|
|
494
496
|
waitOnWindowAuth.resolve();
|
|
495
497
|
}
|
|
496
498
|
};
|
|
@@ -504,11 +506,11 @@ export default class TeraFyServer {
|
|
|
504
506
|
// Display a message to the user, offering the ability to re-open the popup if it was originally denied
|
|
505
507
|
this.uiSplat(focusContent, {logo: true});
|
|
506
508
|
|
|
507
|
-
this.debug('Begin auth-check deferred wait...');
|
|
509
|
+
this.debug('INFO', 4, 'Begin auth-check deferred wait...');
|
|
508
510
|
return waitOnWindowAuth.promise;
|
|
509
511
|
});
|
|
510
512
|
|
|
511
|
-
this.debug('Cleaning up popup auth');
|
|
513
|
+
this.debug('INFO', 4, 'Cleaning up popup auth');
|
|
512
514
|
|
|
513
515
|
// Remove message subscription
|
|
514
516
|
window.removeEventListener('message', listenMessages);
|
|
@@ -789,7 +791,7 @@ export default class TeraFyServer {
|
|
|
789
791
|
saveProjectState() {
|
|
790
792
|
if (!app.service('$projects').active) throw new Error('No active project');
|
|
791
793
|
|
|
792
|
-
|
|
794
|
+
// TODO: Force saving projects is not supported - stuff is saved in realtime anyway
|
|
793
795
|
return Promise.resolve();
|
|
794
796
|
}
|
|
795
797
|
|
|
@@ -820,7 +822,7 @@ export default class TeraFyServer {
|
|
|
820
822
|
*/
|
|
821
823
|
applyProjectStatePatch(patch) {
|
|
822
824
|
if (!app.service('$projects').active) throw new Error('No active project to patch');
|
|
823
|
-
this.debug('Applying', patch.length, 'project state
|
|
825
|
+
this.debug('INFO', 1, 'Applying', patch.length, 'project state patch', patch);
|
|
824
826
|
diffApply(app.service('$projects').active, patch, jsPatchConverter);
|
|
825
827
|
|
|
826
828
|
return Promise.resolve();
|
|
@@ -1124,7 +1126,7 @@ export default class TeraFyServer {
|
|
|
1124
1126
|
settings.path = `/projects/${app.service('$projects').active.id}/${settings.path}`;
|
|
1125
1127
|
}
|
|
1126
1128
|
|
|
1127
|
-
this.debug('Save citation library as', path);
|
|
1129
|
+
this.debug('INFO', 2, 'Save citation library as', path);
|
|
1128
1130
|
})
|
|
1129
1131
|
.then(()=> {
|
|
1130
1132
|
// Mutate settings.ref -> Blob or File format needed by Supabase
|
|
@@ -1198,6 +1200,7 @@ export default class TeraFyServer {
|
|
|
1198
1200
|
*/
|
|
1199
1201
|
init() {
|
|
1200
1202
|
globalThis.addEventListener('message', this.acceptMessage.bind(this));
|
|
1203
|
+
this.debug('INFO', 1, 'Ready');
|
|
1201
1204
|
}
|
|
1202
1205
|
// }}}
|
|
1203
1206
|
|
|
@@ -1328,22 +1331,28 @@ export default class TeraFyServer {
|
|
|
1328
1331
|
* Debugging output function
|
|
1329
1332
|
* This function will only act if `settings.devMode` is truthy
|
|
1330
1333
|
*
|
|
1334
|
+
* @param {'INFO'|'LOG'|'WARN'|'ERROR'} [method='LOG'] Logging method to use
|
|
1335
|
+
* @param {Number} [verboseLevel=1] The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored
|
|
1331
1336
|
* @param {String} [msg...] Output to show
|
|
1332
1337
|
*/
|
|
1333
1338
|
debug(...msg) {
|
|
1339
|
+
if (!this.settings.devMode || this.settings.verbosity < 1) return; // Debugging is disabled
|
|
1334
1340
|
let method = 'log';
|
|
1335
|
-
|
|
1341
|
+
let verboseLevel = 1;
|
|
1342
|
+
// Argument mangling for prefix method + verbosity level {{{
|
|
1336
1343
|
if (typeof msg[0] == 'string' && ['INFO', 'LOG', 'WARN', 'ERROR'].includes(msg[0])) {
|
|
1337
1344
|
method = msg.shift().toLowerCase();
|
|
1338
1345
|
}
|
|
1346
|
+
|
|
1347
|
+
if (typeof msg[0] == 'number') {
|
|
1348
|
+
verboseLevel = msg[0];
|
|
1349
|
+
msg.shift();
|
|
1350
|
+
}
|
|
1339
1351
|
// }}}
|
|
1340
1352
|
|
|
1341
|
-
if (
|
|
1342
|
-
['INFO', 'LOG'].includes(method)
|
|
1343
|
-
&& !this.settings.devMode
|
|
1344
|
-
) return;
|
|
1353
|
+
if (this.settings.verbosity < verboseLevel) return; // Called but this output is too verbose for our settings - skip
|
|
1345
1354
|
|
|
1346
|
-
console
|
|
1355
|
+
console[method](
|
|
1347
1356
|
'%c[TERA-FY SERVER]',
|
|
1348
1357
|
'font-weight: bold; color: #4d659c;',
|
|
1349
1358
|
...msg,
|
package/package.json
CHANGED
package/plugins/vue2.js
CHANGED
|
@@ -80,7 +80,7 @@ export default class TeraFyPluginVue2 extends TeraFyPluginBase {
|
|
|
80
80
|
// }}}
|
|
81
81
|
]))
|
|
82
82
|
.then(([snapshot]) => {
|
|
83
|
-
this.debug('Got project snapshot', snapshot);
|
|
83
|
+
this.debug('INFO', 2, 'Got project snapshot', snapshot);
|
|
84
84
|
|
|
85
85
|
// Create initial Observable
|
|
86
86
|
let stateObservable = this.Vue.observable(snapshot);
|
|
@@ -223,12 +223,13 @@ export default class TeraFyPluginVue2 extends TeraFyPluginBase {
|
|
|
223
223
|
component: this.settings.app.$root,
|
|
224
224
|
})
|
|
225
225
|
.then(state => this.state = state)
|
|
226
|
-
.then(()=> this.debug('INFO', 'Loaded project state', this.state)),
|
|
226
|
+
.then(()=> this.debug('INFO', 1, 'Loaded initial project state', this.state)),
|
|
227
227
|
|
|
228
228
|
// Fetch available projects
|
|
229
229
|
settings.subscribeProjects && this.getProjects()
|
|
230
230
|
.then(projects => this.projects = this.Vue.observable(projects))
|
|
231
|
-
.then(()=> this.debug('INFO', 'Loaded
|
|
231
|
+
.then(()=> this.debug('INFO', 2, 'Loaded project list', this.projects)),
|
|
232
232
|
]))
|
|
233
|
+
.then(()=> this.debug('INFO', 1, 'Ready'))
|
|
233
234
|
}
|
|
234
235
|
}
|
package/plugins/vue3.js
CHANGED
|
@@ -48,8 +48,6 @@ export default class TeraFyPluginVue extends TeraFyPluginBase {
|
|
|
48
48
|
autoRequire: settings.autoRequire ,
|
|
49
49
|
}))
|
|
50
50
|
.then(snapshot => {
|
|
51
|
-
this.debug('Fetched project snapshot', snapshot);
|
|
52
|
-
|
|
53
51
|
// Create initial reactive
|
|
54
52
|
let stateReactive = reactive(snapshot);
|
|
55
53
|
|
|
@@ -161,13 +159,14 @@ export default class TeraFyPluginVue extends TeraFyPluginBase {
|
|
|
161
159
|
// Bind available project and wait on it
|
|
162
160
|
settings.subscribeState && $tera.bindProjectState(settings.stateOptions)
|
|
163
161
|
.then(state => $tera.state = state)
|
|
164
|
-
.then(()=> $tera.debug('INFO', 'Loaded project state', $tera.state)),
|
|
162
|
+
.then(()=> $tera.debug('INFO', 1, 'Loaded initial project state', $tera.state)),
|
|
165
163
|
|
|
166
164
|
// Fetch available projects
|
|
167
165
|
settings.subscribeProjects && $tera.getProjects()
|
|
168
166
|
.then(projects => $tera.projects = reactive(projects))
|
|
169
|
-
.then(()=> $tera.debug('INFO', 'Loaded
|
|
167
|
+
.then(()=> $tera.debug('INFO', 2, 'Loaded project list', $tera.projects)),
|
|
170
168
|
]))
|
|
169
|
+
.then(()=> this.debug('INFO', 1, 'Ready'))
|
|
171
170
|
|
|
172
171
|
|
|
173
172
|
// Make this module available globally
|