@iebh/tera-fy 1.6.0 → 1.6.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.
@@ -1,5 +1,5 @@
1
- var bo=Object.defineProperty;var vo=(t,e,r)=>e in t?bo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var x=(t,e,r)=>(vo(t,typeof e!="symbol"?e+"":e,r),r),Jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var lt=(t,e,r)=>(Jt(t,e,"read from private field"),r?r.call(t):e.get(t)),Xt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Qt=(t,e,r,o)=>(Jt(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r);function te(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:f,basePath:m,basePathForRemoves:h,diffs:v}){var A=Object.keys(i),O=A.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(A[u]):A[u];l in f||(b=h.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=h.concat(u),v.remove.push({op:"remove",path:r(b)});for(var E=i.slice(p),u=0;u<_;u++)s({key:u,obj1:E,obj2: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:h,pathForRemoves:v,diffs:A}){var O=f[i],y=m[i];if(!(i in f)&&i in m){var _=y;A.add.push({op:"add",path:r(h),value:_})}else O!==y&&(Object(O)!==O||Object(y)!==y||wo(O,y)||!Object.keys(O).length&&!Object.keys(y).length&&String(O)!=String(y)?n(h,A,y):o({obj1:f[i],obj2:m[i],basePath:h,basePathForRemoves:v,diffs:A}))}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,Ao=ht||So||Function("return this")(),g=Ao;var Po=g.Symbol,T=Po;var re=Object.prototype,jo=re.hasOwnProperty,Io=re.toString,mt=T?T.toStringTag:void 0;function _o(t){var e=jo.call(t,mt),r=t[mt];try{t[mt]=void 0;var o=!0}catch{}var a=Io.call(t);return o&&(e?t[mt]=r:delete t[mt]),a}var oe=_o;var Eo=Object.prototype,Co=Eo.toString;function 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 j=Bo;var Lo="[object Symbol]";function Do(t){return typeof t=="symbol"||j(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 P=Ko;function Go(t){return t}var me=Go;var Wo="[object AsyncFunction]",Ho="[object Function]",$o="[object GeneratorFunction]",qo="[object Proxy]";function Yo(t){if(!P(t))return!1;var e=I(t);return e==Ho||e==$o||e==Wo||e==qo}var xt=Yo;var Vo=g["__core-js_shared__"],gt=Vo;var ue=function(){var t=/[^.]+$/.exec(gt&&gt.keys&&gt.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(!P(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(!P(e))return{};if(xe)return xe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ge=ma;function ua(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var ye=ua;function da(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var be=da;var ca=800,ha=16,xa=Date.now;function ga(t){var e=0,r=0;return function(){var o=xa(),a=ha-(o-r);if(r=o,a>0){if(++e>=ca)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ve=ga;function ya(t){return function(){return t}}var we=ya;var ba=function(){try{var t=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 Aa(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 H=Aa;function Pa(t,e,r){e=="__proto__"&&W?W(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var bt=Pa;function ja(t,e){return t===e||t!==t&&e!==e}var vt=ja;var Ia=Object.prototype,_a=Ia.hasOwnProperty;function Ea(t,e,r){var o=t[e];(!(_a.call(t,e)&&vt(o,r))||r===void 0&&!(e in t))&&bt(t,e,r)}var $=Ea;function Ca(t,e,r,o){var a=!r;r||(r={});for(var s=-1,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):$(r,i,f)}return r}var N=Ca;var Ae=Math.max;function Fa(t,e,r){return e=Ae(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=Ae(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 Pe=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 je=Da;var Ua="[object Arguments]";function ka(t){return j(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 j(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,Ha=Ee&&Ee.exports===Fe,Ce=Ha?g.Buffer:void 0,$a=Ce?Ce.isBuffer:void 0,qa=$a||_e,Tt=qa;var Ya="[object Arguments]",Va="[object Array]",Za="[object Boolean]",Ja="[object Date]",Xa="[object Error]",Qa="[object Function]",ti="[object Map]",ei="[object Number]",ri="[object Object]",oi="[object RegExp]",ai="[object Set]",ii="[object String]",si="[object WeakMap]",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]",c={};c[pi]=c[li]=c[mi]=c[ui]=c[di]=c[ci]=c[hi]=c[xi]=c[gi]=!0;c[Ya]=c[Va]=c[ni]=c[Za]=c[fi]=c[Ja]=c[Xa]=c[Qa]=c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=!1;function yi(t){return j(t)&&q(t.length)&&!!c[I(t)]}var 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 Ai(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?je(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")||H(m,f)))&&i.push(m);return i}var Ot=Ai;function Pi(t,e){return function(r){return t(e(r))}}var St=Pi;var ji=St(Object.keys,Object),Le=ji;var Ii=Object.prototype,_i=Ii.hasOwnProperty;function Ei(t){if(!Y(t))return Le(t);var e=[];for(var r in Object(t))_i.call(t,r)&&r!="constructor"&&e.push(r);return e}var De=Ei;function Ci(t){return wt(t)?Ot(t):De(t)}var J=Ci;function 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(!P(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,Hi=Wi.hasOwnProperty;function $i(t){var e=this.__data__;if(M){var r=e[t];return r===Gi?void 0:r}return Hi.call(e,t)?e[t]:void 0}var We=$i;var qi=Object.prototype,Yi=qi.hasOwnProperty;function Vi(t){var e=this.__data__;return M?e[t]!==void 0:Yi.call(e,t)}var He=Vi;var Zi="__lodash_hash_undefined__";function Ji(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?Zi:e,this}var $e=Ji;function Q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Q.prototype.clear=Ke;Q.prototype.delete=Ge;Q.prototype.get=We;Q.prototype.has=He;Q.prototype.set=$e;var Lt=Q;function Xi(){this.__data__=[],this.size=0}var qe=Xi;function Qi(t,e){for(var r=t.length;r--;)if(vt(t[r][0],e))return r;return-1}var 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 As(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ot=As;var pr=T?T.isConcatSpreadable:void 0;function Ps(t){return w(t)||V(t)||!!(pr&&t&&t[pr])}var lr=Ps;function mr(t,e,r,o,a){var s=-1,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 js(t){var e=t==null?0:t.length;return e?ur(t,1):[]}var dr=js;function Is(t){return Oe(Pe(t,void 0,dr),t+"")}var cr=Is;var _s=St(Object.getPrototypeOf,Object),At=_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 Pr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Or=Pr&&typeof module=="object"&&module&&!module.nodeType&&module,Ds=Or&&Or.exports===Pr,Sr=Ds?g.Buffer:void 0,Ar=Sr?Sr.allocUnsafe:void 0;function Us(t,e){if(e)return t.slice();var r=t.length,o=Ar?Ar(r):new t.constructor(r);return t.copy(o),o}var jr=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 Pt=zs;var Ks=Object.prototype,Gs=Ks.propertyIsEnumerable,_r=Object.getOwnPropertySymbols,Ws=_r?function(t){return t==null?[]:(t=Object(t),Ir(_r(t),function(e){return Gs.call(t,e)}))}:Pt,it=Ws;function Hs(t,e){return N(t,it(t),e)}var Er=Hs;var $s=Object.getOwnPropertySymbols,qs=$s?function(t){for(var e=[];t;)ot(e,it(t)),t=At(t);return e}:Pt,jt=qs;function Ys(t,e){return N(t,jt(t),e)}var Cr=Ys;function Vs(t,e,r){var o=e(t);return w(t)?o:ot(o,r(t))}var It=Vs;function Zs(t){return It(t,J,it)}var Fr=Zs;function Js(t){return It(t,X,jt)}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 Hr=gn;var yn="[object Boolean]",bn="[object Date]",vn="[object Map]",wn="[object Number]",Tn="[object RegExp]",On="[object Set]",Sn="[object String]",An="[object Symbol]",Pn="[object ArrayBuffer]",jn="[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 Pn:return nt(t);case yn:case bn:return new o(+t);case jn:return kr(t,r);case In:case _n:case En:case Cn:case Fn:case Mn:case Nn:case Rn:case Bn:return Hr(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 An:return Wr(t)}}var $r=Ln;function Dn(t){return typeof t.constructor=="function"&&!Y(t)?ge(At(t)):{}}var qr=Dn;var Un="[object Map]";function kn(t){return j(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 j(t)&&st(t)==Kn}var Jr=Gn;var Xr=F&&F.isSet,Wn=Xr?Z(Xr):Jr,Qr=Wn;var Hn=1,$n=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&Hn,f=e&$n,m=e&qn;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!P(t))return t;var h=w(t);if(h){if(n=Ur(t),!i)return be(t,n)}else{var v=st(t),A=v==eo||v==Xn;if(Tt(t))return jr(t,i);if(v==ro||v==to||A&&!a){if(n=f||A?{}:qr(t),!i)return f?Cr(t,Tr(n,t)):Er(t,wr(n,t))}else{if(!d[v])return a?t:{};n=$r(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,_=h?void 0:y(t);return Se(_||t,function(b,p){_&&(p=b,b=t[p]),$(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)&&H(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(!P(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 h=i[f];m=o?o(h,f,i):void 0,m===void 0&&(m=P(h)?h:H(e[a+1])?[]:{})}$(i,f,m),i=i[f]}return t}var no=Sf;function Af(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=Af;function Pf(t,e){return fo(t,e,function(r,o){return so(t,o)})}var po=Pf;var jf=cr(function(t,e){return t==null?{}:po(t,e)}),Mt=jf;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:h=ft,output:v=Kf,fullform:A=!1,fullforms:O=[],exponent:y=-1,roundingMethod:_=Bf,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Nt=ft;h===Df?(o=10,h=Kt):h===co||h===Kt?o=2:o===2?h=co:(o=10,h=Kt);let ct=o===10?1e3:1024,go=A===!0,$t=u<0,qt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Mf);if(typeof qt!==Ff)throw new TypeError(Nf);if($t&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(ct)),p<0&&(p=0)),p>8&&(b>0&&(b+=8-p),p=8),v===Cf)return p;if(u===0)l[0]=0,Nt=l[1]=Gt.symbol[h][e?mo:uo][p];else{E=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(E=E*8,E>=ct&&p<8&&(E=E/ct,p++));let pt=Math.pow(10,p>0?a:0);l[0]=qt(E*pt)/pt,l[0]===ct&&p<8&&y===-1&&(l[0]=1,p++),Nt=l[1]=o===10&&p===1?e?Uf:kf:Gt.symbol[h][e?mo:uo][p]}if($t&&(l[0]=-l[0]),b>0&&(l[0]=l[0].toPrecision(b)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,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[h][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);x(this,"id");x(this,"name");x(this,"icon");x(this,"path");x(this,"parsedName");x(this,"created");x(this,"createdFormatted");x(this,"modified");x(this,"modifiedFormatted");x(this,"accessed");x(this,"accessedFormatted");x(this,"size");x(this,"sizeFormatted");x(this,"mime");x(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),delete this.tera,Qt(this,k,e.tera),this.sizeFormatted=xo(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return lt(this,k).getProjectFile(this.path)}setContents(e){return lt(this,k).setProjectFile(this.path,e)}getRefs(){return lt(this,k).getProjectLibrary(this.path)}setRefs(e){return lt(this,k).setProjectLibrary(this.path,e)}serialize(){return Mt(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new Wt(Mt(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};k=new WeakMap;var K=Wt;var Ht=class{constructor(e){x(this,"settings",{devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3});x(this,"events",lo());x(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});x(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","setPageTitle","uiAlert","uiSplat","uiWindow"]);x(this,"plugins",[]);x(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=zt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||zt(),...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 K({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new K({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new K({tera:this,...r}))}};export{Ht as default};
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&&gt.keys&&gt.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 K({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new K({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new K({tera:this,...r}))}};export{$t as default};
3
3
  /*! Bundled license information:
4
4
 
5
5
  lodash-es/lodash.js:
package/dist/terafy.js CHANGED
@@ -1,4 +1,4 @@
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]",Ao="[object Undefined]",Xt=w?w.toStringTag:void 0;function Po(t){return t==null?t===void 0?Ao:So:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var j=Po;function jo(t){return t!=null&&typeof t=="object"}var P=jo;var Io="[object Symbol]";function _o(t){return typeof t=="symbol"||P(t)&&j(t)==Io}var z=_o;function Eo(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Qt=Eo;var Co=Array.isArray,v=Co;var 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 A=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(!A(t))return!1;var e=j(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 Ho=/[\\^$.*+?()[\]{}|]/g,$o=/^\[object .+?Constructor\]$/,qo=Function.prototype,Yo=Object.prototype,Vo=qo.toString,Zo=Yo.hasOwnProperty,Jo=RegExp("^"+Vo.call(Zo).replace(Ho,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Xo(t){if(!A(t)||se(t))return!1;var e=dt(t)?Jo:$o;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(!A(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)&&gt(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 Aa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Sa}var H=Aa;function Pa(t){return t!=null&&H(t.length)&&!dt(t)}var yt=Pa;var ja=Object.prototype;function Ia(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||ja;return t===r}var $=Ia;function _a(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ve=_a;var Ea="[object Arguments]";function Ca(t){return P(t)&&j(t)==Ea}var Ft=Ca;var we=Object.prototype,Fa=we.hasOwnProperty,Ma=we.propertyIsEnumerable,Na=Ft(function(){return arguments}())?Ft:function(t){return P(t)&&Fa.call(t,"callee")&&!Ma.call(t,"callee")},q=Na;function Ra(){return!1}var Te=Ra;var Ae=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Ae&&typeof module=="object"&&module&&!module.nodeType&&module,Ba=Oe&&Oe.exports===Ae,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]",Ha="[object Map]",$a="[object Number]",qa="[object Object]",Ya="[object RegExp]",Va="[object Set]",Za="[object String]",Ja="[object WeakMap]",Xa="[object ArrayBuffer]",Qa="[object DataView]",ti="[object Float32Array]",ei="[object Float64Array]",ri="[object Int8Array]",oi="[object Int16Array]",ai="[object Int32Array]",ii="[object Uint8Array]",si="[object Uint8ClampedArray]",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[Ha]=c[$a]=c[qa]=c[Ya]=c[Va]=c[Za]=c[Ja]=!1;function pi(t){return P(t)&&H(t.length)&&!!c[j(t)]}var Pe=pi;function li(t){return function(e){return t(e)}}var Y=li;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=je&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===je,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):Pe,_e=di;var ci=Object.prototype,hi=ci.hasOwnProperty;function xi(t,e){var r=v(t),o=!r&&q(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&_e(t),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(!$(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,Ai=Si.hasOwnProperty;function Pi(t){if(!A(t))return Fe(t);var e=$(t),r=[];for(var o in t)o=="constructor"&&(e||!Ai.call(t,o))||r.push(o);return r}var Me=Pi;function ji(t){return yt(t)?vt(t,!0):Me(t)}var Z=ji;var Ii=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_i=/^\w*$/;function Ei(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||z(t)?!0:_i.test(t)||!Ii.test(t)||e!=null&&t in Object(e)}var 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 Hi=Array.prototype,$i=Hi.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():$i.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 He=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Qi;function ts(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var L=ts;function es(t){var e=L(this,t).delete(t);return this.size-=e?1:0,e}var qe=es;function rs(t){return L(this,t).get(t)}var Ye=rs;function os(t){return L(this,t).has(t)}var Ve=os;function as(t,e){var r=L(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=as;function Q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Q.prototype.clear=He;Q.prototype.delete=qe;Q.prototype.get=Ye;Q.prototype.has=Ve;Q.prototype.set=Ze;var lt=Q;var is="Expected a function";function 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 As=200;function Ps(t,e){var r=this.__data__;if(r instanceof R){var o=r.__data__;if(!B||o.length<As-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new lt(o)}return r.set(t,e),this.size=r.size,this}var ur=Ps;function rt(t){var e=this.__data__=new 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 js(t,e){return t&&M(e,V(e),t)}var cr=js;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 At=ks;function zs(t){return At(t,V,ot)}var Ar=zs;function Ks(t){return At(t,Z,St)}var Pr=Ks;var Gs=O(x,"DataView"),Pt=Gs;var Ws=O(x,"Promise"),jt=Ws;var Hs=O(x,"Set"),It=Hs;var jr="[object Map]",$s="[object Object]",Ir="[object Promise]",_r="[object Set]",Er="[object WeakMap]",Cr="[object DataView]",qs=E(Pt),Ys=E(B),Vs=E(jt),Zs=E(It),Js=E(ht),U=j;(Pt&&U(new Pt(new ArrayBuffer(1)))!=Cr||B&&U(new B)!=jr||jt&&U(jt.resolve())!=Ir||It&&U(new It)!=_r||ht&&U(new ht)!=Er)&&(U=function(t){var e=j(t),r=e==$s?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case qs:return Cr;case Ys:return jr;case Vs:return Ir;case Zs:return _r;case Js:return Er}return e});var at=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]",An="[object Uint8ClampedArray]",Pn="[object Uint16Array]",jn="[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 An:case Pn:case jn: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"&&!$(t)?le(Tt(t)):{}}var kr=_n;var En="[object Map]";function Cn(t){return P(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 P(t)&&at(t)==Mn}var Wr=Nn;var Hr=C&&C.isSet,Rn=Hr?Y(Hr):Wr,$r=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]",Hn="[object Number]",Vr="[object Object]",$n="[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[Hn]=d[Vr]=d[$n]=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(!A(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),$r(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?Pr:Ar: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&&H(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(!A(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=A(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",Af="Invalid rounding method",Ut="jedec",Pf="object",no=".",jf="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=jf,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(Af);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),Ht=Wt[1]||st,$t=Ht.length,lo=a-$t;l[0]=`${Wt[0]}${nt}${Ht.padEnd($t+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===Pf?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(f)}var k=class t{#t;id;name;icon;path;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;meta={};constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),delete this.tera,this.#t=e.tera,this.sizeFormatted=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.path)}setContents(e){return this.#t.setProjectFile(this.path,e)}getRefs(){return this.#t.getProjectLibrary(this.path)}setRefs(e){return this.#t.setProjectLibrary(this.path,e)}serialize(){return Et(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3};events=oo();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","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(`
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)&&gt(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
2
  `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new k({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new k({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new k({tera:this,...r}))}};export{zt as default};
3
3
  /*! Bundled license information:
4
4
 
@@ -43,6 +43,22 @@ export default class ProjectFile {
43
43
  path;
44
44
 
45
45
 
46
+ /**
47
+ * Fully qualified URL to view / access / download the file from TERA
48
+ * This will usually open an edit UI within the TERA site
49
+ * @type {String}
50
+ */
51
+ url;
52
+
53
+
54
+ /**
55
+ * Rewrite of the URL where the absolute URL has been removed in place of a relative path, assuming the owner project is active
56
+ * This is used to direct to the edit/view/download UI when the files project is active and is usually used in place of URL for TERA related operations
57
+ * @type {String}
58
+ */
59
+ teraUrl;
60
+
61
+
46
62
  /**
47
63
  * An object representing meta file parts of a file name
48
64
  * @type {Object}
@@ -136,6 +152,9 @@ export default class ProjectFile {
136
152
  delete this.tera;
137
153
  this.#tera = baseFile.tera;
138
154
 
155
+ // Calculate `teraUrl` from URL
156
+ this.teraUrl = this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/(.+)$/, '/project/$1');
157
+
139
158
  // Set all `*Formatted` fields
140
159
  this.sizeFormatted = filesize(this.size || 0, {spacer: ''});
141
160
  this.createdFormatted = this.created ? this.created.toLocaleDateString() : 'Unknown created date';
@@ -152,7 +171,7 @@ export default class ProjectFile {
152
171
  * @see getProjectFile()
153
172
  */
154
173
  getContents() {
155
- return this.#tera.getProjectFile(this.path);
174
+ return this.#tera.getProjectFile(this.id);
156
175
  }
157
176
 
158
177
 
@@ -166,7 +185,7 @@ export default class ProjectFile {
166
185
  * @see setProjectFile()
167
186
  */
168
187
  setContents(contents) {
169
- return this.#tera.setProjectFile(this.path, contents);
188
+ return this.#tera.setProjectFile(this.id, contents);
170
189
  }
171
190
 
172
191
 
@@ -178,7 +197,7 @@ export default class ProjectFile {
178
197
  * @see getProjectLibrary()
179
198
  */
180
199
  getRefs() {
181
- return this.#tera.getProjectLibrary(this.path);
200
+ return this.#tera.getProjectLibrary(this.id);
182
201
  }
183
202
 
184
203
 
@@ -192,7 +211,7 @@ export default class ProjectFile {
192
211
  * @see setProjectLibrary()
193
212
  */
194
213
  setRefs(refs) {
195
- return this.#tera.setProjectLibrary(this.path, refs);
214
+ return this.#tera.setProjectLibrary(this.id, refs);
196
215
  }
197
216
 
198
217
 
@@ -209,6 +228,7 @@ export default class ProjectFile {
209
228
  'name',
210
229
  'icon',
211
230
  'path',
231
+ 'url',
212
232
  'parsedName',
213
233
  'created',
214
234
  'modified',
@@ -234,6 +254,7 @@ export default class ProjectFile {
234
254
  'name',
235
255
  'icon',
236
256
  'path',
257
+ 'url',
237
258
  'parsedName',
238
259
  'created',
239
260
  'modified',
@@ -947,11 +947,11 @@ export default class TeraFy {
947
947
  /**
948
948
  * Fetch a project file
949
949
  *
950
- * @param {String} path File path to read
950
+ * @param {String} id File ID to read
951
951
  * @returns {Promise<Blob>} The eventual fetched file as a blob
952
952
  */
953
- getProjectFile(path) {
954
- return this.rpc('getProjectFile', path)
953
+ getProjectFile(id) {
954
+ return this.rpc('getProjectFile', id)
955
955
  .then(file => file
956
956
  ? new ProjectFile({
957
957
  tera: this,
@@ -966,7 +966,7 @@ export default class TeraFy {
966
966
  * Replace a project files contents
967
967
  *
968
968
  * @function setProjectFile
969
- * @param {String} path File path to write
969
+ * @param {String} id File to overwrite
970
970
  * @param {File|Blob|FormData|Object|Array} contents The new file contents
971
971
  * @returns {Promise} A promise which will resolve when the write operation has completed
972
972
  */
@@ -995,7 +995,7 @@ export default class TeraFy {
995
995
  * Fetch + convert a project file into a library of citations
996
996
  *
997
997
  * @function getProjectLibrary
998
- * @param {String} path File path to read, if omitted the contents of `options` are used to guess at a suitable file
998
+ * @param {String} id File ID to read
999
999
  *
1000
1000
  * @param {Object} [options] Additional options to mutate behaviour
1001
1001
  * @param {String} [options.format='json'] Format for the file. ENUM: 'pojo' (return a parsed JS collection), 'blob' (raw JS Blob object), 'file' (named JS File object)
@@ -1011,17 +1011,17 @@ export default class TeraFy {
1011
1011
  * Save back a citation library from some input
1012
1012
  *
1013
1013
  * @function setProjectLibrary
1014
- * @param {String} [path] File path to save back to, if omitted one will be prompted for
1014
+ * @param {String} [id] File ID to save back to, if omitted a file will be prompted for
1015
1015
  * @param {Array<RefLibRef>|Blob|File} [refs] Collection of references for the selected library or the raw Blob/File
1016
1016
  *
1017
1017
  * @param {Object} [options] Additional options to mutate behaviour
1018
- * @param {String} [options.path] Alternate method to specify the path to save as, if omitted one will be prompted for
1018
+ * @param {String} [options.id] Alternate method to specify the file ID to save as, if omitted one will be prompted for
1019
1019
  * @param {Array<RefLibRef>|Blob|File} [options.refs] Alternate method to specify the refs to save as an array or raw Blob/File
1020
1020
  * @param {String} [options.format='json'] Input format used. ENUM: 'pojo' (return a parsed JS collection), 'blob' (raw JS Blob object), 'file' (named JS File object)
1021
1021
  * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
1022
1022
  * @param {String} [options.hint] Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
1023
- * @param {String} [options.filename] Suggested filename if path is unspecified
1024
- * @param {String} [options.title='Save citation library'] Dialog title if path is unspecified and we need to prompt
1023
+ * @param {String} [options.filename] Suggested filename if `id` is unspecified
1024
+ * @param {String} [options.title='Save citation library'] Dialog title if `id` is unspecified and a prompt is necessary
1025
1025
  * @param {Boolean} [options.overwrite=true] Allow existing file upsert
1026
1026
  * @param {Object} [options.meta] Optional meta data to merge into the file data
1027
1027
  *