@iebh/tera-fy 1.6.1 → 1.7.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 +20 -0
- package/api.md +316 -278
- package/dist/terafy.es2019.js +2 -2
- package/dist/terafy.js +2 -2
- package/lib/terafy.client.js +40 -4
- package/lib/terafy.server.js +83 -15
- package/package.json +2 -2
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 c=(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:f,basePath:m,basePathForRemoves:x,diffs:v}){var j=Object.keys(i),O=j.length,y=Object.keys(f),_=y.length,b,p=i.length-f.length;if(To(i,f)){for(var u=0;u<O;u++){var l=Array.isArray(i)?Number(j[u]):j[u];l in f||(b=x.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<_;u++){var l=Array.isArray(f)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:f,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=x.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:f,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:f,obj2:m,path:x,pathForRemoves:v,diffs:j}){var O=f[i],y=m[i];if(!(i in f)&&i in m){var _=y;j.add.push({op:"add",path:r(x),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)?n(x,j,y):o({obj1:f[i],obj2:m[i],basePath:x,basePathForRemoves:v,diffs:j}))}function n(i,f,m){f.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 n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)a++;return o>=a}return!0}var Oo=typeof global=="object"&&global&&global.Object===Object&&global,ht=Oo;var So=typeof self=="object"&&self&&self.Object===Object&&self,jo=ht||So||Function("return this")(),g=jo;var Ao=g.Symbol,T=Ao;var re=Object.prototype,Po=re.hasOwnProperty,Io=re.toString,mt=T?T.toStringTag:void 0;function _o(t){var e=Po.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 Fo(t){return Co.call(t)}var ae=Fo;var Mo="[object Null]",No="[object Undefined]",ie=T?T.toStringTag:void 0;function Ro(t){return t==null?t===void 0?No:Mo:ie&&ie in Object(t)?oe(t):ae(t)}var I=Ro;function Bo(t){return t!=null&&typeof t=="object"}var P=Bo;var Lo="[object Symbol]";function Do(t){return typeof t=="symbol"||P(t)&&I(t)==Lo}var G=Do;function Uo(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=Uo;var ko=Array.isArray,w=ko;var zo=1/0,ne=T?T.prototype:void 0,fe=ne?ne.toString:void 0;function pe(t){if(typeof t=="string")return t;if(w(t))return se(t,pe)+"";if(G(t))return fe?fe.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 A=Ko;function Go(t){return t}var me=Go;var Wo="[object AsyncFunction]",$o="[object Function]",Ho="[object GeneratorFunction]",qo="[object Proxy]";function Yo(t){if(!A(t))return!1;var e=I(t);return e==$o||e==Ho||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 na(t){if(!A(t)||de(t))return!1;var e=xt(t)?sa:ea;return e.test(C(t))}var ce=na;function fa(t,e){return t==null?void 0:t[e]}var he=fa;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(!A(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),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 Se=Ta;var Oa=9007199254740991,Sa=/^(?:0|[1-9]\d*)$/;function ja(t,e){var r=typeof t;return e=e==null?Oa:e,!!e&&(r=="number"||r!="symbol"&&Sa.test(t))&&t>-1&&t%1==0&&t<e}var $=ja;function Aa(t,e,r){e=="__proto__"&&W?W(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var bt=Aa;function Pa(t,e){return t===e||t!==t&&e!==e}var vt=Pa;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 H=Ea;function Ca(t,e,r,o){var a=!r;r||(r={});for(var s=-1,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?bt(r,i,f):H(r,i,f)}return r}var N=Ca;var je=Math.max;function Fa(t,e,r){return e=je(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=je(o.length-e,0),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),ye(t,this,i)}}var Ae=Fa;var Ma=9007199254740991;function Na(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ma}var q=Na;function Ra(t){return t!=null&&q(t.length)&&!xt(t)}var wt=Ra;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 Pe=Da;var Ua="[object Arguments]";function ka(t){return P(t)&&I(t)==Ua}var Rt=ka;var Ie=Object.prototype,za=Ie.hasOwnProperty,Ka=Ie.propertyIsEnumerable,Ga=Rt(function(){return arguments}())?Rt:function(t){return P(t)&&za.call(t,"callee")&&!Ka.call(t,"callee")},V=Ga;function Wa(){return!1}var _e=Wa;var Fe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ee=Fe&&typeof module=="object"&&module&&!module.nodeType&&module,$a=Ee&&Ee.exports===Fe,Ce=$a?g.Buffer:void 0,Ha=Ce?Ce.isBuffer:void 0,qa=Ha||_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]",ni="[object ArrayBuffer]",fi="[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]",h={};h[pi]=h[li]=h[mi]=h[ui]=h[di]=h[ci]=h[hi]=h[xi]=h[gi]=!0;h[Ya]=h[Va]=h[ni]=h[Za]=h[fi]=h[Ja]=h[Xa]=h[Qa]=h[ti]=h[ei]=h[ri]=h[oi]=h[ai]=h[ii]=h[si]=!1;function yi(t){return P(t)&&q(t.length)&&!!h[I(t)]}var Me=yi;function bi(t){return function(e){return t(e)}}var Z=bi;var Ne=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ut=Ne&&typeof module=="object"&&module&&!module.nodeType&&module,vi=ut&&ut.exports===Ne,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{}}(),F=wi;var Re=F&&F.isTypedArray,Ti=Re?Z(Re):Me,Be=Ti;var Oi=Object.prototype,Si=Oi.hasOwnProperty;function ji(t,e){var r=w(t),o=!r&&V(t),a=!r&&!o&&Tt(t),s=!r&&!o&&!a&&Be(t),n=r||o||a||s,i=n?Pe(t.length,String):[],f=i.length;for(var m in t)(e||Si.call(t,m))&&!(n&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||$(m,f)))&&i.push(m);return i}var Ot=ji;function Ai(t,e){return function(r){return t(e(r))}}var St=Ai;var Pi=St(Object.keys,Object),Le=Pi;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 Fi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ue=Fi;var Mi=Object.prototype,Ni=Mi.hasOwnProperty;function Ri(t){if(!A(t))return Ue(t);var e=Y(t),r=[];for(var o in t)o=="constructor"&&(e||!Ni.call(t,o))||r.push(o);return r}var ke=Ri;function Bi(t){return wt(t)?Ot(t,!0):ke(t)}var X=Bi;var Li=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Di=/^\w*$/;function Ui(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=Ui;var ki=S(Object,"create"),M=ki;function zi(){this.__data__=M?M(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,$i=Wi.hasOwnProperty;function Hi(t){var e=this.__data__;if(M){var r=e[t];return r===Gi?void 0:r}return $i.call(e,t)?e[t]:void 0}var We=Hi;var qi=Object.prototype,Yi=qi.hasOwnProperty;function Vi(t){var e=this.__data__;return M?e[t]!==void 0:Yi.call(e,t)}var $e=Vi;var Zi="__lodash_hash_undefined__";function Ji(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?Zi:e,this}var He=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=$e;Q.prototype.set=He;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 R=Qi;var ts=Array.prototype,es=ts.splice;function rs(t){var e=this.__data__,r=R(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=R(e,t);return r<0?void 0:e[r][1]}var Ve=os;function as(t){return R(this.__data__,t)>-1}var Ze=as;function is(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 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=S(g,"Map"),L=ss;function ns(){this.size=0,this.__data__={hash:new Lt,map:new(L||B),string:new Lt}}var Xe=ns;function fs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Qe=fs;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 n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};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 nr=vs;function ws(t,e){return w(t)?t:ze(t,e)?[t]:sr(nr(t))}var U=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 Ss(t,e){e=U(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 fr=Ss;function js(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ot=js;var pr=T?T.isConcatSpreadable:void 0;function As(t){return w(t)||V(t)||!!(pr&&t&&t[pr])}var lr=As;function mr(t,e,r,o,a){var s=-1,n=t.length;for(r||(r=lr),a||(a=[]);++s<n;){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 Ps(t){var e=t==null?0:t.length;return e?ur(t,1):[]}var dr=Ps;function Is(t){return Oe(Ae(t,void 0,dr),t+"")}var cr=Is;var _s=St(Object.getPrototypeOf,Object),jt=_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 Fs(t){return this.__data__.get(t)}var gr=Fs;function Ms(t){return this.__data__.has(t)}var yr=Ms;var Ns=200;function Rs(t,e){var r=this.__data__;if(r instanceof B){var o=r.__data__;if(!L||o.length<Ns-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=Rs;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&&N(e,J(e),t)}var wr=Bs;function Ls(t,e){return t&&N(e,X(e),t)}var Tr=Ls;var Ar=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Or=Ar&&typeof module=="object"&&module&&!module.nodeType&&module,Ds=Or&&Or.exports===Ar,Sr=Ds?g.Buffer:void 0,jr=Sr?Sr.allocUnsafe:void 0;function Us(t,e){if(e)return t.slice();var r=t.length,o=jr?jr(r):new t.constructor(r);return t.copy(o),o}var Pr=Us;function ks(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var Ir=ks;function zs(){return[]}var At=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)}))}:At,it=Ws;function $s(t,e){return N(t,it(t),e)}var Er=$s;var Hs=Object.getOwnPropertySymbols,qs=Hs?function(t){for(var e=[];t;)ot(e,it(t)),t=jt(t);return e}:At,Pt=qs;function Ys(t,e){return N(t,Pt(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 Fr=Zs;function Js(t){return It(t,X,Pt)}var Mr=Js;var Xs=S(g,"DataView"),_t=Xs;var Qs=S(g,"Promise"),Et=Qs;var tn=S(g,"Set"),Ct=tn;var Nr="[object Map]",en="[object Object]",Rr="[object Promise]",Br="[object Set]",Lr="[object WeakMap]",Dr="[object DataView]",rn=C(_t),on=C(L),an=C(Et),sn=C(Ct),nn=C(yt),z=I;(_t&&z(new _t(new ArrayBuffer(1)))!=Dr||L&&z(new L)!=Nr||Et&&z(Et.resolve())!=Rr||Ct&&z(new Ct)!=Br||yt&&z(new yt)!=Lr)&&(z=function(t){var e=I(t),r=e==en?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case rn:return Dr;case on:return Nr;case an:return Rr;case sn:return Br;case nn:return Lr}return e});var st=z;var fn=Object.prototype,pn=fn.hasOwnProperty;function ln(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&pn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ur=ln;var mn=g.Uint8Array,Ut=mn;function un(t){var e=new t.constructor(t.byteLength);return new Ut(e).set(new Ut(t)),e}var nt=un;function dn(t,e){var r=e?nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var kr=dn;var cn=/\w*$/;function hn(t){var e=new t.constructor(t.source,cn.exec(t));return e.lastIndex=t.lastIndex,e}var zr=hn;var Kr=T?T.prototype:void 0,Gr=Kr?Kr.valueOf:void 0;function xn(t){return Gr?Object(Gr.call(t)):{}}var Wr=xn;function gn(t,e){var r=e?nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var $r=gn;var yn="[object Boolean]",bn="[object Date]",vn="[object Map]",wn="[object Number]",Tn="[object RegExp]",On="[object Set]",Sn="[object String]",jn="[object Symbol]",An="[object ArrayBuffer]",Pn="[object DataView]",In="[object Float32Array]",_n="[object Float64Array]",En="[object Int8Array]",Cn="[object Int16Array]",Fn="[object Int32Array]",Mn="[object Uint8Array]",Nn="[object Uint8ClampedArray]",Rn="[object Uint16Array]",Bn="[object Uint32Array]";function Ln(t,e,r){var o=t.constructor;switch(e){case An:return nt(t);case yn:case bn:return new o(+t);case Pn:return kr(t,r);case In:case _n:case En:case Cn:case Fn:case Mn:case Nn:case Rn:case Bn:return $r(t,r);case vn:return new o;case wn:case Sn:return new o(t);case Tn:return zr(t);case On:return new o;case jn:return Wr(t)}}var Hr=Ln;function Dn(t){return typeof t.constructor=="function"&&!Y(t)?ge(jt(t)):{}}var qr=Dn;var Un="[object Map]";function kn(t){return P(t)&&st(t)==Un}var Yr=kn;var Vr=F&&F.isMap,zn=Vr?Z(Vr):Yr,Zr=zn;var Kn="[object Set]";function Gn(t){return P(t)&&st(t)==Kn}var Jr=Gn;var Xr=F&&F.isSet,Wn=Xr?Z(Xr):Jr,Qr=Wn;var $n=1,Hn=2,qn=4,to="[object Arguments]",Yn="[object Array]",Vn="[object Boolean]",Zn="[object Date]",Jn="[object Error]",eo="[object Function]",Xn="[object GeneratorFunction]",Qn="[object Map]",tf="[object Number]",ro="[object Object]",ef="[object RegExp]",rf="[object Set]",of="[object String]",af="[object Symbol]",sf="[object WeakMap]",nf="[object ArrayBuffer]",ff="[object DataView]",pf="[object Float32Array]",lf="[object Float64Array]",mf="[object Int8Array]",uf="[object Int16Array]",df="[object Int32Array]",cf="[object Uint8Array]",hf="[object Uint8ClampedArray]",xf="[object Uint16Array]",gf="[object Uint32Array]",d={};d[to]=d[Yn]=d[nf]=d[ff]=d[Vn]=d[Zn]=d[pf]=d[lf]=d[mf]=d[uf]=d[df]=d[Qn]=d[tf]=d[ro]=d[ef]=d[rf]=d[of]=d[af]=d[cf]=d[hf]=d[xf]=d[gf]=!0;d[Jn]=d[eo]=d[sf]=!1;function Ft(t,e,r,o,a,s){var n,i=e&$n,f=e&Hn,m=e&qn;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!A(t))return t;var x=w(t);if(x){if(n=Ur(t),!i)return be(t,n)}else{var v=st(t),j=v==eo||v==Xn;if(Tt(t))return Pr(t,i);if(v==ro||v==to||j&&!a){if(n=f||j?{}:qr(t),!i)return f?Cr(t,Tr(n,t)):Er(t,wr(n,t))}else{if(!d[v])return a?t:{};n=Hr(t,v,i)}}s||(s=new vr);var O=s.get(t);if(O)return O;s.set(t,n),Qr(t)?t.forEach(function(b){n.add(Ft(b,e,r,b,t,s))}):Zr(t)&&t.forEach(function(b,p){n.set(p,Ft(b,e,r,p,t,s))});var y=m?f?Mr:Fr:f?X:J,_=x?void 0:y(t);return Se(_||t,function(b,p){_&&(p=b,b=t[p]),H(n,p,Ft(b,e,r,p,t,s))}),n}var oo=Ft;var yf=1,bf=4;function vf(t){return oo(t,yf|bf)}var kt=vf;function wf(t,e){return t!=null&&e in Object(t)}var ao=wf;function Tf(t,e,r){e=U(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=rt(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&q(a)&&$(n,a)&&(w(t)||V(t)))}var io=Tf;function Of(t,e){return t!=null&&io(t,e,ao)}var so=Of;function Sf(t,e,r,o){if(!A(t))return t;e=U(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=rt(e[a]),m=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var x=i[f];m=o?o(x,f,i):void 0,m===void 0&&(m=A(x)?x:$(e[a+1])?[]:{})}H(i,f,m),i=i[f]}return t}var no=Sf;function jf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=fr(t,n);r(i,n)&&no(s,U(n,t),i)}return s}var fo=jf;function Af(t,e){return fo(t,e,function(r,o){return so(t,o)})}var po=Af;var Pf=cr(function(t,e){return t==null?{}:po(t,e)}),Mt=Pf;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 If="array",_f="bit",mo="bits",Ef="byte",uo="bytes",ft="",Cf="exponent",Ff="function",co="iec",Mf="Invalid number",Nf="Invalid rounding method",Kt="jedec",Rf="object",ho=".",Bf="round",Lf="s",Df="si",Uf="kbit",kf="kB",zf=" ",Kf="string",Gf="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=ft,localeOptions:n={},separator:i=ft,spacer:f=zf,symbols:m={},standard:x=ft,output:v=Kf,fullform:j=!1,fullforms:O=[],exponent:y=-1,roundingMethod:_=Bf,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Nt=ft;x===Df?(o=10,x=Kt):x===co||x===Kt?o=2:o===2?x=co:(o=10,x=Kt);let ct=o===10?1e3:1024,go=j===!0,Ht=u<0,qt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Mf);if(typeof qt!==Ff)throw new TypeError(Nf);if(Ht&&(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===Cf)return p;if(u===0)l[0]=0,Nt=l[1]=Gt.symbol[x][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++),Nt=l[1]=o===10&&p===1?e?Uf:kf:Gt.symbol[x][e?mo:uo][p]}if(Ht&&(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,n):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]||ft,Zt=Vt.length,yo=a-Zt;l[0]=`${Yt[0]}${pt}${Vt.padEnd(Zt+yo,Gf)}`}return go&&(l[1]=O[p]?O[p]:Gt.fullform[x][p]+(e?_f:Ef)+(l[0]===1?ft:Lf)),v===If?l:v===Rf?{value:l[0],symbol:l[1],exponent:p,unit:Nt}:l.join(f)}var k,Wt=class Wt{constructor(e){Xt(this,k,void 0);c(this,"id");c(this,"name");c(this,"icon");c(this,"path");c(this,"url");c(this,"teraUrl");c(this,"parsedName");c(this,"created");c(this,"createdFormatted");c(this,"modified");c(this,"modifiedFormatted");c(this,"accessed");c(this,"accessedFormatted");c(this,"size");c(this,"sizeFormatted");c(this,"mime");c(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,k,e.tera),this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/,"/project/$1"),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,k).getProjectFile(this.id)}setContents(e){return lt(this,k).setProjectFile(this.id,e)}getRefs(){return lt(this,k).getProjectLibrary(this.id)}setRefs(e){return lt(this,k).setProjectLibrary(this.id,e)}serialize(){return Mt(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new Wt(Mt(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};k=new WeakMap;var K=Wt;var $t=class{constructor(e){c(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});c(this,"events",lo());c(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});c(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","setPageTitle","uiAlert","uiSplat","uiWindow"]);c(this,"plugins",[]);c(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(),...kt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;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.debug("INFO",4,"[0/5] Init using server",this.settings.siteUrl)).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/5] Setting client mode to",o),this.settings.mode=o}).then(()=>this.debug("INFO",4,"[2/5] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.debug("INFO",4,"[3/5] Set server mode")).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[4/5] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[5/5] Init complete")).catch(o=>this.debug("WARN",0,"Init caught error",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){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
|
|
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 c=(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:f,basePath:m,basePathForRemoves:x,diffs:v}){var P=Object.keys(i),O=P.length,y=Object.keys(f),_=y.length,b,p=i.length-f.length;if(To(i,f)){for(var u=0;u<O;u++){var l=Array.isArray(i)?Number(P[u]):P[u];l in f||(b=x.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<_;u++){var l=Array.isArray(f)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:f,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=x.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:f,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:f,obj2:m,path:x,pathForRemoves:v,diffs:P}){var O=f[i],y=m[i];if(!(i in f)&&i in m){var _=y;P.add.push({op:"add",path:r(x),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)?n(x,P,y):o({obj1:f[i],obj2:m[i],basePath:x,basePathForRemoves:v,diffs:P}))}function n(i,f,m){f.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 n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)a++;return o>=a}return!0}var Oo=typeof global=="object"&&global&&global.Object===Object&&global,ht=Oo;var jo=typeof self=="object"&&self&&self.Object===Object&&self,Po=ht||jo||Function("return this")(),g=Po;var So=g.Symbol,T=So;var re=Object.prototype,Ao=re.hasOwnProperty,Io=re.toString,mt=T?T.toStringTag:void 0;function _o(t){var e=Ao.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 Fo(t){return Co.call(t)}var ae=Fo;var Mo="[object Null]",No="[object Undefined]",ie=T?T.toStringTag:void 0;function Ro(t){return t==null?t===void 0?No:Mo:ie&&ie in Object(t)?oe(t):ae(t)}var I=Ro;function Bo(t){return t!=null&&typeof t=="object"}var A=Bo;var Lo="[object Symbol]";function Do(t){return typeof t=="symbol"||A(t)&&I(t)==Lo}var G=Do;function Uo(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=Uo;var ko=Array.isArray,w=ko;var zo=1/0,ne=T?T.prototype:void 0,fe=ne?ne.toString:void 0;function pe(t){if(typeof t=="string")return t;if(w(t))return se(t,pe)+"";if(G(t))return fe?fe.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 S=Ko;function Go(t){return t}var me=Go;var Wo="[object AsyncFunction]",$o="[object Function]",Ho="[object GeneratorFunction]",qo="[object Proxy]";function Yo(t){if(!S(t))return!1;var e=I(t);return e==$o||e==Ho||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 na(t){if(!S(t)||de(t))return!1;var e=xt(t)?sa:ea;return e.test(C(t))}var ce=na;function fa(t,e){return t==null?void 0:t[e]}var he=fa;function pa(t,e){var r=he(t,e);return ce(r)?r:void 0}var j=pa;var la=j(g,"WeakMap"),yt=la;var xe=Object.create,ma=function(){function t(){}return function(e){if(!S(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=j(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 je=Ta;var Oa=9007199254740991,ja=/^(?:0|[1-9]\d*)$/;function Pa(t,e){var r=typeof t;return e=e==null?Oa:e,!!e&&(r=="number"||r!="symbol"&&ja.test(t))&&t>-1&&t%1==0&&t<e}var $=Pa;function Sa(t,e,r){e=="__proto__"&&W?W(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var bt=Sa;function Aa(t,e){return t===e||t!==t&&e!==e}var vt=Aa;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 H=Ea;function Ca(t,e,r,o){var a=!r;r||(r={});for(var s=-1,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?bt(r,i,f):H(r,i,f)}return r}var N=Ca;var Pe=Math.max;function Fa(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),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),ye(t,this,i)}}var Se=Fa;var Ma=9007199254740991;function Na(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ma}var q=Na;function Ra(t){return t!=null&&q(t.length)&&!xt(t)}var wt=Ra;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 Ae=Da;var Ua="[object Arguments]";function ka(t){return A(t)&&I(t)==Ua}var Rt=ka;var Ie=Object.prototype,za=Ie.hasOwnProperty,Ka=Ie.propertyIsEnumerable,Ga=Rt(function(){return arguments}())?Rt:function(t){return A(t)&&za.call(t,"callee")&&!Ka.call(t,"callee")},V=Ga;function Wa(){return!1}var _e=Wa;var Fe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ee=Fe&&typeof module=="object"&&module&&!module.nodeType&&module,$a=Ee&&Ee.exports===Fe,Ce=$a?g.Buffer:void 0,Ha=Ce?Ce.isBuffer:void 0,qa=Ha||_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]",ni="[object ArrayBuffer]",fi="[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]",h={};h[pi]=h[li]=h[mi]=h[ui]=h[di]=h[ci]=h[hi]=h[xi]=h[gi]=!0;h[Ya]=h[Va]=h[ni]=h[Za]=h[fi]=h[Ja]=h[Xa]=h[Qa]=h[ti]=h[ei]=h[ri]=h[oi]=h[ai]=h[ii]=h[si]=!1;function yi(t){return A(t)&&q(t.length)&&!!h[I(t)]}var Me=yi;function bi(t){return function(e){return t(e)}}var Z=bi;var Ne=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ut=Ne&&typeof module=="object"&&module&&!module.nodeType&&module,vi=ut&&ut.exports===Ne,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{}}(),F=wi;var Re=F&&F.isTypedArray,Ti=Re?Z(Re):Me,Be=Ti;var Oi=Object.prototype,ji=Oi.hasOwnProperty;function Pi(t,e){var r=w(t),o=!r&&V(t),a=!r&&!o&&Tt(t),s=!r&&!o&&!a&&Be(t),n=r||o||a||s,i=n?Ae(t.length,String):[],f=i.length;for(var m in t)(e||ji.call(t,m))&&!(n&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||$(m,f)))&&i.push(m);return i}var Ot=Pi;function Si(t,e){return function(r){return t(e(r))}}var jt=Si;var Ai=jt(Object.keys,Object),Le=Ai;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 Fi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ue=Fi;var Mi=Object.prototype,Ni=Mi.hasOwnProperty;function Ri(t){if(!S(t))return Ue(t);var e=Y(t),r=[];for(var o in t)o=="constructor"&&(e||!Ni.call(t,o))||r.push(o);return r}var ke=Ri;function Bi(t){return wt(t)?Ot(t,!0):ke(t)}var X=Bi;var Li=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Di=/^\w*$/;function Ui(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=Ui;var ki=j(Object,"create"),M=ki;function zi(){this.__data__=M?M(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,$i=Wi.hasOwnProperty;function Hi(t){var e=this.__data__;if(M){var r=e[t];return r===Gi?void 0:r}return $i.call(e,t)?e[t]:void 0}var We=Hi;var qi=Object.prototype,Yi=qi.hasOwnProperty;function Vi(t){var e=this.__data__;return M?e[t]!==void 0:Yi.call(e,t)}var $e=Vi;var Zi="__lodash_hash_undefined__";function Ji(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?Zi:e,this}var He=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=$e;Q.prototype.set=He;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 R=Qi;var ts=Array.prototype,es=ts.splice;function rs(t){var e=this.__data__,r=R(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=R(e,t);return r<0?void 0:e[r][1]}var Ve=os;function as(t){return R(this.__data__,t)>-1}var Ze=as;function is(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 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=j(g,"Map"),L=ss;function ns(){this.size=0,this.__data__={hash:new Lt,map:new(L||B),string:new Lt}}var Xe=ns;function fs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Qe=fs;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 n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};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 nr=vs;function ws(t,e){return w(t)?t:ze(t,e)?[t]:sr(nr(t))}var U=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 js(t,e){e=U(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 fr=js;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 Ss(t){return w(t)||V(t)||!!(pr&&t&&t[pr])}var lr=Ss;function mr(t,e,r,o,a){var s=-1,n=t.length;for(r||(r=lr),a||(a=[]);++s<n;){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 As(t){var e=t==null?0:t.length;return e?ur(t,1):[]}var dr=As;function Is(t){return Oe(Se(t,void 0,dr),t+"")}var cr=Is;var _s=jt(Object.getPrototypeOf,Object),Pt=_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 Fs(t){return this.__data__.get(t)}var gr=Fs;function Ms(t){return this.__data__.has(t)}var yr=Ms;var Ns=200;function Rs(t,e){var r=this.__data__;if(r instanceof B){var o=r.__data__;if(!L||o.length<Ns-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=Rs;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&&N(e,J(e),t)}var wr=Bs;function Ls(t,e){return t&&N(e,X(e),t)}var Tr=Ls;var Sr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Or=Sr&&typeof module=="object"&&module&&!module.nodeType&&module,Ds=Or&&Or.exports===Sr,jr=Ds?g.Buffer:void 0,Pr=jr?jr.allocUnsafe:void 0;function Us(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 Ar=Us;function ks(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var Ir=ks;function zs(){return[]}var St=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)}))}:St,it=Ws;function $s(t,e){return N(t,it(t),e)}var Er=$s;var Hs=Object.getOwnPropertySymbols,qs=Hs?function(t){for(var e=[];t;)ot(e,it(t)),t=Pt(t);return e}:St,At=qs;function Ys(t,e){return N(t,At(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 Fr=Zs;function Js(t){return It(t,X,At)}var Mr=Js;var Xs=j(g,"DataView"),_t=Xs;var Qs=j(g,"Promise"),Et=Qs;var tn=j(g,"Set"),Ct=tn;var Nr="[object Map]",en="[object Object]",Rr="[object Promise]",Br="[object Set]",Lr="[object WeakMap]",Dr="[object DataView]",rn=C(_t),on=C(L),an=C(Et),sn=C(Ct),nn=C(yt),K=I;(_t&&K(new _t(new ArrayBuffer(1)))!=Dr||L&&K(new L)!=Nr||Et&&K(Et.resolve())!=Rr||Ct&&K(new Ct)!=Br||yt&&K(new yt)!=Lr)&&(K=function(t){var e=I(t),r=e==en?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case rn:return Dr;case on:return Nr;case an:return Rr;case sn:return Br;case nn:return Lr}return e});var st=K;var fn=Object.prototype,pn=fn.hasOwnProperty;function ln(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&pn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ur=ln;var mn=g.Uint8Array,Ut=mn;function un(t){var e=new t.constructor(t.byteLength);return new Ut(e).set(new Ut(t)),e}var nt=un;function dn(t,e){var r=e?nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var kr=dn;var cn=/\w*$/;function hn(t){var e=new t.constructor(t.source,cn.exec(t));return e.lastIndex=t.lastIndex,e}var zr=hn;var Kr=T?T.prototype:void 0,Gr=Kr?Kr.valueOf:void 0;function xn(t){return Gr?Object(Gr.call(t)):{}}var Wr=xn;function gn(t,e){var r=e?nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var $r=gn;var yn="[object Boolean]",bn="[object Date]",vn="[object Map]",wn="[object Number]",Tn="[object RegExp]",On="[object Set]",jn="[object String]",Pn="[object Symbol]",Sn="[object ArrayBuffer]",An="[object DataView]",In="[object Float32Array]",_n="[object Float64Array]",En="[object Int8Array]",Cn="[object Int16Array]",Fn="[object Int32Array]",Mn="[object Uint8Array]",Nn="[object Uint8ClampedArray]",Rn="[object Uint16Array]",Bn="[object Uint32Array]";function Ln(t,e,r){var o=t.constructor;switch(e){case Sn:return nt(t);case yn:case bn:return new o(+t);case An:return kr(t,r);case In:case _n:case En:case Cn:case Fn:case Mn:case Nn:case Rn:case Bn:return $r(t,r);case vn:return new o;case wn:case jn:return new o(t);case Tn:return zr(t);case On:return new o;case Pn:return Wr(t)}}var Hr=Ln;function Dn(t){return typeof t.constructor=="function"&&!Y(t)?ge(Pt(t)):{}}var qr=Dn;var Un="[object Map]";function kn(t){return A(t)&&st(t)==Un}var Yr=kn;var Vr=F&&F.isMap,zn=Vr?Z(Vr):Yr,Zr=zn;var Kn="[object Set]";function Gn(t){return A(t)&&st(t)==Kn}var Jr=Gn;var Xr=F&&F.isSet,Wn=Xr?Z(Xr):Jr,Qr=Wn;var $n=1,Hn=2,qn=4,to="[object Arguments]",Yn="[object Array]",Vn="[object Boolean]",Zn="[object Date]",Jn="[object Error]",eo="[object Function]",Xn="[object GeneratorFunction]",Qn="[object Map]",tf="[object Number]",ro="[object Object]",ef="[object RegExp]",rf="[object Set]",of="[object String]",af="[object Symbol]",sf="[object WeakMap]",nf="[object ArrayBuffer]",ff="[object DataView]",pf="[object Float32Array]",lf="[object Float64Array]",mf="[object Int8Array]",uf="[object Int16Array]",df="[object Int32Array]",cf="[object Uint8Array]",hf="[object Uint8ClampedArray]",xf="[object Uint16Array]",gf="[object Uint32Array]",d={};d[to]=d[Yn]=d[nf]=d[ff]=d[Vn]=d[Zn]=d[pf]=d[lf]=d[mf]=d[uf]=d[df]=d[Qn]=d[tf]=d[ro]=d[ef]=d[rf]=d[of]=d[af]=d[cf]=d[hf]=d[xf]=d[gf]=!0;d[Jn]=d[eo]=d[sf]=!1;function Ft(t,e,r,o,a,s){var n,i=e&$n,f=e&Hn,m=e&qn;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!S(t))return t;var x=w(t);if(x){if(n=Ur(t),!i)return be(t,n)}else{var v=st(t),P=v==eo||v==Xn;if(Tt(t))return Ar(t,i);if(v==ro||v==to||P&&!a){if(n=f||P?{}:qr(t),!i)return f?Cr(t,Tr(n,t)):Er(t,wr(n,t))}else{if(!d[v])return a?t:{};n=Hr(t,v,i)}}s||(s=new vr);var O=s.get(t);if(O)return O;s.set(t,n),Qr(t)?t.forEach(function(b){n.add(Ft(b,e,r,b,t,s))}):Zr(t)&&t.forEach(function(b,p){n.set(p,Ft(b,e,r,p,t,s))});var y=m?f?Mr:Fr:f?X:J,_=x?void 0:y(t);return je(_||t,function(b,p){_&&(p=b,b=t[p]),H(n,p,Ft(b,e,r,p,t,s))}),n}var oo=Ft;var yf=1,bf=4;function vf(t){return oo(t,yf|bf)}var kt=vf;function wf(t,e){return t!=null&&e in Object(t)}var ao=wf;function Tf(t,e,r){e=U(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=rt(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&q(a)&&$(n,a)&&(w(t)||V(t)))}var io=Tf;function Of(t,e){return t!=null&&io(t,e,ao)}var so=Of;function jf(t,e,r,o){if(!S(t))return t;e=U(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=rt(e[a]),m=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var x=i[f];m=o?o(x,f,i):void 0,m===void 0&&(m=S(x)?x:$(e[a+1])?[]:{})}H(i,f,m),i=i[f]}return t}var no=jf;function Pf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=fr(t,n);r(i,n)&&no(s,U(n,t),i)}return s}var fo=Pf;function Sf(t,e){return fo(t,e,function(r,o){return so(t,o)})}var po=Sf;var Af=cr(function(t,e){return t==null?{}:po(t,e)}),Mt=Af;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 If="array",_f="bit",mo="bits",Ef="byte",uo="bytes",ft="",Cf="exponent",Ff="function",co="iec",Mf="Invalid number",Nf="Invalid rounding method",Kt="jedec",Rf="object",ho=".",Bf="round",Lf="s",Df="si",Uf="kbit",kf="kB",zf=" ",Kf="string",Gf="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=ft,localeOptions:n={},separator:i=ft,spacer:f=zf,symbols:m={},standard:x=ft,output:v=Kf,fullform:P=!1,fullforms:O=[],exponent:y=-1,roundingMethod:_=Bf,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Nt=ft;x===Df?(o=10,x=Kt):x===co||x===Kt?o=2:o===2?x=co:(o=10,x=Kt);let ct=o===10?1e3:1024,go=P===!0,Ht=u<0,qt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Mf);if(typeof qt!==Ff)throw new TypeError(Nf);if(Ht&&(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===Cf)return p;if(u===0)l[0]=0,Nt=l[1]=Gt.symbol[x][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++),Nt=l[1]=o===10&&p===1?e?Uf:kf:Gt.symbol[x][e?mo:uo][p]}if(Ht&&(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,n):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]||ft,Zt=Vt.length,yo=a-Zt;l[0]=`${Yt[0]}${pt}${Vt.padEnd(Zt+yo,Gf)}`}return go&&(l[1]=O[p]?O[p]:Gt.fullform[x][p]+(e?_f:Ef)+(l[0]===1?ft:Lf)),v===If?l:v===Rf?{value:l[0],symbol:l[1],exponent:p,unit:Nt}:l.join(f)}var k,Wt=class Wt{constructor(e){Xt(this,k,void 0);c(this,"id");c(this,"name");c(this,"icon");c(this,"path");c(this,"url");c(this,"teraUrl");c(this,"parsedName");c(this,"created");c(this,"createdFormatted");c(this,"modified");c(this,"modifiedFormatted");c(this,"accessed");c(this,"accessedFormatted");c(this,"size");c(this,"sizeFormatted");c(this,"mime");c(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,k,e.tera),this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/,"/project/$1"),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,k).getProjectFile(this.id)}setContents(e){return lt(this,k).setProjectFile(this.id,e)}getRefs(){return lt(this,k).getProjectLibrary(this.id)}setRefs(e){return lt(this,k).setProjectLibrary(this.id,e)}serialize(){return Mt(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new Wt(Mt(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};k=new WeakMap;var z=Wt;var $t=class{constructor(e){c(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});c(this,"events",lo());c(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});c(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","applyProjectStatePatch","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","setPageTitle","uiAlert","uiSplat","uiWindow"]);c(this,"plugins",[]);c(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(),...kt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;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.debug("INFO",4,"[0/5] Init using server",this.settings.siteUrl)).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/5] Setting client mode to",o),this.settings.mode=o}).then(()=>this.debug("INFO",4,"[2/5] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.debug("INFO",4,"[3/5] Set server mode")).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[4/5] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[5/5] Init complete")).catch(o=>this.debug("WARN",0,"Init caught error",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){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 z({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new z({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new z({tera:this,...r}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new z({tera:this,...r}))}};export{$t 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:f,basePath:m,basePathForRemoves:h,diffs:b}){var S=Object.keys(i),T=S.length,g=Object.keys(f),I=g.length,y,p=i.length-f.length;if(uo(i,f)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(S[u]):S[u];l in f||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<I;u++){var l=Array.isArray(f)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:f,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:f,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:f,obj2:m,path:h,pathForRemoves:b,diffs:S}){var T=f[i],g=m[i];if(!(i in f)&&i in m){var I=g;S.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)?n(h,S,g):o({obj1:f[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:S}))}function n(i,f,m){f.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 n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)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,ft=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,ft),r=t[ft];try{t[ft]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[ft]=r:delete t[ft]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Oo(t){return To.call(t)}var Jt=Oo;var So="[object Null]",jo="[object Undefined]",Xt=w?w.toStringTag:void 0;function Ao(t){return t==null?t===void 0?jo:So:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var P=Ao;function Po(t){return t!=null&&typeof t=="object"}var A=Po;var Io="[object Symbol]";function _o(t){return typeof t=="symbol"||A(t)&&P(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 Fo=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==-Fo?"-0":e}var oe=re;function Mo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var j=Mo;function No(t){return t}var ae=No;var Ro="[object AsyncFunction]",Bo="[object Function]",Lo="[object GeneratorFunction]",Do="[object Proxy]";function Uo(t){if(!j(t))return!1;var e=P(t);return e==Bo||e==Lo||e==Ro||e==Do}var dt=Uo;var ko=x["__core-js_shared__"],ct=ko;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 $o=/[\\^$.*+?()[\]{}|]/g,Ho=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Vo=qo.toString,Zo=Yo.hasOwnProperty,Jo=RegExp("^"+Vo.call(Zo).replace($o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xo(t){if(!j(t)||se(t))return!1;var e=dt(t)?Jo:Ho;return e.test(E(t))}var ne=Xo;function Qo(t,e){return t?.[e]}var fe=Qo;function ta(t,e){var r=fe(t,e);return ne(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(!j(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,na=Date.now;function fa(t){var e=0,r=0;return function(){var o=na(),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=fa;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,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?xt(r,i,f):W(r,i,f)}return r}var M=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),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),me(t,this,i)}}var be=Oa;var Sa=9007199254740991;function ja(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Sa}var $=ja;function Aa(t){return t!=null&&$(t.length)&&!dt(t)}var yt=Aa;var Pa=Object.prototype;function Ia(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Pa;return t===r}var H=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 A(t)&&P(t)==Ea}var Ft=Ca;var we=Object.prototype,Fa=we.hasOwnProperty,Ma=we.propertyIsEnumerable,Na=Ft(function(){return arguments}())?Ft:function(t){return A(t)&&Fa.call(t,"callee")&&!Ma.call(t,"callee")},q=Na;function Ra(){return!1}var Te=Ra;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=je&&typeof module=="object"&&module&&!module.nodeType&&module,Ba=Oe&&Oe.exports===je,Se=Ba?x.Buffer:void 0,La=Se?Se.isBuffer:void 0,Da=La||Te,bt=Da;var Ua="[object Arguments]",ka="[object Array]",za="[object Boolean]",Ka="[object Date]",Ga="[object Error]",Wa="[object Function]",$a="[object Map]",Ha="[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]",ni="[object Uint16Array]",fi="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[ni]=c[fi]=!0;c[Ua]=c[ka]=c[Xa]=c[za]=c[Qa]=c[Ka]=c[Ga]=c[Wa]=c[$a]=c[Ha]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=!1;function pi(t){return A(t)&&$(t.length)&&!!c[P(t)]}var Ae=pi;function li(t){return function(e){return t(e)}}var Y=li;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===Pe,Mt=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch{}}(),C=ui;var Ie=C&&C.isTypedArray,di=Ie?Y(Ie):Ae,_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),n=r||o||a||s,i=n?ve(t.length,String):[],f=i.length;for(var m in t)(e||hi.call(t,m))&&!(n&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,f)))&&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(!H(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 Fe=Oi;var Si=Object.prototype,ji=Si.hasOwnProperty;function Ai(t){if(!j(t))return Fe(t);var e=H(t),r=[];for(var o in t)o=="constructor"&&(e||!ji.call(t,o))||r.push(o);return r}var Me=Ai;function Pi(t){return yt(t)?vt(t,!0):Me(t)}var Z=Pi;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 Ne=Ei;var Ci=O(Object,"create"),F=Ci;function Fi(){this.__data__=F?F(null):{},this.size=0}var Re=Fi;function Mi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Mi;var Ni="__lodash_hash_undefined__",Ri=Object.prototype,Bi=Ri.hasOwnProperty;function Li(t){var e=this.__data__;if(F){var r=e[t];return r===Ni?void 0:r}return Bi.call(e,t)?e[t]:void 0}var Le=Li;var Di=Object.prototype,Ui=Di.hasOwnProperty;function ki(t){var e=this.__data__;return F?e[t]!==void 0:Ui.call(e,t)}var De=ki;var zi="__lodash_hash_undefined__";function Ki(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=F&&e===void 0?zi:e,this}var Ue=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=Re;J.prototype.delete=Be;J.prototype.get=Le;J.prototype.has=De;J.prototype.set=Ue;var Nt=J;function Gi(){this.__data__=[],this.size=0}var ke=Gi;function Wi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var N=Wi;var $i=Array.prototype,Hi=$i.splice;function qi(t){var e=this.__data__,r=N(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Hi.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=N(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return N(this.__data__,t)>-1}var Ge=Vi;function Zi(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 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=ke;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var R=X;var Ji=O(x,"Map"),B=Ji;function Xi(){this.size=0,this.__data__={hash:new Nt,map:new(B||R),string:new Nt}}var $e=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var He=Qi;function ts(t,e){var r=t.__data__;return He(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=$e;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 Rt(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 n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};return r.cache=new(Rt.Cache||lt),r}Rt.Cache=lt;var Je=Rt;var ss=500;function ns(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=ns;var fs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(fs,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:Ne(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,n=t.length;for(r||(r=or),a||(a=[]);++s<n;){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 nr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new R,this.size=0}var fr=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 Ss(t){return this.__data__.has(t)}var mr=Ss;var js=200;function As(t,e){var r=this.__data__;if(r instanceof R){var o=r.__data__;if(!B||o.length<js-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=As;function rt(t){var e=this.__data__=new R(t);this.size=e.size}rt.prototype.clear=fr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function Ps(t,e){return t&&M(e,V(e),t)}var cr=Ps;function Is(t,e){return t&&M(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 n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var wr=Cs;function Fs(){return[]}var Ot=Fs;var Ms=Object.prototype,Ns=Ms.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Rs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Ns.call(t,e)}))}:Ot,ot=Rs;function Bs(t,e){return M(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,St=Ds;function Us(t,e){return M(t,St(t),e)}var Sr=Us;function ks(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var jt=ks;function zs(t){return jt(t,V,ot)}var jr=zs;function Ks(t){return jt(t,Z,St)}var Ar=Ks;var Gs=O(x,"DataView"),At=Gs;var Ws=O(x,"Promise"),Pt=Ws;var $s=O(x,"Set"),It=$s;var Pr="[object Map]",Hs="[object Object]",Ir="[object Promise]",_r="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=E(At),Ys=E(B),Vs=E(Pt),Zs=E(It),Js=E(ht),U=P;(At&&U(new At(new ArrayBuffer(1)))!=Cr||B&&U(new B)!=Pr||Pt&&U(Pt.resolve())!=Ir||It&&U(new It)!=_r||ht&&U(new ht)!=Er)&&(U=function(t){var e=P(t),r=e==Hs?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Pr;case Vs:return Ir;case Zs:return _r;case Js:return Er}return e});var at=U;var Xs=Object.prototype,Qs=Xs.hasOwnProperty;function tn(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 Fr=tn;var en=x.Uint8Array,Bt=en;function rn(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var it=rn;function on(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Mr=on;var an=/\w*$/;function sn(t){var e=new t.constructor(t.source,an.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=sn;var Rr=w?w.prototype:void 0,Br=Rr?Rr.valueOf:void 0;function nn(t){return Br?Object(Br.call(t)):{}}var Lr=nn;function fn(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=fn;var pn="[object Boolean]",ln="[object Date]",mn="[object Map]",un="[object Number]",dn="[object RegExp]",cn="[object Set]",hn="[object String]",xn="[object Symbol]",gn="[object ArrayBuffer]",yn="[object DataView]",bn="[object Float32Array]",vn="[object Float64Array]",wn="[object Int8Array]",Tn="[object Int16Array]",On="[object Int32Array]",Sn="[object Uint8Array]",jn="[object Uint8ClampedArray]",An="[object Uint16Array]",Pn="[object Uint32Array]";function In(t,e,r){var o=t.constructor;switch(e){case gn:return it(t);case pn:case ln:return new o(+t);case yn:return Mr(t,r);case bn:case vn:case wn:case Tn:case On:case Sn:case jn:case An:case Pn:return Dr(t,r);case mn:return new o;case un:case hn:return new o(t);case dn:return Nr(t);case cn:return new o;case xn:return Lr(t)}}var Ur=In;function _n(t){return typeof t.constructor=="function"&&!H(t)?le(Tt(t)):{}}var kr=_n;var En="[object Map]";function Cn(t){return A(t)&&at(t)==En}var zr=Cn;var Kr=C&&C.isMap,Fn=Kr?Y(Kr):zr,Gr=Fn;var Mn="[object Set]";function Nn(t){return A(t)&&at(t)==Mn}var Wr=Nn;var $r=C&&C.isSet,Rn=$r?Y($r):Wr,Hr=Rn;var Bn=1,Ln=2,Dn=4,qr="[object Arguments]",Un="[object Array]",kn="[object Boolean]",zn="[object Date]",Kn="[object Error]",Yr="[object Function]",Gn="[object GeneratorFunction]",Wn="[object Map]",$n="[object Number]",Vr="[object Object]",Hn="[object RegExp]",qn="[object Set]",Yn="[object String]",Vn="[object Symbol]",Zn="[object WeakMap]",Jn="[object ArrayBuffer]",Xn="[object DataView]",Qn="[object Float32Array]",tf="[object Float64Array]",ef="[object Int8Array]",rf="[object Int16Array]",of="[object Int32Array]",af="[object Uint8Array]",sf="[object Uint8ClampedArray]",nf="[object Uint16Array]",ff="[object Uint32Array]",d={};d[qr]=d[Un]=d[Jn]=d[Xn]=d[kn]=d[zn]=d[Qn]=d[tf]=d[ef]=d[rf]=d[of]=d[Wn]=d[$n]=d[Vr]=d[Hn]=d[qn]=d[Yn]=d[Vn]=d[af]=d[sf]=d[nf]=d[ff]=!0;d[Kn]=d[Yr]=d[Zn]=!1;function _t(t,e,r,o,a,s){var n,i=e&Bn,f=e&Ln,m=e&Dn;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!j(t))return t;var h=v(t);if(h){if(n=Fr(t),!i)return ue(t,n)}else{var b=at(t),S=b==Yr||b==Gn;if(bt(t))return vr(t,i);if(b==Vr||b==qr||S&&!a){if(n=f||S?{}:kr(t),!i)return f?Sr(t,hr(n,t)):Or(t,cr(n,t))}else{if(!d[b])return a?t:{};n=Ur(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,n),Hr(t)?t.forEach(function(y){n.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){n.set(p,_t(y,e,r,p,t,s))});var g=m?f?Ar:jr:f?Z:V,I=h?void 0:g(t);return ge(I||t,function(y,p){I&&(p=y,y=t[p]),W(n,p,_t(y,e,r,p,t,s))}),n}var Zr=_t;var pf=1,lf=4;function mf(t){return Zr(t,pf|lf)}var Lt=mf;function uf(t,e){return t!=null&&e in Object(t)}var Jr=uf;function df(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=tt(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&$(a)&&G(n,a)&&(v(t)||q(t)))}var Xr=df;function cf(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cf;function hf(t,e,r,o){if(!j(t))return t;e=D(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=tt(e[a]),m=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var h=i[f];m=o?o(h,f,i):void 0,m===void 0&&(m=j(h)?h:G(e[a+1])?[]:{})}W(i,f,m),i=i[f]}return t}var to=hf;function xf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=er(t,n);r(i,n)&&to(s,D(n,t),i)}return s}var eo=xf;function gf(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gf;var yf=nr(function(t,e){return t==null?{}:ro(t,e)}),Et=yf;function oo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var 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 bf="array",vf="bit",ao="bits",wf="byte",io="bytes",st="",Tf="exponent",Of="function",so="iec",Sf="Invalid number",jf="Invalid rounding method",Ut="jedec",Af="object",no=".",Pf="round",If="s",_f="si",Ef="kbit",Cf="kB",Ff=" ",Mf="string",Nf="0",kt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:n={},separator:i=st,spacer:f=Ff,symbols:m={},standard:h=st,output:b=Mf,fullform:S=!1,fullforms:T=[],exponent:g=-1,roundingMethod:I=Pf,precision:y=0}={}){let p=g,u=Number(t),l=[],_=0,Ct=st;h===_f?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=S===!0,Kt=u<0,Gt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Sf);if(typeof Gt!==Of)throw new TypeError(jf);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===Tf)return p;if(u===0)l[0]=0,Ct=l[1]=kt.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 nt=Math.pow(10,p>0?a:0);l[0]=Gt(_*nt)/nt,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?Ef:Cf:kt.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,n):i.length>0&&(l[0]=l[0].toString().replace(no,i)),r&&Number.isInteger(l[0])===!1&&a>0){let nt=i||no,Wt=l[0].toString().split(nt),$t=Wt[1]||st,Ht=$t.length,lo=a-Ht;l[0]=`${Wt[0]}${nt}${$t.padEnd(Ht+lo,Nf)}`}return po&&(l[1]=T[p]?T[p]:kt.fullform[h][p]+(e?vf:wf)+(l[0]===1?st:If)),b===bf?l:b===Af?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(f)}var k=class t{#t;id;name;icon;path;url;teraUrl;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;meta={};constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),delete this.tera,this.#t=e.tera,this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return this.#t.getProjectFile(this.id)}setContents(e){return this.#t.setProjectFile(this.id,e)}getRefs(){return this.#t.getProjectLibrary(this.id)}setRefs(e){return this.#t.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","url","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","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","setPageTitle","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.debug("INFO",4,"[0/5] Init using server",this.settings.siteUrl)).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/5] Setting client mode to",o),this.settings.mode=o}).then(()=>this.debug("INFO",4,"[2/5] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.debug("INFO",4,"[3/5] Set server mode")).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[4/5] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[5/5] Init complete")).catch(o=>this.debug("WARN",0,"Init caught error",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){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
|
|
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:f,basePath:m,basePathForRemoves:h,diffs:b}){var j=Object.keys(i),T=j.length,g=Object.keys(f),I=g.length,y,p=i.length-f.length;if(uo(i,f)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(j[u]):j[u];l in f||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<I;u++){var l=Array.isArray(f)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:f,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:f,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:f,obj2:m,path:h,pathForRemoves:b,diffs:j}){var T=f[i],g=m[i];if(!(i in f)&&i in m){var I=g;j.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)?n(h,j,g):o({obj1:f[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:j}))}function n(i,f,m){f.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 n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)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,ft=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,ft),r=t[ft];try{t[ft]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[ft]=r:delete t[ft]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Oo(t){return To.call(t)}var Jt=Oo;var jo="[object Null]",Po="[object Undefined]",Xt=w?w.toStringTag:void 0;function So(t){return t==null?t===void 0?Po:jo:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var A=So;function Ao(t){return t!=null&&typeof t=="object"}var S=Ao;var Io="[object Symbol]";function _o(t){return typeof t=="symbol"||S(t)&&A(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 Fo=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==-Fo?"-0":e}var oe=re;function Mo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Mo;function No(t){return t}var ae=No;var Ro="[object AsyncFunction]",Bo="[object Function]",Lo="[object GeneratorFunction]",Do="[object Proxy]";function Uo(t){if(!P(t))return!1;var e=A(t);return e==Bo||e==Lo||e==Ro||e==Do}var dt=Uo;var ko=x["__core-js_shared__"],ct=ko;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 $o=/[\\^$.*+?()[\]{}|]/g,Ho=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Vo=qo.toString,Zo=Yo.hasOwnProperty,Jo=RegExp("^"+Vo.call(Zo).replace($o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xo(t){if(!P(t)||se(t))return!1;var e=dt(t)?Jo:Ho;return e.test(E(t))}var ne=Xo;function Qo(t,e){return t?.[e]}var fe=Qo;function ta(t,e){var r=fe(t,e);return ne(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(!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,na=Date.now;function fa(t){var e=0,r=0;return function(){var o=na(),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=fa;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,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?xt(r,i,f):W(r,i,f)}return r}var M=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),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),me(t,this,i)}}var be=Oa;var ja=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ja}var $=Pa;function Sa(t){return t!=null&&$(t.length)&&!dt(t)}var yt=Sa;var Aa=Object.prototype;function Ia(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Aa;return t===r}var H=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 S(t)&&A(t)==Ea}var Ft=Ca;var we=Object.prototype,Fa=we.hasOwnProperty,Ma=we.propertyIsEnumerable,Na=Ft(function(){return arguments}())?Ft:function(t){return S(t)&&Fa.call(t,"callee")&&!Ma.call(t,"callee")},q=Na;function Ra(){return!1}var Te=Ra;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,Ba=Oe&&Oe.exports===Pe,je=Ba?x.Buffer:void 0,La=je?je.isBuffer:void 0,Da=La||Te,bt=Da;var Ua="[object Arguments]",ka="[object Array]",za="[object Boolean]",Ka="[object Date]",Ga="[object Error]",Wa="[object Function]",$a="[object Map]",Ha="[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]",ni="[object Uint16Array]",fi="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[ni]=c[fi]=!0;c[Ua]=c[ka]=c[Xa]=c[za]=c[Qa]=c[Ka]=c[Ga]=c[Wa]=c[$a]=c[Ha]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=!1;function pi(t){return S(t)&&$(t.length)&&!!c[A(t)]}var Se=pi;function li(t){return function(e){return t(e)}}var Y=li;var Ae=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=Ae&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===Ae,Mt=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Mt&&Mt.binding&&Mt.binding("util")}catch{}}(),C=ui;var Ie=C&&C.isTypedArray,di=Ie?Y(Ie):Se,_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),n=r||o||a||s,i=n?ve(t.length,String):[],f=i.length;for(var m in t)(e||hi.call(t,m))&&!(n&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,f)))&&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(!H(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 Fe=Oi;var ji=Object.prototype,Pi=ji.hasOwnProperty;function Si(t){if(!P(t))return Fe(t);var e=H(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Me=Si;function Ai(t){return yt(t)?vt(t,!0):Me(t)}var Z=Ai;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 Ne=Ei;var Ci=O(Object,"create"),F=Ci;function Fi(){this.__data__=F?F(null):{},this.size=0}var Re=Fi;function Mi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Mi;var Ni="__lodash_hash_undefined__",Ri=Object.prototype,Bi=Ri.hasOwnProperty;function Li(t){var e=this.__data__;if(F){var r=e[t];return r===Ni?void 0:r}return Bi.call(e,t)?e[t]:void 0}var Le=Li;var Di=Object.prototype,Ui=Di.hasOwnProperty;function ki(t){var e=this.__data__;return F?e[t]!==void 0:Ui.call(e,t)}var De=ki;var zi="__lodash_hash_undefined__";function Ki(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=F&&e===void 0?zi:e,this}var Ue=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=Re;J.prototype.delete=Be;J.prototype.get=Le;J.prototype.has=De;J.prototype.set=Ue;var Nt=J;function Gi(){this.__data__=[],this.size=0}var ke=Gi;function Wi(t,e){for(var r=t.length;r--;)if(gt(t[r][0],e))return r;return-1}var N=Wi;var $i=Array.prototype,Hi=$i.splice;function qi(t){var e=this.__data__,r=N(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Hi.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=N(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return N(this.__data__,t)>-1}var Ge=Vi;function Zi(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 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=ke;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var R=X;var Ji=O(x,"Map"),B=Ji;function Xi(){this.size=0,this.__data__={hash:new Nt,map:new(B||R),string:new Nt}}var $e=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var He=Qi;function ts(t,e){var r=t.__data__;return He(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=$e;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 Rt(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 n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};return r.cache=new(Rt.Cache||lt),r}Rt.Cache=lt;var Je=Rt;var ss=500;function ns(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=ns;var fs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(fs,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:Ne(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,n=t.length;for(r||(r=or),a||(a=[]);++s<n;){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 nr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new R,this.size=0}var fr=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 js(t){return this.__data__.has(t)}var mr=js;var Ps=200;function Ss(t,e){var r=this.__data__;if(r instanceof R){var o=r.__data__;if(!B||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=Ss;function rt(t){var e=this.__data__=new R(t);this.size=e.size}rt.prototype.clear=fr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function As(t,e){return t&&M(e,V(e),t)}var cr=As;function Is(t,e){return t&&M(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 n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var wr=Cs;function Fs(){return[]}var Ot=Fs;var Ms=Object.prototype,Ns=Ms.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Rs=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Ns.call(t,e)}))}:Ot,ot=Rs;function Bs(t,e){return M(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,jt=Ds;function Us(t,e){return M(t,jt(t),e)}var jr=Us;function ks(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var Pt=ks;function zs(t){return Pt(t,V,ot)}var Pr=zs;function Ks(t){return Pt(t,Z,jt)}var Sr=Ks;var Gs=O(x,"DataView"),St=Gs;var Ws=O(x,"Promise"),At=Ws;var $s=O(x,"Set"),It=$s;var Ar="[object Map]",Hs="[object Object]",Ir="[object Promise]",_r="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=E(St),Ys=E(B),Vs=E(At),Zs=E(It),Js=E(ht),k=A;(St&&k(new St(new ArrayBuffer(1)))!=Cr||B&&k(new B)!=Ar||At&&k(At.resolve())!=Ir||It&&k(new It)!=_r||ht&&k(new ht)!=Er)&&(k=function(t){var e=A(t),r=e==Hs?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case qs:return Cr;case Ys:return Ar;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 tn(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 Fr=tn;var en=x.Uint8Array,Bt=en;function rn(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var it=rn;function on(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Mr=on;var an=/\w*$/;function sn(t){var e=new t.constructor(t.source,an.exec(t));return e.lastIndex=t.lastIndex,e}var Nr=sn;var Rr=w?w.prototype:void 0,Br=Rr?Rr.valueOf:void 0;function nn(t){return Br?Object(Br.call(t)):{}}var Lr=nn;function fn(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=fn;var pn="[object Boolean]",ln="[object Date]",mn="[object Map]",un="[object Number]",dn="[object RegExp]",cn="[object Set]",hn="[object String]",xn="[object Symbol]",gn="[object ArrayBuffer]",yn="[object DataView]",bn="[object Float32Array]",vn="[object Float64Array]",wn="[object Int8Array]",Tn="[object Int16Array]",On="[object Int32Array]",jn="[object Uint8Array]",Pn="[object Uint8ClampedArray]",Sn="[object Uint16Array]",An="[object Uint32Array]";function In(t,e,r){var o=t.constructor;switch(e){case gn:return it(t);case pn:case ln:return new o(+t);case yn:return Mr(t,r);case bn:case vn:case wn:case Tn:case On:case jn:case Pn:case Sn:case An:return Dr(t,r);case mn:return new o;case un:case hn:return new o(t);case dn:return Nr(t);case cn:return new o;case xn:return Lr(t)}}var Ur=In;function _n(t){return typeof t.constructor=="function"&&!H(t)?le(Tt(t)):{}}var kr=_n;var En="[object Map]";function Cn(t){return S(t)&&at(t)==En}var zr=Cn;var Kr=C&&C.isMap,Fn=Kr?Y(Kr):zr,Gr=Fn;var Mn="[object Set]";function Nn(t){return S(t)&&at(t)==Mn}var Wr=Nn;var $r=C&&C.isSet,Rn=$r?Y($r):Wr,Hr=Rn;var Bn=1,Ln=2,Dn=4,qr="[object Arguments]",Un="[object Array]",kn="[object Boolean]",zn="[object Date]",Kn="[object Error]",Yr="[object Function]",Gn="[object GeneratorFunction]",Wn="[object Map]",$n="[object Number]",Vr="[object Object]",Hn="[object RegExp]",qn="[object Set]",Yn="[object String]",Vn="[object Symbol]",Zn="[object WeakMap]",Jn="[object ArrayBuffer]",Xn="[object DataView]",Qn="[object Float32Array]",tf="[object Float64Array]",ef="[object Int8Array]",rf="[object Int16Array]",of="[object Int32Array]",af="[object Uint8Array]",sf="[object Uint8ClampedArray]",nf="[object Uint16Array]",ff="[object Uint32Array]",d={};d[qr]=d[Un]=d[Jn]=d[Xn]=d[kn]=d[zn]=d[Qn]=d[tf]=d[ef]=d[rf]=d[of]=d[Wn]=d[$n]=d[Vr]=d[Hn]=d[qn]=d[Yn]=d[Vn]=d[af]=d[sf]=d[nf]=d[ff]=!0;d[Kn]=d[Yr]=d[Zn]=!1;function _t(t,e,r,o,a,s){var n,i=e&Bn,f=e&Ln,m=e&Dn;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!P(t))return t;var h=v(t);if(h){if(n=Fr(t),!i)return ue(t,n)}else{var b=at(t),j=b==Yr||b==Gn;if(bt(t))return vr(t,i);if(b==Vr||b==qr||j&&!a){if(n=f||j?{}:kr(t),!i)return f?jr(t,hr(n,t)):Or(t,cr(n,t))}else{if(!d[b])return a?t:{};n=Ur(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,n),Hr(t)?t.forEach(function(y){n.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){n.set(p,_t(y,e,r,p,t,s))});var g=m?f?Sr:Pr:f?Z:V,I=h?void 0:g(t);return ge(I||t,function(y,p){I&&(p=y,y=t[p]),W(n,p,_t(y,e,r,p,t,s))}),n}var Zr=_t;var pf=1,lf=4;function mf(t){return Zr(t,pf|lf)}var Lt=mf;function uf(t,e){return t!=null&&e in Object(t)}var Jr=uf;function df(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=tt(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&$(a)&&G(n,a)&&(v(t)||q(t)))}var Xr=df;function cf(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cf;function hf(t,e,r,o){if(!P(t))return t;e=D(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=tt(e[a]),m=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var h=i[f];m=o?o(h,f,i):void 0,m===void 0&&(m=P(h)?h:G(e[a+1])?[]:{})}W(i,f,m),i=i[f]}return t}var to=hf;function xf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=er(t,n);r(i,n)&&to(s,D(n,t),i)}return s}var eo=xf;function gf(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gf;var yf=nr(function(t,e){return t==null?{}:ro(t,e)}),Et=yf;function oo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var 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 bf="array",vf="bit",ao="bits",wf="byte",io="bytes",st="",Tf="exponent",Of="function",so="iec",jf="Invalid number",Pf="Invalid rounding method",Ut="jedec",Sf="object",no=".",Af="round",If="s",_f="si",Ef="kbit",Cf="kB",Ff=" ",Mf="string",Nf="0",kt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function fo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:n={},separator:i=st,spacer:f=Ff,symbols:m={},standard:h=st,output:b=Mf,fullform:j=!1,fullforms:T=[],exponent:g=-1,roundingMethod:I=Af,precision:y=0}={}){let p=g,u=Number(t),l=[],_=0,Ct=st;h===_f?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=j===!0,Kt=u<0,Gt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(jf);if(typeof Gt!==Of)throw new TypeError(Pf);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===Tf)return p;if(u===0)l[0]=0,Ct=l[1]=kt.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 nt=Math.pow(10,p>0?a:0);l[0]=Gt(_*nt)/nt,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?Ef:Cf:kt.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,n):i.length>0&&(l[0]=l[0].toString().replace(no,i)),r&&Number.isInteger(l[0])===!1&&a>0){let nt=i||no,Wt=l[0].toString().split(nt),$t=Wt[1]||st,Ht=$t.length,lo=a-Ht;l[0]=`${Wt[0]}${nt}${$t.padEnd(Ht+lo,Nf)}`}return po&&(l[1]=T[p]?T[p]:kt.fullform[h][p]+(e?vf:wf)+(l[0]===1?st:If)),b===bf?l:b===Sf?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(f)}var U=class t{#t;id;name;icon;path;url;teraUrl;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;meta={};constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),delete this.tera,this.#t=e.tera,this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/,"/project/$1"),this.sizeFormatted=fo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return this.#t.getProjectFile(this.id)}setContents(e){return this.#t.setProjectFile(this.id,e)}getRefs(){return this.#t.getProjectLibrary(this.id)}setRefs(e){return this.#t.setProjectLibrary(this.id,e)}serialize(){return Et(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","url","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","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","applyProjectStatePatch","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","setPageTitle","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.debug("INFO",4,"[0/5] Init using server",this.settings.siteUrl)).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/5] Setting client mode to",o),this.settings.mode=o}).then(()=>this.debug("INFO",4,"[2/5] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.debug("INFO",4,"[3/5] Set server mode")).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[4/5] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[5/5] Init complete")).catch(o=>this.debug("WARN",0,"Init caught error",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){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}))}createProjectFile(e){return this.rpc("createProjectFile",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
|
@@ -112,6 +112,8 @@ export default class TeraFy {
|
|
|
112
112
|
// 'selectProjectFile', - Handled below (requires return collection mapped to ProjectFile)
|
|
113
113
|
// 'getProjectFiles', - Handled below (requires return collection mapped to ProjectFile)
|
|
114
114
|
// 'getProjectFile', - Handled below (requires return mapped to ProjectFile)
|
|
115
|
+
// 'createProjectFile', - Handled below (requires return mapped to ProjectFile)
|
|
116
|
+
'deleteProjectFile',
|
|
115
117
|
'setProjectFile',
|
|
116
118
|
|
|
117
119
|
// Project Libraries
|
|
@@ -910,7 +912,7 @@ export default class TeraFy {
|
|
|
910
912
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
911
913
|
* @param {FileFilters} [options.filter] Optional file filters
|
|
912
914
|
*
|
|
913
|
-
* @returns {Promise<ProjectFile>} The eventually selected file
|
|
915
|
+
* @returns {Promise<ProjectFile>} The eventually selected file, if in save mode new files are created as stubs
|
|
914
916
|
*/
|
|
915
917
|
selectProjectFile(options) {
|
|
916
918
|
return this.rpc('selectProjectFile', options)
|
|
@@ -945,10 +947,15 @@ export default class TeraFy {
|
|
|
945
947
|
|
|
946
948
|
|
|
947
949
|
/**
|
|
948
|
-
* Fetch a project file
|
|
950
|
+
* Fetch a project file by its name
|
|
949
951
|
*
|
|
950
|
-
* @param {String}
|
|
951
|
-
*
|
|
952
|
+
* @param {String} name The name + relative directory path component
|
|
953
|
+
*
|
|
954
|
+
* @param {Object|String} [options] Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
|
|
955
|
+
* @param {String} [options.subkey] If specified only the extracted subkey is returned rather than the full object
|
|
956
|
+
* @param {Boolean} [options.cache=true] Use the existing file cache if possible, set to false to force a refresh of files from the server first
|
|
957
|
+
*
|
|
958
|
+
* @returns {Promise<ProjectFile>} The eventual fetched ProjectFile (or requested subkey)
|
|
952
959
|
*/
|
|
953
960
|
getProjectFile(id) {
|
|
954
961
|
return this.rpc('getProjectFile', id)
|
|
@@ -962,6 +969,35 @@ export default class TeraFy {
|
|
|
962
969
|
}
|
|
963
970
|
|
|
964
971
|
|
|
972
|
+
/**
|
|
973
|
+
* Create a new file
|
|
974
|
+
* This creates an empty file which can then be written to
|
|
975
|
+
*
|
|
976
|
+
* @param {String} name The name + relative directory path component
|
|
977
|
+
* @returns {Promise<ProjectFile>} The eventual ProjectFile created
|
|
978
|
+
*/
|
|
979
|
+
createProjectFile(name) {
|
|
980
|
+
return this.rpc('createProjectFile', name)
|
|
981
|
+
.then(file => file
|
|
982
|
+
? new ProjectFile({
|
|
983
|
+
tera: this,
|
|
984
|
+
...file,
|
|
985
|
+
})
|
|
986
|
+
: file
|
|
987
|
+
)
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Remove a project file by its ID
|
|
993
|
+
*
|
|
994
|
+
* @function deleteProjectFile
|
|
995
|
+
* @param {String} id The File ID to remove
|
|
996
|
+
*
|
|
997
|
+
* @returns {Promise} A promise which resolves when the operation has completed
|
|
998
|
+
*/
|
|
999
|
+
|
|
1000
|
+
|
|
965
1001
|
/**
|
|
966
1002
|
* Replace a project files contents
|
|
967
1003
|
*
|
package/lib/terafy.server.js
CHANGED
|
@@ -868,7 +868,7 @@ export default class TeraFyServer {
|
|
|
868
868
|
}
|
|
869
869
|
// }}}
|
|
870
870
|
|
|
871
|
-
// Project files - selectProjectFile(), getProjectFiles(), getProjectFile(), setProjectFile() {{{
|
|
871
|
+
// Project files - selectProjectFile(), getProjectFiles(), getProjectFile(), createProjectFile(), deleteProjectFile(), setProjectFile() {{{
|
|
872
872
|
|
|
873
873
|
/**
|
|
874
874
|
* Data structure for a project file
|
|
@@ -914,7 +914,7 @@ export default class TeraFyServer {
|
|
|
914
914
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
915
915
|
* @param {FileFilters} [options.filter] Optional file filters
|
|
916
916
|
*
|
|
917
|
-
* @returns {Promise<ProjectFile>} The eventually selected file
|
|
917
|
+
* @returns {Promise<ProjectFile>} The eventually selected file, if in save mode new files are created as stubs
|
|
918
918
|
*/
|
|
919
919
|
selectProjectFile(options) {
|
|
920
920
|
let settings = {
|
|
@@ -949,8 +949,8 @@ export default class TeraFyServer {
|
|
|
949
949
|
filters: settings.filters,
|
|
950
950
|
},
|
|
951
951
|
componentEvents: {
|
|
952
|
-
fileSave(
|
|
953
|
-
app.service('$prompt').close(true,
|
|
952
|
+
fileSave(file) {
|
|
953
|
+
app.service('$prompt').close(true, file);
|
|
954
954
|
},
|
|
955
955
|
fileSelect(file) {
|
|
956
956
|
app.service('$prompt').close(true, file);
|
|
@@ -989,14 +989,79 @@ export default class TeraFyServer {
|
|
|
989
989
|
|
|
990
990
|
|
|
991
991
|
/**
|
|
992
|
-
* Fetch a project file
|
|
993
|
-
*
|
|
994
|
-
* @
|
|
992
|
+
* Fetch a project file by its name
|
|
993
|
+
*
|
|
994
|
+
* @param {String} name The name + relative directory path component
|
|
995
|
+
*
|
|
996
|
+
* @param {Object|String} [options] Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
|
|
997
|
+
* @param {String} [options.subkey] If specified only the extracted subkey is returned rather than the full object
|
|
998
|
+
* @param {Boolean} [options.cache=true] Use the existing file cache if possible, set to false to force a refresh of files from the server first
|
|
999
|
+
*
|
|
1000
|
+
* @returns {Promise<ProjectFile>} The eventual fetched ProjectFile (or requested subkey)
|
|
995
1001
|
*/
|
|
996
|
-
getProjectFile(
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1002
|
+
getProjectFile(name, options) {
|
|
1003
|
+
let settings = {
|
|
1004
|
+
subkey: null,
|
|
1005
|
+
cache: true,
|
|
1006
|
+
...(typeof options == 'string' ? {subkey: options} : options),
|
|
1007
|
+
};
|
|
1008
|
+
|
|
1009
|
+
return Promise.resolve()
|
|
1010
|
+
.then(()=>
|
|
1011
|
+
app.service('$projects').activeFiles.length == 0 // If we have no files in the cache
|
|
1012
|
+
|| !settings.cache // OR caching is disabled
|
|
1013
|
+
? app.service('$projects').refreshFiles({ // Go refresh files first
|
|
1014
|
+
lazy: false,
|
|
1015
|
+
})
|
|
1016
|
+
: app.service('$projects').activeFiles // Otherwise use file cache
|
|
1017
|
+
)
|
|
1018
|
+
.then(files =>
|
|
1019
|
+
files.find(file =>
|
|
1020
|
+
file.name == name
|
|
1021
|
+
)
|
|
1022
|
+
)
|
|
1023
|
+
.then(file => file && settings.subkey ? file[settings.subkey] : file) // Provide subkey if asked
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Create a new file
|
|
1029
|
+
* This creates an empty file which can then be written to
|
|
1030
|
+
* This function also forces a local file list cache update
|
|
1031
|
+
*
|
|
1032
|
+
* @param {String} name The name + relative directory path component
|
|
1033
|
+
* @returns {Promise<ProjectFile>} The eventual ProjectFile created
|
|
1034
|
+
*/
|
|
1035
|
+
createProjectFile(name) {
|
|
1036
|
+
return Promise.resolve()
|
|
1037
|
+
.then(()=> app.service('$supabase').fileUpload(app.service('$projects').convertRelativePath(name), {
|
|
1038
|
+
file: new Blob([''], {type: 'text/plain'}),
|
|
1039
|
+
mode: 'encoded',
|
|
1040
|
+
overwrite: false,
|
|
1041
|
+
multiple: false,
|
|
1042
|
+
toast: false,
|
|
1043
|
+
transcoders: false,
|
|
1044
|
+
}))
|
|
1045
|
+
.then(()=> this.getProjectFile(name, {
|
|
1046
|
+
cache: false, // Force cache to update, as this is a new file
|
|
1047
|
+
}))
|
|
1048
|
+
.then(file => file || Promise.reject(`Could not create new file "${name}"`))
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Remove a project file by its ID
|
|
1054
|
+
*
|
|
1055
|
+
* @param {String} id The File ID to remove
|
|
1056
|
+
*
|
|
1057
|
+
* @returns {Promise} A promise which resolves when the operation has completed
|
|
1058
|
+
*/
|
|
1059
|
+
deleteProjectFile(id) {
|
|
1060
|
+
return app.service('$supabase').fileRemove(app.service('$projects').decodeFilePath(id))
|
|
1061
|
+
.then(()=> app.service('$projects').refreshFiles({ // Force a local file list update
|
|
1062
|
+
lazy: false,
|
|
1063
|
+
}))
|
|
1064
|
+
.then(()=> null)
|
|
1000
1065
|
}
|
|
1001
1066
|
|
|
1002
1067
|
|
|
@@ -1051,7 +1116,7 @@ export default class TeraFyServer {
|
|
|
1051
1116
|
|
|
1052
1117
|
return app.service('$projects').promise()
|
|
1053
1118
|
.then(()=> this.selectProjectFile(settings))
|
|
1054
|
-
.then(selectedFile => this.getProjectLibrary(selectedFile.
|
|
1119
|
+
.then(selectedFile => this.getProjectLibrary(selectedFile.id, settings))
|
|
1055
1120
|
}
|
|
1056
1121
|
|
|
1057
1122
|
|
|
@@ -1165,7 +1230,6 @@ export default class TeraFyServer {
|
|
|
1165
1230
|
})
|
|
1166
1231
|
.then(()=> { // Compute filePath
|
|
1167
1232
|
filePath = app.service('$projects').decodeFilePath(settings.id);
|
|
1168
|
-
debugger; // FIXME: Untested
|
|
1169
1233
|
})
|
|
1170
1234
|
.then(()=> {
|
|
1171
1235
|
// Mutate settings.ref -> Blob or File format needed by Supabase
|
|
@@ -1184,7 +1248,7 @@ export default class TeraFyServer {
|
|
|
1184
1248
|
|
|
1185
1249
|
// Get Reflib to encode the POJO into a Blob/File
|
|
1186
1250
|
return Reflib.downloadFile(settings.refs, {
|
|
1187
|
-
filename: app.service('$supabase')._parsePath(filePath).
|
|
1251
|
+
filename: app.service('$supabase')._parsePath(filePath).basename,
|
|
1188
1252
|
promptDownload: false, // Just return the fileBlob we hand to Supabase
|
|
1189
1253
|
})
|
|
1190
1254
|
case 'blob':
|
|
@@ -1197,7 +1261,11 @@ export default class TeraFyServer {
|
|
|
1197
1261
|
throw new Error(`Unsupported library format "${settings.format}"`);
|
|
1198
1262
|
}
|
|
1199
1263
|
})
|
|
1200
|
-
.then(fileBlob => app.service('$supabase').fileUpload(filePath
|
|
1264
|
+
.then(fileBlob => app.service('$supabase').fileUpload(filePath, {
|
|
1265
|
+
file: fileBlob,
|
|
1266
|
+
overwrite: true,
|
|
1267
|
+
mode: 'encoded',
|
|
1268
|
+
}))
|
|
1201
1269
|
}
|
|
1202
1270
|
|
|
1203
1271
|
// }}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iebh/tera-fy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "TERA website worker",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "esbuild --platform=browser --format=esm --bundle lib/terafy.client.js --outfile=dist/terafy.js --minify --serve --servedir=.",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"./projectFile": "./lib/projectFile.js",
|
|
31
31
|
"./server": "./lib/terafy.server.js",
|
|
32
32
|
"./plugins/*": "./plugins/*.js",
|
|
33
|
-
"./widgets/*": "./widgets/*.
|
|
33
|
+
"./widgets/*": "./widgets/*.vue"
|
|
34
34
|
},
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|