@iebh/tera-fy 1.13.3 → 1.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/api.md +13 -12
- package/dist/terafy.es2019.js +1 -1
- package/dist/terafy.js +1 -1
- package/lib/projectFile.js +3 -3
- package/lib/terafy.client.js +12 -8
- package/lib/terafy.proxy.js +3 -0
- package/lib/terafy.server.js +12 -10
- package/package.json +4 -4
- package/plugins/vite.js +1 -0
- package/plugins/vue3.js +6 -2
- package/utils/pathTools.js +3 -3
- package/widgets/tera-file-select.vue +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.13.4](https://github.com/IEBH/TERA-fy/compare/v1.13.3...v1.13.4) (2024-07-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* ProjectFile.teraUrl should never assume we are using the base tera-tools.com domain - accept any source ([87f417b](https://github.com/IEBH/TERA-fy/commit/87f417ba9b186e822a0045911011ffd4eb15e171))
|
|
9
|
+
|
|
3
10
|
## [1.13.3](https://github.com/IEBH/TERA-fy/compare/v1.13.2...v1.13.3) (2024-07-13)
|
|
4
11
|
|
|
5
12
|
## [1.13.2](https://github.com/IEBH/TERA-fy/compare/v1.13.1...v1.13.2) (2024-07-11)
|
package/api.md
CHANGED
|
@@ -274,7 +274,9 @@ Fetch the raw file contents as a Blob
|
|
|
274
274
|
|
|
275
275
|
#### Parameters
|
|
276
276
|
|
|
277
|
-
* `options` **[Object][149]?** Additioanl options to mutate
|
|
277
|
+
* `options` **[Object][149]?** Additioanl options to mutate behaviour
|
|
278
|
+
|
|
279
|
+
Returns **[Blob][152]** The eventual raw file contents as a Blob
|
|
278
280
|
|
|
279
281
|
### setContents
|
|
280
282
|
|
|
@@ -304,8 +306,7 @@ Overwrite the contents of a file with a new collection of Reflib refs
|
|
|
304
306
|
|
|
305
307
|
#### Parameters
|
|
306
308
|
|
|
307
|
-
* `refs`
|
|
308
|
-
* `Collection` **[Array][154]\<RefLibRef>** of references for the selected library
|
|
309
|
+
* `refs` **[Array][154]\<RefLibRef>** Collection of references for the selected library
|
|
309
310
|
|
|
310
311
|
Returns **[Promise][155]** A promise which resolves when the operation has completed
|
|
311
312
|
|
|
@@ -411,7 +412,7 @@ Call an RPC function in the server instance
|
|
|
411
412
|
#### Parameters
|
|
412
413
|
|
|
413
414
|
* `method` **[String][148]** The method name to call
|
|
414
|
-
* `args` **...any
|
|
415
|
+
* `args` **...any?** Optional arguments to pass to the function
|
|
415
416
|
|
|
416
417
|
Returns **[Promise][155]\<any>** The resolved output of the server function
|
|
417
418
|
|
|
@@ -421,8 +422,9 @@ Accept an incoming message
|
|
|
421
422
|
|
|
422
423
|
#### Parameters
|
|
423
424
|
|
|
424
|
-
* `rawMessage`
|
|
425
|
-
|
|
425
|
+
* `rawMessage` **[MessageEvent][159]** Raw message event to process
|
|
426
|
+
|
|
427
|
+
Returns **[Promise][155]** A promise which will resolve when the message has been processed
|
|
426
428
|
|
|
427
429
|
### acceptPostboxes
|
|
428
430
|
|
|
@@ -509,7 +511,7 @@ This function will only act if `settings.devMode` is truthy
|
|
|
509
511
|
|
|
510
512
|
#### Parameters
|
|
511
513
|
|
|
512
|
-
* `msg` **...any
|
|
514
|
+
* `msg` **...any?** Output to show
|
|
513
515
|
* `method` **(`"INFO"` | `"LOG"` | `"WARN"` | `"ERROR"`)** Logging method to use (optional, default `'LOG'`)
|
|
514
516
|
* `verboseLevel` **[Number][151]** The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored (optional, default `1`)
|
|
515
517
|
|
|
@@ -548,9 +550,8 @@ Include a TeraFy client plugin
|
|
|
548
550
|
|
|
549
551
|
#### Parameters
|
|
550
552
|
|
|
551
|
-
* `mod`
|
|
553
|
+
* `mod` **[Object][149]** The module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
|
|
552
554
|
* `options` **[Object][149]?** Additional options to mutate behaviour during construction (pass options to init() to intialize later options)
|
|
553
|
-
* `The` **[Object][149]** module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
|
|
554
555
|
|
|
555
556
|
Returns **[TeraFy][30]** This chainable terafy instance
|
|
556
557
|
|
|
@@ -618,8 +619,7 @@ Fetch a project file by its name
|
|
|
618
619
|
|
|
619
620
|
#### Parameters
|
|
620
621
|
|
|
621
|
-
* `id`
|
|
622
|
-
* `name` **[String][148]** The name + relative directory path component
|
|
622
|
+
* `id` **[String][148]** The name + relative directory path component
|
|
623
623
|
* `options` **([Object][149] | [String][148])?** Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
|
|
624
624
|
|
|
625
625
|
* `options.subkey` **[String][148]?** If specified only the extracted subkey is returned rather than the full object
|
|
@@ -919,6 +919,7 @@ Prompt the user to select a library to operate on and return a array of referenc
|
|
|
919
919
|
* `options.allowCancel` **[Boolean][157]** Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed (optional, default `true`)
|
|
920
920
|
* `options.autoRequire` **[Boolean][157]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
921
921
|
* `options.filters` **[FileFilters][114]?** Optional file filters, defaults to citation library selection only
|
|
922
|
+
* `options` **...any?** Additional options - see `getProjectLibrary()`
|
|
922
923
|
|
|
923
924
|
Returns **[Promise][155]<[Array][154]\<Ref>>** A collection of references from the selected file
|
|
924
925
|
|
|
@@ -981,7 +982,7 @@ This is usually called by a tool nested within the tera-tools.com embed
|
|
|
981
982
|
|
|
982
983
|
* `options` **([Object][149] | [String][148])** Context information about the page, if this is a string, its assumed to popupate `url`
|
|
983
984
|
|
|
984
|
-
* `options.
|
|
985
|
+
* `options.path` **[String][148]?** The URL path segment to restore on next refresh
|
|
985
986
|
* `options.title` **[String][148]?** The page title associated with the path
|
|
986
987
|
|
|
987
988
|
## uiAlert
|
package/dist/terafy.es2019.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Io=Object.defineProperty;var _o=(t,e,r)=>e in t?Io(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var c=(t,e,r)=>_o(t,typeof e!="symbol"?e+"":e,r);function ne(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:f,basePath:u,basePathForRemoves:p,diffs:g}){var P=Object.keys(i),T=P.length,b=Object.keys(f),F=b.length,O,l=i.length-f.length;if(Fo(i,f)){for(var d=0;d<T;d++){var m=Array.isArray(i)?Number(P[d]):P[d];m in f||(O=p.concat(m),g.remove.push({op:"remove",path:r(O)}))}for(var d=0;d<F;d++){var m=Array.isArray(f)?Number(b[d]):b[d];n({key:m,obj1:i,obj2:f,path:u.concat(m),pathForRemoves:u.concat(m),diffs:g})}}else{for(var d=0;d<l;d++)O=p.concat(d),g.remove.push({op:"remove",path:r(O)});for(var C=i.slice(l),d=0;d<F;d++)n({key:d,obj1:C,obj2:f,path:u.concat(d),pathForRemoves:u.concat(d+l),diffs:g})}}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 n({key:i,obj1:f,obj2:u,path:p,pathForRemoves:g,diffs:P}){var T=f[i],b=u[i];if(!(i in f)&&i in u){var F=b;P.add.push({op:"add",path:r(p),value:F})}else T!==b&&(Object(T)!==T||Object(b)!==b||Eo(T,b)||!Object.keys(T).length&&!Object.keys(b).length&&String(T)!=String(b)?s(p,P,b):o({obj1:f[i],obj2:u[i],basePath:p,basePathForRemoves:g,diffs:P}))}function s(i,f,u){f.replace.push({op:"replace",path:r(i),value:u})}}function Eo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Fo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,n=0;n<e.length&&String(t[n])===String(e[n]);n++)o++;for(var s=e.length;s>0&&String(t[s+r])===String(e[s]);s--)a++;return o>=a}return!0}var Co=typeof global=="object"&&global&&global.Object===Object&&global,wt=Co;var Mo=typeof self=="object"&&self&&self.Object===Object&&self,Ro=wt||Mo||Function("return this")(),y=Ro;var No=y.Symbol,j=No;var se=Object.prototype,Lo=se.hasOwnProperty,Bo=se.toString,ht=j?j.toStringTag:void 0;function Do(t){var e=Lo.call(t,ht),r=t[ht];try{t[ht]=void 0;var o=!0}catch{}var a=Bo.call(t);return o&&(e?t[ht]=r:delete t[ht]),a}var fe=Do;var Uo=Object.prototype,ko=Uo.toString;function Go(t){return ko.call(t)}var pe=Go;var Ko="[object Null]",zo="[object Undefined]",le=j?j.toStringTag:void 0;function Wo(t){return t==null?t===void 0?zo:Ko:le&&le in Object(t)?fe(t):pe(t)}var I=Wo;function $o(t){return t!=null&&typeof t=="object"}var A=$o;var Ho="[object Symbol]";function Vo(t){return typeof t=="symbol"||A(t)&&I(t)==Ho}var V=Vo;function qo(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 me=qo;var Yo=Array.isArray,v=Yo;var Zo=1/0,ue=j?j.prototype:void 0,de=ue?ue.toString:void 0;function ce(t){if(typeof t=="string")return t;if(v(t))return me(t,ce)+"";if(V(t))return de?de.call(t):"";var e=t+"";return e=="0"&&1/t==-Zo?"-0":e}var he=ce;function Jo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var w=Jo;function Xo(t){return t}var Tt=Xo;var Qo="[object AsyncFunction]",ta="[object Function]",ea="[object GeneratorFunction]",ra="[object Proxy]";function oa(t){if(!w(t))return!1;var e=I(t);return e==ta||e==ea||e==Qo||e==ra}var q=oa;var aa=y["__core-js_shared__"],Ot=aa;var xe=function(){var t=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function ia(t){return!!xe&&xe in t}var ge=ia;var na=Function.prototype,sa=na.toString;function fa(t){if(t!=null){try{return sa.call(t)}catch{}try{return t+""}catch{}}return""}var M=fa;var pa=/[\\^$.*+?()[\]{}|]/g,la=/^\[object .+?Constructor\]$/,ma=Function.prototype,ua=Object.prototype,da=ma.toString,ca=ua.hasOwnProperty,ha=RegExp("^"+da.call(ca).replace(pa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function xa(t){if(!w(t)||ge(t))return!1;var e=q(t)?ha:la;return e.test(M(t))}var be=xa;function ga(t,e){return t==null?void 0:t[e]}var ye=ga;function ba(t,e){var r=ye(t,e);return be(r)?r:void 0}var S=ba;var ya=S(y,"WeakMap"),Pt=ya;var ve=Object.create,va=function(){function t(){}return function(e){if(!w(e))return{};if(ve)return ve(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),we=va;function wa(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 Te=wa;function Ta(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var At=Ta;var Oa=800,Pa=16,Aa=Date.now;function ja(t){var e=0,r=0;return function(){var o=Aa(),a=Pa-(o-r);if(r=o,a>0){if(++e>=Oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Oe=ja;function Sa(t){return function(){return t}}var Pe=Sa;var Ia=function(){try{var t=S(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Y=Ia;var _a=Y?function(t,e){return Y(t,"toString",{configurable:!0,enumerable:!1,value:Pe(e),writable:!0})}:Tt,Ae=_a;var Ea=Oe(Ae),jt=Ea;function Fa(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var je=Fa;var Ca=9007199254740991,Ma=/^(?:0|[1-9]\d*)$/;function Ra(t,e){var r=typeof t;return e=e==null?Ca:e,!!e&&(r=="number"||r!="symbol"&&Ma.test(t))&&t>-1&&t%1==0&&t<e}var B=Ra;function Na(t,e,r){e=="__proto__"&&Y?Y(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Z=Na;function La(t,e){return t===e||t!==t&&e!==e}var D=La;var Ba=Object.prototype,Da=Ba.hasOwnProperty;function Ua(t,e,r){var o=t[e];(!(Da.call(t,e)&&D(o,r))||r===void 0&&!(e in t))&&Z(t,e,r)}var J=Ua;function ka(t,e,r,o){var a=!r;r||(r={});for(var n=-1,s=e.length;++n<s;){var i=e[n],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?Z(r,i,f):J(r,i,f)}return r}var _=ka;var Se=Math.max;function Ga(t,e,r){return e=Se(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,n=Se(o.length-e,0),s=Array(n);++a<n;)s[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(s),Te(t,this,i)}}var St=Ga;function Ka(t,e){return jt(St(t,e,Tt),t+"")}var Ie=Ka;var za=9007199254740991;function Wa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=za}var X=Wa;function $a(t){return t!=null&&X(t.length)&&!q(t)}var U=$a;function Ha(t,e,r){if(!w(r))return!1;var o=typeof e;return(o=="number"?U(r)&&B(e,r.length):o=="string"&&e in r)?D(r[e],t):!1}var _e=Ha;function Va(t){return Ie(function(e,r){var o=-1,a=r.length,n=a>1?r[a-1]:void 0,s=a>2?r[2]:void 0;for(n=t.length>3&&typeof n=="function"?(a--,n):void 0,s&&_e(r[0],r[1],s)&&(n=a<3?void 0:n,a=1),e=Object(e);++o<a;){var i=r[o];i&&t(e,i,o,n)}return e})}var Ee=Va;var qa=Object.prototype;function Ya(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||qa;return t===r}var Q=Ya;function Za(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Fe=Za;var Ja="[object Arguments]";function Xa(t){return A(t)&&I(t)==Ja}var Wt=Xa;var Ce=Object.prototype,Qa=Ce.hasOwnProperty,ti=Ce.propertyIsEnumerable,ei=Wt(function(){return arguments}())?Wt:function(t){return A(t)&&Qa.call(t,"callee")&&!ti.call(t,"callee")},R=ei;function ri(){return!1}var Me=ri;var Le=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Re=Le&&typeof module=="object"&&module&&!module.nodeType&&module,oi=Re&&Re.exports===Le,Ne=oi?y.Buffer:void 0,ai=Ne?Ne.isBuffer:void 0,ii=ai||Me,tt=ii;var ni="[object Arguments]",si="[object Array]",fi="[object Boolean]",pi="[object Date]",li="[object Error]",mi="[object Function]",ui="[object Map]",di="[object Number]",ci="[object Object]",hi="[object RegExp]",xi="[object Set]",gi="[object String]",bi="[object WeakMap]",yi="[object ArrayBuffer]",vi="[object DataView]",wi="[object Float32Array]",Ti="[object Float64Array]",Oi="[object Int8Array]",Pi="[object Int16Array]",Ai="[object Int32Array]",ji="[object Uint8Array]",Si="[object Uint8ClampedArray]",Ii="[object Uint16Array]",_i="[object Uint32Array]",x={};x[wi]=x[Ti]=x[Oi]=x[Pi]=x[Ai]=x[ji]=x[Si]=x[Ii]=x[_i]=!0;x[ni]=x[si]=x[yi]=x[fi]=x[vi]=x[pi]=x[li]=x[mi]=x[ui]=x[di]=x[ci]=x[hi]=x[xi]=x[gi]=x[bi]=!1;function Ei(t){return A(t)&&X(t.length)&&!!x[I(t)]}var Be=Ei;function Fi(t){return function(e){return t(e)}}var et=Fi;var De=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xt=De&&typeof module=="object"&&module&&!module.nodeType&&module,Ci=xt&&xt.exports===De,$t=Ci&&wt.process,Mi=function(){try{var t=xt&&xt.require&&xt.require("util").types;return t||$t&&$t.binding&&$t.binding("util")}catch{}}(),N=Mi;var Ue=N&&N.isTypedArray,Ri=Ue?et(Ue):Be,It=Ri;var Ni=Object.prototype,Li=Ni.hasOwnProperty;function Bi(t,e){var r=v(t),o=!r&&R(t),a=!r&&!o&&tt(t),n=!r&&!o&&!a&&It(t),s=r||o||a||n,i=s?Fe(t.length,String):[],f=i.length;for(var u in t)(e||Li.call(t,u))&&!(s&&(u=="length"||a&&(u=="offset"||u=="parent")||n&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||B(u,f)))&&i.push(u);return i}var _t=Bi;function Di(t,e){return function(r){return t(e(r))}}var Et=Di;var Ui=Et(Object.keys,Object),ke=Ui;var ki=Object.prototype,Gi=ki.hasOwnProperty;function Ki(t){if(!Q(t))return ke(t);var e=[];for(var r in Object(t))Gi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ge=Ki;function zi(t){return U(t)?_t(t):Ge(t)}var rt=zi;function Wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ke=Wi;var $i=Object.prototype,Hi=$i.hasOwnProperty;function Vi(t){if(!w(t))return Ke(t);var e=Q(t),r=[];for(var o in t)o=="constructor"&&(e||!Hi.call(t,o))||r.push(o);return r}var ze=Vi;function qi(t){return U(t)?_t(t,!0):ze(t)}var E=qi;var Yi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zi=/^\w*$/;function Ji(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||V(t)?!0:Zi.test(t)||!Yi.test(t)||e!=null&&t in Object(e)}var We=Ji;var Xi=S(Object,"create"),L=Xi;function Qi(){this.__data__=L?L(null):{},this.size=0}var $e=Qi;function tn(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var He=tn;var en="__lodash_hash_undefined__",rn=Object.prototype,on=rn.hasOwnProperty;function an(t){var e=this.__data__;if(L){var r=e[t];return r===en?void 0:r}return on.call(e,t)?e[t]:void 0}var Ve=an;var nn=Object.prototype,sn=nn.hasOwnProperty;function fn(t){var e=this.__data__;return L?e[t]!==void 0:sn.call(e,t)}var qe=fn;var pn="__lodash_hash_undefined__";function ln(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=L&&e===void 0?pn:e,this}var Ye=ln;function ot(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])}}ot.prototype.clear=$e;ot.prototype.delete=He;ot.prototype.get=Ve;ot.prototype.has=qe;ot.prototype.set=Ye;var Ht=ot;function mn(){this.__data__=[],this.size=0}var Ze=mn;function un(t,e){for(var r=t.length;r--;)if(D(t[r][0],e))return r;return-1}var k=un;var dn=Array.prototype,cn=dn.splice;function hn(t){var e=this.__data__,r=k(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():cn.call(e,r,1),--this.size,!0}var Je=hn;function xn(t){var e=this.__data__,r=k(e,t);return r<0?void 0:e[r][1]}var Xe=xn;function gn(t){return k(this.__data__,t)>-1}var Qe=gn;function bn(t,e){var r=this.__data__,o=k(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var tr=bn;function at(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])}}at.prototype.clear=Ze;at.prototype.delete=Je;at.prototype.get=Xe;at.prototype.has=Qe;at.prototype.set=tr;var G=at;var yn=S(y,"Map"),K=yn;function vn(){this.size=0,this.__data__={hash:new Ht,map:new(K||G),string:new Ht}}var er=vn;function wn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var rr=wn;function Tn(t,e){var r=t.__data__;return rr(e)?r[typeof e=="string"?"string":"hash"]:r.map}var z=Tn;function On(t){var e=z(this,t).delete(t);return this.size-=e?1:0,e}var or=On;function Pn(t){return z(this,t).get(t)}var ar=Pn;function An(t){return z(this,t).has(t)}var ir=An;function jn(t,e){var r=z(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var nr=jn;function it(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])}}it.prototype.clear=er;it.prototype.delete=or;it.prototype.get=ar;it.prototype.has=ir;it.prototype.set=nr;var gt=it;var Sn="Expected a function";function Vt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Sn);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],n=r.cache;if(n.has(a))return n.get(a);var s=t.apply(this,o);return r.cache=n.set(a,s)||n,s};return r.cache=new(Vt.Cache||gt),r}Vt.Cache=gt;var sr=Vt;var In=500;function _n(t){var e=sr(t,function(o){return r.size===In&&r.clear(),o}),r=e.cache;return e}var fr=_n;var En=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Fn=/\\(\\)?/g,Cn=fr(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(En,function(r,o,a,n){e.push(a?n.replace(Fn,"$1"):o||r)}),e}),pr=Cn;function Mn(t){return t==null?"":he(t)}var lr=Mn;function Rn(t,e){return v(t)?t:We(t,e)?[t]:pr(lr(t))}var W=Rn;var Nn=1/0;function Ln(t){if(typeof t=="string"||V(t))return t;var e=t+"";return e=="0"&&1/t==-Nn?"-0":e}var nt=Ln;function Bn(t,e){e=W(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[nt(e[r++])];return r&&r==o?t:void 0}var mr=Bn;function Dn(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var st=Dn;var ur=j?j.isConcatSpreadable:void 0;function Un(t){return v(t)||R(t)||!!(ur&&t&&t[ur])}var dr=Un;function cr(t,e,r,o,a){var n=-1,s=t.length;for(r||(r=dr),a||(a=[]);++n<s;){var i=t[n];e>0&&r(i)?e>1?cr(i,e-1,r,o,a):st(a,i):o||(a[a.length]=i)}return a}var hr=cr;function kn(t){var e=t==null?0:t.length;return e?hr(t,1):[]}var xr=kn;function Gn(t){return jt(St(t,void 0,xr),t+"")}var gr=Gn;var Kn=Et(Object.getPrototypeOf,Object),ft=Kn;var zn="[object Object]",Wn=Function.prototype,$n=Object.prototype,br=Wn.toString,Hn=$n.hasOwnProperty,Vn=br.call(Object);function qn(t){if(!A(t)||I(t)!=zn)return!1;var e=ft(t);if(e===null)return!0;var r=Hn.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&br.call(r)==Vn}var yr=qn;function Yn(){this.__data__=new G,this.size=0}var vr=Yn;function Zn(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var wr=Zn;function Jn(t){return this.__data__.get(t)}var Tr=Jn;function Xn(t){return this.__data__.has(t)}var Or=Xn;var Qn=200;function ts(t,e){var r=this.__data__;if(r instanceof G){var o=r.__data__;if(!K||o.length<Qn-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new gt(o)}return r.set(t,e),this.size=r.size,this}var Pr=ts;function pt(t){var e=this.__data__=new G(t);this.size=e.size}pt.prototype.clear=vr;pt.prototype.delete=wr;pt.prototype.get=Tr;pt.prototype.has=Or;pt.prototype.set=Pr;var Ft=pt;function es(t,e){return t&&_(e,rt(e),t)}var Ar=es;function rs(t,e){return t&&_(e,E(e),t)}var jr=rs;var Er=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sr=Er&&typeof module=="object"&&module&&!module.nodeType&&module,os=Sr&&Sr.exports===Er,Ir=os?y.Buffer:void 0,_r=Ir?Ir.allocUnsafe:void 0;function as(t,e){if(e)return t.slice();var r=t.length,o=_r?_r(r):new t.constructor(r);return t.copy(o),o}var Ct=as;function is(t,e){for(var r=-1,o=t==null?0:t.length,a=0,n=[];++r<o;){var s=t[r];e(s,r,t)&&(n[a++]=s)}return n}var Fr=is;function ns(){return[]}var Mt=ns;var ss=Object.prototype,fs=ss.propertyIsEnumerable,Cr=Object.getOwnPropertySymbols,ps=Cr?function(t){return t==null?[]:(t=Object(t),Fr(Cr(t),function(e){return fs.call(t,e)}))}:Mt,lt=ps;function ls(t,e){return _(t,lt(t),e)}var Mr=ls;var ms=Object.getOwnPropertySymbols,us=ms?function(t){for(var e=[];t;)st(e,lt(t)),t=ft(t);return e}:Mt,Rt=us;function ds(t,e){return _(t,Rt(t),e)}var Rr=ds;function cs(t,e,r){var o=e(t);return v(t)?o:st(o,r(t))}var Nt=cs;function hs(t){return Nt(t,rt,lt)}var Nr=hs;function xs(t){return Nt(t,E,Rt)}var Lr=xs;var gs=S(y,"DataView"),Lt=gs;var bs=S(y,"Promise"),Bt=bs;var ys=S(y,"Set"),Dt=ys;var Br="[object Map]",vs="[object Object]",Dr="[object Promise]",Ur="[object Set]",kr="[object WeakMap]",Gr="[object DataView]",ws=M(Lt),Ts=M(K),Os=M(Bt),Ps=M(Dt),As=M(Pt),H=I;(Lt&&H(new Lt(new ArrayBuffer(1)))!=Gr||K&&H(new K)!=Br||Bt&&H(Bt.resolve())!=Dr||Dt&&H(new Dt)!=Ur||Pt&&H(new Pt)!=kr)&&(H=function(t){var e=I(t),r=e==vs?t.constructor:void 0,o=r?M(r):"";if(o)switch(o){case ws:return Gr;case Ts:return Br;case Os:return Dr;case Ps:return Ur;case As:return kr}return e});var mt=H;var js=Object.prototype,Ss=js.hasOwnProperty;function Is(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Ss.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Kr=Is;var _s=y.Uint8Array,qt=_s;function Es(t){var e=new t.constructor(t.byteLength);return new qt(e).set(new qt(t)),e}var ut=Es;function Fs(t,e){var r=e?ut(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var zr=Fs;var Cs=/\w*$/;function Ms(t){var e=new t.constructor(t.source,Cs.exec(t));return e.lastIndex=t.lastIndex,e}var Wr=Ms;var $r=j?j.prototype:void 0,Hr=$r?$r.valueOf:void 0;function Rs(t){return Hr?Object(Hr.call(t)):{}}var Vr=Rs;function Ns(t,e){var r=e?ut(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Ut=Ns;var Ls="[object Boolean]",Bs="[object Date]",Ds="[object Map]",Us="[object Number]",ks="[object RegExp]",Gs="[object Set]",Ks="[object String]",zs="[object Symbol]",Ws="[object ArrayBuffer]",$s="[object DataView]",Hs="[object Float32Array]",Vs="[object Float64Array]",qs="[object Int8Array]",Ys="[object Int16Array]",Zs="[object Int32Array]",Js="[object Uint8Array]",Xs="[object Uint8ClampedArray]",Qs="[object Uint16Array]",tf="[object Uint32Array]";function ef(t,e,r){var o=t.constructor;switch(e){case Ws:return ut(t);case Ls:case Bs:return new o(+t);case $s:return zr(t,r);case Hs:case Vs:case qs:case Ys:case Zs:case Js:case Xs:case Qs:case tf:return Ut(t,r);case Ds:return new o;case Us:case Ks:return new o(t);case ks:return Wr(t);case Gs:return new o;case zs:return Vr(t)}}var qr=ef;function rf(t){return typeof t.constructor=="function"&&!Q(t)?we(ft(t)):{}}var kt=rf;var of="[object Map]";function af(t){return A(t)&&mt(t)==of}var Yr=af;var Zr=N&&N.isMap,nf=Zr?et(Zr):Yr,Jr=nf;var sf="[object Set]";function ff(t){return A(t)&&mt(t)==sf}var Xr=ff;var Qr=N&&N.isSet,pf=Qr?et(Qr):Xr,to=pf;var lf=1,mf=2,uf=4,eo="[object Arguments]",df="[object Array]",cf="[object Boolean]",hf="[object Date]",xf="[object Error]",ro="[object Function]",gf="[object GeneratorFunction]",bf="[object Map]",yf="[object Number]",oo="[object Object]",vf="[object RegExp]",wf="[object Set]",Tf="[object String]",Of="[object Symbol]",Pf="[object WeakMap]",Af="[object ArrayBuffer]",jf="[object DataView]",Sf="[object Float32Array]",If="[object Float64Array]",_f="[object Int8Array]",Ef="[object Int16Array]",Ff="[object Int32Array]",Cf="[object Uint8Array]",Mf="[object Uint8ClampedArray]",Rf="[object Uint16Array]",Nf="[object Uint32Array]",h={};h[eo]=h[df]=h[Af]=h[jf]=h[cf]=h[hf]=h[Sf]=h[If]=h[_f]=h[Ef]=h[Ff]=h[bf]=h[yf]=h[oo]=h[vf]=h[wf]=h[Tf]=h[Of]=h[Cf]=h[Mf]=h[Rf]=h[Nf]=!0;h[xf]=h[ro]=h[Pf]=!1;function Gt(t,e,r,o,a,n){var s,i=e&lf,f=e&mf,u=e&uf;if(r&&(s=a?r(t,o,a,n):r(t)),s!==void 0)return s;if(!w(t))return t;var p=v(t);if(p){if(s=Kr(t),!i)return At(t,s)}else{var g=mt(t),P=g==ro||g==gf;if(tt(t))return Ct(t,i);if(g==oo||g==eo||P&&!a){if(s=f||P?{}:kt(t),!i)return f?Rr(t,jr(s,t)):Mr(t,Ar(s,t))}else{if(!h[g])return a?t:{};s=qr(t,g,i)}}n||(n=new Ft);var T=n.get(t);if(T)return T;n.set(t,s),to(t)?t.forEach(function(O){s.add(Gt(O,e,r,O,t,n))}):Jr(t)&&t.forEach(function(O,l){s.set(l,Gt(O,e,r,l,t,n))});var b=u?f?Lr:Nr:f?E:rt,F=p?void 0:b(t);return je(F||t,function(O,l){F&&(l=O,O=t[l]),J(s,l,Gt(O,e,r,l,t,n))}),s}var ao=Gt;var Lf=1,Bf=4;function Df(t){return ao(t,Lf|Bf)}var Yt=Df;function Uf(t,e){return t!=null&&e in Object(t)}var io=Uf;function kf(t,e,r){e=W(e,t);for(var o=-1,a=e.length,n=!1;++o<a;){var s=nt(e[o]);if(!(n=t!=null&&r(t,s)))break;t=t[s]}return n||++o!=a?n:(a=t==null?0:t.length,!!a&&X(a)&&B(s,a)&&(v(t)||R(t)))}var no=kf;function Gf(t,e){return t!=null&&no(t,e,io)}var so=Gf;function Kf(t){return function(e,r,o){for(var a=-1,n=Object(e),s=o(e),i=s.length;i--;){var f=s[t?i:++a];if(r(n[f],f,n)===!1)break}return e}}var fo=Kf;var zf=fo(),po=zf;function Wf(t,e,r){(r!==void 0&&!D(t[e],r)||r===void 0&&!(e in t))&&Z(t,e,r)}var bt=Wf;function $f(t){return A(t)&&U(t)}var lo=$f;function Hf(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var yt=Hf;function Vf(t){return _(t,E(t))}var mo=Vf;function qf(t,e,r,o,a,n,s){var i=yt(t,r),f=yt(e,r),u=s.get(f);if(u){bt(t,r,u);return}var p=n?n(i,f,r+"",t,e,s):void 0,g=p===void 0;if(g){var P=v(f),T=!P&&tt(f),b=!P&&!T&&It(f);p=f,P||T||b?v(i)?p=i:lo(i)?p=At(i):T?(g=!1,p=Ct(f,!0)):b?(g=!1,p=Ut(f,!0)):p=[]:yr(f)||R(f)?(p=i,R(i)?p=mo(i):(!w(i)||q(i))&&(p=kt(f))):g=!1}g&&(s.set(f,p),a(p,f,o,n,s),s.delete(f)),bt(t,r,p)}var uo=qf;function co(t,e,r,o,a){t!==e&&po(e,function(n,s){if(a||(a=new Ft),w(n))uo(t,e,s,r,co,o,a);else{var i=o?o(yt(t,s),n,s+"",t,e,a):void 0;i===void 0&&(i=n),bt(t,s,i)}},E)}var ho=co;var Yf=Ee(function(t,e,r){ho(t,e,r)}),Zt=Yf;function Zf(t,e,r,o){if(!w(t))return t;e=W(e,t);for(var a=-1,n=e.length,s=n-1,i=t;i!=null&&++a<n;){var f=nt(e[a]),u=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=s){var p=i[f];u=o?o(p,f,i):void 0,u===void 0&&(u=w(p)?p:B(e[a+1])?[]:{})}J(i,f,u),i=i[f]}return t}var xo=Zf;function Jf(t,e,r){for(var o=-1,a=e.length,n={};++o<a;){var s=e[o],i=mr(t,s);r(i,s)&&xo(n,W(s,t),i)}return n}var go=Jf;function Xf(t,e){return go(t,e,function(r,o){return so(t,o)})}var bo=Xf;var Qf=gr(function(t,e){return t==null?{}:bo(t,e)}),Kt=Qf;function yo(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 vo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Jt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=vo[r[t]&63];return e};var tp="array",ep="bit",wo="bits",rp="byte",To="bytes",dt="",op="exponent",ap="function",Oo="iec",ip="Invalid number",np="Invalid rounding method",Xt="jedec",sp="object",Po=".",fp="round",pp="s",lp="si",mp="kbit",up="kB",dp=" ",cp="string",hp="0",Qt={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 Ao(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:n=dt,localeOptions:s={},separator:i=dt,spacer:f=dp,symbols:u={},standard:p=dt,output:g=cp,fullform:P=!1,fullforms:T=[],exponent:b=-1,roundingMethod:F=fp,precision:O=0}={}){let l=b,d=Number(t),m=[],C=0,zt=dt;p===lp?(o=10,p=Xt):p===Oo||p===Xt?o=2:o===2?p=Oo:(o=10,p=Xt);let vt=o===10?1e3:1024,jo=P===!0,ee=d<0,re=Math[F];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(ip);if(typeof re!==ap)throw new TypeError(np);if(ee&&(d=-d),(l===-1||isNaN(l))&&(l=Math.floor(Math.log(d)/Math.log(vt)),l<0&&(l=0)),l>8&&(O>0&&(O+=8-l),l=8),g===op)return l;if(d===0)m[0]=0,zt=m[1]=Qt.symbol[p][e?wo:To][l];else{C=d/(o===2?Math.pow(2,l*10):Math.pow(1e3,l)),e&&(C=C*8,C>=vt&&l<8&&(C=C/vt,l++));let ct=Math.pow(10,l>0?a:0);m[0]=re(C*ct)/ct,m[0]===vt&&l<8&&b===-1&&(m[0]=1,l++),zt=m[1]=o===10&&l===1?e?mp:up:Qt.symbol[p][e?wo:To][l]}if(ee&&(m[0]=-m[0]),O>0&&(m[0]=m[0].toPrecision(O)),m[1]=u[m[1]]||m[1],n===!0?m[0]=m[0].toLocaleString():n.length>0?m[0]=m[0].toLocaleString(n,s):i.length>0&&(m[0]=m[0].toString().replace(Po,i)),r&&Number.isInteger(m[0])===!1&&a>0){let ct=i||Po,oe=m[0].toString().split(ct),ae=oe[1]||dt,ie=ae.length,So=a-ie;m[0]=`${oe[0]}${ct}${ae.padEnd(ie+So,hp)}`}return jo&&(m[1]=T[l]?T[l]:Qt.fullform[p][l]+(e?ep:rp)+(m[0]===1?dt:pp)),g===tp?m:g===sp?{value:m[0],symbol:m[1],exponent:l,unit:zt}:m.join(f)}var $=class t{constructor(e){c(this,"_tera");c(this,"id");c(this,"name");c(this,"icon");c(this,"path");c(this,"url");c(this,"teraUrl");c(this,"parsedName");c(this,"created");c(this,"createdFormatted");c(this,"modified");c(this,"modifiedFormatted");c(this,"accessed");c(this,"accessedFormatted");c(this,"size");c(this,"sizeFormatted");c(this,"mime");c(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=Ao(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFile(this.id,e)}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Kt(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Kt(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var te=class{constructor(e){c(this,"settings",{devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child:{siteUrl:"https://dev.tera-tools.com/embed",restrictOrigin:"*"}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"https://tera-tools.com",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null});c(this,"events",yo());c(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});c(this,"methods",["handshake","setServerVerbosity","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","getProjectFileContents","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiProgress","uiPrompt","uiTrhow","uiSplat","uiWindow"]);c(this,"plugins",[]);c(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Jt();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||Jt(),...Yt(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=ne(r,e);return this.debug("INFO",3,"Created project patch",{patch:o,newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatch(e){if(this.settings.devMode&&this.settings.debugPaths){if(!Array.isArray(this.settings.debugPaths))throw new Error("teraFyClient.settings.debugPaths should be either null or an Array<String>");let r=e.filter(o=>this.settings.debugPaths.some(a=>o.path.join(".").slice(0,a.length)==a)).map(o=>o.path.join("."));if(r.length>0){console.info("Detected writes to",r,"- entering debugging mode");debugger}}return this.rpc("applyProjectStatePatch",e)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.debug("INFO",4,"[0/6] Init",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/6] Setting client mode to",o),Zt(this.settings,{mode:o,...this.settings.modeOverrides[o]})}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).catch(o=>this.debug("WARN",0,"Init process fault",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":this.debug("INFO",2,"Using TERA window parent");break;case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let n=0,s,i=setTimeout(()=>{clearTimeout(s),a("TIMEOUT")},r.handshakeTimeout),f=()=>{this.debug("INFO",4,"Trying handshake",++n),clearTimeout(s),s=setTimeout(f,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(i),clearTimeout(s)}).then(()=>o()).catch(a)};f()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
1
|
+
var Io=Object.defineProperty;var _o=(t,e,r)=>e in t?Io(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var c=(t,e,r)=>_o(t,typeof e!="symbol"?e+"":e,r);function ne(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:f,basePath:u,basePathForRemoves:p,diffs:g}){var P=Object.keys(i),T=P.length,b=Object.keys(f),F=b.length,O,l=i.length-f.length;if(Fo(i,f)){for(var d=0;d<T;d++){var m=Array.isArray(i)?Number(P[d]):P[d];m in f||(O=p.concat(m),g.remove.push({op:"remove",path:r(O)}))}for(var d=0;d<F;d++){var m=Array.isArray(f)?Number(b[d]):b[d];n({key:m,obj1:i,obj2:f,path:u.concat(m),pathForRemoves:u.concat(m),diffs:g})}}else{for(var d=0;d<l;d++)O=p.concat(d),g.remove.push({op:"remove",path:r(O)});for(var C=i.slice(l),d=0;d<F;d++)n({key:d,obj1:C,obj2:f,path:u.concat(d),pathForRemoves:u.concat(d+l),diffs:g})}}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 n({key:i,obj1:f,obj2:u,path:p,pathForRemoves:g,diffs:P}){var T=f[i],b=u[i];if(!(i in f)&&i in u){var F=b;P.add.push({op:"add",path:r(p),value:F})}else T!==b&&(Object(T)!==T||Object(b)!==b||Eo(T,b)||!Object.keys(T).length&&!Object.keys(b).length&&String(T)!=String(b)?s(p,P,b):o({obj1:f[i],obj2:u[i],basePath:p,basePathForRemoves:g,diffs:P}))}function s(i,f,u){f.replace.push({op:"replace",path:r(i),value:u})}}function Eo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Fo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,n=0;n<e.length&&String(t[n])===String(e[n]);n++)o++;for(var s=e.length;s>0&&String(t[s+r])===String(e[s]);s--)a++;return o>=a}return!0}var Co=typeof global=="object"&&global&&global.Object===Object&&global,wt=Co;var Mo=typeof self=="object"&&self&&self.Object===Object&&self,Ro=wt||Mo||Function("return this")(),y=Ro;var No=y.Symbol,j=No;var se=Object.prototype,Lo=se.hasOwnProperty,Bo=se.toString,ht=j?j.toStringTag:void 0;function Do(t){var e=Lo.call(t,ht),r=t[ht];try{t[ht]=void 0;var o=!0}catch{}var a=Bo.call(t);return o&&(e?t[ht]=r:delete t[ht]),a}var fe=Do;var Uo=Object.prototype,ko=Uo.toString;function Go(t){return ko.call(t)}var pe=Go;var Ko="[object Null]",zo="[object Undefined]",le=j?j.toStringTag:void 0;function Wo(t){return t==null?t===void 0?zo:Ko:le&&le in Object(t)?fe(t):pe(t)}var I=Wo;function $o(t){return t!=null&&typeof t=="object"}var A=$o;var Ho="[object Symbol]";function Vo(t){return typeof t=="symbol"||A(t)&&I(t)==Ho}var V=Vo;function qo(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 me=qo;var Yo=Array.isArray,v=Yo;var Zo=1/0,ue=j?j.prototype:void 0,de=ue?ue.toString:void 0;function ce(t){if(typeof t=="string")return t;if(v(t))return me(t,ce)+"";if(V(t))return de?de.call(t):"";var e=t+"";return e=="0"&&1/t==-Zo?"-0":e}var he=ce;function Jo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var w=Jo;function Xo(t){return t}var Tt=Xo;var Qo="[object AsyncFunction]",ta="[object Function]",ea="[object GeneratorFunction]",ra="[object Proxy]";function oa(t){if(!w(t))return!1;var e=I(t);return e==ta||e==ea||e==Qo||e==ra}var q=oa;var aa=y["__core-js_shared__"],Ot=aa;var xe=function(){var t=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function ia(t){return!!xe&&xe in t}var ge=ia;var na=Function.prototype,sa=na.toString;function fa(t){if(t!=null){try{return sa.call(t)}catch{}try{return t+""}catch{}}return""}var M=fa;var pa=/[\\^$.*+?()[\]{}|]/g,la=/^\[object .+?Constructor\]$/,ma=Function.prototype,ua=Object.prototype,da=ma.toString,ca=ua.hasOwnProperty,ha=RegExp("^"+da.call(ca).replace(pa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function xa(t){if(!w(t)||ge(t))return!1;var e=q(t)?ha:la;return e.test(M(t))}var be=xa;function ga(t,e){return t==null?void 0:t[e]}var ye=ga;function ba(t,e){var r=ye(t,e);return be(r)?r:void 0}var S=ba;var ya=S(y,"WeakMap"),Pt=ya;var ve=Object.create,va=function(){function t(){}return function(e){if(!w(e))return{};if(ve)return ve(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),we=va;function wa(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 Te=wa;function Ta(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var At=Ta;var Oa=800,Pa=16,Aa=Date.now;function ja(t){var e=0,r=0;return function(){var o=Aa(),a=Pa-(o-r);if(r=o,a>0){if(++e>=Oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Oe=ja;function Sa(t){return function(){return t}}var Pe=Sa;var Ia=function(){try{var t=S(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Y=Ia;var _a=Y?function(t,e){return Y(t,"toString",{configurable:!0,enumerable:!1,value:Pe(e),writable:!0})}:Tt,Ae=_a;var Ea=Oe(Ae),jt=Ea;function Fa(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var je=Fa;var Ca=9007199254740991,Ma=/^(?:0|[1-9]\d*)$/;function Ra(t,e){var r=typeof t;return e=e==null?Ca:e,!!e&&(r=="number"||r!="symbol"&&Ma.test(t))&&t>-1&&t%1==0&&t<e}var B=Ra;function Na(t,e,r){e=="__proto__"&&Y?Y(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Z=Na;function La(t,e){return t===e||t!==t&&e!==e}var D=La;var Ba=Object.prototype,Da=Ba.hasOwnProperty;function Ua(t,e,r){var o=t[e];(!(Da.call(t,e)&&D(o,r))||r===void 0&&!(e in t))&&Z(t,e,r)}var J=Ua;function ka(t,e,r,o){var a=!r;r||(r={});for(var n=-1,s=e.length;++n<s;){var i=e[n],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?Z(r,i,f):J(r,i,f)}return r}var _=ka;var Se=Math.max;function Ga(t,e,r){return e=Se(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,n=Se(o.length-e,0),s=Array(n);++a<n;)s[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(s),Te(t,this,i)}}var St=Ga;function Ka(t,e){return jt(St(t,e,Tt),t+"")}var Ie=Ka;var za=9007199254740991;function Wa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=za}var X=Wa;function $a(t){return t!=null&&X(t.length)&&!q(t)}var U=$a;function Ha(t,e,r){if(!w(r))return!1;var o=typeof e;return(o=="number"?U(r)&&B(e,r.length):o=="string"&&e in r)?D(r[e],t):!1}var _e=Ha;function Va(t){return Ie(function(e,r){var o=-1,a=r.length,n=a>1?r[a-1]:void 0,s=a>2?r[2]:void 0;for(n=t.length>3&&typeof n=="function"?(a--,n):void 0,s&&_e(r[0],r[1],s)&&(n=a<3?void 0:n,a=1),e=Object(e);++o<a;){var i=r[o];i&&t(e,i,o,n)}return e})}var Ee=Va;var qa=Object.prototype;function Ya(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||qa;return t===r}var Q=Ya;function Za(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Fe=Za;var Ja="[object Arguments]";function Xa(t){return A(t)&&I(t)==Ja}var Wt=Xa;var Ce=Object.prototype,Qa=Ce.hasOwnProperty,ti=Ce.propertyIsEnumerable,ei=Wt(function(){return arguments}())?Wt:function(t){return A(t)&&Qa.call(t,"callee")&&!ti.call(t,"callee")},R=ei;function ri(){return!1}var Me=ri;var Le=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Re=Le&&typeof module=="object"&&module&&!module.nodeType&&module,oi=Re&&Re.exports===Le,Ne=oi?y.Buffer:void 0,ai=Ne?Ne.isBuffer:void 0,ii=ai||Me,tt=ii;var ni="[object Arguments]",si="[object Array]",fi="[object Boolean]",pi="[object Date]",li="[object Error]",mi="[object Function]",ui="[object Map]",di="[object Number]",ci="[object Object]",hi="[object RegExp]",xi="[object Set]",gi="[object String]",bi="[object WeakMap]",yi="[object ArrayBuffer]",vi="[object DataView]",wi="[object Float32Array]",Ti="[object Float64Array]",Oi="[object Int8Array]",Pi="[object Int16Array]",Ai="[object Int32Array]",ji="[object Uint8Array]",Si="[object Uint8ClampedArray]",Ii="[object Uint16Array]",_i="[object Uint32Array]",x={};x[wi]=x[Ti]=x[Oi]=x[Pi]=x[Ai]=x[ji]=x[Si]=x[Ii]=x[_i]=!0;x[ni]=x[si]=x[yi]=x[fi]=x[vi]=x[pi]=x[li]=x[mi]=x[ui]=x[di]=x[ci]=x[hi]=x[xi]=x[gi]=x[bi]=!1;function Ei(t){return A(t)&&X(t.length)&&!!x[I(t)]}var Be=Ei;function Fi(t){return function(e){return t(e)}}var et=Fi;var De=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xt=De&&typeof module=="object"&&module&&!module.nodeType&&module,Ci=xt&&xt.exports===De,$t=Ci&&wt.process,Mi=function(){try{var t=xt&&xt.require&&xt.require("util").types;return t||$t&&$t.binding&&$t.binding("util")}catch{}}(),N=Mi;var Ue=N&&N.isTypedArray,Ri=Ue?et(Ue):Be,It=Ri;var Ni=Object.prototype,Li=Ni.hasOwnProperty;function Bi(t,e){var r=v(t),o=!r&&R(t),a=!r&&!o&&tt(t),n=!r&&!o&&!a&&It(t),s=r||o||a||n,i=s?Fe(t.length,String):[],f=i.length;for(var u in t)(e||Li.call(t,u))&&!(s&&(u=="length"||a&&(u=="offset"||u=="parent")||n&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||B(u,f)))&&i.push(u);return i}var _t=Bi;function Di(t,e){return function(r){return t(e(r))}}var Et=Di;var Ui=Et(Object.keys,Object),ke=Ui;var ki=Object.prototype,Gi=ki.hasOwnProperty;function Ki(t){if(!Q(t))return ke(t);var e=[];for(var r in Object(t))Gi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ge=Ki;function zi(t){return U(t)?_t(t):Ge(t)}var rt=zi;function Wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ke=Wi;var $i=Object.prototype,Hi=$i.hasOwnProperty;function Vi(t){if(!w(t))return Ke(t);var e=Q(t),r=[];for(var o in t)o=="constructor"&&(e||!Hi.call(t,o))||r.push(o);return r}var ze=Vi;function qi(t){return U(t)?_t(t,!0):ze(t)}var E=qi;var Yi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zi=/^\w*$/;function Ji(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||V(t)?!0:Zi.test(t)||!Yi.test(t)||e!=null&&t in Object(e)}var We=Ji;var Xi=S(Object,"create"),L=Xi;function Qi(){this.__data__=L?L(null):{},this.size=0}var $e=Qi;function tn(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var He=tn;var en="__lodash_hash_undefined__",rn=Object.prototype,on=rn.hasOwnProperty;function an(t){var e=this.__data__;if(L){var r=e[t];return r===en?void 0:r}return on.call(e,t)?e[t]:void 0}var Ve=an;var nn=Object.prototype,sn=nn.hasOwnProperty;function fn(t){var e=this.__data__;return L?e[t]!==void 0:sn.call(e,t)}var qe=fn;var pn="__lodash_hash_undefined__";function ln(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=L&&e===void 0?pn:e,this}var Ye=ln;function ot(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])}}ot.prototype.clear=$e;ot.prototype.delete=He;ot.prototype.get=Ve;ot.prototype.has=qe;ot.prototype.set=Ye;var Ht=ot;function mn(){this.__data__=[],this.size=0}var Ze=mn;function un(t,e){for(var r=t.length;r--;)if(D(t[r][0],e))return r;return-1}var k=un;var dn=Array.prototype,cn=dn.splice;function hn(t){var e=this.__data__,r=k(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():cn.call(e,r,1),--this.size,!0}var Je=hn;function xn(t){var e=this.__data__,r=k(e,t);return r<0?void 0:e[r][1]}var Xe=xn;function gn(t){return k(this.__data__,t)>-1}var Qe=gn;function bn(t,e){var r=this.__data__,o=k(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var tr=bn;function at(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])}}at.prototype.clear=Ze;at.prototype.delete=Je;at.prototype.get=Xe;at.prototype.has=Qe;at.prototype.set=tr;var G=at;var yn=S(y,"Map"),K=yn;function vn(){this.size=0,this.__data__={hash:new Ht,map:new(K||G),string:new Ht}}var er=vn;function wn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var rr=wn;function Tn(t,e){var r=t.__data__;return rr(e)?r[typeof e=="string"?"string":"hash"]:r.map}var z=Tn;function On(t){var e=z(this,t).delete(t);return this.size-=e?1:0,e}var or=On;function Pn(t){return z(this,t).get(t)}var ar=Pn;function An(t){return z(this,t).has(t)}var ir=An;function jn(t,e){var r=z(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var nr=jn;function it(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])}}it.prototype.clear=er;it.prototype.delete=or;it.prototype.get=ar;it.prototype.has=ir;it.prototype.set=nr;var gt=it;var Sn="Expected a function";function Vt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Sn);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],n=r.cache;if(n.has(a))return n.get(a);var s=t.apply(this,o);return r.cache=n.set(a,s)||n,s};return r.cache=new(Vt.Cache||gt),r}Vt.Cache=gt;var sr=Vt;var In=500;function _n(t){var e=sr(t,function(o){return r.size===In&&r.clear(),o}),r=e.cache;return e}var fr=_n;var En=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Fn=/\\(\\)?/g,Cn=fr(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(En,function(r,o,a,n){e.push(a?n.replace(Fn,"$1"):o||r)}),e}),pr=Cn;function Mn(t){return t==null?"":he(t)}var lr=Mn;function Rn(t,e){return v(t)?t:We(t,e)?[t]:pr(lr(t))}var W=Rn;var Nn=1/0;function Ln(t){if(typeof t=="string"||V(t))return t;var e=t+"";return e=="0"&&1/t==-Nn?"-0":e}var nt=Ln;function Bn(t,e){e=W(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[nt(e[r++])];return r&&r==o?t:void 0}var mr=Bn;function Dn(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var st=Dn;var ur=j?j.isConcatSpreadable:void 0;function Un(t){return v(t)||R(t)||!!(ur&&t&&t[ur])}var dr=Un;function cr(t,e,r,o,a){var n=-1,s=t.length;for(r||(r=dr),a||(a=[]);++n<s;){var i=t[n];e>0&&r(i)?e>1?cr(i,e-1,r,o,a):st(a,i):o||(a[a.length]=i)}return a}var hr=cr;function kn(t){var e=t==null?0:t.length;return e?hr(t,1):[]}var xr=kn;function Gn(t){return jt(St(t,void 0,xr),t+"")}var gr=Gn;var Kn=Et(Object.getPrototypeOf,Object),ft=Kn;var zn="[object Object]",Wn=Function.prototype,$n=Object.prototype,br=Wn.toString,Hn=$n.hasOwnProperty,Vn=br.call(Object);function qn(t){if(!A(t)||I(t)!=zn)return!1;var e=ft(t);if(e===null)return!0;var r=Hn.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&br.call(r)==Vn}var yr=qn;function Yn(){this.__data__=new G,this.size=0}var vr=Yn;function Zn(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var wr=Zn;function Jn(t){return this.__data__.get(t)}var Tr=Jn;function Xn(t){return this.__data__.has(t)}var Or=Xn;var Qn=200;function ts(t,e){var r=this.__data__;if(r instanceof G){var o=r.__data__;if(!K||o.length<Qn-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new gt(o)}return r.set(t,e),this.size=r.size,this}var Pr=ts;function pt(t){var e=this.__data__=new G(t);this.size=e.size}pt.prototype.clear=vr;pt.prototype.delete=wr;pt.prototype.get=Tr;pt.prototype.has=Or;pt.prototype.set=Pr;var Ft=pt;function es(t,e){return t&&_(e,rt(e),t)}var Ar=es;function rs(t,e){return t&&_(e,E(e),t)}var jr=rs;var Er=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sr=Er&&typeof module=="object"&&module&&!module.nodeType&&module,os=Sr&&Sr.exports===Er,Ir=os?y.Buffer:void 0,_r=Ir?Ir.allocUnsafe:void 0;function as(t,e){if(e)return t.slice();var r=t.length,o=_r?_r(r):new t.constructor(r);return t.copy(o),o}var Ct=as;function is(t,e){for(var r=-1,o=t==null?0:t.length,a=0,n=[];++r<o;){var s=t[r];e(s,r,t)&&(n[a++]=s)}return n}var Fr=is;function ns(){return[]}var Mt=ns;var ss=Object.prototype,fs=ss.propertyIsEnumerable,Cr=Object.getOwnPropertySymbols,ps=Cr?function(t){return t==null?[]:(t=Object(t),Fr(Cr(t),function(e){return fs.call(t,e)}))}:Mt,lt=ps;function ls(t,e){return _(t,lt(t),e)}var Mr=ls;var ms=Object.getOwnPropertySymbols,us=ms?function(t){for(var e=[];t;)st(e,lt(t)),t=ft(t);return e}:Mt,Rt=us;function ds(t,e){return _(t,Rt(t),e)}var Rr=ds;function cs(t,e,r){var o=e(t);return v(t)?o:st(o,r(t))}var Nt=cs;function hs(t){return Nt(t,rt,lt)}var Nr=hs;function xs(t){return Nt(t,E,Rt)}var Lr=xs;var gs=S(y,"DataView"),Lt=gs;var bs=S(y,"Promise"),Bt=bs;var ys=S(y,"Set"),Dt=ys;var Br="[object Map]",vs="[object Object]",Dr="[object Promise]",Ur="[object Set]",kr="[object WeakMap]",Gr="[object DataView]",ws=M(Lt),Ts=M(K),Os=M(Bt),Ps=M(Dt),As=M(Pt),H=I;(Lt&&H(new Lt(new ArrayBuffer(1)))!=Gr||K&&H(new K)!=Br||Bt&&H(Bt.resolve())!=Dr||Dt&&H(new Dt)!=Ur||Pt&&H(new Pt)!=kr)&&(H=function(t){var e=I(t),r=e==vs?t.constructor:void 0,o=r?M(r):"";if(o)switch(o){case ws:return Gr;case Ts:return Br;case Os:return Dr;case Ps:return Ur;case As:return kr}return e});var mt=H;var js=Object.prototype,Ss=js.hasOwnProperty;function Is(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Ss.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Kr=Is;var _s=y.Uint8Array,qt=_s;function Es(t){var e=new t.constructor(t.byteLength);return new qt(e).set(new qt(t)),e}var ut=Es;function Fs(t,e){var r=e?ut(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var zr=Fs;var Cs=/\w*$/;function Ms(t){var e=new t.constructor(t.source,Cs.exec(t));return e.lastIndex=t.lastIndex,e}var Wr=Ms;var $r=j?j.prototype:void 0,Hr=$r?$r.valueOf:void 0;function Rs(t){return Hr?Object(Hr.call(t)):{}}var Vr=Rs;function Ns(t,e){var r=e?ut(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Ut=Ns;var Ls="[object Boolean]",Bs="[object Date]",Ds="[object Map]",Us="[object Number]",ks="[object RegExp]",Gs="[object Set]",Ks="[object String]",zs="[object Symbol]",Ws="[object ArrayBuffer]",$s="[object DataView]",Hs="[object Float32Array]",Vs="[object Float64Array]",qs="[object Int8Array]",Ys="[object Int16Array]",Zs="[object Int32Array]",Js="[object Uint8Array]",Xs="[object Uint8ClampedArray]",Qs="[object Uint16Array]",tf="[object Uint32Array]";function ef(t,e,r){var o=t.constructor;switch(e){case Ws:return ut(t);case Ls:case Bs:return new o(+t);case $s:return zr(t,r);case Hs:case Vs:case qs:case Ys:case Zs:case Js:case Xs:case Qs:case tf:return Ut(t,r);case Ds:return new o;case Us:case Ks:return new o(t);case ks:return Wr(t);case Gs:return new o;case zs:return Vr(t)}}var qr=ef;function rf(t){return typeof t.constructor=="function"&&!Q(t)?we(ft(t)):{}}var kt=rf;var of="[object Map]";function af(t){return A(t)&&mt(t)==of}var Yr=af;var Zr=N&&N.isMap,nf=Zr?et(Zr):Yr,Jr=nf;var sf="[object Set]";function ff(t){return A(t)&&mt(t)==sf}var Xr=ff;var Qr=N&&N.isSet,pf=Qr?et(Qr):Xr,to=pf;var lf=1,mf=2,uf=4,eo="[object Arguments]",df="[object Array]",cf="[object Boolean]",hf="[object Date]",xf="[object Error]",ro="[object Function]",gf="[object GeneratorFunction]",bf="[object Map]",yf="[object Number]",oo="[object Object]",vf="[object RegExp]",wf="[object Set]",Tf="[object String]",Of="[object Symbol]",Pf="[object WeakMap]",Af="[object ArrayBuffer]",jf="[object DataView]",Sf="[object Float32Array]",If="[object Float64Array]",_f="[object Int8Array]",Ef="[object Int16Array]",Ff="[object Int32Array]",Cf="[object Uint8Array]",Mf="[object Uint8ClampedArray]",Rf="[object Uint16Array]",Nf="[object Uint32Array]",h={};h[eo]=h[df]=h[Af]=h[jf]=h[cf]=h[hf]=h[Sf]=h[If]=h[_f]=h[Ef]=h[Ff]=h[bf]=h[yf]=h[oo]=h[vf]=h[wf]=h[Tf]=h[Of]=h[Cf]=h[Mf]=h[Rf]=h[Nf]=!0;h[xf]=h[ro]=h[Pf]=!1;function Gt(t,e,r,o,a,n){var s,i=e&lf,f=e&mf,u=e&uf;if(r&&(s=a?r(t,o,a,n):r(t)),s!==void 0)return s;if(!w(t))return t;var p=v(t);if(p){if(s=Kr(t),!i)return At(t,s)}else{var g=mt(t),P=g==ro||g==gf;if(tt(t))return Ct(t,i);if(g==oo||g==eo||P&&!a){if(s=f||P?{}:kt(t),!i)return f?Rr(t,jr(s,t)):Mr(t,Ar(s,t))}else{if(!h[g])return a?t:{};s=qr(t,g,i)}}n||(n=new Ft);var T=n.get(t);if(T)return T;n.set(t,s),to(t)?t.forEach(function(O){s.add(Gt(O,e,r,O,t,n))}):Jr(t)&&t.forEach(function(O,l){s.set(l,Gt(O,e,r,l,t,n))});var b=u?f?Lr:Nr:f?E:rt,F=p?void 0:b(t);return je(F||t,function(O,l){F&&(l=O,O=t[l]),J(s,l,Gt(O,e,r,l,t,n))}),s}var ao=Gt;var Lf=1,Bf=4;function Df(t){return ao(t,Lf|Bf)}var Yt=Df;function Uf(t,e){return t!=null&&e in Object(t)}var io=Uf;function kf(t,e,r){e=W(e,t);for(var o=-1,a=e.length,n=!1;++o<a;){var s=nt(e[o]);if(!(n=t!=null&&r(t,s)))break;t=t[s]}return n||++o!=a?n:(a=t==null?0:t.length,!!a&&X(a)&&B(s,a)&&(v(t)||R(t)))}var no=kf;function Gf(t,e){return t!=null&&no(t,e,io)}var so=Gf;function Kf(t){return function(e,r,o){for(var a=-1,n=Object(e),s=o(e),i=s.length;i--;){var f=s[t?i:++a];if(r(n[f],f,n)===!1)break}return e}}var fo=Kf;var zf=fo(),po=zf;function Wf(t,e,r){(r!==void 0&&!D(t[e],r)||r===void 0&&!(e in t))&&Z(t,e,r)}var bt=Wf;function $f(t){return A(t)&&U(t)}var lo=$f;function Hf(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var yt=Hf;function Vf(t){return _(t,E(t))}var mo=Vf;function qf(t,e,r,o,a,n,s){var i=yt(t,r),f=yt(e,r),u=s.get(f);if(u){bt(t,r,u);return}var p=n?n(i,f,r+"",t,e,s):void 0,g=p===void 0;if(g){var P=v(f),T=!P&&tt(f),b=!P&&!T&&It(f);p=f,P||T||b?v(i)?p=i:lo(i)?p=At(i):T?(g=!1,p=Ct(f,!0)):b?(g=!1,p=Ut(f,!0)):p=[]:yr(f)||R(f)?(p=i,R(i)?p=mo(i):(!w(i)||q(i))&&(p=kt(f))):g=!1}g&&(s.set(f,p),a(p,f,o,n,s),s.delete(f)),bt(t,r,p)}var uo=qf;function co(t,e,r,o,a){t!==e&&po(e,function(n,s){if(a||(a=new Ft),w(n))uo(t,e,s,r,co,o,a);else{var i=o?o(yt(t,s),n,s+"",t,e,a):void 0;i===void 0&&(i=n),bt(t,s,i)}},E)}var ho=co;var Yf=Ee(function(t,e,r){ho(t,e,r)}),Zt=Yf;function Zf(t,e,r,o){if(!w(t))return t;e=W(e,t);for(var a=-1,n=e.length,s=n-1,i=t;i!=null&&++a<n;){var f=nt(e[a]),u=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=s){var p=i[f];u=o?o(p,f,i):void 0,u===void 0&&(u=w(p)?p:B(e[a+1])?[]:{})}J(i,f,u),i=i[f]}return t}var xo=Zf;function Jf(t,e,r){for(var o=-1,a=e.length,n={};++o<a;){var s=e[o],i=mr(t,s);r(i,s)&&xo(n,W(s,t),i)}return n}var go=Jf;function Xf(t,e){return go(t,e,function(r,o){return so(t,o)})}var bo=Xf;var Qf=gr(function(t,e){return t==null?{}:bo(t,e)}),Kt=Qf;function yo(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 vo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Jt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=vo[r[t]&63];return e};var tp="array",ep="bit",wo="bits",rp="byte",To="bytes",dt="",op="exponent",ap="function",Oo="iec",ip="Invalid number",np="Invalid rounding method",Xt="jedec",sp="object",Po=".",fp="round",pp="s",lp="si",mp="kbit",up="kB",dp=" ",cp="string",hp="0",Qt={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 Ao(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:n=dt,localeOptions:s={},separator:i=dt,spacer:f=dp,symbols:u={},standard:p=dt,output:g=cp,fullform:P=!1,fullforms:T=[],exponent:b=-1,roundingMethod:F=fp,precision:O=0}={}){let l=b,d=Number(t),m=[],C=0,zt=dt;p===lp?(o=10,p=Xt):p===Oo||p===Xt?o=2:o===2?p=Oo:(o=10,p=Xt);let vt=o===10?1e3:1024,jo=P===!0,ee=d<0,re=Math[F];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(ip);if(typeof re!==ap)throw new TypeError(np);if(ee&&(d=-d),(l===-1||isNaN(l))&&(l=Math.floor(Math.log(d)/Math.log(vt)),l<0&&(l=0)),l>8&&(O>0&&(O+=8-l),l=8),g===op)return l;if(d===0)m[0]=0,zt=m[1]=Qt.symbol[p][e?wo:To][l];else{C=d/(o===2?Math.pow(2,l*10):Math.pow(1e3,l)),e&&(C=C*8,C>=vt&&l<8&&(C=C/vt,l++));let ct=Math.pow(10,l>0?a:0);m[0]=re(C*ct)/ct,m[0]===vt&&l<8&&b===-1&&(m[0]=1,l++),zt=m[1]=o===10&&l===1?e?mp:up:Qt.symbol[p][e?wo:To][l]}if(ee&&(m[0]=-m[0]),O>0&&(m[0]=m[0].toPrecision(O)),m[1]=u[m[1]]||m[1],n===!0?m[0]=m[0].toLocaleString():n.length>0?m[0]=m[0].toLocaleString(n,s):i.length>0&&(m[0]=m[0].toString().replace(Po,i)),r&&Number.isInteger(m[0])===!1&&a>0){let ct=i||Po,oe=m[0].toString().split(ct),ae=oe[1]||dt,ie=ae.length,So=a-ie;m[0]=`${oe[0]}${ct}${ae.padEnd(ie+So,hp)}`}return jo&&(m[1]=T[l]?T[l]:Qt.fullform[p][l]+(e?ep:rp)+(m[0]===1?dt:pp)),g===tp?m:g===sp?{value:m[0],symbol:m[1],exponent:l,unit:zt}:m.join(f)}var $=class t{constructor(e){c(this,"_tera");c(this,"id");c(this,"name");c(this,"icon");c(this,"path");c(this,"url");c(this,"teraUrl");c(this,"parsedName");c(this,"created");c(this,"createdFormatted");c(this,"modified");c(this,"modifiedFormatted");c(this,"accessed");c(this,"accessedFormatted");c(this,"size");c(this,"sizeFormatted");c(this,"mime");c(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=Ao(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFile(this.id,e)}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Kt(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Kt(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var te=class{constructor(e){c(this,"settings",{devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child:{siteUrl:"https://dev.tera-tools.com/embed",restrictOrigin:"*"}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"https://tera-tools.com",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null});c(this,"events",yo());c(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});c(this,"methods",["handshake","setServerVerbosity","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","getProjectFileContents","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiProgress","uiPrompt","uiTrhow","uiSplat","uiWindow"]);c(this,"plugins",[]);c(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Jt();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||Jt(),...Yt(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=ne(r,e);return this.debug("INFO",3,"Created project patch",{patch:o,newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatch(e){if(this.settings.devMode&&this.settings.debugPaths){if(!Array.isArray(this.settings.debugPaths))throw new Error("teraFyClient.settings.debugPaths should be either null or an Array<String>");let r=e.filter(o=>this.settings.debugPaths.some(a=>o.path.join(".").slice(0,a.length)==a)).map(o=>o.path.join("."));if(r.length>0){console.info("Detected writes to",r,"- entering debugging mode");debugger}}return this.rpc("applyProjectStatePatch",e)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.debug("INFO",4,"[0/6] Init",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/6] Setting client mode to",o),Zt(this.settings,{mode:o,...this.settings.modeOverrides[o]})}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).catch(o=>this.debug("WARN",0,"Init process fault",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":this.debug("INFO",2,"Using TERA window parent");break;case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let n=0,s,i=setTimeout(()=>{clearTimeout(s),a("TIMEOUT")},r.handshakeTimeout),f=()=>{this.debug("INFO",4,"Trying handshake",++n),clearTimeout(s),s=setTimeout(f,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(i),clearTimeout(s)}).then(()=>o()).catch(a)};f()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
2
2
|
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){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 e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.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 $({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new $({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new $({tera:this,...r}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new $({tera:this,...r}))}};export{te as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
package/dist/terafy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function ie(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:f,basePath:u,basePathForRemoves:p,diffs:g}){var O=Object.keys(i),w=O.length,x=Object.keys(f),E=x.length,T,l=i.length-f.length;if(Io(i,f)){for(var d=0;d<w;d++){var m=Array.isArray(i)?Number(O[d]):O[d];m in f||(T=p.concat(m),g.remove.push({op:"remove",path:r(T)}))}for(var d=0;d<E;d++){var m=Array.isArray(f)?Number(x[d]):x[d];s({key:m,obj1:i,obj2:f,path:u.concat(m),pathForRemoves:u.concat(m),diffs:g})}}else{for(var d=0;d<l;d++)T=p.concat(d),g.remove.push({op:"remove",path:r(T)});for(var F=i.slice(l),d=0;d<E;d++)s({key:d,obj1:F,obj2:f,path:u.concat(d),pathForRemoves:u.concat(d+l),diffs:g})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:f,obj2:u,path:p,pathForRemoves:g,diffs:O}){var w=f[i],x=u[i];if(!(i in f)&&i in u){var E=x;O.add.push({op:"add",path:r(p),value:E})}else w!==x&&(Object(w)!==w||Object(x)!==x||So(w,x)||!Object.keys(w).length&&!Object.keys(x).length&&String(w)!=String(x)?n(p,O,x):o({obj1:f[i],obj2:u[i],basePath:p,basePathForRemoves:g,diffs:O}))}function n(i,f,u){f.replace.push({op:"replace",path:r(i),value:u})}}function So(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Io(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)a++;return o>=a}return!0}var _o=typeof global=="object"&&global&&global.Object===Object&&global,vt=_o;var Eo=typeof self=="object"&&self&&self.Object===Object&&self,Fo=vt||Eo||Function("return this")(),b=Fo;var Co=b.Symbol,A=Co;var se=Object.prototype,Mo=se.hasOwnProperty,Ro=se.toString,ct=A?A.toStringTag:void 0;function No(t){var e=Mo.call(t,ct),r=t[ct];try{t[ct]=void 0;var o=!0}catch{}var a=Ro.call(t);return o&&(e?t[ct]=r:delete t[ct]),a}var ne=No;var Lo=Object.prototype,Bo=Lo.toString;function Do(t){return Bo.call(t)}var fe=Do;var Uo="[object Null]",ko="[object Undefined]",pe=A?A.toStringTag:void 0;function Go(t){return t==null?t===void 0?ko:Uo:pe&&pe in Object(t)?ne(t):fe(t)}var S=Go;function Ko(t){return t!=null&&typeof t=="object"}var P=Ko;var zo="[object Symbol]";function Wo(t){return typeof t=="symbol"||P(t)&&S(t)==zo}var H=Wo;function $o(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 le=$o;var Ho=Array.isArray,y=Ho;var Vo=1/0,me=A?A.prototype:void 0,ue=me?me.toString:void 0;function de(t){if(typeof t=="string")return t;if(y(t))return le(t,de)+"";if(H(t))return ue?ue.call(t):"";var e=t+"";return e=="0"&&1/t==-Vo?"-0":e}var ce=de;function qo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v=qo;function Yo(t){return t}var wt=Yo;var Zo="[object AsyncFunction]",Jo="[object Function]",Xo="[object GeneratorFunction]",Qo="[object Proxy]";function ta(t){if(!v(t))return!1;var e=S(t);return e==Jo||e==Xo||e==Zo||e==Qo}var V=ta;var ea=b["__core-js_shared__"],Tt=ea;var he=function(){var t=/[^.]+$/.exec(Tt&&Tt.keys&&Tt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function ra(t){return!!he&&he in t}var ge=ra;var oa=Function.prototype,aa=oa.toString;function ia(t){if(t!=null){try{return aa.call(t)}catch{}try{return t+""}catch{}}return""}var C=ia;var sa=/[\\^$.*+?()[\]{}|]/g,na=/^\[object .+?Constructor\]$/,fa=Function.prototype,pa=Object.prototype,la=fa.toString,ma=pa.hasOwnProperty,ua=RegExp("^"+la.call(ma).replace(sa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function da(t){if(!v(t)||ge(t))return!1;var e=V(t)?ua:na;return e.test(C(t))}var xe=da;function ca(t,e){return t?.[e]}var be=ca;function ha(t,e){var r=be(t,e);return xe(r)?r:void 0}var j=ha;var ga=j(b,"WeakMap"),Ot=ga;var ye=Object.create,xa=function(){function t(){}return function(e){if(!v(e))return{};if(ye)return ye(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ve=xa;function ba(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 we=ba;function ya(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Pt=ya;var va=800,wa=16,Ta=Date.now;function Oa(t){var e=0,r=0;return function(){var o=Ta(),a=wa-(o-r);if(r=o,a>0){if(++e>=va)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Te=Oa;function Pa(t){return function(){return t}}var Oe=Pa;var Aa=function(){try{var t=j(Object,"defineProperty");return t({},"",{}),t}catch{}}(),q=Aa;var ja=q?function(t,e){return q(t,"toString",{configurable:!0,enumerable:!1,value:Oe(e),writable:!0})}:wt,Pe=ja;var Sa=Te(Pe),At=Sa;function Ia(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Ae=Ia;var _a=9007199254740991,Ea=/^(?:0|[1-9]\d*)$/;function Fa(t,e){var r=typeof t;return e=e??_a,!!e&&(r=="number"||r!="symbol"&&Ea.test(t))&&t>-1&&t%1==0&&t<e}var L=Fa;function Ca(t,e,r){e=="__proto__"&&q?q(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Y=Ca;function Ma(t,e){return t===e||t!==t&&e!==e}var B=Ma;var Ra=Object.prototype,Na=Ra.hasOwnProperty;function La(t,e,r){var o=t[e];(!(Na.call(t,e)&&B(o,r))||r===void 0&&!(e in t))&&Y(t,e,r)}var Z=La;function Ba(t,e,r,o){var a=!r;r||(r={});for(var s=-1,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?Y(r,i,f):Z(r,i,f)}return r}var I=Ba;var je=Math.max;function Da(t,e,r){return e=je(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=je(o.length-e,0),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),we(t,this,i)}}var jt=Da;function Ua(t,e){return At(jt(t,e,wt),t+"")}var Se=Ua;var ka=9007199254740991;function Ga(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ka}var J=Ga;function Ka(t){return t!=null&&J(t.length)&&!V(t)}var D=Ka;function za(t,e,r){if(!v(r))return!1;var o=typeof e;return(o=="number"?D(r)&&L(e,r.length):o=="string"&&e in r)?B(r[e],t):!1}var Ie=za;function Wa(t){return Se(function(e,r){var o=-1,a=r.length,s=a>1?r[a-1]:void 0,n=a>2?r[2]:void 0;for(s=t.length>3&&typeof s=="function"?(a--,s):void 0,n&&Ie(r[0],r[1],n)&&(s=a<3?void 0:s,a=1),e=Object(e);++o<a;){var i=r[o];i&&t(e,i,o,s)}return e})}var _e=Wa;var $a=Object.prototype;function Ha(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||$a;return t===r}var X=Ha;function Va(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Ee=Va;var qa="[object Arguments]";function Ya(t){return P(t)&&S(t)==qa}var zt=Ya;var Fe=Object.prototype,Za=Fe.hasOwnProperty,Ja=Fe.propertyIsEnumerable,Xa=zt(function(){return arguments}())?zt:function(t){return P(t)&&Za.call(t,"callee")&&!Ja.call(t,"callee")},M=Xa;function Qa(){return!1}var Ce=Qa;var Ne=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Me=Ne&&typeof module=="object"&&module&&!module.nodeType&&module,ti=Me&&Me.exports===Ne,Re=ti?b.Buffer:void 0,ei=Re?Re.isBuffer:void 0,ri=ei||Ce,Q=ri;var oi="[object Arguments]",ai="[object Array]",ii="[object Boolean]",si="[object Date]",ni="[object Error]",fi="[object Function]",pi="[object Map]",li="[object Number]",mi="[object Object]",ui="[object RegExp]",di="[object Set]",ci="[object String]",hi="[object WeakMap]",gi="[object ArrayBuffer]",xi="[object DataView]",bi="[object Float32Array]",yi="[object Float64Array]",vi="[object Int8Array]",wi="[object Int16Array]",Ti="[object Int32Array]",Oi="[object Uint8Array]",Pi="[object Uint8ClampedArray]",Ai="[object Uint16Array]",ji="[object Uint32Array]",h={};h[bi]=h[yi]=h[vi]=h[wi]=h[Ti]=h[Oi]=h[Pi]=h[Ai]=h[ji]=!0;h[oi]=h[ai]=h[gi]=h[ii]=h[xi]=h[si]=h[ni]=h[fi]=h[pi]=h[li]=h[mi]=h[ui]=h[di]=h[ci]=h[hi]=!1;function Si(t){return P(t)&&J(t.length)&&!!h[S(t)]}var Le=Si;function Ii(t){return function(e){return t(e)}}var tt=Ii;var Be=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ht=Be&&typeof module=="object"&&module&&!module.nodeType&&module,_i=ht&&ht.exports===Be,Wt=_i&&vt.process,Ei=function(){try{var t=ht&&ht.require&&ht.require("util").types;return t||Wt&&Wt.binding&&Wt.binding("util")}catch{}}(),R=Ei;var De=R&&R.isTypedArray,Fi=De?tt(De):Le,St=Fi;var Ci=Object.prototype,Mi=Ci.hasOwnProperty;function Ri(t,e){var r=y(t),o=!r&&M(t),a=!r&&!o&&Q(t),s=!r&&!o&&!a&&St(t),n=r||o||a||s,i=n?Ee(t.length,String):[],f=i.length;for(var u in t)(e||Mi.call(t,u))&&!(n&&(u=="length"||a&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||L(u,f)))&&i.push(u);return i}var It=Ri;function Ni(t,e){return function(r){return t(e(r))}}var _t=Ni;var Li=_t(Object.keys,Object),Ue=Li;var Bi=Object.prototype,Di=Bi.hasOwnProperty;function Ui(t){if(!X(t))return Ue(t);var e=[];for(var r in Object(t))Di.call(t,r)&&r!="constructor"&&e.push(r);return e}var ke=Ui;function ki(t){return D(t)?It(t):ke(t)}var et=ki;function Gi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ge=Gi;var Ki=Object.prototype,zi=Ki.hasOwnProperty;function Wi(t){if(!v(t))return Ge(t);var e=X(t),r=[];for(var o in t)o=="constructor"&&(e||!zi.call(t,o))||r.push(o);return r}var Ke=Wi;function $i(t){return D(t)?It(t,!0):Ke(t)}var _=$i;var Hi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Vi=/^\w*$/;function qi(t,e){if(y(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||H(t)?!0:Vi.test(t)||!Hi.test(t)||e!=null&&t in Object(e)}var ze=qi;var Yi=j(Object,"create"),N=Yi;function Zi(){this.__data__=N?N(null):{},this.size=0}var We=Zi;function Ji(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var $e=Ji;var Xi="__lodash_hash_undefined__",Qi=Object.prototype,ts=Qi.hasOwnProperty;function es(t){var e=this.__data__;if(N){var r=e[t];return r===Xi?void 0:r}return ts.call(e,t)?e[t]:void 0}var He=es;var rs=Object.prototype,os=rs.hasOwnProperty;function as(t){var e=this.__data__;return N?e[t]!==void 0:os.call(e,t)}var Ve=as;var is="__lodash_hash_undefined__";function ss(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=N&&e===void 0?is:e,this}var qe=ss;function rt(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])}}rt.prototype.clear=We;rt.prototype.delete=$e;rt.prototype.get=He;rt.prototype.has=Ve;rt.prototype.set=qe;var $t=rt;function ns(){this.__data__=[],this.size=0}var Ye=ns;function fs(t,e){for(var r=t.length;r--;)if(B(t[r][0],e))return r;return-1}var U=fs;var ps=Array.prototype,ls=ps.splice;function ms(t){var e=this.__data__,r=U(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():ls.call(e,r,1),--this.size,!0}var Ze=ms;function us(t){var e=this.__data__,r=U(e,t);return r<0?void 0:e[r][1]}var Je=us;function ds(t){return U(this.__data__,t)>-1}var Xe=ds;function cs(t,e){var r=this.__data__,o=U(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Qe=cs;function ot(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])}}ot.prototype.clear=Ye;ot.prototype.delete=Ze;ot.prototype.get=Je;ot.prototype.has=Xe;ot.prototype.set=Qe;var k=ot;var hs=j(b,"Map"),G=hs;function gs(){this.size=0,this.__data__={hash:new $t,map:new(G||k),string:new $t}}var tr=gs;function xs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var er=xs;function bs(t,e){var r=t.__data__;return er(e)?r[typeof e=="string"?"string":"hash"]:r.map}var K=bs;function ys(t){var e=K(this,t).delete(t);return this.size-=e?1:0,e}var rr=ys;function vs(t){return K(this,t).get(t)}var or=vs;function ws(t){return K(this,t).has(t)}var ar=ws;function Ts(t,e){var r=K(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var ir=Ts;function at(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])}}at.prototype.clear=tr;at.prototype.delete=rr;at.prototype.get=or;at.prototype.has=ar;at.prototype.set=ir;var gt=at;var Os="Expected a function";function Ht(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Os);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};return r.cache=new(Ht.Cache||gt),r}Ht.Cache=gt;var sr=Ht;var Ps=500;function As(t){var e=sr(t,function(o){return r.size===Ps&&r.clear(),o}),r=e.cache;return e}var nr=As;var js=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ss=/\\(\\)?/g,Is=nr(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(js,function(r,o,a,s){e.push(a?s.replace(Ss,"$1"):o||r)}),e}),fr=Is;function _s(t){return t==null?"":ce(t)}var pr=_s;function Es(t,e){return y(t)?t:ze(t,e)?[t]:fr(pr(t))}var z=Es;var Fs=1/0;function Cs(t){if(typeof t=="string"||H(t))return t;var e=t+"";return e=="0"&&1/t==-Fs?"-0":e}var it=Cs;function Ms(t,e){e=z(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[it(e[r++])];return r&&r==o?t:void 0}var lr=Ms;function Rs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var st=Rs;var mr=A?A.isConcatSpreadable:void 0;function Ns(t){return y(t)||M(t)||!!(mr&&t&&t[mr])}var ur=Ns;function dr(t,e,r,o,a){var s=-1,n=t.length;for(r||(r=ur),a||(a=[]);++s<n;){var i=t[s];e>0&&r(i)?e>1?dr(i,e-1,r,o,a):st(a,i):o||(a[a.length]=i)}return a}var cr=dr;function Ls(t){var e=t==null?0:t.length;return e?cr(t,1):[]}var hr=Ls;function Bs(t){return At(jt(t,void 0,hr),t+"")}var gr=Bs;var Ds=_t(Object.getPrototypeOf,Object),nt=Ds;var Us="[object Object]",ks=Function.prototype,Gs=Object.prototype,xr=ks.toString,Ks=Gs.hasOwnProperty,zs=xr.call(Object);function Ws(t){if(!P(t)||S(t)!=Us)return!1;var e=nt(t);if(e===null)return!0;var r=Ks.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&xr.call(r)==zs}var br=Ws;function $s(){this.__data__=new k,this.size=0}var yr=$s;function Hs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var vr=Hs;function Vs(t){return this.__data__.get(t)}var wr=Vs;function qs(t){return this.__data__.has(t)}var Tr=qs;var Ys=200;function Zs(t,e){var r=this.__data__;if(r instanceof k){var o=r.__data__;if(!G||o.length<Ys-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new gt(o)}return r.set(t,e),this.size=r.size,this}var Or=Zs;function ft(t){var e=this.__data__=new k(t);this.size=e.size}ft.prototype.clear=yr;ft.prototype.delete=vr;ft.prototype.get=wr;ft.prototype.has=Tr;ft.prototype.set=Or;var Et=ft;function Js(t,e){return t&&I(e,et(e),t)}var Pr=Js;function Xs(t,e){return t&&I(e,_(e),t)}var Ar=Xs;var _r=typeof exports=="object"&&exports&&!exports.nodeType&&exports,jr=_r&&typeof module=="object"&&module&&!module.nodeType&&module,Qs=jr&&jr.exports===_r,Sr=Qs?b.Buffer:void 0,Ir=Sr?Sr.allocUnsafe:void 0;function tn(t,e){if(e)return t.slice();var r=t.length,o=Ir?Ir(r):new t.constructor(r);return t.copy(o),o}var Ft=tn;function en(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var Er=en;function rn(){return[]}var Ct=rn;var on=Object.prototype,an=on.propertyIsEnumerable,Fr=Object.getOwnPropertySymbols,sn=Fr?function(t){return t==null?[]:(t=Object(t),Er(Fr(t),function(e){return an.call(t,e)}))}:Ct,pt=sn;function nn(t,e){return I(t,pt(t),e)}var Cr=nn;var fn=Object.getOwnPropertySymbols,pn=fn?function(t){for(var e=[];t;)st(e,pt(t)),t=nt(t);return e}:Ct,Mt=pn;function ln(t,e){return I(t,Mt(t),e)}var Mr=ln;function mn(t,e,r){var o=e(t);return y(t)?o:st(o,r(t))}var Rt=mn;function un(t){return Rt(t,et,pt)}var Rr=un;function dn(t){return Rt(t,_,Mt)}var Nr=dn;var cn=j(b,"DataView"),Nt=cn;var hn=j(b,"Promise"),Lt=hn;var gn=j(b,"Set"),Bt=gn;var Lr="[object Map]",xn="[object Object]",Br="[object Promise]",Dr="[object Set]",Ur="[object WeakMap]",kr="[object DataView]",bn=C(Nt),yn=C(G),vn=C(Lt),wn=C(Bt),Tn=C(Ot),$=S;(Nt&&$(new Nt(new ArrayBuffer(1)))!=kr||G&&$(new G)!=Lr||Lt&&$(Lt.resolve())!=Br||Bt&&$(new Bt)!=Dr||Ot&&$(new Ot)!=Ur)&&($=function(t){var e=S(t),r=e==xn?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case bn:return kr;case yn:return Lr;case vn:return Br;case wn:return Dr;case Tn:return Ur}return e});var lt=$;var On=Object.prototype,Pn=On.hasOwnProperty;function An(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Pn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Gr=An;var jn=b.Uint8Array,Vt=jn;function Sn(t){var e=new t.constructor(t.byteLength);return new Vt(e).set(new Vt(t)),e}var mt=Sn;function In(t,e){var r=e?mt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Kr=In;var _n=/\w*$/;function En(t){var e=new t.constructor(t.source,_n.exec(t));return e.lastIndex=t.lastIndex,e}var zr=En;var Wr=A?A.prototype:void 0,$r=Wr?Wr.valueOf:void 0;function Fn(t){return $r?Object($r.call(t)):{}}var Hr=Fn;function Cn(t,e){var r=e?mt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dt=Cn;var Mn="[object Boolean]",Rn="[object Date]",Nn="[object Map]",Ln="[object Number]",Bn="[object RegExp]",Dn="[object Set]",Un="[object String]",kn="[object Symbol]",Gn="[object ArrayBuffer]",Kn="[object DataView]",zn="[object Float32Array]",Wn="[object Float64Array]",$n="[object Int8Array]",Hn="[object Int16Array]",Vn="[object Int32Array]",qn="[object Uint8Array]",Yn="[object Uint8ClampedArray]",Zn="[object Uint16Array]",Jn="[object Uint32Array]";function Xn(t,e,r){var o=t.constructor;switch(e){case Gn:return mt(t);case Mn:case Rn:return new o(+t);case Kn:return Kr(t,r);case zn:case Wn:case $n:case Hn:case Vn:case qn:case Yn:case Zn:case Jn:return Dt(t,r);case Nn:return new o;case Ln:case Un:return new o(t);case Bn:return zr(t);case Dn:return new o;case kn:return Hr(t)}}var Vr=Xn;function Qn(t){return typeof t.constructor=="function"&&!X(t)?ve(nt(t)):{}}var Ut=Qn;var tf="[object Map]";function ef(t){return P(t)&<(t)==tf}var qr=ef;var Yr=R&&R.isMap,rf=Yr?tt(Yr):qr,Zr=rf;var of="[object Set]";function af(t){return P(t)&<(t)==of}var Jr=af;var Xr=R&&R.isSet,sf=Xr?tt(Xr):Jr,Qr=sf;var nf=1,ff=2,pf=4,to="[object Arguments]",lf="[object Array]",mf="[object Boolean]",uf="[object Date]",df="[object Error]",eo="[object Function]",cf="[object GeneratorFunction]",hf="[object Map]",gf="[object Number]",ro="[object Object]",xf="[object RegExp]",bf="[object Set]",yf="[object String]",vf="[object Symbol]",wf="[object WeakMap]",Tf="[object ArrayBuffer]",Of="[object DataView]",Pf="[object Float32Array]",Af="[object Float64Array]",jf="[object Int8Array]",Sf="[object Int16Array]",If="[object Int32Array]",_f="[object Uint8Array]",Ef="[object Uint8ClampedArray]",Ff="[object Uint16Array]",Cf="[object Uint32Array]",c={};c[to]=c[lf]=c[Tf]=c[Of]=c[mf]=c[uf]=c[Pf]=c[Af]=c[jf]=c[Sf]=c[If]=c[hf]=c[gf]=c[ro]=c[xf]=c[bf]=c[yf]=c[vf]=c[_f]=c[Ef]=c[Ff]=c[Cf]=!0;c[df]=c[eo]=c[wf]=!1;function kt(t,e,r,o,a,s){var n,i=e&nf,f=e&ff,u=e&pf;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!v(t))return t;var p=y(t);if(p){if(n=Gr(t),!i)return Pt(t,n)}else{var g=lt(t),O=g==eo||g==cf;if(Q(t))return Ft(t,i);if(g==ro||g==to||O&&!a){if(n=f||O?{}:Ut(t),!i)return f?Mr(t,Ar(n,t)):Cr(t,Pr(n,t))}else{if(!c[g])return a?t:{};n=Vr(t,g,i)}}s||(s=new Et);var w=s.get(t);if(w)return w;s.set(t,n),Qr(t)?t.forEach(function(T){n.add(kt(T,e,r,T,t,s))}):Zr(t)&&t.forEach(function(T,l){n.set(l,kt(T,e,r,l,t,s))});var x=u?f?Nr:Rr:f?_:et,E=p?void 0:x(t);return Ae(E||t,function(T,l){E&&(l=T,T=t[l]),Z(n,l,kt(T,e,r,l,t,s))}),n}var oo=kt;var Mf=1,Rf=4;function Nf(t){return oo(t,Mf|Rf)}var qt=Nf;function Lf(t,e){return t!=null&&e in Object(t)}var ao=Lf;function Bf(t,e,r){e=z(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=it(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&J(a)&&L(n,a)&&(y(t)||M(t)))}var io=Bf;function Df(t,e){return t!=null&&io(t,e,ao)}var so=Df;function Uf(t){return function(e,r,o){for(var a=-1,s=Object(e),n=o(e),i=n.length;i--;){var f=n[t?i:++a];if(r(s[f],f,s)===!1)break}return e}}var no=Uf;var kf=no(),fo=kf;function Gf(t,e,r){(r!==void 0&&!B(t[e],r)||r===void 0&&!(e in t))&&Y(t,e,r)}var xt=Gf;function Kf(t){return P(t)&&D(t)}var po=Kf;function zf(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var bt=zf;function Wf(t){return I(t,_(t))}var lo=Wf;function $f(t,e,r,o,a,s,n){var i=bt(t,r),f=bt(e,r),u=n.get(f);if(u){xt(t,r,u);return}var p=s?s(i,f,r+"",t,e,n):void 0,g=p===void 0;if(g){var O=y(f),w=!O&&Q(f),x=!O&&!w&&St(f);p=f,O||w||x?y(i)?p=i:po(i)?p=Pt(i):w?(g=!1,p=Ft(f,!0)):x?(g=!1,p=Dt(f,!0)):p=[]:br(f)||M(f)?(p=i,M(i)?p=lo(i):(!v(i)||V(i))&&(p=Ut(f))):g=!1}g&&(n.set(f,p),a(p,f,o,s,n),n.delete(f)),xt(t,r,p)}var mo=$f;function uo(t,e,r,o,a){t!==e&&fo(e,function(s,n){if(a||(a=new Et),v(s))mo(t,e,n,r,uo,o,a);else{var i=o?o(bt(t,n),s,n+"",t,e,a):void 0;i===void 0&&(i=s),xt(t,n,i)}},_)}var co=uo;var Hf=_e(function(t,e,r){co(t,e,r)}),Yt=Hf;function Vf(t,e,r,o){if(!v(t))return t;e=z(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=it(e[a]),u=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var p=i[f];u=o?o(p,f,i):void 0,u===void 0&&(u=v(p)?p:L(e[a+1])?[]:{})}Z(i,f,u),i=i[f]}return t}var ho=Vf;function qf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=lr(t,n);r(i,n)&&ho(s,z(n,t),i)}return s}var go=qf;function Yf(t,e){return go(t,e,function(r,o){return so(t,o)})}var xo=Yf;var Zf=gr(function(t,e){return t==null?{}:xo(t,e)}),Gt=Zf;function bo(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 yo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Zt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=yo[r[t]&63];return e};var Jf="array",Xf="bit",vo="bits",Qf="byte",wo="bytes",ut="",tp="exponent",ep="function",To="iec",rp="Invalid number",op="Invalid rounding method",Jt="jedec",ap="object",Oo=".",ip="round",sp="s",np="si",fp="kbit",pp="kB",lp=" ",mp="string",up="0",Xt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function Po(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=ut,localeOptions:n={},separator:i=ut,spacer:f=lp,symbols:u={},standard:p=ut,output:g=mp,fullform:O=!1,fullforms:w=[],exponent:x=-1,roundingMethod:E=ip,precision:T=0}={}){let l=x,d=Number(t),m=[],F=0,Kt=ut;p===np?(o=10,p=Jt):p===To||p===Jt?o=2:o===2?p=To:(o=10,p=Jt);let yt=o===10?1e3:1024,Ao=O===!0,te=d<0,ee=Math[E];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(rp);if(typeof ee!==ep)throw new TypeError(op);if(te&&(d=-d),(l===-1||isNaN(l))&&(l=Math.floor(Math.log(d)/Math.log(yt)),l<0&&(l=0)),l>8&&(T>0&&(T+=8-l),l=8),g===tp)return l;if(d===0)m[0]=0,Kt=m[1]=Xt.symbol[p][e?vo:wo][l];else{F=d/(o===2?Math.pow(2,l*10):Math.pow(1e3,l)),e&&(F=F*8,F>=yt&&l<8&&(F=F/yt,l++));let dt=Math.pow(10,l>0?a:0);m[0]=ee(F*dt)/dt,m[0]===yt&&l<8&&x===-1&&(m[0]=1,l++),Kt=m[1]=o===10&&l===1?e?fp:pp:Xt.symbol[p][e?vo:wo][l]}if(te&&(m[0]=-m[0]),T>0&&(m[0]=m[0].toPrecision(T)),m[1]=u[m[1]]||m[1],s===!0?m[0]=m[0].toLocaleString():s.length>0?m[0]=m[0].toLocaleString(s,n):i.length>0&&(m[0]=m[0].toString().replace(Oo,i)),r&&Number.isInteger(m[0])===!1&&a>0){let dt=i||Oo,re=m[0].toString().split(dt),oe=re[1]||ut,ae=oe.length,jo=a-ae;m[0]=`${re[0]}${dt}${oe.padEnd(ae+jo,up)}`}return Ao&&(m[1]=w[l]?w[l]:Xt.fullform[p][l]+(e?Xf:Qf)+(m[0]===1?ut:sp)),g===Jf?m:g===ap?{value:m[0],symbol:m[1],exponent:l,unit:Kt}:m.join(f)}var W=class t{_tera;id;name;icon;path;url;teraUrl;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;meta={};constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https:\/\/tera-tools.com\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=Po(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFile(this.id,e)}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Gt(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Gt(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var Qt=class{settings={devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child:{siteUrl:"https://dev.tera-tools.com/embed",restrictOrigin:"*"}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"https://tera-tools.com",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};events=bo();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","setServerVerbosity","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","getProjectFileContents","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiProgress","uiPrompt","uiTrhow","uiSplat","uiWindow"];plugins=[];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(),...qt(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=ie(r,e);return this.debug("INFO",3,"Created project patch",{patch:o,newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatch(e){if(this.settings.devMode&&this.settings.debugPaths){if(!Array.isArray(this.settings.debugPaths))throw new Error("teraFyClient.settings.debugPaths should be either null or an Array<String>");let r=e.filter(o=>this.settings.debugPaths.some(a=>o.path.join(".").slice(0,a.length)==a)).map(o=>o.path.join("."));if(r.length>0){console.info("Detected writes to",r,"- entering debugging mode");debugger}}return this.rpc("applyProjectStatePatch",e)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}constructor(e){e&&this.set(e)}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.debug("INFO",4,"[0/6] Init",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/6] Setting client mode to",o),Yt(this.settings,{mode:o,...this.settings.modeOverrides[o]})}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).catch(o=>this.debug("WARN",0,"Init process fault",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":this.debug("INFO",2,"Using TERA window parent");break;case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,n,i=setTimeout(()=>{clearTimeout(n),a("TIMEOUT")},r.handshakeTimeout),f=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(n),n=setTimeout(f,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(i),clearTimeout(n)}).then(()=>o()).catch(a)};f()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
1
|
+
function ie(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:f,basePath:u,basePathForRemoves:p,diffs:g}){var O=Object.keys(i),w=O.length,x=Object.keys(f),E=x.length,T,l=i.length-f.length;if(Io(i,f)){for(var d=0;d<w;d++){var m=Array.isArray(i)?Number(O[d]):O[d];m in f||(T=p.concat(m),g.remove.push({op:"remove",path:r(T)}))}for(var d=0;d<E;d++){var m=Array.isArray(f)?Number(x[d]):x[d];s({key:m,obj1:i,obj2:f,path:u.concat(m),pathForRemoves:u.concat(m),diffs:g})}}else{for(var d=0;d<l;d++)T=p.concat(d),g.remove.push({op:"remove",path:r(T)});for(var F=i.slice(l),d=0;d<E;d++)s({key:d,obj1:F,obj2:f,path:u.concat(d),pathForRemoves:u.concat(d+l),diffs:g})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function s({key:i,obj1:f,obj2:u,path:p,pathForRemoves:g,diffs:O}){var w=f[i],x=u[i];if(!(i in f)&&i in u){var E=x;O.add.push({op:"add",path:r(p),value:E})}else w!==x&&(Object(w)!==w||Object(x)!==x||So(w,x)||!Object.keys(w).length&&!Object.keys(x).length&&String(w)!=String(x)?n(p,O,x):o({obj1:f[i],obj2:u[i],basePath:p,basePathForRemoves:g,diffs:O}))}function n(i,f,u){f.replace.push({op:"replace",path:r(i),value:u})}}function So(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Io(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,s=0;s<e.length&&String(t[s])===String(e[s]);s++)o++;for(var n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)a++;return o>=a}return!0}var _o=typeof global=="object"&&global&&global.Object===Object&&global,vt=_o;var Eo=typeof self=="object"&&self&&self.Object===Object&&self,Fo=vt||Eo||Function("return this")(),b=Fo;var Co=b.Symbol,A=Co;var se=Object.prototype,Mo=se.hasOwnProperty,Ro=se.toString,ct=A?A.toStringTag:void 0;function No(t){var e=Mo.call(t,ct),r=t[ct];try{t[ct]=void 0;var o=!0}catch{}var a=Ro.call(t);return o&&(e?t[ct]=r:delete t[ct]),a}var ne=No;var Lo=Object.prototype,Bo=Lo.toString;function Do(t){return Bo.call(t)}var fe=Do;var Uo="[object Null]",ko="[object Undefined]",pe=A?A.toStringTag:void 0;function Go(t){return t==null?t===void 0?ko:Uo:pe&&pe in Object(t)?ne(t):fe(t)}var S=Go;function Ko(t){return t!=null&&typeof t=="object"}var P=Ko;var zo="[object Symbol]";function Wo(t){return typeof t=="symbol"||P(t)&&S(t)==zo}var H=Wo;function $o(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 le=$o;var Ho=Array.isArray,y=Ho;var Vo=1/0,me=A?A.prototype:void 0,ue=me?me.toString:void 0;function de(t){if(typeof t=="string")return t;if(y(t))return le(t,de)+"";if(H(t))return ue?ue.call(t):"";var e=t+"";return e=="0"&&1/t==-Vo?"-0":e}var ce=de;function qo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v=qo;function Yo(t){return t}var wt=Yo;var Zo="[object AsyncFunction]",Jo="[object Function]",Xo="[object GeneratorFunction]",Qo="[object Proxy]";function ta(t){if(!v(t))return!1;var e=S(t);return e==Jo||e==Xo||e==Zo||e==Qo}var V=ta;var ea=b["__core-js_shared__"],Tt=ea;var he=function(){var t=/[^.]+$/.exec(Tt&&Tt.keys&&Tt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function ra(t){return!!he&&he in t}var ge=ra;var oa=Function.prototype,aa=oa.toString;function ia(t){if(t!=null){try{return aa.call(t)}catch{}try{return t+""}catch{}}return""}var C=ia;var sa=/[\\^$.*+?()[\]{}|]/g,na=/^\[object .+?Constructor\]$/,fa=Function.prototype,pa=Object.prototype,la=fa.toString,ma=pa.hasOwnProperty,ua=RegExp("^"+la.call(ma).replace(sa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function da(t){if(!v(t)||ge(t))return!1;var e=V(t)?ua:na;return e.test(C(t))}var xe=da;function ca(t,e){return t?.[e]}var be=ca;function ha(t,e){var r=be(t,e);return xe(r)?r:void 0}var j=ha;var ga=j(b,"WeakMap"),Ot=ga;var ye=Object.create,xa=function(){function t(){}return function(e){if(!v(e))return{};if(ye)return ye(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),ve=xa;function ba(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 we=ba;function ya(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Pt=ya;var va=800,wa=16,Ta=Date.now;function Oa(t){var e=0,r=0;return function(){var o=Ta(),a=wa-(o-r);if(r=o,a>0){if(++e>=va)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Te=Oa;function Pa(t){return function(){return t}}var Oe=Pa;var Aa=function(){try{var t=j(Object,"defineProperty");return t({},"",{}),t}catch{}}(),q=Aa;var ja=q?function(t,e){return q(t,"toString",{configurable:!0,enumerable:!1,value:Oe(e),writable:!0})}:wt,Pe=ja;var Sa=Te(Pe),At=Sa;function Ia(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Ae=Ia;var _a=9007199254740991,Ea=/^(?:0|[1-9]\d*)$/;function Fa(t,e){var r=typeof t;return e=e??_a,!!e&&(r=="number"||r!="symbol"&&Ea.test(t))&&t>-1&&t%1==0&&t<e}var L=Fa;function Ca(t,e,r){e=="__proto__"&&q?q(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Y=Ca;function Ma(t,e){return t===e||t!==t&&e!==e}var B=Ma;var Ra=Object.prototype,Na=Ra.hasOwnProperty;function La(t,e,r){var o=t[e];(!(Na.call(t,e)&&B(o,r))||r===void 0&&!(e in t))&&Y(t,e,r)}var Z=La;function Ba(t,e,r,o){var a=!r;r||(r={});for(var s=-1,n=e.length;++s<n;){var i=e[s],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?Y(r,i,f):Z(r,i,f)}return r}var I=Ba;var je=Math.max;function Da(t,e,r){return e=je(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,s=je(o.length-e,0),n=Array(s);++a<s;)n[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(n),we(t,this,i)}}var jt=Da;function Ua(t,e){return At(jt(t,e,wt),t+"")}var Se=Ua;var ka=9007199254740991;function Ga(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ka}var J=Ga;function Ka(t){return t!=null&&J(t.length)&&!V(t)}var D=Ka;function za(t,e,r){if(!v(r))return!1;var o=typeof e;return(o=="number"?D(r)&&L(e,r.length):o=="string"&&e in r)?B(r[e],t):!1}var Ie=za;function Wa(t){return Se(function(e,r){var o=-1,a=r.length,s=a>1?r[a-1]:void 0,n=a>2?r[2]:void 0;for(s=t.length>3&&typeof s=="function"?(a--,s):void 0,n&&Ie(r[0],r[1],n)&&(s=a<3?void 0:s,a=1),e=Object(e);++o<a;){var i=r[o];i&&t(e,i,o,s)}return e})}var _e=Wa;var $a=Object.prototype;function Ha(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||$a;return t===r}var X=Ha;function Va(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Ee=Va;var qa="[object Arguments]";function Ya(t){return P(t)&&S(t)==qa}var zt=Ya;var Fe=Object.prototype,Za=Fe.hasOwnProperty,Ja=Fe.propertyIsEnumerable,Xa=zt(function(){return arguments}())?zt:function(t){return P(t)&&Za.call(t,"callee")&&!Ja.call(t,"callee")},M=Xa;function Qa(){return!1}var Ce=Qa;var Ne=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Me=Ne&&typeof module=="object"&&module&&!module.nodeType&&module,ti=Me&&Me.exports===Ne,Re=ti?b.Buffer:void 0,ei=Re?Re.isBuffer:void 0,ri=ei||Ce,Q=ri;var oi="[object Arguments]",ai="[object Array]",ii="[object Boolean]",si="[object Date]",ni="[object Error]",fi="[object Function]",pi="[object Map]",li="[object Number]",mi="[object Object]",ui="[object RegExp]",di="[object Set]",ci="[object String]",hi="[object WeakMap]",gi="[object ArrayBuffer]",xi="[object DataView]",bi="[object Float32Array]",yi="[object Float64Array]",vi="[object Int8Array]",wi="[object Int16Array]",Ti="[object Int32Array]",Oi="[object Uint8Array]",Pi="[object Uint8ClampedArray]",Ai="[object Uint16Array]",ji="[object Uint32Array]",h={};h[bi]=h[yi]=h[vi]=h[wi]=h[Ti]=h[Oi]=h[Pi]=h[Ai]=h[ji]=!0;h[oi]=h[ai]=h[gi]=h[ii]=h[xi]=h[si]=h[ni]=h[fi]=h[pi]=h[li]=h[mi]=h[ui]=h[di]=h[ci]=h[hi]=!1;function Si(t){return P(t)&&J(t.length)&&!!h[S(t)]}var Le=Si;function Ii(t){return function(e){return t(e)}}var tt=Ii;var Be=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ht=Be&&typeof module=="object"&&module&&!module.nodeType&&module,_i=ht&&ht.exports===Be,Wt=_i&&vt.process,Ei=function(){try{var t=ht&&ht.require&&ht.require("util").types;return t||Wt&&Wt.binding&&Wt.binding("util")}catch{}}(),R=Ei;var De=R&&R.isTypedArray,Fi=De?tt(De):Le,St=Fi;var Ci=Object.prototype,Mi=Ci.hasOwnProperty;function Ri(t,e){var r=y(t),o=!r&&M(t),a=!r&&!o&&Q(t),s=!r&&!o&&!a&&St(t),n=r||o||a||s,i=n?Ee(t.length,String):[],f=i.length;for(var u in t)(e||Mi.call(t,u))&&!(n&&(u=="length"||a&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||L(u,f)))&&i.push(u);return i}var It=Ri;function Ni(t,e){return function(r){return t(e(r))}}var _t=Ni;var Li=_t(Object.keys,Object),Ue=Li;var Bi=Object.prototype,Di=Bi.hasOwnProperty;function Ui(t){if(!X(t))return Ue(t);var e=[];for(var r in Object(t))Di.call(t,r)&&r!="constructor"&&e.push(r);return e}var ke=Ui;function ki(t){return D(t)?It(t):ke(t)}var et=ki;function Gi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ge=Gi;var Ki=Object.prototype,zi=Ki.hasOwnProperty;function Wi(t){if(!v(t))return Ge(t);var e=X(t),r=[];for(var o in t)o=="constructor"&&(e||!zi.call(t,o))||r.push(o);return r}var Ke=Wi;function $i(t){return D(t)?It(t,!0):Ke(t)}var _=$i;var Hi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Vi=/^\w*$/;function qi(t,e){if(y(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||H(t)?!0:Vi.test(t)||!Hi.test(t)||e!=null&&t in Object(e)}var ze=qi;var Yi=j(Object,"create"),N=Yi;function Zi(){this.__data__=N?N(null):{},this.size=0}var We=Zi;function Ji(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var $e=Ji;var Xi="__lodash_hash_undefined__",Qi=Object.prototype,ts=Qi.hasOwnProperty;function es(t){var e=this.__data__;if(N){var r=e[t];return r===Xi?void 0:r}return ts.call(e,t)?e[t]:void 0}var He=es;var rs=Object.prototype,os=rs.hasOwnProperty;function as(t){var e=this.__data__;return N?e[t]!==void 0:os.call(e,t)}var Ve=as;var is="__lodash_hash_undefined__";function ss(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=N&&e===void 0?is:e,this}var qe=ss;function rt(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])}}rt.prototype.clear=We;rt.prototype.delete=$e;rt.prototype.get=He;rt.prototype.has=Ve;rt.prototype.set=qe;var $t=rt;function ns(){this.__data__=[],this.size=0}var Ye=ns;function fs(t,e){for(var r=t.length;r--;)if(B(t[r][0],e))return r;return-1}var U=fs;var ps=Array.prototype,ls=ps.splice;function ms(t){var e=this.__data__,r=U(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():ls.call(e,r,1),--this.size,!0}var Ze=ms;function us(t){var e=this.__data__,r=U(e,t);return r<0?void 0:e[r][1]}var Je=us;function ds(t){return U(this.__data__,t)>-1}var Xe=ds;function cs(t,e){var r=this.__data__,o=U(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Qe=cs;function ot(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])}}ot.prototype.clear=Ye;ot.prototype.delete=Ze;ot.prototype.get=Je;ot.prototype.has=Xe;ot.prototype.set=Qe;var k=ot;var hs=j(b,"Map"),G=hs;function gs(){this.size=0,this.__data__={hash:new $t,map:new(G||k),string:new $t}}var tr=gs;function xs(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var er=xs;function bs(t,e){var r=t.__data__;return er(e)?r[typeof e=="string"?"string":"hash"]:r.map}var K=bs;function ys(t){var e=K(this,t).delete(t);return this.size-=e?1:0,e}var rr=ys;function vs(t){return K(this,t).get(t)}var or=vs;function ws(t){return K(this,t).has(t)}var ar=ws;function Ts(t,e){var r=K(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var ir=Ts;function at(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])}}at.prototype.clear=tr;at.prototype.delete=rr;at.prototype.get=or;at.prototype.has=ar;at.prototype.set=ir;var gt=at;var Os="Expected a function";function Ht(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Os);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=r.cache;if(s.has(a))return s.get(a);var n=t.apply(this,o);return r.cache=s.set(a,n)||s,n};return r.cache=new(Ht.Cache||gt),r}Ht.Cache=gt;var sr=Ht;var Ps=500;function As(t){var e=sr(t,function(o){return r.size===Ps&&r.clear(),o}),r=e.cache;return e}var nr=As;var js=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ss=/\\(\\)?/g,Is=nr(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(js,function(r,o,a,s){e.push(a?s.replace(Ss,"$1"):o||r)}),e}),fr=Is;function _s(t){return t==null?"":ce(t)}var pr=_s;function Es(t,e){return y(t)?t:ze(t,e)?[t]:fr(pr(t))}var z=Es;var Fs=1/0;function Cs(t){if(typeof t=="string"||H(t))return t;var e=t+"";return e=="0"&&1/t==-Fs?"-0":e}var it=Cs;function Ms(t,e){e=z(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[it(e[r++])];return r&&r==o?t:void 0}var lr=Ms;function Rs(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var st=Rs;var mr=A?A.isConcatSpreadable:void 0;function Ns(t){return y(t)||M(t)||!!(mr&&t&&t[mr])}var ur=Ns;function dr(t,e,r,o,a){var s=-1,n=t.length;for(r||(r=ur),a||(a=[]);++s<n;){var i=t[s];e>0&&r(i)?e>1?dr(i,e-1,r,o,a):st(a,i):o||(a[a.length]=i)}return a}var cr=dr;function Ls(t){var e=t==null?0:t.length;return e?cr(t,1):[]}var hr=Ls;function Bs(t){return At(jt(t,void 0,hr),t+"")}var gr=Bs;var Ds=_t(Object.getPrototypeOf,Object),nt=Ds;var Us="[object Object]",ks=Function.prototype,Gs=Object.prototype,xr=ks.toString,Ks=Gs.hasOwnProperty,zs=xr.call(Object);function Ws(t){if(!P(t)||S(t)!=Us)return!1;var e=nt(t);if(e===null)return!0;var r=Ks.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&xr.call(r)==zs}var br=Ws;function $s(){this.__data__=new k,this.size=0}var yr=$s;function Hs(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var vr=Hs;function Vs(t){return this.__data__.get(t)}var wr=Vs;function qs(t){return this.__data__.has(t)}var Tr=qs;var Ys=200;function Zs(t,e){var r=this.__data__;if(r instanceof k){var o=r.__data__;if(!G||o.length<Ys-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new gt(o)}return r.set(t,e),this.size=r.size,this}var Or=Zs;function ft(t){var e=this.__data__=new k(t);this.size=e.size}ft.prototype.clear=yr;ft.prototype.delete=vr;ft.prototype.get=wr;ft.prototype.has=Tr;ft.prototype.set=Or;var Et=ft;function Js(t,e){return t&&I(e,et(e),t)}var Pr=Js;function Xs(t,e){return t&&I(e,_(e),t)}var Ar=Xs;var _r=typeof exports=="object"&&exports&&!exports.nodeType&&exports,jr=_r&&typeof module=="object"&&module&&!module.nodeType&&module,Qs=jr&&jr.exports===_r,Sr=Qs?b.Buffer:void 0,Ir=Sr?Sr.allocUnsafe:void 0;function tn(t,e){if(e)return t.slice();var r=t.length,o=Ir?Ir(r):new t.constructor(r);return t.copy(o),o}var Ft=tn;function en(t,e){for(var r=-1,o=t==null?0:t.length,a=0,s=[];++r<o;){var n=t[r];e(n,r,t)&&(s[a++]=n)}return s}var Er=en;function rn(){return[]}var Ct=rn;var on=Object.prototype,an=on.propertyIsEnumerable,Fr=Object.getOwnPropertySymbols,sn=Fr?function(t){return t==null?[]:(t=Object(t),Er(Fr(t),function(e){return an.call(t,e)}))}:Ct,pt=sn;function nn(t,e){return I(t,pt(t),e)}var Cr=nn;var fn=Object.getOwnPropertySymbols,pn=fn?function(t){for(var e=[];t;)st(e,pt(t)),t=nt(t);return e}:Ct,Mt=pn;function ln(t,e){return I(t,Mt(t),e)}var Mr=ln;function mn(t,e,r){var o=e(t);return y(t)?o:st(o,r(t))}var Rt=mn;function un(t){return Rt(t,et,pt)}var Rr=un;function dn(t){return Rt(t,_,Mt)}var Nr=dn;var cn=j(b,"DataView"),Nt=cn;var hn=j(b,"Promise"),Lt=hn;var gn=j(b,"Set"),Bt=gn;var Lr="[object Map]",xn="[object Object]",Br="[object Promise]",Dr="[object Set]",Ur="[object WeakMap]",kr="[object DataView]",bn=C(Nt),yn=C(G),vn=C(Lt),wn=C(Bt),Tn=C(Ot),$=S;(Nt&&$(new Nt(new ArrayBuffer(1)))!=kr||G&&$(new G)!=Lr||Lt&&$(Lt.resolve())!=Br||Bt&&$(new Bt)!=Dr||Ot&&$(new Ot)!=Ur)&&($=function(t){var e=S(t),r=e==xn?t.constructor:void 0,o=r?C(r):"";if(o)switch(o){case bn:return kr;case yn:return Lr;case vn:return Br;case wn:return Dr;case Tn:return Ur}return e});var lt=$;var On=Object.prototype,Pn=On.hasOwnProperty;function An(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Pn.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Gr=An;var jn=b.Uint8Array,Vt=jn;function Sn(t){var e=new t.constructor(t.byteLength);return new Vt(e).set(new Vt(t)),e}var mt=Sn;function In(t,e){var r=e?mt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Kr=In;var _n=/\w*$/;function En(t){var e=new t.constructor(t.source,_n.exec(t));return e.lastIndex=t.lastIndex,e}var zr=En;var Wr=A?A.prototype:void 0,$r=Wr?Wr.valueOf:void 0;function Fn(t){return $r?Object($r.call(t)):{}}var Hr=Fn;function Cn(t,e){var r=e?mt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Dt=Cn;var Mn="[object Boolean]",Rn="[object Date]",Nn="[object Map]",Ln="[object Number]",Bn="[object RegExp]",Dn="[object Set]",Un="[object String]",kn="[object Symbol]",Gn="[object ArrayBuffer]",Kn="[object DataView]",zn="[object Float32Array]",Wn="[object Float64Array]",$n="[object Int8Array]",Hn="[object Int16Array]",Vn="[object Int32Array]",qn="[object Uint8Array]",Yn="[object Uint8ClampedArray]",Zn="[object Uint16Array]",Jn="[object Uint32Array]";function Xn(t,e,r){var o=t.constructor;switch(e){case Gn:return mt(t);case Mn:case Rn:return new o(+t);case Kn:return Kr(t,r);case zn:case Wn:case $n:case Hn:case Vn:case qn:case Yn:case Zn:case Jn:return Dt(t,r);case Nn:return new o;case Ln:case Un:return new o(t);case Bn:return zr(t);case Dn:return new o;case kn:return Hr(t)}}var Vr=Xn;function Qn(t){return typeof t.constructor=="function"&&!X(t)?ve(nt(t)):{}}var Ut=Qn;var tf="[object Map]";function ef(t){return P(t)&<(t)==tf}var qr=ef;var Yr=R&&R.isMap,rf=Yr?tt(Yr):qr,Zr=rf;var of="[object Set]";function af(t){return P(t)&<(t)==of}var Jr=af;var Xr=R&&R.isSet,sf=Xr?tt(Xr):Jr,Qr=sf;var nf=1,ff=2,pf=4,to="[object Arguments]",lf="[object Array]",mf="[object Boolean]",uf="[object Date]",df="[object Error]",eo="[object Function]",cf="[object GeneratorFunction]",hf="[object Map]",gf="[object Number]",ro="[object Object]",xf="[object RegExp]",bf="[object Set]",yf="[object String]",vf="[object Symbol]",wf="[object WeakMap]",Tf="[object ArrayBuffer]",Of="[object DataView]",Pf="[object Float32Array]",Af="[object Float64Array]",jf="[object Int8Array]",Sf="[object Int16Array]",If="[object Int32Array]",_f="[object Uint8Array]",Ef="[object Uint8ClampedArray]",Ff="[object Uint16Array]",Cf="[object Uint32Array]",c={};c[to]=c[lf]=c[Tf]=c[Of]=c[mf]=c[uf]=c[Pf]=c[Af]=c[jf]=c[Sf]=c[If]=c[hf]=c[gf]=c[ro]=c[xf]=c[bf]=c[yf]=c[vf]=c[_f]=c[Ef]=c[Ff]=c[Cf]=!0;c[df]=c[eo]=c[wf]=!1;function kt(t,e,r,o,a,s){var n,i=e&nf,f=e&ff,u=e&pf;if(r&&(n=a?r(t,o,a,s):r(t)),n!==void 0)return n;if(!v(t))return t;var p=y(t);if(p){if(n=Gr(t),!i)return Pt(t,n)}else{var g=lt(t),O=g==eo||g==cf;if(Q(t))return Ft(t,i);if(g==ro||g==to||O&&!a){if(n=f||O?{}:Ut(t),!i)return f?Mr(t,Ar(n,t)):Cr(t,Pr(n,t))}else{if(!c[g])return a?t:{};n=Vr(t,g,i)}}s||(s=new Et);var w=s.get(t);if(w)return w;s.set(t,n),Qr(t)?t.forEach(function(T){n.add(kt(T,e,r,T,t,s))}):Zr(t)&&t.forEach(function(T,l){n.set(l,kt(T,e,r,l,t,s))});var x=u?f?Nr:Rr:f?_:et,E=p?void 0:x(t);return Ae(E||t,function(T,l){E&&(l=T,T=t[l]),Z(n,l,kt(T,e,r,l,t,s))}),n}var oo=kt;var Mf=1,Rf=4;function Nf(t){return oo(t,Mf|Rf)}var qt=Nf;function Lf(t,e){return t!=null&&e in Object(t)}var ao=Lf;function Bf(t,e,r){e=z(e,t);for(var o=-1,a=e.length,s=!1;++o<a;){var n=it(e[o]);if(!(s=t!=null&&r(t,n)))break;t=t[n]}return s||++o!=a?s:(a=t==null?0:t.length,!!a&&J(a)&&L(n,a)&&(y(t)||M(t)))}var io=Bf;function Df(t,e){return t!=null&&io(t,e,ao)}var so=Df;function Uf(t){return function(e,r,o){for(var a=-1,s=Object(e),n=o(e),i=n.length;i--;){var f=n[t?i:++a];if(r(s[f],f,s)===!1)break}return e}}var no=Uf;var kf=no(),fo=kf;function Gf(t,e,r){(r!==void 0&&!B(t[e],r)||r===void 0&&!(e in t))&&Y(t,e,r)}var xt=Gf;function Kf(t){return P(t)&&D(t)}var po=Kf;function zf(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var bt=zf;function Wf(t){return I(t,_(t))}var lo=Wf;function $f(t,e,r,o,a,s,n){var i=bt(t,r),f=bt(e,r),u=n.get(f);if(u){xt(t,r,u);return}var p=s?s(i,f,r+"",t,e,n):void 0,g=p===void 0;if(g){var O=y(f),w=!O&&Q(f),x=!O&&!w&&St(f);p=f,O||w||x?y(i)?p=i:po(i)?p=Pt(i):w?(g=!1,p=Ft(f,!0)):x?(g=!1,p=Dt(f,!0)):p=[]:br(f)||M(f)?(p=i,M(i)?p=lo(i):(!v(i)||V(i))&&(p=Ut(f))):g=!1}g&&(n.set(f,p),a(p,f,o,s,n),n.delete(f)),xt(t,r,p)}var mo=$f;function uo(t,e,r,o,a){t!==e&&fo(e,function(s,n){if(a||(a=new Et),v(s))mo(t,e,n,r,uo,o,a);else{var i=o?o(bt(t,n),s,n+"",t,e,a):void 0;i===void 0&&(i=s),xt(t,n,i)}},_)}var co=uo;var Hf=_e(function(t,e,r){co(t,e,r)}),Yt=Hf;function Vf(t,e,r,o){if(!v(t))return t;e=z(e,t);for(var a=-1,s=e.length,n=s-1,i=t;i!=null&&++a<s;){var f=it(e[a]),u=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=n){var p=i[f];u=o?o(p,f,i):void 0,u===void 0&&(u=v(p)?p:L(e[a+1])?[]:{})}Z(i,f,u),i=i[f]}return t}var ho=Vf;function qf(t,e,r){for(var o=-1,a=e.length,s={};++o<a;){var n=e[o],i=lr(t,n);r(i,n)&&ho(s,z(n,t),i)}return s}var go=qf;function Yf(t,e){return go(t,e,function(r,o){return so(t,o)})}var xo=Yf;var Zf=gr(function(t,e){return t==null?{}:xo(t,e)}),Gt=Zf;function bo(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 yo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Zt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=yo[r[t]&63];return e};var Jf="array",Xf="bit",vo="bits",Qf="byte",wo="bytes",ut="",tp="exponent",ep="function",To="iec",rp="Invalid number",op="Invalid rounding method",Jt="jedec",ap="object",Oo=".",ip="round",sp="s",np="si",fp="kbit",pp="kB",lp=" ",mp="string",up="0",Xt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function Po(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:s=ut,localeOptions:n={},separator:i=ut,spacer:f=lp,symbols:u={},standard:p=ut,output:g=mp,fullform:O=!1,fullforms:w=[],exponent:x=-1,roundingMethod:E=ip,precision:T=0}={}){let l=x,d=Number(t),m=[],F=0,Kt=ut;p===np?(o=10,p=Jt):p===To||p===Jt?o=2:o===2?p=To:(o=10,p=Jt);let yt=o===10?1e3:1024,Ao=O===!0,te=d<0,ee=Math[E];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(rp);if(typeof ee!==ep)throw new TypeError(op);if(te&&(d=-d),(l===-1||isNaN(l))&&(l=Math.floor(Math.log(d)/Math.log(yt)),l<0&&(l=0)),l>8&&(T>0&&(T+=8-l),l=8),g===tp)return l;if(d===0)m[0]=0,Kt=m[1]=Xt.symbol[p][e?vo:wo][l];else{F=d/(o===2?Math.pow(2,l*10):Math.pow(1e3,l)),e&&(F=F*8,F>=yt&&l<8&&(F=F/yt,l++));let dt=Math.pow(10,l>0?a:0);m[0]=ee(F*dt)/dt,m[0]===yt&&l<8&&x===-1&&(m[0]=1,l++),Kt=m[1]=o===10&&l===1?e?fp:pp:Xt.symbol[p][e?vo:wo][l]}if(te&&(m[0]=-m[0]),T>0&&(m[0]=m[0].toPrecision(T)),m[1]=u[m[1]]||m[1],s===!0?m[0]=m[0].toLocaleString():s.length>0?m[0]=m[0].toLocaleString(s,n):i.length>0&&(m[0]=m[0].toString().replace(Oo,i)),r&&Number.isInteger(m[0])===!1&&a>0){let dt=i||Oo,re=m[0].toString().split(dt),oe=re[1]||ut,ae=oe.length,jo=a-ae;m[0]=`${re[0]}${dt}${oe.padEnd(ae+jo,up)}`}return Ao&&(m[1]=w[l]?w[l]:Xt.fullform[p][l]+(e?Xf:Qf)+(m[0]===1?ut:sp)),g===Jf?m:g===ap?{value:m[0],symbol:m[1],exponent:l,unit:Kt}:m.join(f)}var W=class t{_tera;id;name;icon;path;url;teraUrl;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;meta={};constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=Po(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFile(this.id,e)}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Gt(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Gt(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var Qt=class{settings={devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child:{siteUrl:"https://dev.tera-tools.com/embed",restrictOrigin:"*"}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"https://tera-tools.com",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null};events=bo();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","setServerVerbosity","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","getProjectFileContents","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiProgress","uiPrompt","uiTrhow","uiSplat","uiWindow"];plugins=[];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(),...qt(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=ie(r,e);return this.debug("INFO",3,"Created project patch",{patch:o,newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatch(e){if(this.settings.devMode&&this.settings.debugPaths){if(!Array.isArray(this.settings.debugPaths))throw new Error("teraFyClient.settings.debugPaths should be either null or an Array<String>");let r=e.filter(o=>this.settings.debugPaths.some(a=>o.path.join(".").slice(0,a.length)==a)).map(o=>o.path.join("."));if(r.length>0){console.info("Detected writes to",r,"- entering debugging mode");debugger}}return this.rpc("applyProjectStatePatch",e)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}constructor(e){e&&this.set(e)}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.debug("INFO",4,"[0/6] Init",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/6] Setting client mode to",o),Yt(this.settings,{mode:o,...this.settings.modeOverrides[o]})}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).catch(o=>this.debug("WARN",0,"Init process fault",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":this.debug("INFO",2,"Using TERA window parent");break;case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let s=0,n,i=setTimeout(()=>{clearTimeout(n),a("TIMEOUT")},r.handshakeTimeout),f=()=>{this.debug("INFO",4,"Trying handshake",++s),clearTimeout(n),n=setTimeout(f,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(i),clearTimeout(n)}).then(()=>o()).catch(a)};f()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
2
2
|
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){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 e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.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 W({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new W({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new W({tera:this,...r}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new W({tera:this,...r}))}};export{Qt as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
package/lib/projectFile.js
CHANGED
|
@@ -164,7 +164,7 @@ export default class ProjectFile {
|
|
|
164
164
|
delete this.tera; // Remove original ref we merged above
|
|
165
165
|
|
|
166
166
|
// Calculate `teraUrl` from URL
|
|
167
|
-
this.teraUrl = this.url.replace(/^https
|
|
167
|
+
this.teraUrl = this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/, '/project/$1');
|
|
168
168
|
|
|
169
169
|
// Set all `*Formatted` fields
|
|
170
170
|
this.sizeFormatted = filesize(this.size || 0, {spacer: ''});
|
|
@@ -179,7 +179,7 @@ export default class ProjectFile {
|
|
|
179
179
|
*
|
|
180
180
|
* @param {Object} [options] Additioanl options to mutate behaviour
|
|
181
181
|
*
|
|
182
|
-
* returns {Blob} The eventual raw file contents as a Blob
|
|
182
|
+
* @returns {Blob} The eventual raw file contents as a Blob
|
|
183
183
|
*
|
|
184
184
|
* @see getProjectFile()
|
|
185
185
|
*/
|
|
@@ -217,7 +217,7 @@ export default class ProjectFile {
|
|
|
217
217
|
/**
|
|
218
218
|
* Overwrite the contents of a file with a new collection of Reflib refs
|
|
219
219
|
*
|
|
220
|
-
* @param {Array<RefLibRef>} Collection of references for the selected library
|
|
220
|
+
* @param {Array<RefLibRef>} refs Collection of references for the selected library
|
|
221
221
|
*
|
|
222
222
|
* @returns {Promise} A promise which resolves when the operation has completed
|
|
223
223
|
*
|
package/lib/terafy.client.js
CHANGED
|
@@ -222,7 +222,7 @@ export default class TeraFy {
|
|
|
222
222
|
* Call an RPC function in the server instance
|
|
223
223
|
*
|
|
224
224
|
* @param {String} method The method name to call
|
|
225
|
-
* @param {
|
|
225
|
+
* @param {...*} [args] Optional arguments to pass to the function
|
|
226
226
|
*
|
|
227
227
|
* @returns {Promise<*>} The resolved output of the server function
|
|
228
228
|
*/
|
|
@@ -238,7 +238,9 @@ export default class TeraFy {
|
|
|
238
238
|
/**
|
|
239
239
|
* Accept an incoming message
|
|
240
240
|
*
|
|
241
|
-
* @param {MessageEvent} Raw message event to process
|
|
241
|
+
* @param {MessageEvent} rawMessage Raw message event to process
|
|
242
|
+
*
|
|
243
|
+
* @returns {Promise} A promise which will resolve when the message has been processed
|
|
242
244
|
*/
|
|
243
245
|
acceptMessage(rawMessage) {
|
|
244
246
|
if (rawMessage.origin == window.location.origin) return; // Message came from us
|
|
@@ -322,7 +324,7 @@ export default class TeraFy {
|
|
|
322
324
|
|
|
323
325
|
if (watchedPaths.length > 0) {
|
|
324
326
|
console.info('Detected writes to', watchedPaths, '- entering debugging mode');
|
|
325
|
-
debugger;
|
|
327
|
+
debugger; // eslint-disable-line no-debugger
|
|
326
328
|
}
|
|
327
329
|
}
|
|
328
330
|
|
|
@@ -698,13 +700,14 @@ export default class TeraFy {
|
|
|
698
700
|
|
|
699
701
|
// Utility - debug(), use(), mixin(), toggleDevMode(), toggleFocus() {{{
|
|
700
702
|
|
|
703
|
+
/* eslint-disable jsdoc/check-param-names */
|
|
701
704
|
/**
|
|
702
705
|
* Debugging output function
|
|
703
706
|
* This function will only act if `settings.devMode` is truthy
|
|
704
707
|
*
|
|
705
708
|
* @param {'INFO'|'LOG'|'WARN'|'ERROR'} [method='LOG'] Logging method to use
|
|
706
709
|
* @param {Number} [verboseLevel=1] The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored
|
|
707
|
-
* @param {
|
|
710
|
+
* @param {...*} [msg] Output to show
|
|
708
711
|
*/
|
|
709
712
|
debug(...msg) {
|
|
710
713
|
if (!this.settings.devMode || this.settings.verbosity < 1) return; // Debugging is disabled
|
|
@@ -729,6 +732,7 @@ export default class TeraFy {
|
|
|
729
732
|
...msg,
|
|
730
733
|
);
|
|
731
734
|
}
|
|
735
|
+
/* eslint-enable */
|
|
732
736
|
|
|
733
737
|
|
|
734
738
|
/**
|
|
@@ -779,7 +783,7 @@ export default class TeraFy {
|
|
|
779
783
|
/**
|
|
780
784
|
* Include a TeraFy client plugin
|
|
781
785
|
*
|
|
782
|
-
* @param {Object} The module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
|
|
786
|
+
* @param {Object} mod The module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
|
|
783
787
|
* @param {Object} [options] Additional options to mutate behaviour during construction (pass options to init() to intialize later options)
|
|
784
788
|
*
|
|
785
789
|
* @returns {TeraFy} This chainable terafy instance
|
|
@@ -1157,7 +1161,7 @@ export default class TeraFy {
|
|
|
1157
1161
|
/**
|
|
1158
1162
|
* Fetch a project file by its name
|
|
1159
1163
|
*
|
|
1160
|
-
* @param {String}
|
|
1164
|
+
* @param {String} id The name + relative directory path component
|
|
1161
1165
|
*
|
|
1162
1166
|
* @param {Object|String} [options] Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
|
|
1163
1167
|
* @param {String} [options.subkey] If specified only the extracted subkey is returned rather than the full object
|
|
@@ -1229,7 +1233,7 @@ export default class TeraFy {
|
|
|
1229
1233
|
* @param {Boolean} [options.allowCancel=true] Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed
|
|
1230
1234
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
1231
1235
|
* @param {FileFilters} [options.filters] Optional file filters, defaults to citation library selection only
|
|
1232
|
-
* @param {
|
|
1236
|
+
* @param {...*} [options] Additional options - see `getProjectLibrary()`
|
|
1233
1237
|
*
|
|
1234
1238
|
* @returns {Promise<Array<Ref>>} A collection of references from the selected file
|
|
1235
1239
|
*/
|
|
@@ -1290,7 +1294,7 @@ export default class TeraFy {
|
|
|
1290
1294
|
*
|
|
1291
1295
|
* @function setPage
|
|
1292
1296
|
* @param {Object|String} options Context information about the page, if this is a string, its assumed to popupate `url`
|
|
1293
|
-
* @param {String} [options.
|
|
1297
|
+
* @param {String} [options.path] The URL path segment to restore on next refresh
|
|
1294
1298
|
* @param {String} [options.title] The page title associated with the path
|
|
1295
1299
|
*/
|
|
1296
1300
|
|
package/lib/terafy.proxy.js
CHANGED
|
@@ -109,6 +109,9 @@ export class TeraProxy {
|
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Utility function to return a new TeraProxy instance
|
|
112
|
+
*
|
|
113
|
+
* @param {Object} [options] Options to pass to the Proxy module
|
|
114
|
+
* @returns {TeraProxy} A TeraProxy instance
|
|
112
115
|
*/
|
|
113
116
|
export default function(options) {
|
|
114
117
|
return new TeraProxy(options);
|
package/lib/terafy.server.js
CHANGED
|
@@ -152,7 +152,7 @@ export default class TeraFyServer {
|
|
|
152
152
|
* This function only works if the context was sub-classed via `createContext()`
|
|
153
153
|
*
|
|
154
154
|
* @param {String} method The method name to call
|
|
155
|
-
* @param {
|
|
155
|
+
* @param {...*} [args] Optional arguments to pass to the function
|
|
156
156
|
*
|
|
157
157
|
* @returns {Promise<*>} The resolved output of the server function
|
|
158
158
|
*/
|
|
@@ -213,7 +213,7 @@ export default class TeraFyServer {
|
|
|
213
213
|
* Unlike send() this method does not expect any response
|
|
214
214
|
*
|
|
215
215
|
* @param {Object} message Message object to send
|
|
216
|
-
* @param {Window} Window context to dispatch the message via if its not the same as the regular window
|
|
216
|
+
* @param {Window} sendVia Window context to dispatch the message via if its not the same as the regular window
|
|
217
217
|
*/
|
|
218
218
|
sendRaw(message, sendVia) {
|
|
219
219
|
let payload;
|
|
@@ -256,7 +256,7 @@ export default class TeraFyServer {
|
|
|
256
256
|
/**
|
|
257
257
|
* Accept a message from the parent event listener
|
|
258
258
|
*
|
|
259
|
-
* @param {MessageEvent} Raw message event to process
|
|
259
|
+
* @param {MessageEvent} rawMessage Raw message event to process
|
|
260
260
|
*/
|
|
261
261
|
acceptMessage(rawMessage) {
|
|
262
262
|
if (rawMessage.origin == window.location.origin) return; // Message came from us
|
|
@@ -326,7 +326,7 @@ export default class TeraFyServer {
|
|
|
326
326
|
* Note that emitted messages have no response - they are sent to clients only with no return value
|
|
327
327
|
*
|
|
328
328
|
* @param {String} event The event name to emit
|
|
329
|
-
* @param {
|
|
329
|
+
* @param {...*} [args] Optional event payload to send
|
|
330
330
|
* @returns {Promise} A promise which resolves when the transmission has completed
|
|
331
331
|
*/
|
|
332
332
|
emitClients(event, ...args) {
|
|
@@ -709,7 +709,7 @@ export default class TeraFyServer {
|
|
|
709
709
|
*
|
|
710
710
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
711
711
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
712
|
-
* @param {Array<String>} Paths to subscribe to e.g. ['/users/'],
|
|
712
|
+
* @param {Array<String>} [options.paths] Paths to subscribe to e.g. ['/users/'],
|
|
713
713
|
*
|
|
714
714
|
* @returns {Promise<Object>} The current project state snapshot
|
|
715
715
|
*/
|
|
@@ -877,7 +877,7 @@ export default class TeraFyServer {
|
|
|
877
877
|
/**
|
|
878
878
|
* Apply a computed `just-diff` patch to the current project state
|
|
879
879
|
*
|
|
880
|
-
* @param {Object} Patch to apply
|
|
880
|
+
* @param {Object} patch Patch to apply
|
|
881
881
|
* @returns {Promise} A promise which resolves when the operation has completed
|
|
882
882
|
*/
|
|
883
883
|
applyProjectStatePatch(patch) {
|
|
@@ -1056,6 +1056,7 @@ export default class TeraFyServer {
|
|
|
1056
1056
|
* Fetch the raw contents of a file by its ID
|
|
1057
1057
|
*
|
|
1058
1058
|
* @param {String} [id] File ID to retrieve the contents of
|
|
1059
|
+
*
|
|
1059
1060
|
* @param {Object} [options] Additioanl options to mutate behaviour
|
|
1060
1061
|
* @param {'blob'|'json'} [options.format='blob'] The format to retrieve the file in. If `json` the raw output is run via JSON.parse() first
|
|
1061
1062
|
*
|
|
@@ -1180,7 +1181,7 @@ export default class TeraFyServer {
|
|
|
1180
1181
|
/**
|
|
1181
1182
|
* Prompt the user to select a library to operate on and return a array of references in a given format
|
|
1182
1183
|
*
|
|
1183
|
-
* @param {Object} [options] Additional options to mutate behaviour
|
|
1184
|
+
* @param {Object} [options] Additional options to mutate behaviour - see `getProjectLibrary()` for parent list of options
|
|
1184
1185
|
* @param {String} [options.title="Select a citation library"] The title of the dialog to display
|
|
1185
1186
|
* @param {String|Array<String>} [options.hint] Hints to identify the library to select in array order of preference. Generally corresponds to the previous stage - e.g. 'deduped', 'review1', 'review2', 'dedisputed'
|
|
1186
1187
|
* @param {Boolean} [options.allowUpload=true] Allow uploading new files
|
|
@@ -1189,7 +1190,6 @@ export default class TeraFyServer {
|
|
|
1189
1190
|
* @param {Boolean} [options.allowCancel=true] Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed
|
|
1190
1191
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
1191
1192
|
* @param {FileFilters} [options.filters] Optional file filters, defaults to citation library selection only
|
|
1192
|
-
* @param {*} [options.*] Additional options - see `getProjectLibrary()`
|
|
1193
1193
|
*
|
|
1194
1194
|
* @returns {Promise<Array<Ref>>} A collection of references from the selected file
|
|
1195
1195
|
*/
|
|
@@ -1386,7 +1386,7 @@ export default class TeraFyServer {
|
|
|
1386
1386
|
* This only really makes a difference to tools within the tera-tools.com site where the tool is working as an embed
|
|
1387
1387
|
*
|
|
1388
1388
|
* @param {Object|String} options Context information about the page, if this is a string, its assumed to popupate `url`
|
|
1389
|
-
* @param {String} [options.
|
|
1389
|
+
* @param {String} [options.path] The URL path segment to restore on next refresh
|
|
1390
1390
|
* @param {String} [options.title] The page title associated with the path
|
|
1391
1391
|
*/
|
|
1392
1392
|
setPage(options) {
|
|
@@ -1718,13 +1718,14 @@ export default class TeraFyServer {
|
|
|
1718
1718
|
|
|
1719
1719
|
// Utility - debug() {{{
|
|
1720
1720
|
|
|
1721
|
+
/* eslint-disable jsdoc/check-param-names */
|
|
1721
1722
|
/**
|
|
1722
1723
|
* Debugging output function
|
|
1723
1724
|
* This function will only act if `settings.devMode` is truthy
|
|
1724
1725
|
*
|
|
1725
1726
|
* @param {'INFO'|'LOG'|'WARN'|'ERROR'} [method='LOG'] Logging method to use
|
|
1726
1727
|
* @param {Number} [verboseLevel=1] The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored
|
|
1727
|
-
* @param {
|
|
1728
|
+
* @param {...*} [msg] Output to show
|
|
1728
1729
|
*/
|
|
1729
1730
|
debug(...msg) {
|
|
1730
1731
|
if (!this.settings.devMode || this.settings.verbosity < 1) return; // Debugging is disabled
|
|
@@ -1749,5 +1750,6 @@ export default class TeraFyServer {
|
|
|
1749
1750
|
...msg,
|
|
1750
1751
|
);
|
|
1751
1752
|
}
|
|
1753
|
+
/* eslint-enable */
|
|
1752
1754
|
// }}}
|
|
1753
1755
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iebh/tera-fy",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.4",
|
|
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=.",
|
|
@@ -76,15 +76,15 @@
|
|
|
76
76
|
"lodash-es": "^4.17.21",
|
|
77
77
|
"mitt": "^3.0.1",
|
|
78
78
|
"nanoid": "^5.0.7",
|
|
79
|
-
"release-it": "^17.
|
|
79
|
+
"release-it": "^17.6.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@momsfriendlydevco/eslint-config": "^2.0.
|
|
82
|
+
"@momsfriendlydevco/eslint-config": "^2.0.3",
|
|
83
83
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
84
84
|
"concurrently": "^8.2.2",
|
|
85
85
|
"documentation": "^14.0.3",
|
|
86
86
|
"esbuild": "^0.23.0",
|
|
87
|
-
"eslint": "^9.
|
|
87
|
+
"eslint": "^9.7.0"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"vue": "^3.0.0"
|
package/plugins/vite.js
CHANGED
package/plugins/vue3.js
CHANGED
|
@@ -118,6 +118,8 @@ export default class TeraFyPluginVue extends TeraFyPluginBase {
|
|
|
118
118
|
* Utility function which returns an awaitable promise when the state is loading or being refreshed
|
|
119
119
|
* This is used in place of `statePromisable` as it has a slightly more logical syntax as a function
|
|
120
120
|
*
|
|
121
|
+
* @returns {Promise} A promise representing the loading of the project state
|
|
122
|
+
*
|
|
121
123
|
* @example Await the state loading
|
|
122
124
|
* await $tera.statePromise();
|
|
123
125
|
*/
|
|
@@ -128,6 +130,8 @@ export default class TeraFyPluginVue extends TeraFyPluginBase {
|
|
|
128
130
|
|
|
129
131
|
/**
|
|
130
132
|
* Provide a Vue@3 compatible plugin
|
|
133
|
+
*
|
|
134
|
+
* @returns {VuePlugin} A Vue@3 plugin spec
|
|
131
135
|
*/
|
|
132
136
|
vuePlugin() {
|
|
133
137
|
let $tera = this;
|
|
@@ -137,12 +141,12 @@ export default class TeraFyPluginVue extends TeraFyPluginBase {
|
|
|
137
141
|
/**
|
|
138
142
|
* Install into Vue as a generic Vue@3 plugin
|
|
139
143
|
*
|
|
144
|
+
* @param {VueApp} app The Vue top-level app to install against
|
|
145
|
+
*
|
|
140
146
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
141
147
|
* @param {Boolean} [options.autoInit=true] Call Init() during the `statePromiseable` cycle if its not already been called
|
|
142
148
|
* @param {String} [options.globalName='$tera'] Globa property to allocate this service as
|
|
143
149
|
* @param {Objecct} [options.bindOptions] Options passed to `bindProjectState()`
|
|
144
|
-
*
|
|
145
|
-
* @returns {VuePlugin} A plugin matching the Vue@3 spec
|
|
146
150
|
*/
|
|
147
151
|
install(app, options) {
|
|
148
152
|
let settings = {
|
package/utils/pathTools.js
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
* General path setters / getters for project state
|
|
12
12
|
* These are _MAINLY_ wrappers for Lodash functionality such as Lodash.set() / Lodash.get(), any deviations are documented inline
|
|
13
13
|
*
|
|
14
|
-
* @typedef {PathTools}
|
|
15
14
|
* In each case these functions work with either dotted or array notation against a target master-object
|
|
16
15
|
* - Dotted notation - e.g. `foo.bar.1.baz`
|
|
17
16
|
* - Array path segments e.g. `['foo', 'bar', 1, 'baz']`
|
|
@@ -77,8 +76,8 @@ export function set(target, path, value, options) {
|
|
|
77
76
|
* @param {*} [fallback] Optional fallback to return if the end point does not exist
|
|
78
77
|
* @returns {*} The fetched value
|
|
79
78
|
*/
|
|
80
|
-
export function get(
|
|
81
|
-
return _get(
|
|
79
|
+
export function get(target, path, fallback) {
|
|
80
|
+
return _get(target, path, fallback);
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
|
|
@@ -132,6 +131,7 @@ export function defaults(target, path, value) {
|
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
133
|
|
|
134
|
+
|
|
135
135
|
// Export all functions as a lookup object
|
|
136
136
|
export default {
|
|
137
137
|
set,
|
|
@@ -55,7 +55,7 @@ export default {
|
|
|
55
55
|
* Trigger the file selection functionality within TERA-fy
|
|
56
56
|
* This sets the `selected` data property to the newly selected file + fires @change
|
|
57
57
|
*
|
|
58
|
-
* @
|
|
58
|
+
* @emits change Fired as `(file:ProjectFile)` when the contents changes
|
|
59
59
|
* @returns {ProjectFile} file The selected file
|
|
60
60
|
*/
|
|
61
61
|
async choose() {
|