@iebh/tera-fy 1.4.3 → 1.5.0

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:n,basePath:m,basePathForRemoves:h,diffs:v}){var P=Object.keys(i),O=P.length,y=Object.keys(n),_=y.length,b,p=i.length-n.length;if(To(i,n)){for(var u=0;u<O;u++){var l=Array.isArray(i)?Number(P[u]):P[u];l in n||(b=h.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<_;u++){var l=Array.isArray(n)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=h.concat(u),v.remove.push({op:"remove",path:r(b)});for(var E=i.slice(p),u=0;u<_;u++)s({key:u,obj1:E,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:v})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:v,diffs:P}){var O=n[i],y=m[i];if(!(i in n)&&i in m){var _=y;P.add.push({op:"add",path:r(h),value:_})}else O!==y&&(Object(O)!==O||Object(y)!==y||wo(O,y)||!Object.keys(O).length&&!Object.keys(y).length&&String(O)!=String(y)?f(h,P,y):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:v,diffs:P}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function ee(t){return[""].concat(t).join("/")}function wo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function To(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var Oo=typeof global=="object"&&global&&global.Object===Object&&global,ht=Oo;var Ao=typeof self=="object"&&self&&self.Object===Object&&self,Po=ht||Ao||Function("return this")(),g=Po;var So=g.Symbol,T=So;var re=Object.prototype,jo=re.hasOwnProperty,Io=re.toString,mt=T?T.toStringTag:void 0;function _o(t){var e=jo.call(t,mt),r=t[mt];try{t[mt]=void 0;var o=!0}catch{}var a=Io.call(t);return o&&(e?t[mt]=r:delete t[mt]),a}var oe=_o;var Eo=Object.prototype,Co=Eo.toString;function Mo(t){return Co.call(t)}var ae=Mo;var Fo="[object Null]",Ro="[object Undefined]",ie=T?T.toStringTag:void 0;function No(t){return t==null?t===void 0?Ro:Fo:ie&&ie in Object(t)?oe(t):ae(t)}var I=No;function Bo(t){return t!=null&&typeof t=="object"}var j=Bo;var Lo="[object Symbol]";function Do(t){return typeof t=="symbol"||j(t)&&I(t)==Lo}var G=Do;function 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,fe=T?T.prototype:void 0,ne=fe?fe.toString:void 0;function pe(t){if(typeof t=="string")return t;if(w(t))return se(t,pe)+"";if(G(t))return ne?ne.call(t):"";var e=t+"";return e=="0"&&1/t==-zo?"-0":e}var le=pe;function Ko(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var S=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(!S(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 fa(t){if(!S(t)||de(t))return!1;var e=xt(t)?sa:ea;return e.test(C(t))}var ce=fa;function na(t,e){return t==null?void 0:t[e]}var he=na;function pa(t,e){var r=he(t,e);return ce(r)?r:void 0}var A=pa;var la=A(g,"WeakMap"),yt=la;var xe=Object.create,ma=function(){function t(){}return function(e){if(!S(e))return{};if(xe)return xe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ge=ma;function ua(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var ye=ua;function da(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var be=da;var ca=800,ha=16,xa=Date.now;function ga(t){var e=0,r=0;return function(){var o=xa(),a=ha-(o-r);if(r=o,a>0){if(++e>=ca)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ve=ga;function ya(t){return function(){return t}}var we=ya;var ba=function(){try{var t=A(Object,"defineProperty");return t({},"",{}),t}catch{}}(),W=ba;var va=W?function(t,e){return W(t,"toString",{configurable:!0,enumerable:!1,value:we(e),writable:!0})}:me,Te=va;var wa=ve(Te),Oe=wa;function Ta(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Ae=Ta;var Oa=9007199254740991,Aa=/^(?:0|[1-9]\d*)$/;function Pa(t,e){var r=typeof t;return e=e==null?Oa:e,!!e&&(r=="number"||r!="symbol"&&Aa.test(t))&&t>-1&&t%1==0&&t<e}var H=Pa;function Sa(t,e,r){e=="__proto__"&&W?W(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var bt=Sa;function ja(t,e){return t===e||t!==t&&e!==e}var vt=ja;var Ia=Object.prototype,_a=Ia.hasOwnProperty;function Ea(t,e,r){var o=t[e];(!(_a.call(t,e)&&vt(o,r))||r===void 0&&!(e in t))&&bt(t,e,r)}var $=Ea;function Ca(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?bt(r,i,n):$(r,i,n)}return r}var R=Ca;var Pe=Math.max;function Ma(t,e,r){return e=Pe(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=Pe(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),ye(t,this,i)}}var Se=Ma;var Fa=9007199254740991;function Ra(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Fa}var q=Ra;function Na(t){return t!=null&&q(t.length)&&!xt(t)}var wt=Na;var Ba=Object.prototype;function La(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ba;return t===r}var Y=La;function Da(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var je=Da;var Ua="[object Arguments]";function ka(t){return j(t)&&I(t)==Ua}var Nt=ka;var Ie=Object.prototype,za=Ie.hasOwnProperty,Ka=Ie.propertyIsEnumerable,Ga=Nt(function(){return arguments}())?Nt:function(t){return j(t)&&za.call(t,"callee")&&!Ka.call(t,"callee")},V=Ga;function Wa(){return!1}var _e=Wa;var Me=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ee=Me&&typeof module=="object"&&module&&!module.nodeType&&module,Ha=Ee&&Ee.exports===Me,Ce=Ha?g.Buffer:void 0,$a=Ce?Ce.isBuffer:void 0,qa=$a||_e,Tt=qa;var Ya="[object Arguments]",Va="[object Array]",Za="[object Boolean]",Ja="[object Date]",Xa="[object Error]",Qa="[object Function]",ti="[object Map]",ei="[object Number]",ri="[object Object]",oi="[object RegExp]",ai="[object Set]",ii="[object String]",si="[object WeakMap]",fi="[object ArrayBuffer]",ni="[object DataView]",pi="[object Float32Array]",li="[object Float64Array]",mi="[object Int8Array]",ui="[object Int16Array]",di="[object Int32Array]",ci="[object Uint8Array]",hi="[object Uint8ClampedArray]",xi="[object Uint16Array]",gi="[object Uint32Array]",c={};c[pi]=c[li]=c[mi]=c[ui]=c[di]=c[ci]=c[hi]=c[xi]=c[gi]=!0;c[Ya]=c[Va]=c[fi]=c[Za]=c[ni]=c[Ja]=c[Xa]=c[Qa]=c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=!1;function yi(t){return j(t)&&q(t.length)&&!!c[I(t)]}var Fe=yi;function bi(t){return function(e){return t(e)}}var Z=bi;var Re=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ut=Re&&typeof module=="object"&&module&&!module.nodeType&&module,vi=ut&&ut.exports===Re,Bt=vi&&ht.process,wi=function(){try{var t=ut&&ut.require&&ut.require("util").types;return t||Bt&&Bt.binding&&Bt.binding("util")}catch{}}(),M=wi;var Ne=M&&M.isTypedArray,Ti=Ne?Z(Ne):Fe,Be=Ti;var Oi=Object.prototype,Ai=Oi.hasOwnProperty;function Pi(t,e){var r=w(t),o=!r&&V(t),a=!r&&!o&&Tt(t),s=!r&&!o&&!a&&Be(t),f=r||o||a||s,i=f?je(t.length,String):[],n=i.length;for(var m in t)(e||Ai.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||H(m,n)))&&i.push(m);return i}var Ot=Pi;function Si(t,e){return function(r){return t(e(r))}}var At=Si;var ji=At(Object.keys,Object),Le=ji;var Ii=Object.prototype,_i=Ii.hasOwnProperty;function Ei(t){if(!Y(t))return Le(t);var e=[];for(var r in Object(t))_i.call(t,r)&&r!="constructor"&&e.push(r);return e}var De=Ei;function Ci(t){return wt(t)?Ot(t):De(t)}var J=Ci;function Mi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ue=Mi;var Fi=Object.prototype,Ri=Fi.hasOwnProperty;function Ni(t){if(!S(t))return Ue(t);var e=Y(t),r=[];for(var o in t)o=="constructor"&&(e||!Ri.call(t,o))||r.push(o);return r}var ke=Ni;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=A(Object,"create"),F=ki;function zi(){this.__data__=F?F(null):{},this.size=0}var Ke=zi;function Ki(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ge=Ki;var Gi="__lodash_hash_undefined__",Wi=Object.prototype,Hi=Wi.hasOwnProperty;function $i(t){var e=this.__data__;if(F){var r=e[t];return r===Gi?void 0:r}return Hi.call(e,t)?e[t]:void 0}var We=$i;var qi=Object.prototype,Yi=qi.hasOwnProperty;function Vi(t){var e=this.__data__;return F?e[t]!==void 0:Yi.call(e,t)}var He=Vi;var Zi="__lodash_hash_undefined__";function Ji(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=F&&e===void 0?Zi:e,this}var $e=Ji;function Q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Q.prototype.clear=Ke;Q.prototype.delete=Ge;Q.prototype.get=We;Q.prototype.has=He;Q.prototype.set=$e;var Lt=Q;function Xi(){this.__data__=[],this.size=0}var qe=Xi;function Qi(t,e){for(var r=t.length;r--;)if(vt(t[r][0],e))return r;return-1}var N=Qi;var ts=Array.prototype,es=ts.splice;function rs(t){var e=this.__data__,r=N(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():es.call(e,r,1),--this.size,!0}var Ye=rs;function os(t){var e=this.__data__,r=N(e,t);return r<0?void 0:e[r][1]}var Ve=os;function as(t){return N(this.__data__,t)>-1}var Ze=as;function is(t,e){var r=this.__data__,o=N(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Je=is;function tt(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}tt.prototype.clear=qe;tt.prototype.delete=Ye;tt.prototype.get=Ve;tt.prototype.has=Ze;tt.prototype.set=Je;var B=tt;var ss=A(g,"Map"),L=ss;function fs(){this.size=0,this.__data__={hash:new Lt,map:new(L||B),string:new Lt}}var Xe=fs;function ns(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Qe=ns;function ps(t,e){var r=t.__data__;return Qe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var D=ps;function ls(t){var e=D(this,t).delete(t);return this.size-=e?1:0,e}var tr=ls;function ms(t){return D(this,t).get(t)}var er=ms;function us(t){return D(this,t).has(t)}var rr=us;function ds(t,e){var r=D(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var or=ds;function et(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}et.prototype.clear=Xe;et.prototype.delete=tr;et.prototype.get=er;et.prototype.has=rr;et.prototype.set=or;var dt=et;var cs="Expected a function";function Dt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(cs);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Dt.Cache||dt),r}Dt.Cache=dt;var ar=Dt;var hs=500;function xs(t){var e=ar(t,function(o){return r.size===hs&&r.clear(),o}),r=e.cache;return e}var ir=xs;var gs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ys=/\\(\\)?/g,bs=ir(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(gs,function(r,o,a,s){e.push(a?s.replace(ys,"$1"):o||r)}),e}),sr=bs;function vs(t){return t==null?"":le(t)}var fr=vs;function ws(t,e){return w(t)?t:ze(t,e)?[t]:sr(fr(t))}var 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 As(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 nr=As;function Ps(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ot=Ps;var pr=T?T.isConcatSpreadable:void 0;function Ss(t){return w(t)||V(t)||!!(pr&&t&&t[pr])}var lr=Ss;function mr(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=lr),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?mr(i,e-1,r,o,a):ot(a,i):o||(a[a.length]=i)}return a}var ur=mr;function js(t){var e=t==null?0:t.length;return e?ur(t,1):[]}var dr=js;function Is(t){return Oe(Se(t,void 0,dr),t+"")}var cr=Is;var _s=At(Object.getPrototypeOf,Object),Pt=_s;function Es(){this.__data__=new B,this.size=0}var hr=Es;function Cs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var xr=Cs;function Ms(t){return this.__data__.get(t)}var gr=Ms;function Fs(t){return this.__data__.has(t)}var yr=Fs;var Rs=200;function Ns(t,e){var r=this.__data__;if(r instanceof B){var o=r.__data__;if(!L||o.length<Rs-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new dt(o)}return r.set(t,e),this.size=r.size,this}var br=Ns;function at(t){var e=this.__data__=new B(t);this.size=e.size}at.prototype.clear=hr;at.prototype.delete=xr;at.prototype.get=gr;at.prototype.has=yr;at.prototype.set=br;var vr=at;function Bs(t,e){return t&&R(e,J(e),t)}var wr=Bs;function Ls(t,e){return t&&R(e,X(e),t)}var Tr=Ls;var Sr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Or=Sr&&typeof module=="object"&&module&&!module.nodeType&&module,Ds=Or&&Or.exports===Sr,Ar=Ds?g.Buffer:void 0,Pr=Ar?Ar.allocUnsafe:void 0;function Us(t,e){if(e)return t.slice();var r=t.length,o=Pr?Pr(r):new t.constructor(r);return t.copy(o),o}var jr=Us;function ks(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var Ir=ks;function zs(){return[]}var St=zs;var Ks=Object.prototype,Gs=Ks.propertyIsEnumerable,_r=Object.getOwnPropertySymbols,Ws=_r?function(t){return t==null?[]:(t=Object(t),Ir(_r(t),function(e){return Gs.call(t,e)}))}:St,it=Ws;function Hs(t,e){return R(t,it(t),e)}var Er=Hs;var $s=Object.getOwnPropertySymbols,qs=$s?function(t){for(var e=[];t;)ot(e,it(t)),t=Pt(t);return e}:St,jt=qs;function Ys(t,e){return R(t,jt(t),e)}var Cr=Ys;function Vs(t,e,r){var o=e(t);return w(t)?o:ot(o,r(t))}var It=Vs;function Zs(t){return It(t,J,it)}var Mr=Zs;function Js(t){return It(t,X,jt)}var Fr=Js;var Xs=A(g,"DataView"),_t=Xs;var Qs=A(g,"Promise"),Et=Qs;var tf=A(g,"Set"),Ct=tf;var Rr="[object Map]",ef="[object Object]",Nr="[object Promise]",Br="[object Set]",Lr="[object WeakMap]",Dr="[object DataView]",rf=C(_t),of=C(L),af=C(Et),sf=C(Ct),ff=C(yt),z=I;(_t&&z(new _t(new ArrayBuffer(1)))!=Dr||L&&z(new L)!=Rr||Et&&z(Et.resolve())!=Nr||Ct&&z(new Ct)!=Br||yt&&z(new yt)!=Lr)&&(z=function(t){var e=I(t),r=e==ef?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case rf:return Dr;case of:return Rr;case af:return Nr;case sf:return Br;case ff:return Lr}return e});var st=z;var nf=Object.prototype,pf=nf.hasOwnProperty;function lf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&pf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ur=lf;var mf=g.Uint8Array,Ut=mf;function uf(t){var e=new t.constructor(t.byteLength);return new Ut(e).set(new Ut(t)),e}var ft=uf;function df(t,e){var r=e?ft(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var kr=df;var cf=/\w*$/;function hf(t){var e=new t.constructor(t.source,cf.exec(t));return e.lastIndex=t.lastIndex,e}var zr=hf;var Kr=T?T.prototype:void 0,Gr=Kr?Kr.valueOf:void 0;function xf(t){return Gr?Object(Gr.call(t)):{}}var Wr=xf;function gf(t,e){var r=e?ft(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Hr=gf;var yf="[object Boolean]",bf="[object Date]",vf="[object Map]",wf="[object Number]",Tf="[object RegExp]",Of="[object Set]",Af="[object String]",Pf="[object Symbol]",Sf="[object ArrayBuffer]",jf="[object DataView]",If="[object Float32Array]",_f="[object Float64Array]",Ef="[object Int8Array]",Cf="[object Int16Array]",Mf="[object Int32Array]",Ff="[object Uint8Array]",Rf="[object Uint8ClampedArray]",Nf="[object Uint16Array]",Bf="[object Uint32Array]";function Lf(t,e,r){var o=t.constructor;switch(e){case Sf:return ft(t);case yf:case bf:return new o(+t);case jf:return kr(t,r);case If:case _f:case Ef:case Cf:case Mf:case Ff:case Rf:case Nf:case Bf:return Hr(t,r);case vf:return new o;case wf:case Af:return new o(t);case Tf:return zr(t);case Of:return new o;case Pf:return Wr(t)}}var $r=Lf;function Df(t){return typeof t.constructor=="function"&&!Y(t)?ge(Pt(t)):{}}var qr=Df;var Uf="[object Map]";function kf(t){return j(t)&&st(t)==Uf}var Yr=kf;var Vr=M&&M.isMap,zf=Vr?Z(Vr):Yr,Zr=zf;var Kf="[object Set]";function Gf(t){return j(t)&&st(t)==Kf}var Jr=Gf;var Xr=M&&M.isSet,Wf=Xr?Z(Xr):Jr,Qr=Wf;var Hf=1,$f=2,qf=4,to="[object Arguments]",Yf="[object Array]",Vf="[object Boolean]",Zf="[object Date]",Jf="[object Error]",eo="[object Function]",Xf="[object GeneratorFunction]",Qf="[object Map]",tn="[object Number]",ro="[object Object]",en="[object RegExp]",rn="[object Set]",on="[object String]",an="[object Symbol]",sn="[object WeakMap]",fn="[object ArrayBuffer]",nn="[object DataView]",pn="[object Float32Array]",ln="[object Float64Array]",mn="[object Int8Array]",un="[object Int16Array]",dn="[object Int32Array]",cn="[object Uint8Array]",hn="[object Uint8ClampedArray]",xn="[object Uint16Array]",gn="[object Uint32Array]",d={};d[to]=d[Yf]=d[fn]=d[nn]=d[Vf]=d[Zf]=d[pn]=d[ln]=d[mn]=d[un]=d[dn]=d[Qf]=d[tn]=d[ro]=d[en]=d[rn]=d[on]=d[an]=d[cn]=d[hn]=d[xn]=d[gn]=!0;d[Jf]=d[eo]=d[sn]=!1;function Mt(t,e,r,o,a,s){var f,i=e&Hf,n=e&$f,m=e&qf;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!S(t))return t;var h=w(t);if(h){if(f=Ur(t),!i)return be(t,f)}else{var v=st(t),P=v==eo||v==Xf;if(Tt(t))return jr(t,i);if(v==ro||v==to||P&&!a){if(f=n||P?{}:qr(t),!i)return n?Cr(t,Tr(f,t)):Er(t,wr(f,t))}else{if(!d[v])return a?t:{};f=$r(t,v,i)}}s||(s=new vr);var O=s.get(t);if(O)return O;s.set(t,f),Qr(t)?t.forEach(function(b){f.add(Mt(b,e,r,b,t,s))}):Zr(t)&&t.forEach(function(b,p){f.set(p,Mt(b,e,r,p,t,s))});var y=m?n?Fr:Mr:n?X:J,_=h?void 0:y(t);return Ae(_||t,function(b,p){_&&(p=b,b=t[p]),$(f,p,Mt(b,e,r,p,t,s))}),f}var oo=Mt;var yn=1,bn=4;function vn(t){return oo(t,yn|bn)}var kt=vn;function wn(t,e){return t!=null&&e in Object(t)}var ao=wn;function Tn(t,e,r){e=U(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=rt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&q(a)&&H(f,a)&&(w(t)||V(t)))}var io=Tn;function On(t,e){return t!=null&&io(t,e,ao)}var so=On;function An(t,e,r,o){if(!S(t))return t;e=U(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=rt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=S(h)?h:H(e[a+1])?[]:{})}$(i,n,m),i=i[n]}return t}var fo=An;function Pn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=nr(t,f);r(i,f)&&fo(s,U(f,t),i)}return s}var no=Pn;function Sn(t,e){return no(t,e,function(r,o){return so(t,o)})}var po=Sn;var jn=cr(function(t,e){return t==null?{}:po(t,e)}),Ft=jn;function lo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var zt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var In="array",_n="bit",mo="bits",En="byte",uo="bytes",nt="",Cn="exponent",Mn="function",co="iec",Fn="Invalid number",Rn="Invalid rounding method",Kt="jedec",Nn="object",ho=".",Bn="round",Ln="s",Dn="si",Un="kbit",kn="kB",zn=" ",Kn="string",Gn="0",Gt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function xo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=nt,localeOptions:f={},separator:i=nt,spacer:n=zn,symbols:m={},standard:h=nt,output:v=Kn,fullform:P=!1,fullforms:O=[],exponent:y=-1,roundingMethod:_=Bn,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Rt=nt;h===Dn?(o=10,h=Kt):h===co||h===Kt?o=2:o===2?h=co:(o=10,h=Kt);let ct=o===10?1e3:1024,go=P===!0,$t=u<0,qt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Fn);if(typeof qt!==Mn)throw new TypeError(Rn);if($t&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(ct)),p<0&&(p=0)),p>8&&(b>0&&(b+=8-p),p=8),v===Cn)return p;if(u===0)l[0]=0,Rt=l[1]=Gt.symbol[h][e?mo:uo][p];else{E=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(E=E*8,E>=ct&&p<8&&(E=E/ct,p++));let pt=Math.pow(10,p>0?a:0);l[0]=qt(E*pt)/pt,l[0]===ct&&p<8&&y===-1&&(l[0]=1,p++),Rt=l[1]=o===10&&p===1?e?Un:kn:Gt.symbol[h][e?mo:uo][p]}if($t&&(l[0]=-l[0]),b>0&&(l[0]=l[0].toPrecision(b)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(ho,i)),r&&Number.isInteger(l[0])===!1&&a>0){let pt=i||ho,Yt=l[0].toString().split(pt),Vt=Yt[1]||nt,Zt=Vt.length,yo=a-Zt;l[0]=`${Yt[0]}${pt}${Vt.padEnd(Zt+yo,Gn)}`}return go&&(l[1]=O[p]?O[p]:Gt.fullform[h][p]+(e?_n:En)+(l[0]===1?nt:Ln)),v===In?l:v===Nn?{value:l[0],symbol:l[1],exponent:p,unit:Rt}:l.join(n)}var 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 Ft(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new Wt(Ft(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};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","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","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.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
- `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new K({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new K({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new K({tera:this,...r}))}setPageUrl(e){}};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 x=(t,e,r)=>(vo(t,typeof e!="symbol"?e+"":e,r),r),Jt=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var lt=(t,e,r)=>(Jt(t,e,"read from private field"),r?r.call(t):e.get(t)),Xt=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},Qt=(t,e,r,o)=>(Jt(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r);function te(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:v}){var P=Object.keys(i),O=P.length,y=Object.keys(n),_=y.length,b,p=i.length-n.length;if(To(i,n)){for(var u=0;u<O;u++){var l=Array.isArray(i)?Number(P[u]):P[u];l in n||(b=h.concat(l),v.remove.push({op:"remove",path:r(b)}))}for(var u=0;u<_;u++){var l=Array.isArray(n)?Number(y[u]):y[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:v})}}else{for(var u=0;u<p;u++)b=h.concat(u),v.remove.push({op:"remove",path:r(b)});for(var E=i.slice(p),u=0;u<_;u++)s({key:u,obj1:E,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:v})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:v,diffs:P}){var O=n[i],y=m[i];if(!(i in n)&&i in m){var _=y;P.add.push({op:"add",path:r(h),value:_})}else O!==y&&(Object(O)!==O||Object(y)!==y||wo(O,y)||!Object.keys(O).length&&!Object.keys(y).length&&String(O)!=String(y)?f(h,P,y):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:v,diffs:P}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function ee(t){return[""].concat(t).join("/")}function wo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function To(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var Oo=typeof global=="object"&&global&&global.Object===Object&&global,ht=Oo;var Ao=typeof self=="object"&&self&&self.Object===Object&&self,Po=ht||Ao||Function("return this")(),g=Po;var So=g.Symbol,T=So;var re=Object.prototype,jo=re.hasOwnProperty,Io=re.toString,mt=T?T.toStringTag:void 0;function _o(t){var e=jo.call(t,mt),r=t[mt];try{t[mt]=void 0;var o=!0}catch{}var a=Io.call(t);return o&&(e?t[mt]=r:delete t[mt]),a}var oe=_o;var Eo=Object.prototype,Co=Eo.toString;function Mo(t){return Co.call(t)}var ae=Mo;var Fo="[object Null]",Ro="[object Undefined]",ie=T?T.toStringTag:void 0;function No(t){return t==null?t===void 0?Ro:Fo:ie&&ie in Object(t)?oe(t):ae(t)}var I=No;function Bo(t){return t!=null&&typeof t=="object"}var j=Bo;var Lo="[object Symbol]";function Do(t){return typeof t=="symbol"||j(t)&&I(t)==Lo}var G=Do;function 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,fe=T?T.prototype:void 0,ne=fe?fe.toString:void 0;function pe(t){if(typeof t=="string")return t;if(w(t))return se(t,pe)+"";if(G(t))return ne?ne.call(t):"";var e=t+"";return e=="0"&&1/t==-zo?"-0":e}var le=pe;function Ko(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var S=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(!S(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 fa(t){if(!S(t)||de(t))return!1;var e=xt(t)?sa:ea;return e.test(C(t))}var ce=fa;function na(t,e){return t==null?void 0:t[e]}var he=na;function pa(t,e){var r=he(t,e);return ce(r)?r:void 0}var A=pa;var la=A(g,"WeakMap"),yt=la;var xe=Object.create,ma=function(){function t(){}return function(e){if(!S(e))return{};if(xe)return xe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ge=ma;function ua(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var ye=ua;function da(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var be=da;var ca=800,ha=16,xa=Date.now;function ga(t){var e=0,r=0;return function(){var o=xa(),a=ha-(o-r);if(r=o,a>0){if(++e>=ca)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var ve=ga;function ya(t){return function(){return t}}var we=ya;var ba=function(){try{var t=A(Object,"defineProperty");return t({},"",{}),t}catch{}}(),W=ba;var va=W?function(t,e){return W(t,"toString",{configurable:!0,enumerable:!1,value:we(e),writable:!0})}:me,Te=va;var wa=ve(Te),Oe=wa;function Ta(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Ae=Ta;var Oa=9007199254740991,Aa=/^(?:0|[1-9]\d*)$/;function Pa(t,e){var r=typeof t;return e=e==null?Oa:e,!!e&&(r=="number"||r!="symbol"&&Aa.test(t))&&t>-1&&t%1==0&&t<e}var H=Pa;function Sa(t,e,r){e=="__proto__"&&W?W(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var bt=Sa;function ja(t,e){return t===e||t!==t&&e!==e}var vt=ja;var Ia=Object.prototype,_a=Ia.hasOwnProperty;function Ea(t,e,r){var o=t[e];(!(_a.call(t,e)&&vt(o,r))||r===void 0&&!(e in t))&&bt(t,e,r)}var $=Ea;function Ca(t,e,r,o){var a=!r;r||(r={});for(var s=-1,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?bt(r,i,n):$(r,i,n)}return r}var R=Ca;var Pe=Math.max;function Ma(t,e,r){return e=Pe(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=Pe(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),ye(t,this,i)}}var Se=Ma;var Fa=9007199254740991;function Ra(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Fa}var q=Ra;function Na(t){return t!=null&&q(t.length)&&!xt(t)}var wt=Na;var Ba=Object.prototype;function La(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Ba;return t===r}var Y=La;function Da(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var je=Da;var Ua="[object Arguments]";function ka(t){return j(t)&&I(t)==Ua}var Nt=ka;var Ie=Object.prototype,za=Ie.hasOwnProperty,Ka=Ie.propertyIsEnumerable,Ga=Nt(function(){return arguments}())?Nt:function(t){return j(t)&&za.call(t,"callee")&&!Ka.call(t,"callee")},V=Ga;function Wa(){return!1}var _e=Wa;var Me=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ee=Me&&typeof module=="object"&&module&&!module.nodeType&&module,Ha=Ee&&Ee.exports===Me,Ce=Ha?g.Buffer:void 0,$a=Ce?Ce.isBuffer:void 0,qa=$a||_e,Tt=qa;var Ya="[object Arguments]",Va="[object Array]",Za="[object Boolean]",Ja="[object Date]",Xa="[object Error]",Qa="[object Function]",ti="[object Map]",ei="[object Number]",ri="[object Object]",oi="[object RegExp]",ai="[object Set]",ii="[object String]",si="[object WeakMap]",fi="[object ArrayBuffer]",ni="[object DataView]",pi="[object Float32Array]",li="[object Float64Array]",mi="[object Int8Array]",ui="[object Int16Array]",di="[object Int32Array]",ci="[object Uint8Array]",hi="[object Uint8ClampedArray]",xi="[object Uint16Array]",gi="[object Uint32Array]",c={};c[pi]=c[li]=c[mi]=c[ui]=c[di]=c[ci]=c[hi]=c[xi]=c[gi]=!0;c[Ya]=c[Va]=c[fi]=c[Za]=c[ni]=c[Ja]=c[Xa]=c[Qa]=c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=!1;function yi(t){return j(t)&&q(t.length)&&!!c[I(t)]}var Fe=yi;function bi(t){return function(e){return t(e)}}var Z=bi;var Re=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ut=Re&&typeof module=="object"&&module&&!module.nodeType&&module,vi=ut&&ut.exports===Re,Bt=vi&&ht.process,wi=function(){try{var t=ut&&ut.require&&ut.require("util").types;return t||Bt&&Bt.binding&&Bt.binding("util")}catch{}}(),M=wi;var Ne=M&&M.isTypedArray,Ti=Ne?Z(Ne):Fe,Be=Ti;var Oi=Object.prototype,Ai=Oi.hasOwnProperty;function Pi(t,e){var r=w(t),o=!r&&V(t),a=!r&&!o&&Tt(t),s=!r&&!o&&!a&&Be(t),f=r||o||a||s,i=f?je(t.length,String):[],n=i.length;for(var m in t)(e||Ai.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||H(m,n)))&&i.push(m);return i}var Ot=Pi;function Si(t,e){return function(r){return t(e(r))}}var At=Si;var ji=At(Object.keys,Object),Le=ji;var Ii=Object.prototype,_i=Ii.hasOwnProperty;function Ei(t){if(!Y(t))return Le(t);var e=[];for(var r in Object(t))_i.call(t,r)&&r!="constructor"&&e.push(r);return e}var De=Ei;function Ci(t){return wt(t)?Ot(t):De(t)}var J=Ci;function Mi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ue=Mi;var Fi=Object.prototype,Ri=Fi.hasOwnProperty;function Ni(t){if(!S(t))return Ue(t);var e=Y(t),r=[];for(var o in t)o=="constructor"&&(e||!Ri.call(t,o))||r.push(o);return r}var ke=Ni;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=A(Object,"create"),F=ki;function zi(){this.__data__=F?F(null):{},this.size=0}var Ke=zi;function Ki(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ge=Ki;var Gi="__lodash_hash_undefined__",Wi=Object.prototype,Hi=Wi.hasOwnProperty;function $i(t){var e=this.__data__;if(F){var r=e[t];return r===Gi?void 0:r}return Hi.call(e,t)?e[t]:void 0}var We=$i;var qi=Object.prototype,Yi=qi.hasOwnProperty;function Vi(t){var e=this.__data__;return F?e[t]!==void 0:Yi.call(e,t)}var He=Vi;var Zi="__lodash_hash_undefined__";function Ji(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=F&&e===void 0?Zi:e,this}var $e=Ji;function Q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Q.prototype.clear=Ke;Q.prototype.delete=Ge;Q.prototype.get=We;Q.prototype.has=He;Q.prototype.set=$e;var Lt=Q;function Xi(){this.__data__=[],this.size=0}var qe=Xi;function Qi(t,e){for(var r=t.length;r--;)if(vt(t[r][0],e))return r;return-1}var N=Qi;var ts=Array.prototype,es=ts.splice;function rs(t){var e=this.__data__,r=N(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():es.call(e,r,1),--this.size,!0}var Ye=rs;function os(t){var e=this.__data__,r=N(e,t);return r<0?void 0:e[r][1]}var Ve=os;function as(t){return N(this.__data__,t)>-1}var Ze=as;function is(t,e){var r=this.__data__,o=N(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Je=is;function tt(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}tt.prototype.clear=qe;tt.prototype.delete=Ye;tt.prototype.get=Ve;tt.prototype.has=Ze;tt.prototype.set=Je;var B=tt;var ss=A(g,"Map"),L=ss;function fs(){this.size=0,this.__data__={hash:new Lt,map:new(L||B),string:new Lt}}var Xe=fs;function ns(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Qe=ns;function ps(t,e){var r=t.__data__;return Qe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var D=ps;function ls(t){var e=D(this,t).delete(t);return this.size-=e?1:0,e}var tr=ls;function ms(t){return D(this,t).get(t)}var er=ms;function us(t){return D(this,t).has(t)}var rr=us;function ds(t,e){var r=D(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var or=ds;function et(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}et.prototype.clear=Xe;et.prototype.delete=tr;et.prototype.get=er;et.prototype.has=rr;et.prototype.set=or;var dt=et;var cs="Expected a function";function Dt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(cs);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Dt.Cache||dt),r}Dt.Cache=dt;var ar=Dt;var hs=500;function xs(t){var e=ar(t,function(o){return r.size===hs&&r.clear(),o}),r=e.cache;return e}var ir=xs;var gs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ys=/\\(\\)?/g,bs=ir(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(gs,function(r,o,a,s){e.push(a?s.replace(ys,"$1"):o||r)}),e}),sr=bs;function vs(t){return t==null?"":le(t)}var fr=vs;function ws(t,e){return w(t)?t:ze(t,e)?[t]:sr(fr(t))}var 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 As(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 nr=As;function Ps(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ot=Ps;var pr=T?T.isConcatSpreadable:void 0;function Ss(t){return w(t)||V(t)||!!(pr&&t&&t[pr])}var lr=Ss;function mr(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=lr),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?mr(i,e-1,r,o,a):ot(a,i):o||(a[a.length]=i)}return a}var ur=mr;function js(t){var e=t==null?0:t.length;return e?ur(t,1):[]}var dr=js;function Is(t){return Oe(Se(t,void 0,dr),t+"")}var cr=Is;var _s=At(Object.getPrototypeOf,Object),Pt=_s;function Es(){this.__data__=new B,this.size=0}var hr=Es;function Cs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var xr=Cs;function Ms(t){return this.__data__.get(t)}var gr=Ms;function Fs(t){return this.__data__.has(t)}var yr=Fs;var Rs=200;function Ns(t,e){var r=this.__data__;if(r instanceof B){var o=r.__data__;if(!L||o.length<Rs-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new dt(o)}return r.set(t,e),this.size=r.size,this}var br=Ns;function at(t){var e=this.__data__=new B(t);this.size=e.size}at.prototype.clear=hr;at.prototype.delete=xr;at.prototype.get=gr;at.prototype.has=yr;at.prototype.set=br;var vr=at;function Bs(t,e){return t&&R(e,J(e),t)}var wr=Bs;function Ls(t,e){return t&&R(e,X(e),t)}var Tr=Ls;var Sr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Or=Sr&&typeof module=="object"&&module&&!module.nodeType&&module,Ds=Or&&Or.exports===Sr,Ar=Ds?g.Buffer:void 0,Pr=Ar?Ar.allocUnsafe:void 0;function Us(t,e){if(e)return t.slice();var r=t.length,o=Pr?Pr(r):new t.constructor(r);return t.copy(o),o}var jr=Us;function ks(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var Ir=ks;function zs(){return[]}var St=zs;var Ks=Object.prototype,Gs=Ks.propertyIsEnumerable,_r=Object.getOwnPropertySymbols,Ws=_r?function(t){return t==null?[]:(t=Object(t),Ir(_r(t),function(e){return Gs.call(t,e)}))}:St,it=Ws;function Hs(t,e){return R(t,it(t),e)}var Er=Hs;var $s=Object.getOwnPropertySymbols,qs=$s?function(t){for(var e=[];t;)ot(e,it(t)),t=Pt(t);return e}:St,jt=qs;function Ys(t,e){return R(t,jt(t),e)}var Cr=Ys;function Vs(t,e,r){var o=e(t);return w(t)?o:ot(o,r(t))}var It=Vs;function Zs(t){return It(t,J,it)}var Mr=Zs;function Js(t){return It(t,X,jt)}var Fr=Js;var Xs=A(g,"DataView"),_t=Xs;var Qs=A(g,"Promise"),Et=Qs;var tf=A(g,"Set"),Ct=tf;var Rr="[object Map]",ef="[object Object]",Nr="[object Promise]",Br="[object Set]",Lr="[object WeakMap]",Dr="[object DataView]",rf=C(_t),of=C(L),af=C(Et),sf=C(Ct),ff=C(yt),z=I;(_t&&z(new _t(new ArrayBuffer(1)))!=Dr||L&&z(new L)!=Rr||Et&&z(Et.resolve())!=Nr||Ct&&z(new Ct)!=Br||yt&&z(new yt)!=Lr)&&(z=function(t){var e=I(t),r=e==ef?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case rf:return Dr;case of:return Rr;case af:return Nr;case sf:return Br;case ff:return Lr}return e});var st=z;var nf=Object.prototype,pf=nf.hasOwnProperty;function lf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&pf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ur=lf;var mf=g.Uint8Array,Ut=mf;function uf(t){var e=new t.constructor(t.byteLength);return new Ut(e).set(new Ut(t)),e}var ft=uf;function df(t,e){var r=e?ft(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var kr=df;var cf=/\w*$/;function hf(t){var e=new t.constructor(t.source,cf.exec(t));return e.lastIndex=t.lastIndex,e}var zr=hf;var Kr=T?T.prototype:void 0,Gr=Kr?Kr.valueOf:void 0;function xf(t){return Gr?Object(Gr.call(t)):{}}var Wr=xf;function gf(t,e){var r=e?ft(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Hr=gf;var yf="[object Boolean]",bf="[object Date]",vf="[object Map]",wf="[object Number]",Tf="[object RegExp]",Of="[object Set]",Af="[object String]",Pf="[object Symbol]",Sf="[object ArrayBuffer]",jf="[object DataView]",If="[object Float32Array]",_f="[object Float64Array]",Ef="[object Int8Array]",Cf="[object Int16Array]",Mf="[object Int32Array]",Ff="[object Uint8Array]",Rf="[object Uint8ClampedArray]",Nf="[object Uint16Array]",Bf="[object Uint32Array]";function Lf(t,e,r){var o=t.constructor;switch(e){case Sf:return ft(t);case yf:case bf:return new o(+t);case jf:return kr(t,r);case If:case _f:case Ef:case Cf:case Mf:case Ff:case Rf:case Nf:case Bf:return Hr(t,r);case vf:return new o;case wf:case Af:return new o(t);case Tf:return zr(t);case Of:return new o;case Pf:return Wr(t)}}var $r=Lf;function Df(t){return typeof t.constructor=="function"&&!Y(t)?ge(Pt(t)):{}}var qr=Df;var Uf="[object Map]";function kf(t){return j(t)&&st(t)==Uf}var Yr=kf;var Vr=M&&M.isMap,zf=Vr?Z(Vr):Yr,Zr=zf;var Kf="[object Set]";function Gf(t){return j(t)&&st(t)==Kf}var Jr=Gf;var Xr=M&&M.isSet,Wf=Xr?Z(Xr):Jr,Qr=Wf;var Hf=1,$f=2,qf=4,to="[object Arguments]",Yf="[object Array]",Vf="[object Boolean]",Zf="[object Date]",Jf="[object Error]",eo="[object Function]",Xf="[object GeneratorFunction]",Qf="[object Map]",tn="[object Number]",ro="[object Object]",en="[object RegExp]",rn="[object Set]",on="[object String]",an="[object Symbol]",sn="[object WeakMap]",fn="[object ArrayBuffer]",nn="[object DataView]",pn="[object Float32Array]",ln="[object Float64Array]",mn="[object Int8Array]",un="[object Int16Array]",dn="[object Int32Array]",cn="[object Uint8Array]",hn="[object Uint8ClampedArray]",xn="[object Uint16Array]",gn="[object Uint32Array]",d={};d[to]=d[Yf]=d[fn]=d[nn]=d[Vf]=d[Zf]=d[pn]=d[ln]=d[mn]=d[un]=d[dn]=d[Qf]=d[tn]=d[ro]=d[en]=d[rn]=d[on]=d[an]=d[cn]=d[hn]=d[xn]=d[gn]=!0;d[Jf]=d[eo]=d[sn]=!1;function Mt(t,e,r,o,a,s){var f,i=e&Hf,n=e&$f,m=e&qf;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!S(t))return t;var h=w(t);if(h){if(f=Ur(t),!i)return be(t,f)}else{var v=st(t),P=v==eo||v==Xf;if(Tt(t))return jr(t,i);if(v==ro||v==to||P&&!a){if(f=n||P?{}:qr(t),!i)return n?Cr(t,Tr(f,t)):Er(t,wr(f,t))}else{if(!d[v])return a?t:{};f=$r(t,v,i)}}s||(s=new vr);var O=s.get(t);if(O)return O;s.set(t,f),Qr(t)?t.forEach(function(b){f.add(Mt(b,e,r,b,t,s))}):Zr(t)&&t.forEach(function(b,p){f.set(p,Mt(b,e,r,p,t,s))});var y=m?n?Fr:Mr:n?X:J,_=h?void 0:y(t);return Ae(_||t,function(b,p){_&&(p=b,b=t[p]),$(f,p,Mt(b,e,r,p,t,s))}),f}var oo=Mt;var yn=1,bn=4;function vn(t){return oo(t,yn|bn)}var kt=vn;function wn(t,e){return t!=null&&e in Object(t)}var ao=wn;function Tn(t,e,r){e=U(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=rt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&q(a)&&H(f,a)&&(w(t)||V(t)))}var io=Tn;function On(t,e){return t!=null&&io(t,e,ao)}var so=On;function An(t,e,r,o){if(!S(t))return t;e=U(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=rt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=S(h)?h:H(e[a+1])?[]:{})}$(i,n,m),i=i[n]}return t}var fo=An;function Pn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=nr(t,f);r(i,f)&&fo(s,U(f,t),i)}return s}var no=Pn;function Sn(t,e){return no(t,e,function(r,o){return so(t,o)})}var po=Sn;var jn=cr(function(t,e){return t==null?{}:po(t,e)}),Ft=jn;function lo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var zt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var In="array",_n="bit",mo="bits",En="byte",uo="bytes",nt="",Cn="exponent",Mn="function",co="iec",Fn="Invalid number",Rn="Invalid rounding method",Kt="jedec",Nn="object",ho=".",Bn="round",Ln="s",Dn="si",Un="kbit",kn="kB",zn=" ",Kn="string",Gn="0",Gt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function xo(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=nt,localeOptions:f={},separator:i=nt,spacer:n=zn,symbols:m={},standard:h=nt,output:v=Kn,fullform:P=!1,fullforms:O=[],exponent:y=-1,roundingMethod:_=Bn,precision:b=0}={}){let p=y,u=Number(t),l=[],E=0,Rt=nt;h===Dn?(o=10,h=Kt):h===co||h===Kt?o=2:o===2?h=co:(o=10,h=Kt);let ct=o===10?1e3:1024,go=P===!0,$t=u<0,qt=Math[_];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(Fn);if(typeof qt!==Mn)throw new TypeError(Rn);if($t&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(ct)),p<0&&(p=0)),p>8&&(b>0&&(b+=8-p),p=8),v===Cn)return p;if(u===0)l[0]=0,Rt=l[1]=Gt.symbol[h][e?mo:uo][p];else{E=u/(o===2?Math.pow(2,p*10):Math.pow(1e3,p)),e&&(E=E*8,E>=ct&&p<8&&(E=E/ct,p++));let pt=Math.pow(10,p>0?a:0);l[0]=qt(E*pt)/pt,l[0]===ct&&p<8&&y===-1&&(l[0]=1,p++),Rt=l[1]=o===10&&p===1?e?Un:kn:Gt.symbol[h][e?mo:uo][p]}if($t&&(l[0]=-l[0]),b>0&&(l[0]=l[0].toPrecision(b)),l[1]=m[l[1]]||l[1],s===!0?l[0]=l[0].toLocaleString():s.length>0?l[0]=l[0].toLocaleString(s,f):i.length>0&&(l[0]=l[0].toString().replace(ho,i)),r&&Number.isInteger(l[0])===!1&&a>0){let pt=i||ho,Yt=l[0].toString().split(pt),Vt=Yt[1]||nt,Zt=Vt.length,yo=a-Zt;l[0]=`${Yt[0]}${pt}${Vt.padEnd(Zt+yo,Gn)}`}return go&&(l[1]=O[p]?O[p]:Gt.fullform[h][p]+(e?_n:En)+(l[0]===1?nt:Ln)),v===In?l:v===Nn?{value:l[0],symbol:l[1],exponent:p,unit:Rt}:l.join(n)}var 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 Ft(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new Wt(Ft(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};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","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.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
+ `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new K({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new K({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new K({tera:this,...r}))}};export{Ht as default};
3
3
  /*! Bundled license information:
4
4
 
5
5
  lodash-es/lodash.js:
package/dist/terafy.js CHANGED
@@ -1,5 +1,5 @@
1
- function qt(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:b}){var A=Object.keys(i),T=A.length,g=Object.keys(n),I=g.length,y,p=i.length-n.length;if(uo(i,n)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(A[u]):A[u];l in n||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<I;u++){var l=Array.isArray(n)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:b})}}else{for(var u=0;u<p;u++)y=h.concat(u),b.remove.push({op:"remove",path:r(y)});for(var _=i.slice(p),u=0;u<I;u++)s({key:u,obj1:_,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:b})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:b,diffs:A}){var T=n[i],g=m[i];if(!(i in n)&&i in m){var I=g;A.add.push({op:"add",path:r(h),value:I})}else T!==g&&(Object(T)!==T||Object(g)!==g||mo(T,g)||!Object.keys(T).length&&!Object.keys(g).length&&String(T)!=String(g)?f(h,A,g):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:A}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function Yt(t){return[""].concat(t).join("/")}function mo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function uo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var co=typeof global=="object"&&global&&global.Object===Object&&global,ut=co;var ho=typeof self=="object"&&self&&self.Object===Object&&self,xo=ut||ho||Function("return this")(),x=xo;var go=x.Symbol,w=go;var Vt=Object.prototype,yo=Vt.hasOwnProperty,bo=Vt.toString,nt=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,nt),r=t[nt];try{t[nt]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[nt]=r:delete t[nt]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Oo(t){return To.call(t)}var Jt=Oo;var Ao="[object Null]",Po="[object Undefined]",Xt=w?w.toStringTag:void 0;function So(t){return t==null?t===void 0?Po:Ao:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var j=So;function jo(t){return t!=null&&typeof t=="object"}var S=jo;var Io="[object Symbol]";function _o(t){return typeof t=="symbol"||S(t)&&j(t)==Io}var z=_o;function Eo(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Qt=Eo;var Co=Array.isArray,v=Co;var Mo=1/0,te=w?w.prototype:void 0,ee=te?te.toString:void 0;function re(t){if(typeof t=="string")return t;if(v(t))return Qt(t,re)+"";if(z(t))return ee?ee.call(t):"";var e=t+"";return e=="0"&&1/t==-Mo?"-0":e}var oe=re;function Fo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Fo;function Ro(t){return t}var ae=Ro;var No="[object AsyncFunction]",Bo="[object Function]",Lo="[object GeneratorFunction]",Do="[object Proxy]";function Uo(t){if(!P(t))return!1;var e=j(t);return e==Bo||e==Lo||e==No||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(!P(t)||se(t))return!1;var e=dt(t)?Jo:$o;return e.test(E(t))}var fe=Xo;function Qo(t,e){return t?.[e]}var ne=Qo;function ta(t,e){var r=ne(t,e);return fe(r)?r:void 0}var O=ta;var ea=O(x,"WeakMap"),ht=ea;var pe=Object.create,ra=function(){function t(){}return function(e){if(!P(e))return{};if(pe)return pe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),le=ra;function oa(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var me=oa;function aa(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=aa;var ia=800,sa=16,fa=Date.now;function na(t){var e=0,r=0;return function(){var o=fa(),a=sa-(o-r);if(r=o,a>0){if(++e>=ia)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var de=na;function pa(t){return function(){return t}}var ce=pa;var la=function(){try{var t=O(Object,"defineProperty");return t({},"",{}),t}catch{}}(),K=la;var ma=K?function(t,e){return K(t,"toString",{configurable:!0,enumerable:!1,value:ce(e),writable:!0})}:ae,he=ma;var ua=de(he),xe=ua;function da(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ge=da;var ca=9007199254740991,ha=/^(?:0|[1-9]\d*)$/;function xa(t,e){var r=typeof t;return e=e??ca,!!e&&(r=="number"||r!="symbol"&&ha.test(t))&&t>-1&&t%1==0&&t<e}var G=xa;function ga(t,e,r){e=="__proto__"&&K?K(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ga;function ya(t,e){return t===e||t!==t&&e!==e}var gt=ya;var ba=Object.prototype,va=ba.hasOwnProperty;function wa(t,e,r){var o=t[e];(!(va.call(t,e)&&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,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?xt(r,i,n):W(r,i,n)}return r}var F=Ta;var ye=Math.max;function Oa(t,e,r){return e=ye(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ye(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),me(t,this,i)}}var be=Oa;var Aa=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Aa}var H=Pa;function Sa(t){return t!=null&&H(t.length)&&!dt(t)}var yt=Sa;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 S(t)&&j(t)==Ea}var Mt=Ca;var we=Object.prototype,Ma=we.hasOwnProperty,Fa=we.propertyIsEnumerable,Ra=Mt(function(){return arguments}())?Mt:function(t){return S(t)&&Ma.call(t,"callee")&&!Fa.call(t,"callee")},q=Ra;function Na(){return!1}var Te=Na;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,Ba=Oe&&Oe.exports===Pe,Ae=Ba?x.Buffer:void 0,La=Ae?Ae.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]",fi="[object Uint16Array]",ni="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[fi]=c[ni]=!0;c[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 S(t)&&H(t.length)&&!!c[j(t)]}var Se=pi;function li(t){return function(e){return t(e)}}var Y=li;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=je&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===je,Ft=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Ft&&Ft.binding&&Ft.binding("util")}catch{}}(),C=ui;var Ie=C&&C.isTypedArray,di=Ie?Y(Ie):Se,_e=di;var ci=Object.prototype,hi=ci.hasOwnProperty;function xi(t,e){var r=v(t),o=!r&&q(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&_e(t),f=r||o||a||s,i=f?ve(t.length,String):[],n=i.length;for(var m in t)(e||hi.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,n)))&&i.push(m);return i}var vt=xi;function gi(t,e){return function(r){return t(e(r))}}var wt=gi;var yi=wt(Object.keys,Object),Ee=yi;var bi=Object.prototype,vi=bi.hasOwnProperty;function wi(t){if(!$(t))return Ee(t);var e=[];for(var r in Object(t))vi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ce=wi;function Ti(t){return yt(t)?vt(t):Ce(t)}var V=Ti;function Oi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Me=Oi;var Ai=Object.prototype,Pi=Ai.hasOwnProperty;function Si(t){if(!P(t))return Me(t);var e=$(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Fe=Si;function ji(t){return yt(t)?vt(t,!0):Fe(t)}var Z=ji;var Ii=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_i=/^\w*$/;function Ei(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||z(t)?!0:_i.test(t)||!Ii.test(t)||e!=null&&t in Object(e)}var Re=Ei;var Ci=O(Object,"create"),M=Ci;function Mi(){this.__data__=M?M(null):{},this.size=0}var Ne=Mi;function Fi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Fi;var Ri="__lodash_hash_undefined__",Ni=Object.prototype,Bi=Ni.hasOwnProperty;function Li(t){var e=this.__data__;if(M){var r=e[t];return r===Ri?void 0:r}return Bi.call(e,t)?e[t]:void 0}var Le=Li;var Di=Object.prototype,Ui=Di.hasOwnProperty;function ki(t){var e=this.__data__;return M?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]=M&&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=Ne;J.prototype.delete=Be;J.prototype.get=Le;J.prototype.has=De;J.prototype.set=Ue;var Rt=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 R=Wi;var Hi=Array.prototype,$i=Hi.splice;function qi(t){var e=this.__data__,r=R(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():$i.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=R(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return R(this.__data__,t)>-1}var Ge=Vi;function Zi(t,e){var r=this.__data__,o=R(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=Zi;function X(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}X.prototype.clear=ke;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var N=X;var Ji=O(x,"Map"),B=Ji;function Xi(){this.size=0,this.__data__={hash:new Rt,map:new(B||N),string:new Rt}}var He=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Qi;function ts(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var L=ts;function es(t){var e=L(this,t).delete(t);return this.size-=e?1:0,e}var qe=es;function rs(t){return L(this,t).get(t)}var Ye=rs;function os(t){return L(this,t).has(t)}var Ve=os;function as(t,e){var r=L(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=as;function Q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Q.prototype.clear=He;Q.prototype.delete=qe;Q.prototype.get=Ye;Q.prototype.has=Ve;Q.prototype.set=Ze;var lt=Q;var is="Expected a function";function Nt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(is);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Nt.Cache||lt),r}Nt.Cache=lt;var Je=Nt;var ss=500;function fs(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=fs;var ns=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ns,function(r,o,a,s){e.push(a?s.replace(ps,"$1"):o||r)}),e}),Qe=ls;function ms(t){return t==null?"":oe(t)}var tr=ms;function us(t,e){return v(t)?t:Re(t,e)?[t]:Qe(tr(t))}var D=us;var ds=1/0;function cs(t){if(typeof t=="string"||z(t))return t;var e=t+"";return e=="0"&&1/t==-ds?"-0":e}var tt=cs;function hs(t,e){e=D(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[tt(e[r++])];return r&&r==o?t:void 0}var er=hs;function xs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var et=xs;var rr=w?w.isConcatSpreadable:void 0;function gs(t){return v(t)||q(t)||!!(rr&&t&&t[rr])}var or=gs;function ar(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=or),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?ar(i,e-1,r,o,a):et(a,i):o||(a[a.length]=i)}return a}var ir=ar;function ys(t){var e=t==null?0:t.length;return e?ir(t,1):[]}var sr=ys;function bs(t){return xe(be(t,void 0,sr),t+"")}var fr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new N,this.size=0}var nr=ws;function Ts(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Ts;function Os(t){return this.__data__.get(t)}var lr=Os;function As(t){return this.__data__.has(t)}var mr=As;var Ps=200;function Ss(t,e){var r=this.__data__;if(r instanceof N){var o=r.__data__;if(!B||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new lt(o)}return r.set(t,e),this.size=r.size,this}var ur=Ss;function rt(t){var e=this.__data__=new N(t);this.size=e.size}rt.prototype.clear=nr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function js(t,e){return t&&F(e,V(e),t)}var cr=js;function Is(t,e){return t&&F(e,Z(e),t)}var hr=Is;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=br&&typeof module=="object"&&module&&!module.nodeType&&module,_s=xr&&xr.exports===br,gr=_s?x.Buffer:void 0,yr=gr?gr.allocUnsafe:void 0;function Es(t,e){if(e)return t.slice();var r=t.length,o=yr?yr(r):new t.constructor(r);return t.copy(o),o}var vr=Es;function Cs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var wr=Cs;function Ms(){return[]}var Ot=Ms;var Fs=Object.prototype,Rs=Fs.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Ns=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Rs.call(t,e)}))}:Ot,ot=Ns;function Bs(t,e){return F(t,ot(t),e)}var Or=Bs;var Ls=Object.getOwnPropertySymbols,Ds=Ls?function(t){for(var e=[];t;)et(e,ot(t)),t=Tt(t);return e}:Ot,At=Ds;function Us(t,e){return F(t,At(t),e)}var Ar=Us;function ks(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var Pt=ks;function zs(t){return Pt(t,V,ot)}var Pr=zs;function Ks(t){return Pt(t,Z,At)}var Sr=Ks;var Gs=O(x,"DataView"),St=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(St),Ys=E(B),Vs=E(jt),Zs=E(It),Js=E(ht),U=j;(St&&U(new St(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 tf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Qs.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Mr=tf;var ef=x.Uint8Array,Bt=ef;function rf(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var it=rf;function of(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Fr=of;var af=/\w*$/;function sf(t){var e=new t.constructor(t.source,af.exec(t));return e.lastIndex=t.lastIndex,e}var Rr=sf;var Nr=w?w.prototype:void 0,Br=Nr?Nr.valueOf:void 0;function ff(t){return Br?Object(Br.call(t)):{}}var Lr=ff;function nf(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=nf;var pf="[object Boolean]",lf="[object Date]",mf="[object Map]",uf="[object Number]",df="[object RegExp]",cf="[object Set]",hf="[object String]",xf="[object Symbol]",gf="[object ArrayBuffer]",yf="[object DataView]",bf="[object Float32Array]",vf="[object Float64Array]",wf="[object Int8Array]",Tf="[object Int16Array]",Of="[object Int32Array]",Af="[object Uint8Array]",Pf="[object Uint8ClampedArray]",Sf="[object Uint16Array]",jf="[object Uint32Array]";function If(t,e,r){var o=t.constructor;switch(e){case gf:return it(t);case pf:case lf:return new o(+t);case yf:return Fr(t,r);case bf:case vf:case wf:case Tf:case Of:case Af:case Pf:case Sf:case jf:return Dr(t,r);case mf:return new o;case uf:case hf:return new o(t);case df:return Rr(t);case cf:return new o;case xf:return Lr(t)}}var Ur=If;function _f(t){return typeof t.constructor=="function"&&!$(t)?le(Tt(t)):{}}var kr=_f;var Ef="[object Map]";function Cf(t){return S(t)&&at(t)==Ef}var zr=Cf;var Kr=C&&C.isMap,Mf=Kr?Y(Kr):zr,Gr=Mf;var Ff="[object Set]";function Rf(t){return S(t)&&at(t)==Ff}var Wr=Rf;var Hr=C&&C.isSet,Nf=Hr?Y(Hr):Wr,$r=Nf;var Bf=1,Lf=2,Df=4,qr="[object Arguments]",Uf="[object Array]",kf="[object Boolean]",zf="[object Date]",Kf="[object Error]",Yr="[object Function]",Gf="[object GeneratorFunction]",Wf="[object Map]",Hf="[object Number]",Vr="[object Object]",$f="[object RegExp]",qf="[object Set]",Yf="[object String]",Vf="[object Symbol]",Zf="[object WeakMap]",Jf="[object ArrayBuffer]",Xf="[object DataView]",Qf="[object Float32Array]",tn="[object Float64Array]",en="[object Int8Array]",rn="[object Int16Array]",on="[object Int32Array]",an="[object Uint8Array]",sn="[object Uint8ClampedArray]",fn="[object Uint16Array]",nn="[object Uint32Array]",d={};d[qr]=d[Uf]=d[Jf]=d[Xf]=d[kf]=d[zf]=d[Qf]=d[tn]=d[en]=d[rn]=d[on]=d[Wf]=d[Hf]=d[Vr]=d[$f]=d[qf]=d[Yf]=d[Vf]=d[an]=d[sn]=d[fn]=d[nn]=!0;d[Kf]=d[Yr]=d[Zf]=!1;function _t(t,e,r,o,a,s){var f,i=e&Bf,n=e&Lf,m=e&Df;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!P(t))return t;var h=v(t);if(h){if(f=Mr(t),!i)return ue(t,f)}else{var b=at(t),A=b==Yr||b==Gf;if(bt(t))return vr(t,i);if(b==Vr||b==qr||A&&!a){if(f=n||A?{}:kr(t),!i)return n?Ar(t,hr(f,t)):Or(t,cr(f,t))}else{if(!d[b])return a?t:{};f=Ur(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,f),$r(t)?t.forEach(function(y){f.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){f.set(p,_t(y,e,r,p,t,s))});var g=m?n?Sr:Pr:n?Z:V,I=h?void 0:g(t);return ge(I||t,function(y,p){I&&(p=y,y=t[p]),W(f,p,_t(y,e,r,p,t,s))}),f}var Zr=_t;var pn=1,ln=4;function mn(t){return Zr(t,pn|ln)}var Lt=mn;function un(t,e){return t!=null&&e in Object(t)}var Jr=un;function dn(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=tt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&H(a)&&G(f,a)&&(v(t)||q(t)))}var Xr=dn;function cn(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cn;function hn(t,e,r,o){if(!P(t))return t;e=D(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=tt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=P(h)?h:G(e[a+1])?[]:{})}W(i,n,m),i=i[n]}return t}var to=hn;function xn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=er(t,f);r(i,f)&&to(s,D(f,t),i)}return s}var eo=xn;function gn(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gn;var yn=fr(function(t,e){return t==null?{}:ro(t,e)}),Et=yn;function oo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var Dt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var bn="array",vn="bit",ao="bits",wn="byte",io="bytes",st="",Tn="exponent",On="function",so="iec",An="Invalid number",Pn="Invalid rounding method",Ut="jedec",Sn="object",fo=".",jn="round",In="s",_n="si",En="kbit",Cn="kB",Mn=" ",Fn="string",Rn="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 no(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:f={},separator:i=st,spacer:n=Mn,symbols:m={},standard:h=st,output:b=Fn,fullform:A=!1,fullforms:T=[],exponent:g=-1,roundingMethod:I=jn,precision:y=0}={}){let p=g,u=Number(t),l=[],_=0,Ct=st;h===_n?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=A===!0,Kt=u<0,Gt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(An);if(typeof Gt!==On)throw new TypeError(Pn);if(Kt&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(mt)),p<0&&(p=0)),p>8&&(y>0&&(y+=8-p),p=8),b===Tn)return p;if(u===0)l[0]=0,Ct=l[1]=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 ft=Math.pow(10,p>0?a:0);l[0]=Gt(_*ft)/ft,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?En:Cn: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,f):i.length>0&&(l[0]=l[0].toString().replace(fo,i)),r&&Number.isInteger(l[0])===!1&&a>0){let ft=i||fo,Wt=l[0].toString().split(ft),Ht=Wt[1]||st,$t=Ht.length,lo=a-$t;l[0]=`${Wt[0]}${ft}${Ht.padEnd($t+lo,Rn)}`}return po&&(l[1]=T[p]?T[p]:kt.fullform[h][p]+(e?vn:wn)+(l[0]===1?st:In)),b===bn?l:b===Sn?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(n)}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=no(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return this.#t.getProjectFile(this.path)}setContents(e){return this.#t.setProjectFile(this.path,e)}getRefs(){return this.#t.getProjectLibrary(this.path)}setRefs(e){return this.#t.setProjectLibrary(this.path,e)}serialize(){return Et(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3};events=oo();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPageUrl","uiAlert","uiSplat","uiWindow"];plugins=[];send(e){let r=Dt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||Dt(),...Lt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("INFO",3,"Recieved message",r),r?.action=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);else{if(r?.action=="rpc")return Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})});if(r?.action=="event")return Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o});r?.id?this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r})}}acceptPostboxes={};createProjectStatePatch(e,r){let o=qt(r,e,Yt);return this.debug("INFO",3,"Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}constructor(e){e&&this.set(e)}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
- `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new 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}))}setPageUrl(e){}};export{zt as default};
1
+ function qt(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:n,basePath:m,basePathForRemoves:h,diffs:b}){var A=Object.keys(i),T=A.length,g=Object.keys(n),I=g.length,y,p=i.length-n.length;if(uo(i,n)){for(var u=0;u<T;u++){var l=Array.isArray(i)?Number(A[u]):A[u];l in n||(y=h.concat(l),b.remove.push({op:"remove",path:r(y)}))}for(var u=0;u<I;u++){var l=Array.isArray(n)?Number(g[u]):g[u];s({key:l,obj1:i,obj2:n,path:m.concat(l),pathForRemoves:m.concat(l),diffs:b})}}else{for(var u=0;u<p;u++)y=h.concat(u),b.remove.push({op:"remove",path:r(y)});for(var _=i.slice(p),u=0;u<I;u++)s({key:u,obj1:_,obj2:n,path:m.concat(u),pathForRemoves:m.concat(u+p),diffs:b})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:n,obj2:m,path:h,pathForRemoves:b,diffs:A}){var T=n[i],g=m[i];if(!(i in n)&&i in m){var I=g;A.add.push({op:"add",path:r(h),value:I})}else T!==g&&(Object(T)!==T||Object(g)!==g||mo(T,g)||!Object.keys(T).length&&!Object.keys(g).length&&String(T)!=String(g)?f(h,A,g):o({obj1:n[i],obj2:m[i],basePath:h,basePathForRemoves:b,diffs:A}))}function f(i,n,m){n.replace.push({op:"replace",path:r(i),value:m})}}function Yt(t){return[""].concat(t).join("/")}function mo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function uo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var co=typeof global=="object"&&global&&global.Object===Object&&global,ut=co;var ho=typeof self=="object"&&self&&self.Object===Object&&self,xo=ut||ho||Function("return this")(),x=xo;var go=x.Symbol,w=go;var Vt=Object.prototype,yo=Vt.hasOwnProperty,bo=Vt.toString,nt=w?w.toStringTag:void 0;function vo(t){var e=yo.call(t,nt),r=t[nt];try{t[nt]=void 0;var o=!0}catch{}var a=bo.call(t);return o&&(e?t[nt]=r:delete t[nt]),a}var Zt=vo;var wo=Object.prototype,To=wo.toString;function Oo(t){return To.call(t)}var Jt=Oo;var Ao="[object Null]",Po="[object Undefined]",Xt=w?w.toStringTag:void 0;function So(t){return t==null?t===void 0?Po:Ao:Xt&&Xt in Object(t)?Zt(t):Jt(t)}var j=So;function jo(t){return t!=null&&typeof t=="object"}var S=jo;var Io="[object Symbol]";function _o(t){return typeof t=="symbol"||S(t)&&j(t)==Io}var z=_o;function Eo(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var Qt=Eo;var Co=Array.isArray,v=Co;var Mo=1/0,te=w?w.prototype:void 0,ee=te?te.toString:void 0;function re(t){if(typeof t=="string")return t;if(v(t))return Qt(t,re)+"";if(z(t))return ee?ee.call(t):"";var e=t+"";return e=="0"&&1/t==-Mo?"-0":e}var oe=re;function Fo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var P=Fo;function Ro(t){return t}var ae=Ro;var No="[object AsyncFunction]",Bo="[object Function]",Lo="[object GeneratorFunction]",Do="[object Proxy]";function Uo(t){if(!P(t))return!1;var e=j(t);return e==Bo||e==Lo||e==No||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(!P(t)||se(t))return!1;var e=dt(t)?Jo:$o;return e.test(E(t))}var fe=Xo;function Qo(t,e){return t?.[e]}var ne=Qo;function ta(t,e){var r=ne(t,e);return fe(r)?r:void 0}var O=ta;var ea=O(x,"WeakMap"),ht=ea;var pe=Object.create,ra=function(){function t(){}return function(e){if(!P(e))return{};if(pe)return pe(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),le=ra;function oa(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var me=oa;function aa(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var ue=aa;var ia=800,sa=16,fa=Date.now;function na(t){var e=0,r=0;return function(){var o=fa(),a=sa-(o-r);if(r=o,a>0){if(++e>=ia)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var de=na;function pa(t){return function(){return t}}var ce=pa;var la=function(){try{var t=O(Object,"defineProperty");return t({},"",{}),t}catch{}}(),K=la;var ma=K?function(t,e){return K(t,"toString",{configurable:!0,enumerable:!1,value:ce(e),writable:!0})}:ae,he=ma;var ua=de(he),xe=ua;function da(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var ge=da;var ca=9007199254740991,ha=/^(?:0|[1-9]\d*)$/;function xa(t,e){var r=typeof t;return e=e??ca,!!e&&(r=="number"||r!="symbol"&&ha.test(t))&&t>-1&&t%1==0&&t<e}var G=xa;function ga(t,e,r){e=="__proto__"&&K?K(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xt=ga;function ya(t,e){return t===e||t!==t&&e!==e}var gt=ya;var ba=Object.prototype,va=ba.hasOwnProperty;function wa(t,e,r){var o=t[e];(!(va.call(t,e)&&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,f=e.length;++s<f;){var i=e[s],n=o?o(r[i],t[i],i,r,t):void 0;n===void 0&&(n=t[i]),a?xt(r,i,n):W(r,i,n)}return r}var F=Ta;var ye=Math.max;function Oa(t,e,r){return e=ye(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=ye(o.length-e,0),f=Array(s);++a<s;)f[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(f),me(t,this,i)}}var be=Oa;var Aa=9007199254740991;function Pa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Aa}var H=Pa;function Sa(t){return t!=null&&H(t.length)&&!dt(t)}var yt=Sa;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 S(t)&&j(t)==Ea}var Mt=Ca;var we=Object.prototype,Ma=we.hasOwnProperty,Fa=we.propertyIsEnumerable,Ra=Mt(function(){return arguments}())?Mt:function(t){return S(t)&&Ma.call(t,"callee")&&!Fa.call(t,"callee")},q=Ra;function Na(){return!1}var Te=Na;var Pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Pe&&typeof module=="object"&&module&&!module.nodeType&&module,Ba=Oe&&Oe.exports===Pe,Ae=Ba?x.Buffer:void 0,La=Ae?Ae.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]",fi="[object Uint16Array]",ni="[object Uint32Array]",c={};c[ti]=c[ei]=c[ri]=c[oi]=c[ai]=c[ii]=c[si]=c[fi]=c[ni]=!0;c[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 S(t)&&H(t.length)&&!!c[j(t)]}var Se=pi;function li(t){return function(e){return t(e)}}var Y=li;var je=typeof exports=="object"&&exports&&!exports.nodeType&&exports,pt=je&&typeof module=="object"&&module&&!module.nodeType&&module,mi=pt&&pt.exports===je,Ft=mi&&ut.process,ui=function(){try{var t=pt&&pt.require&&pt.require("util").types;return t||Ft&&Ft.binding&&Ft.binding("util")}catch{}}(),C=ui;var Ie=C&&C.isTypedArray,di=Ie?Y(Ie):Se,_e=di;var ci=Object.prototype,hi=ci.hasOwnProperty;function xi(t,e){var r=v(t),o=!r&&q(t),a=!r&&!o&&bt(t),s=!r&&!o&&!a&&_e(t),f=r||o||a||s,i=f?ve(t.length,String):[],n=i.length;for(var m in t)(e||hi.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||s&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||G(m,n)))&&i.push(m);return i}var vt=xi;function gi(t,e){return function(r){return t(e(r))}}var wt=gi;var yi=wt(Object.keys,Object),Ee=yi;var bi=Object.prototype,vi=bi.hasOwnProperty;function wi(t){if(!$(t))return Ee(t);var e=[];for(var r in Object(t))vi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ce=wi;function Ti(t){return yt(t)?vt(t):Ce(t)}var V=Ti;function Oi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Me=Oi;var Ai=Object.prototype,Pi=Ai.hasOwnProperty;function Si(t){if(!P(t))return Me(t);var e=$(t),r=[];for(var o in t)o=="constructor"&&(e||!Pi.call(t,o))||r.push(o);return r}var Fe=Si;function ji(t){return yt(t)?vt(t,!0):Fe(t)}var Z=ji;var Ii=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_i=/^\w*$/;function Ei(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||z(t)?!0:_i.test(t)||!Ii.test(t)||e!=null&&t in Object(e)}var Re=Ei;var Ci=O(Object,"create"),M=Ci;function Mi(){this.__data__=M?M(null):{},this.size=0}var Ne=Mi;function Fi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Be=Fi;var Ri="__lodash_hash_undefined__",Ni=Object.prototype,Bi=Ni.hasOwnProperty;function Li(t){var e=this.__data__;if(M){var r=e[t];return r===Ri?void 0:r}return Bi.call(e,t)?e[t]:void 0}var Le=Li;var Di=Object.prototype,Ui=Di.hasOwnProperty;function ki(t){var e=this.__data__;return M?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]=M&&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=Ne;J.prototype.delete=Be;J.prototype.get=Le;J.prototype.has=De;J.prototype.set=Ue;var Rt=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 R=Wi;var Hi=Array.prototype,$i=Hi.splice;function qi(t){var e=this.__data__,r=R(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():$i.call(e,r,1),--this.size,!0}var ze=qi;function Yi(t){var e=this.__data__,r=R(e,t);return r<0?void 0:e[r][1]}var Ke=Yi;function Vi(t){return R(this.__data__,t)>-1}var Ge=Vi;function Zi(t,e){var r=this.__data__,o=R(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var We=Zi;function X(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}X.prototype.clear=ke;X.prototype.delete=ze;X.prototype.get=Ke;X.prototype.has=Ge;X.prototype.set=We;var N=X;var Ji=O(x,"Map"),B=Ji;function Xi(){this.size=0,this.__data__={hash:new Rt,map:new(B||N),string:new Rt}}var He=Xi;function Qi(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var $e=Qi;function ts(t,e){var r=t.__data__;return $e(e)?r[typeof e=="string"?"string":"hash"]:r.map}var L=ts;function es(t){var e=L(this,t).delete(t);return this.size-=e?1:0,e}var qe=es;function rs(t){return L(this,t).get(t)}var Ye=rs;function os(t){return L(this,t).has(t)}var Ve=os;function as(t,e){var r=L(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ze=as;function Q(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}Q.prototype.clear=He;Q.prototype.delete=qe;Q.prototype.get=Ye;Q.prototype.has=Ve;Q.prototype.set=Ze;var lt=Q;var is="Expected a function";function Nt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(is);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var f=t.apply(this,o);return r.cache=s.set(a,f)||s,f};return r.cache=new(Nt.Cache||lt),r}Nt.Cache=lt;var Je=Nt;var ss=500;function fs(t){var e=Je(t,function(o){return r.size===ss&&r.clear(),o}),r=e.cache;return e}var Xe=fs;var ns=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ps=/\\(\\)?/g,ls=Xe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ns,function(r,o,a,s){e.push(a?s.replace(ps,"$1"):o||r)}),e}),Qe=ls;function ms(t){return t==null?"":oe(t)}var tr=ms;function us(t,e){return v(t)?t:Re(t,e)?[t]:Qe(tr(t))}var D=us;var ds=1/0;function cs(t){if(typeof t=="string"||z(t))return t;var e=t+"";return e=="0"&&1/t==-ds?"-0":e}var tt=cs;function hs(t,e){e=D(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[tt(e[r++])];return r&&r==o?t:void 0}var er=hs;function xs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var et=xs;var rr=w?w.isConcatSpreadable:void 0;function gs(t){return v(t)||q(t)||!!(rr&&t&&t[rr])}var or=gs;function ar(t,e,r,o,a){var s=-1,f=t.length;for(r||(r=or),a||(a=[]);++s<f;){var i=t[s];e>0&&r(i)?e>1?ar(i,e-1,r,o,a):et(a,i):o||(a[a.length]=i)}return a}var ir=ar;function ys(t){var e=t==null?0:t.length;return e?ir(t,1):[]}var sr=ys;function bs(t){return xe(be(t,void 0,sr),t+"")}var fr=bs;var vs=wt(Object.getPrototypeOf,Object),Tt=vs;function ws(){this.__data__=new N,this.size=0}var nr=ws;function Ts(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var pr=Ts;function Os(t){return this.__data__.get(t)}var lr=Os;function As(t){return this.__data__.has(t)}var mr=As;var Ps=200;function Ss(t,e){var r=this.__data__;if(r instanceof N){var o=r.__data__;if(!B||o.length<Ps-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new lt(o)}return r.set(t,e),this.size=r.size,this}var ur=Ss;function rt(t){var e=this.__data__=new N(t);this.size=e.size}rt.prototype.clear=nr;rt.prototype.delete=pr;rt.prototype.get=lr;rt.prototype.has=mr;rt.prototype.set=ur;var dr=rt;function js(t,e){return t&&F(e,V(e),t)}var cr=js;function Is(t,e){return t&&F(e,Z(e),t)}var hr=Is;var br=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xr=br&&typeof module=="object"&&module&&!module.nodeType&&module,_s=xr&&xr.exports===br,gr=_s?x.Buffer:void 0,yr=gr?gr.allocUnsafe:void 0;function Es(t,e){if(e)return t.slice();var r=t.length,o=yr?yr(r):new t.constructor(r);return t.copy(o),o}var vr=Es;function Cs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var f=t[r];e(f,r,t)&&(s[a++]=f)}return s}var wr=Cs;function Ms(){return[]}var Ot=Ms;var Fs=Object.prototype,Rs=Fs.propertyIsEnumerable,Tr=Object.getOwnPropertySymbols,Ns=Tr?function(t){return t==null?[]:(t=Object(t),wr(Tr(t),function(e){return Rs.call(t,e)}))}:Ot,ot=Ns;function Bs(t,e){return F(t,ot(t),e)}var Or=Bs;var Ls=Object.getOwnPropertySymbols,Ds=Ls?function(t){for(var e=[];t;)et(e,ot(t)),t=Tt(t);return e}:Ot,At=Ds;function Us(t,e){return F(t,At(t),e)}var Ar=Us;function ks(t,e,r){var o=e(t);return v(t)?o:et(o,r(t))}var Pt=ks;function zs(t){return Pt(t,V,ot)}var Pr=zs;function Ks(t){return Pt(t,Z,At)}var Sr=Ks;var Gs=O(x,"DataView"),St=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(St),Ys=E(B),Vs=E(jt),Zs=E(It),Js=E(ht),U=j;(St&&U(new St(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 tf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Qs.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Mr=tf;var ef=x.Uint8Array,Bt=ef;function rf(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}var it=rf;function of(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Fr=of;var af=/\w*$/;function sf(t){var e=new t.constructor(t.source,af.exec(t));return e.lastIndex=t.lastIndex,e}var Rr=sf;var Nr=w?w.prototype:void 0,Br=Nr?Nr.valueOf:void 0;function ff(t){return Br?Object(Br.call(t)):{}}var Lr=ff;function nf(t,e){var r=e?it(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dr=nf;var pf="[object Boolean]",lf="[object Date]",mf="[object Map]",uf="[object Number]",df="[object RegExp]",cf="[object Set]",hf="[object String]",xf="[object Symbol]",gf="[object ArrayBuffer]",yf="[object DataView]",bf="[object Float32Array]",vf="[object Float64Array]",wf="[object Int8Array]",Tf="[object Int16Array]",Of="[object Int32Array]",Af="[object Uint8Array]",Pf="[object Uint8ClampedArray]",Sf="[object Uint16Array]",jf="[object Uint32Array]";function If(t,e,r){var o=t.constructor;switch(e){case gf:return it(t);case pf:case lf:return new o(+t);case yf:return Fr(t,r);case bf:case vf:case wf:case Tf:case Of:case Af:case Pf:case Sf:case jf:return Dr(t,r);case mf:return new o;case uf:case hf:return new o(t);case df:return Rr(t);case cf:return new o;case xf:return Lr(t)}}var Ur=If;function _f(t){return typeof t.constructor=="function"&&!$(t)?le(Tt(t)):{}}var kr=_f;var Ef="[object Map]";function Cf(t){return S(t)&&at(t)==Ef}var zr=Cf;var Kr=C&&C.isMap,Mf=Kr?Y(Kr):zr,Gr=Mf;var Ff="[object Set]";function Rf(t){return S(t)&&at(t)==Ff}var Wr=Rf;var Hr=C&&C.isSet,Nf=Hr?Y(Hr):Wr,$r=Nf;var Bf=1,Lf=2,Df=4,qr="[object Arguments]",Uf="[object Array]",kf="[object Boolean]",zf="[object Date]",Kf="[object Error]",Yr="[object Function]",Gf="[object GeneratorFunction]",Wf="[object Map]",Hf="[object Number]",Vr="[object Object]",$f="[object RegExp]",qf="[object Set]",Yf="[object String]",Vf="[object Symbol]",Zf="[object WeakMap]",Jf="[object ArrayBuffer]",Xf="[object DataView]",Qf="[object Float32Array]",tn="[object Float64Array]",en="[object Int8Array]",rn="[object Int16Array]",on="[object Int32Array]",an="[object Uint8Array]",sn="[object Uint8ClampedArray]",fn="[object Uint16Array]",nn="[object Uint32Array]",d={};d[qr]=d[Uf]=d[Jf]=d[Xf]=d[kf]=d[zf]=d[Qf]=d[tn]=d[en]=d[rn]=d[on]=d[Wf]=d[Hf]=d[Vr]=d[$f]=d[qf]=d[Yf]=d[Vf]=d[an]=d[sn]=d[fn]=d[nn]=!0;d[Kf]=d[Yr]=d[Zf]=!1;function _t(t,e,r,o,a,s){var f,i=e&Bf,n=e&Lf,m=e&Df;if(r&&(f=a?r(t,o,a,s):r(t)),f!==void 0)return f;if(!P(t))return t;var h=v(t);if(h){if(f=Mr(t),!i)return ue(t,f)}else{var b=at(t),A=b==Yr||b==Gf;if(bt(t))return vr(t,i);if(b==Vr||b==qr||A&&!a){if(f=n||A?{}:kr(t),!i)return n?Ar(t,hr(f,t)):Or(t,cr(f,t))}else{if(!d[b])return a?t:{};f=Ur(t,b,i)}}s||(s=new dr);var T=s.get(t);if(T)return T;s.set(t,f),$r(t)?t.forEach(function(y){f.add(_t(y,e,r,y,t,s))}):Gr(t)&&t.forEach(function(y,p){f.set(p,_t(y,e,r,p,t,s))});var g=m?n?Sr:Pr:n?Z:V,I=h?void 0:g(t);return ge(I||t,function(y,p){I&&(p=y,y=t[p]),W(f,p,_t(y,e,r,p,t,s))}),f}var Zr=_t;var pn=1,ln=4;function mn(t){return Zr(t,pn|ln)}var Lt=mn;function un(t,e){return t!=null&&e in Object(t)}var Jr=un;function dn(t,e,r){e=D(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var f=tt(e[o]);if(!(s=t!=null&&r(t,f)))break;t=t[f]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&H(a)&&G(f,a)&&(v(t)||q(t)))}var Xr=dn;function cn(t,e){return t!=null&&Xr(t,e,Jr)}var Qr=cn;function hn(t,e,r,o){if(!P(t))return t;e=D(e,t);for(var a=-1,s=e.length,f=s-1,i=t;i!=null&&++a<s;){var n=tt(e[a]),m=r;if(n==="__proto__"||n==="constructor"||n==="prototype")return t;if(a!=f){var h=i[n];m=o?o(h,n,i):void 0,m===void 0&&(m=P(h)?h:G(e[a+1])?[]:{})}W(i,n,m),i=i[n]}return t}var to=hn;function xn(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var f=e[o],i=er(t,f);r(i,f)&&to(s,D(f,t),i)}return s}var eo=xn;function gn(t,e){return eo(t,e,function(r,o){return Qr(t,o)})}var ro=gn;var yn=fr(function(t,e){return t==null?{}:ro(t,e)}),Et=yn;function oo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var Dt=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var bn="array",vn="bit",ao="bits",wn="byte",io="bytes",st="",Tn="exponent",On="function",so="iec",An="Invalid number",Pn="Invalid rounding method",Ut="jedec",Sn="object",fo=".",jn="round",In="s",_n="si",En="kbit",Cn="kB",Mn=" ",Fn="string",Rn="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 no(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=st,localeOptions:f={},separator:i=st,spacer:n=Mn,symbols:m={},standard:h=st,output:b=Fn,fullform:A=!1,fullforms:T=[],exponent:g=-1,roundingMethod:I=jn,precision:y=0}={}){let p=g,u=Number(t),l=[],_=0,Ct=st;h===_n?(o=10,h=Ut):h===so||h===Ut?o=2:o===2?h=so:(o=10,h=Ut);let mt=o===10?1e3:1024,po=A===!0,Kt=u<0,Gt=Math[I];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(An);if(typeof Gt!==On)throw new TypeError(Pn);if(Kt&&(u=-u),(p===-1||isNaN(p))&&(p=Math.floor(Math.log(u)/Math.log(mt)),p<0&&(p=0)),p>8&&(y>0&&(y+=8-p),p=8),b===Tn)return p;if(u===0)l[0]=0,Ct=l[1]=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 ft=Math.pow(10,p>0?a:0);l[0]=Gt(_*ft)/ft,l[0]===mt&&p<8&&g===-1&&(l[0]=1,p++),Ct=l[1]=o===10&&p===1?e?En:Cn: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,f):i.length>0&&(l[0]=l[0].toString().replace(fo,i)),r&&Number.isInteger(l[0])===!1&&a>0){let ft=i||fo,Wt=l[0].toString().split(ft),Ht=Wt[1]||st,$t=Ht.length,lo=a-$t;l[0]=`${Wt[0]}${ft}${Ht.padEnd($t+lo,Rn)}`}return po&&(l[1]=T[p]?T[p]:kt.fullform[h][p]+(e?vn:wn)+(l[0]===1?st:In)),b===bn?l:b===Sn?{value:l[0],symbol:l[1],exponent:p,unit:Ct}:l.join(n)}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=no(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return this.#t.getProjectFile(this.path)}setContents(e){return this.#t.setProjectFile(this.path,e)}getRefs(){return this.#t.getProjectLibrary(this.path)}setRefs(e){return this.#t.setProjectLibrary(this.path,e)}serialize(){return Et(this,["id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Et(e,["tera","id","name","icon","path","parsedName","created","modified","accessed","size","mime","meta"]))}};var zt=class{settings={devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3};events=oo();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","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.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",2,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("INFO",2,"Using TERA window parent"),e();break;case"popup":this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("INFO",3,"Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("INFO",3,"Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
+ `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new k({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new k({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new k({tera:this,...r}))}};export{zt as default};
3
3
  /*! Bundled license information:
4
4
 
5
5
  lodash-es/lodash.js:
@@ -122,6 +122,7 @@ export default class TeraFy {
122
122
 
123
123
  // Webpages
124
124
  'setPageUrl',
125
+ 'setPageTitle',
125
126
 
126
127
  // UI
127
128
  'uiAlert',
@@ -1017,8 +1018,15 @@ export default class TeraFy {
1017
1018
  * @function setPageUrl
1018
1019
  * @param {String} url The URL to restore on next refresh
1019
1020
  */
1020
- setPageUrl(url) {
1021
- }
1021
+
1022
+
1023
+ /**
1024
+ * Set the active page title
1025
+ * This is usually called by a tool nested within the tera-tools.com embed
1026
+ *
1027
+ * @function setPageTitle
1028
+ * @param {String} title The current page title
1029
+ */
1022
1030
 
1023
1031
 
1024
1032
  /**
@@ -1192,9 +1192,27 @@ export default class TeraFyServer {
1192
1192
  * @param {String} url The URL to restore on next refresh
1193
1193
  */
1194
1194
  setPageUrl(url) {
1195
- debugger; // FIXME: Untested
1195
+ if (!url.startsWith('/')) throw new Error('All pageURLs must be a relative path starting with a slash');
1196
+
1197
+ let $routeMatched = app.service('$route').matched[0];
1198
+ if (!$routeMatched?.name) throw new Error('No active route');
1199
+ if (!$routeMatched?.path.endsWith('/:toolPath(.*)?')) throw new Error('No tool active');
1200
+
1201
+ app.router.push({
1202
+ path: $routeMatched.path.replace(/\/:toolPath\(\.\*\)\?$/, url),
1203
+ });
1196
1204
  }
1197
1205
 
1206
+
1207
+ /**
1208
+ * Set the active page title
1209
+ * This is usually called by a tool nested within the tera-tools.com embed
1210
+ *
1211
+ * @param {String} [title] The current page title. Set to a falsy value to revert back to the default page title
1212
+ */
1213
+ setPageTitle(title) {
1214
+ app.root.setPageTitle(title);
1215
+ }
1198
1216
  // }}}
1199
1217
 
1200
1218
  // Init - constructor(), init() {{{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iebh/tera-fy",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "description": "TERA website worker",
5
5
  "scripts": {
6
6
  "dev": "esbuild --platform=browser --format=esm --bundle lib/terafy.client.js --outfile=dist/terafy.js --minify --serve --servedir=.",
@@ -26,6 +26,7 @@
26
26
  "require": "./dist/terafy.js",
27
27
  "default": "./dist/terafy.js"
28
28
  },
29
+ "./dist/*": "./dist/*",
29
30
  "./projectFile": "./lib/projectFile.js",
30
31
  "./server": "./lib/terafy.server.js",
31
32
  "./plugins/*": "./plugins/*.js",