/*! For license information please see ething.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EThing=t():e.EThing=t()}(this,(()=>{return e={669:(e,t,r)=>{e.exports=r(609)},448:(e,t,r)=>{"use strict";var n=r(867),o=r(26),i=r(327),s=r(109),a=r(985),u=r(61);e.exports=function(e){return new Promise((function(t,c){var f=e.data,p=e.headers;n.isFormData(f)&&delete p["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",h=e.auth.password||"";p.Authorization="Basic "+btoa(d+":"+h)}if(l.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l.onreadystatechange=function(){if(l&&4===l.readyState&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in l?s(l.getAllResponseHeaders()):null,n={data:e.responseType&&"text"!==e.responseType?l.response:l.responseText,status:l.status,statusText:l.statusText,headers:r,config:e,request:l};o(t,c,n),l=null}},l.onerror=function(){c(u("Network Error",e,null,l)),l=null},l.ontimeout=function(){c(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",l)),l=null},n.isStandardBrowserEnv()){var y=r(372),g=(e.withCredentials||a(e.url))&&e.xsrfCookieName?y.read(e.xsrfCookieName):void 0;g&&(p[e.xsrfHeaderName]=g)}if("setRequestHeader"in l&&n.forEach(p,(function(e,t){void 0===f&&"content-type"===t.toLowerCase()?delete p[t]:l.setRequestHeader(t,e)})),e.withCredentials&&(l.withCredentials=!0),e.responseType)try{l.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){l&&(l.abort(),c(e),l=null)})),void 0===f&&(f=null),l.send(f)}))}},609:(e,t,r)=>{"use strict";var n=r(867),o=r(849),i=r(321),s=r(655);function a(e){var t=new i(e),r=o(i.prototype.request,t);return n.extend(r,i.prototype,t),n.extend(r,t),r}var u=a(s);u.Axios=i,u.create=function(e){return a(n.merge(s,e))},u.Cancel=r(263),u.CancelToken=r(972),u.isCancel=r(502),u.all=function(e){return Promise.all(e)},u.spread=r(713),e.exports=u,e.exports.default=u},263:e=>{"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},972:(e,t,r)=>{"use strict";var n=r(263);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},502:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:(e,t,r)=>{"use strict";var n=r(655),o=r(867),i=r(782),s=r(572);function a(e){this.defaults=e,this.interceptors={request:new i,response:new i}}a.prototype.request=function(e){"string"==typeof e&&(e=o.merge({url:arguments[0]},arguments[1])),(e=o.merge(n,{method:"get"},this.defaults,e)).method=e.method.toLowerCase();var t=[s,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},o.forEach(["delete","get","head","options"],(function(e){a.prototype[e]=function(t,r){return this.request(o.merge(r||{},{method:e,url:t}))}})),o.forEach(["post","put","patch"],(function(e){a.prototype[e]=function(t,r,n){return this.request(o.merge(n||{},{method:e,url:t,data:r}))}})),e.exports=a},782:(e,t,r)=>{"use strict";var n=r(867);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},61:(e,t,r)=>{"use strict";var n=r(481);e.exports=function(e,t,r,o,i){var s=new Error(e);return n(s,t,r,o,i)}},572:(e,t,r)=>{"use strict";var n=r(867),o=r(527),i=r(502),s=r(655),a=r(793),u=r(303);function c(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return c(e),e.baseURL&&!a(e.url)&&(e.url=u(e.baseURL,e.url)),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return c(e),t.data=o(t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(c(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:e=>{"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e}},26:(e,t,r)=>{"use strict";var n=r(61);e.exports=function(e,t,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},527:(e,t,r)=>{"use strict";var n=r(867);e.exports=function(e,t,r){return n.forEach(r,(function(r){e=r(e,t)})),e}},655:(e,t,r)=>{"use strict";var n=r(867),o=r(16),i={"Content-Type":"application/x-www-form-urlencoded"};function s(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var a,u={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process)&&(a=r(448)),a),transformRequest:[function(e,t){return o(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(s(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(s(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};n.forEach(["delete","get","head"],(function(e){u.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){u.headers[e]=n.merge(i)})),e.exports=u},849:e=>{"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n{"use strict";var n=r(867);function o(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(n.isURLSearchParams(t))i=t.toString();else{var s=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}return i&&(e+=(-1===e.indexOf("?")?"?":"&")+i),e}},303:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},372:(e,t,r)=>{"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},793:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},985:(e,t,r)=>{"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},16:(e,t,r)=>{"use strict";var n=r(867);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},109:(e,t,r)=>{"use strict";var n=r(867),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,i,s={};return e?(n.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=n.trim(e.substr(0,i)).toLowerCase(),r=n.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([r]):s[t]?s[t]+", "+r:r}})),s):s}},713:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},867:(e,t,r)=>{"use strict";var n=r(849),o=r(778),i=Object.prototype.toString;function s(e){return"[object Array]"===i.call(e)}function a(e){return null!==e&&"object"==typeof e}function u(e){return"[object Function]"===i.call(e)}function c(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),s(e))for(var r=0,n=e.length;r{e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},386:e=>{e.exports=function(e,t){if("string"!=typeof e)throw new TypeError("Expected a string");for(var r,n=String(e),o="",i=!!t&&!!t.extended,s=!!t&&!!t.globstar,a=!1,u=t&&"string"==typeof t.flags?t.flags:"",c=0,f=n.length;c1)||"/"!==p&&void 0!==p||"/"!==d&&void 0!==d?o+="([^/]*)":(o+="((?:[^/]*(?:/|$))*)",c++):o+=".*";break;default:o+=r}return u&&~u.indexOf("g")||(o="^"+o+"$"),new RegExp(o,u)}},385:(e,t,r)=>{var n=r(895),o=(r(555),r(214),r(386));n.on("ething.resource.removed",(function(e,t){var r=n.arbo.get(t);r&&n.arbo.remove(r)})),n.arbo={resources:[],loaddfr:null,load:function(e,t){var r=this;return(null===this.loaddfr||t)&&(this.loaddfr=n.request({url:"/resources",method:"GET",dataType:"json"}).then((function(e){return r.loaddfr=!0,r.resources.splice(0,r.resources.length),e.map((function(e){return n.instanciate(e)})).filter((function(e){return!!e})).forEach((function(e){r.resources.push(e)})),n.trigger("ething.arbo.loaded"),r.resources}))),this.loaddfr.then((function(t){"function"==typeof e&&e.call(r,t)})),this.loaddfr},lastRefreshTs:0,refresh:function(e){var t=this;return this.lastRefreshTs=Date.now(),n.request({url:"/resources",method:"GET",dataType:"json"}).then((function(r){return r=r.map((function(e){return n.instanciate(e)})).filter((function(e){return e})),t.update(r,!0),"function"==typeof e&&e.call(t,t.resources),t.resources}))},remove:function(e,t){if(Array.isArray(e))e.forEach((function(e){remove(e,t)}));else if("string"!=typeof e||(e=this.get(e))){for(var r=[],o=0;o0||s.length>0||a.length>0;return!r&&u&&n.trigger("ething.arbo.changed",[s,i,a]),{resources:e,removed:i,added:s,updated:a,hasChanged:u}},get:function(e){for(var t=0;t{var n=r(555),o=r(895);function i(){}function s(){}function a(e,t){this.login=e,this.password=t}function u(e){this.apikey=e}i.prototype.install=function(){},i.prototype.uninstall=function(){},i.prototype.set=function(e){},i.prototype.setUrl=function(e){return e},n.inherits(s,i),n.inherits(a,i),a.prototype.install=function(){o.axios.defaults.auth={username:this.login,password:this.password}},a.prototype.uninstall=function(){o.axios.defaults.auth={}},a.prototype.setUrl=function(e){return e.replace(/\/\/([^:]+:)?[^@]+@/,"//").replace(/\/\//,"//"+login+":"+password+"@")},n.inherits(u,i),u.prototype.install=function(){o.axios.defaults.headers.common["X-API-KEY"]=this.apikey},u.prototype.uninstall=function(){delete o.axios.defaults.headers.common["X-API-KEY"]},u.prototype.setUrl=function(e){return n.insertParam(e,"api_key",this.apiey)};var c=null,f={instance:function(){return c},isAuthenticated:function(){return!(c instanceof s)},install:function(e){c&&c.uninstall(),(c=e).install()},reset:function(){this.install(new s)},setApiKey:function(e){this.install(new u(e))},setBasicAuth:function(e,t){this.install(new a(e,t))}};f.reset(),o.auth=f,e.exports=f},895:(e,t,r)=>{var n=r(555),o=r(592),i=r(797),s=r(669),a={};n.extend,n.isPlainObject,a.Event=o,a.utils=n,a.axios=s.create({}),a.config={serverUrl:"http://localhost:8000"},a.pairing=!1,i(a),a.toApiUrl=function(e,t){return/^([a-z]+:)?\/\//.test(e=e||"")||(!/^\//.test(e)&&e&&(e="/"+e),e=c()+e),t&&u(e)&&(e=this.auth.instance().setUrl(e)),e};var u=function(e){return new RegExp("^([a-z]+:)?//"+c().replace(/^([a-z]+:)?\/\//,"")).test(e)},c=function(){return a.config.serverUrl.replace(/\/+$/,"")+"/api"};a.apiUrl=function(){return a.toApiUrl()},a.instanciate=function(e){for(var t in e.extends){var r=e.extends[t].split("/").pop();if(void 0!==a[r])return new a[r](e)}return console.warn("unknown type: "+e.type),new a.Resource(e)},a.resourceConverter=function(e){if("object"==typeof e&&null!==e){var t=Array.isArray(e);t||(e=[e]),e=e.map((function(e){return a.instanciate(e)})).filter((function(e){return e})),a.arbo&&(e=a.arbo.update(e).resources),t||(e=e.length?e[0]:null)}return e},a.request=function(e,t){var r=this;"string"==typeof e&&(e={url:e});var n=Object.assign({method:"GET",context:this,url:null,data:null,contentType:null,headers:null,dataType:"json",converter:null,params:{}},e);return this.auth.instance().set(n),n.contentType&&(n.headers=n.headers||{},n.headers["content-type"]=n.contentType),this.axios.request({url:n.url,baseURL:this.apiUrl(),method:n.method.toLowerCase(),params:n.params,data:n.data,responseType:n.dataType.toLowerCase(),headers:n.headers}).then((function(e){var t=e.data;if(n.converter)try{t=n.converter.call(n.context,t)}catch(e){return Promise.reject(String(e))}return Promise.resolve(t)}),(function(e){return e.response?new Promise((function(t,r){var n=e.response.data,o=e.config.responseType;function i(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){return void r("invalid JSON data")}t(e)}switch(o){case"text":i(n);break;case"json":t(n);break;case"blob":if("undefined"==typeof FileReader)return void r("FileReader not supported.");var s=new FileReader;s.onload=function(){i(String.fromCharCode.apply(null,new Uint8Array(this.result)))},s.readAsArrayBuffer(n);break;case"arraybuffer":i(String.fromCharCode.apply(null,new Uint8Array(n)));break;case"buffer":i(n.toString("utf8"));break;default:r(o+" response type not supported.")}})).then((function(e){return Promise.reject(e.message)}),(function(e){return Promise.reject(e)})):e.request?Promise.reject("no response from the server"):(console.log("Error",e.message),Promise.reject(e.message||"invalid request"))})).then((function(e){return r.trigger("ething.request.success",[e]),"function"==typeof t&&t.call(r,e,!1),e}),(function(e){return r.trigger("ething.request.error",[e]),"function"==typeof t&&t.call(r,null,e),Promise.reject(e)}))},a.list=a.find=function(e,t){var r=null,o=null;return 1==arguments.length?"function"==typeof arguments[0]?o=arguments[0]:r=arguments[0]:arguments.length>=2&&(r=arguments[0],o=arguments[1]),a.request({url:"/resources?"+n.param({q:r}),method:"GET",dataType:"json",converter:a.resourceConverter},o)},a.get=function(e,t){var r;if(e instanceof a.Resource)r=e,e=e.id();else if(!n.isId(e))throw"First argument must be a Resource object or a Resource id : "+e;var o=t;return a.request({url:"/resources/"+e,dataType:"json",method:"GET",context:r,converter:a.resourceConverter},o)},a.startPairing=function(e){return a.request({url:"/start_pairing",dataType:"json",method:"POST"},e)},a.stopPairing=function(e){return a.request({url:"/stop_pairing",dataType:"json",method:"POST"},e)},a.dispatch=function(e){var t,r,n,i=e.type,s=!!e.resource,u=o(i,{data:e.data,originalEvent:e}),c=a.arbo;if(s)c&&("string"==typeof e.resource?(r=e.resource,n={}):(r=e.resource.id,n=e.resource),"signals/ResourceDeleted"===i?c.remove(r):"signals/ResourceCreated"===i?c.update(a.instanciate(n)):"signals/ResourceUpdated"===i&&(t=c.get(r))&&t._fromJson(n),t||(t=c.get(r)),t&&(u.resource=t,t.trigger(u)));else if("signals/PluginUpdated"===i){var f=a.Plugin._updateFromJson(e.plugin);f&&(u.plugin=f,f.trigger(u))}else"signals/PairingUpdated"===i&&(a.pairing=!!e.data.state);a.trigger(u)},e.exports=a},83:(e,t,r)=>{var n=r(895),o=r(555),i=r(214),s=function(e){i.call(this,e)};o.inherits(s,i),s.prototype.location=function(){return this._json.location||""},s.prototype.connected=function(){return!!this._json.connected},s.prototype.lastSeenDate=function(){return"string"==typeof this._json.lastSeenDate?new Date(this._json.lastSeenDate):null},s.prototype.hasBattery=function(){return"number"==typeof this._json.battery&&this._json.battery>=0},s.prototype.battery=function(){return this.hasBattery()?this._json.battery:null},s.create=function(e,t,r){return i.create(Object.assign({type:e},t),r).then((function(e){return n.trigger("ething.device.created",[e]),e}))},n.Device=s,e.exports=s},977:(e,t,r)=>{var n=r(895);n.VERSION="0.1.26",r(214),r(451),r(648),r(810),r(700),r(98),r(83),r(385),r(326),e.exports=n},592:(e,t,r)=>{var n=r(555);function o(){return!0}function i(){return!1}var s=function(e,t){if(!(this instanceof s))return new s(e,t);this.type=e,t&&n.extend(this,t),this.timeStamp=Date.now()};s.prototype={constructor:s,isDefaultPrevented:i,isPropagationStopped:i,isImmediatePropagationStopped:i,preventDefault:function(){this.isDefaultPrevented=o},stopPropagation:function(){this.isPropagationStopped=o},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=o,this.stopPropagation()}},e.exports=s},797:(e,t,r)=>{var n=r(592);e.exports=function(e){var t={};e.on=function(e,r){if("function"==typeof r){e=e.split(" ");for(var n=0;n{var n=r(895),o=r(555),i=r(214),s=function(e){i.call(this,e)};o.inherits(s,i),s.prototype.size=function(){return this._json.size},s.prototype.mime=function(){return this._json.mime},s.prototype.contentModifiedDate=function(){return new Date(this._json.contentModifiedDate)},s.prototype.getContentUrl=function(e){return n.toApiUrl("files/"+this.id(),e)},s.prototype.read=function(e,t){var r=[].slice.call(arguments);return r.unshift(this),s.read.apply(n,r)},s.prototype.write=function(e,t){var r=[].slice.call(arguments);return r.unshift(this),s.write.apply(n,r)},s.create=function(e,t){"string"==typeof e&&(e={name:e});var r=Object.assign({type:"resources/File"},e),o=r.content;return delete r.content,p=new Promise((function(e,t){i.create(r).then((function(r){n.trigger("ething.file.created",[r]),o?s.write(r,o).then((function(t){e(t)})).catch((function(e){t(e)})):e(r)})).catch((function(e){t(e)}))})),t&&p.then((function(e){t.call(n,e,!1)})).catch((function(e){t.call(n,null,e)})),p},s.read=function(e,t,r){var i;if(e instanceof s)i=e,e=e.id();else if(!o.isId(e))throw"First argument must be a File object or a file id !";return void 0===r&&"function"==typeof t&&(r=t,t=!1),n.request({url:"/files/"+e,method:"GET",dataType:t?"string"==typeof t?t:"arraybuffer":"text",context:i},r)},s.write=function(e,t,r){var i,a=null;if(e instanceof s)i=e,a=e.id();else{if(!o.isId(e))throw"First argument must be a File object or a file id !";a=e}var u=r;return n.request({url:"/files/"+a,dataType:"json",method:"PUT",contentType:"string"==typeof t?"text/plain":"application/octet-stream",data:t,context:i,converter:n.resourceConverter},u)},n.File=s,e.exports=s},98:(e,t,r)=>{var n=r(895),o=r(555),i=r(214),s=function(e){i.call(this,e)};o.inherits(s,i),s.prototype.nodes=function(){return this._json.nodes},s.prototype.connections=function(){return this._json.connections},s.prototype.deploy=function(e){var t=[].slice.call(arguments);return t.unshift(this),s.deploy.apply(n,t)},s.create=function(e,t){return i.create(Object.assign({type:"resources/Flow"},e),t).then((function(e){return n.trigger("ething.flow.created",[e]),e}))},s.deploy=function(e,t){var r,i=null;if(e instanceof s)r=e,i=e.id();else{if(!o.isId(e))throw"First argument must be a Flow object or a flow id !";i=e}var a=t;return n.request({url:"/flows/"+i+"/deploy",method:"GET",dataType:"text",context:r},a)},n.Flow=s,e.exports=s},326:(e,t,r)=>{var n=r(895),o=r(555),i=r(797),s=function(e){i(this),this._json={},this._fromJson(e,!0)};s.prototype._fromJson=function(e,t){var r=[];!t&&i&&Object.keys(e).forEach((function(t){void 0===this._json[t]||o.isEqual(e[t],this._json[t])||r.push(t)}),this);var i=r.length>0;return Object.assign(this._json,e),!t&&i&&(this.trigger("updated",[r]),n.trigger("ething.plugin.updated",[this,r])),i},s.prototype.name=function(){return this._json.name},s.prototype.type=function(){return this._json.type},s.prototype.attr=function(e,t){return void 0===e?this._json:(void 0===t&&(t=null),this._json.hasOwnProperty(e)?this._json[e]:t)},s.prototype.execute=function(){var e=[].slice.call(arguments);return e.unshift(this),s.execute.apply(n,e)},s.prototype.executeUrl=function(e,t){var r="plugins/"+this.id()+"/call/"+e;return o.isPlainObject(t)&&0!==Object.keys(t).length&&(r+="?"+o.param(t)),n.toApiUrl(r,!0)},s.prototype.set=function(e,t){var r=[].slice.call(arguments);return r.unshift(this),s.set.apply(n,r)},s.list=function(e){return n.request({url:"/plugins",method:"GET",dataType:"json",converter:s._updateFromJson},e)},s.set=function(e,t,r){var i;if(!o.isPlainObject(t)||!t)throw"Second argument must be a unempty object !";if(e instanceof s)i=e,e=e.name();else if("string"!=typeof e)throw"First argument must be a Plugin object or a Plugin name : "+e;var a=r;return n.request({url:"/plugins/"+e,dataType:"json",method:"POST",contentType:"application/json; charset=utf-8",data:t,context:i,headers:{"X-HTTP-Method-Override":"PATCH"},converter:s._updateFromJson},a)},s.execute=function(e,t,r,o,i){var a;if(e instanceof s)a=e,e=e.name();else if("string"==typeof e)throw"First argument must be a Resource object or a Resource id !";return 4==arguments.length?"function"==typeof o&&(i=o,o=void 0):3==arguments.length&&"function"==typeof r&&(i=r,r=void 0),n.request({url:"/plugins/"+e+"/call/"+t,method:"POST",contentType:"application/json; charset=utf-8",data:null!=r?JSON.stringify(r):void 0,dataType:o?"string"==typeof o?o:"arraybuffer":"text",context:a},i)},s.plugins={},s._updateFromJson=function(e){if("object"==typeof e&&null!==e){var t=Array.isArray(e);t||(e=[e]),e=e.map((function(e){var t=e.name,r=s.plugins[t];return r?r._fromJson(e):(r=new s(e),s.plugins[t]=r),r})),t||(e=e.length?e[0]:null)}return e},n.Plugin=s,e.exports=s},214:(e,r,n)=>{var o=n(555),i=n(797),s=n(895),a=function(e){i(this),this._json={},this._fromJson(e,!0)};a.prototype._fromJson=function(e,t){var r=this._json.modifiedDate&&e.modifiedDate&&this._json.modifiedDate!==e.modifiedDate,n=[];return!t&&r&&Object.keys(e).forEach((function(t){void 0===this._json[t]||o.isEqual(e[t],this._json[t])||n.push(t)}),this),Object.assign(this._json,e),!t&&r&&(this.trigger("updated",[n]),s.trigger("ething.resource.updated",[this,n])),r},a.prototype.json=function(){return this._json},a.prototype.isTypeof=function(e){return-1!==this._json.extends.indexOf(e)},a.prototype.name=function(){return this._json.name},a.prototype.dirname=function(){return s.Resource.dirname(this._json.name)},a.prototype.basename=function(){return s.Resource.basename(this._json.name)},a.prototype.extension=function(){return s.Resource.extension(this._json.name)},a.prototype.id=function(){return this._json.id},a.prototype.createdBy=function(){return this._json.createdBy},a.prototype.type=function(){return this._json.type},a.prototype.types=function(){return this._json.extends.slice()},a.prototype.baseType=function(){return t=this.types(),t[t.length-1]},a.prototype.createdDate=function(){return new Date(this._json.createdDate)},a.prototype.ctime=function(){return this.createdDate()},a.prototype.modifiedDate=function(){return new Date(this._json.modifiedDate)},a.prototype.mtime=function(){return this.modifiedDate()},a.prototype.data=function(e,t){return void 0===e?this._json.data:this._json.data.hasOwnProperty(e)?this._json.data[e]:t},a.prototype.attr=function(e,t){return void 0===e?this._json:(void 0===t&&(t=null),this._json.hasOwnProperty(e)?this._json[e]:t)},a.prototype.hasAttr=function(e){return this._json.hasOwnProperty(e)},a.prototype.description=function(){return this._json.description||""},a.prototype.remove=function(e){var t=[].slice.call(arguments);return t.unshift(this),a.remove.apply(s,t)},a.prototype.update=function(e){return s.get(this,e)},a.prototype.set=function(e,t){var r=[].slice.call(arguments);return r.unshift(this),a.set.apply(s,r)},a.prototype.setData=function(e,t){if("string"==typeof e&&"function"!=typeof t){var r=e,n=t;t=arguments[2],(e={})[r]=n}return this.set({data:e},t)},a.prototype.execute=function(){var e=[].slice.call(arguments);return e.unshift(this),a.execute.apply(s,e)},a.prototype.executeUrl=function(e,t){var r="resources/"+this.id()+"/call/"+e;return o.isPlainObject(t)&&0!==Object.keys(t).length&&(r+="?"+o.param(t)),s.toApiUrl(r,!0)},a.create=function(e,t){if(void 0===e.type)throw"type attribute is mandatory !";return s.request({url:"/resources",dataType:"json",method:"POST",contentType:"application/json; charset=utf-8",data:e,converter:s.resourceConverter},t).then((function(e){return s.trigger("ething.resource.created",[e]),e}))},a.remove=function(e,t){var r;if(e instanceof a)r=e,e=e.id();else if(!o.isId(e))throw"First argument must be a Resource object or a Resource id : "+e;return s.request({url:"/resources/"+e,method:"DELETE",context:r},t).then((function(){s.trigger("ething.resource.removed",[e])}))},a.set=function(e,t,r){var n;if(!o.isPlainObject(t)||!t)throw"Second argument must be a unempty object !";if(e instanceof a)n=e,e=e.id();else if(!o.isId(e))throw"First argument must be a Resource object or a Resource id : "+e;var i=r;return s.request({url:"/resources/"+e,dataType:"json",method:"POST",contentType:"application/json; charset=utf-8",data:t,context:n,headers:{"X-HTTP-Method-Override":"PATCH"},converter:s.resourceConverter},i)},a.execute=function(e,t,r,n,i){var u;if(e instanceof a)u=e,e=e.id();else if(!o.isId(e))throw"First argument must be a Resource object or a Resource id !";return 4==arguments.length?"function"==typeof n&&(i=n,n=void 0):3==arguments.length&&"function"==typeof r&&(i=r,r=void 0),s.request({url:"/resources/"+e+"/call/"+t,method:"POST",contentType:"application/json; charset=utf-8",data:null!=r?JSON.stringify(r):void 0,dataType:n?"string"==typeof n?n:"arraybuffer":"text",context:u},i)},a.dirname=function(e){var t=e.replace(/\/[^\/]*\/?$/,"");return t===e?"":t},a.basename=function(e){return e.replace(/.*\//,"")},a.extension=function(e){return e.indexOf(".")>=0?e.split(".").pop():""},a.fnmatch=function(e,t){for(var r,n,o=e.split(" "),i=0;i{var n=r(895),o=r(555),i={get:function(e){return n.request({url:"/settings",dataType:"json",method:"GET"},e)},set:function(e,t){if(!o.isPlainObject(e))throw"First argument must be an object !";return n.request({url:"/settings",dataType:"json",method:"POST",contentType:"application/json; charset=utf-8",data:e,headers:{"X-HTTP-Method-Override":"PATCH"}},t)}};n.settings=i,e.exports=i},700:(e,t,r)=>{var n=r(895),o=r(555),i=r(214),s=function(e){i.call(this,e)};o.inherits(s,i),s.prototype.length=function(){return this._json.length},s.prototype.maxLength=function(){return this._json.maxLength},s.prototype.keys=function(){var e=[];for(var t in this._json.keys)this._json.keys.hasOwnProperty(t)&&e.push(t);return e},s.prototype.contentModifiedDate=function(){return new Date(this._json.contentModifiedDate)},s.prototype.select=function(e,t){var r=[].slice.call(arguments);return r.unshift(this),s.select.apply(n,r)},s.prototype.computeStatistics=function(e,t,r){var o=[].slice.call(arguments);return o.unshift(this),s.computeStatistics.apply(n,o)},s.prototype.removeRow=function(e,t){var r=[].slice.call(arguments);return r.unshift(this),s.removeRow.apply(n,r)},s.prototype.replaceRow=function(e,t){var r=[].slice.call(arguments);return r.unshift(this),s.replaceRow.apply(n,r)},s.prototype.findOneAndReplace=function(e,t,r,o){var i=[].slice.call(arguments);return i.unshift(this),s.findOneAndReplace.apply(n,i)},s.prototype.insert=function(e,t){var r=[].slice.call(arguments);return r.unshift(this),s.insert.apply(this,r)},s.prototype.import=function(e,t){var r=[].slice.call(arguments);return r.unshift(this),s.import.apply(this,r)},s.prototype.getContentUrl=function(e){return n.toApiUrl("tables/"+this.id(),e)},s.create=function(e,t){return"string"==typeof e&&(e={name:e}),i.create(Object.assign({type:"resources/Table"},e),t).then((function(e){return n.trigger("ething.table.created",[e]),e}))},s.select=function(e,t,r){var i,a=null;if(e instanceof s)i=e,a=e.id();else{if(!o.isId(e))throw"First argument must be a Table object or a table id !";a=e}return void 0===r&&"function"==typeof t&&(r=t,t=null),t=t||{},Array.isArray(t.fields)&&(t.fields=t.fields.join(",")),n.request({url:"/tables/"+a+"?"+o.param({start:t.start,length:t.length,sort:t.sort,q:t.query,fields:t.fields,datefmt:t.datefmt}),method:"GET",dataType:"json",context:i},r)},s.computeStatistics=function(e,t,r,i){var a,u=null;if(e instanceof s)a=e,u=e.id();else{if(!o.isId(e))throw"First argument must be a Table object or a table id !";u=e}return void 0===i&&"function"==typeof r&&(i=r,r=null),n.request({url:"/tables/"+u+"/statistics?"+o.param({key:t,q:r}),method:"GET",dataType:"json",context:a},i)},s.removeRow=function(e,t,r){var i,a=null;if(e instanceof s)i=e,a=e.id();else{if(!o.isId(e))throw"First argument must be a Table object or a table id !";a=e}var u=Array.isArray(t)?t:[t],c=r;return n.request({url:"/tables/"+a+"/remove",dataType:"json",method:"POST",contentType:"application/json; charset=utf-8",data:u,context:i,converter:n.resourceConverter},c)},s.replaceRow=function(e,t,r){var i,a=null;if(e instanceof s)i=e,a=e.id();else{if(!o.isId(e))throw"First argument must be a Table object or a table id !";a=e}if("object"==typeof t&&!o.isId(t.id))throw"Second argument must be an object containing at least a document id";var u=t.id,c=r;return n.request({url:"/tables/"+a+"/id/"+u,dataType:"json",method:"POST",contentType:"application/json; charset=utf-8",data:t,context:i,headers:{"X-HTTP-Method-Override":"PATCH"}},c)},s.findOneAndReplace=function(e,t,r,i,a){var u,c=null,f=a,p=!1;if(e instanceof s)u=e,c=e.id();else{if(!o.isId(e))throw"First argument must be a Table object or a table id !";c=e}if("string"!=typeof t)throw"Second argument must be a query string";if("object"!=typeof r)throw"Third argument must be an object";return void 0===a&&"function"==typeof i&&(f=i,p=!1),"boolean"==typeof i&&(p=i),n.request({url:"/tables/"+c+"/replace?"+o.param({q:t,upsert:p}),dataType:"json",method:"POST",contentType:"application/json; charset=utf-8",data:r,context:u,converter:n.resourceConverter},f)},s.insert=function(e,t,r,i){var a,u,c,f=null;if(e instanceof s)u=e,f=e.id();else{if(!o.isId(e))throw"First argument must be a Table object or a table id !";f=e}return"string"==typeof r?(c=r,a=i):a=r,n.request({url:"/tables/"+f+"?"+o.param({invalid_field:c}),dataType:"json",method:"POST",contentType:"application/json; charset=utf-8",data:t,context:u,converter:n.resourceConverter},a)},s.import=function(e,t){var r,i,a,u;if(e instanceof s)r=e,e=e.id();else if(!o.isId(e))throw"First argument must be a Table object or a table id !";if(!Array.isArray(t))throw"The data must be an array of objects";for(var c=2;c{var t={};function r(e,t,n){var o;if(Array.isArray(t))for(var i in t){var s=t[i];/\[\]$/.test(e)?n(e,s):r(e+"["+("object"==typeof s?i:"")+"]",s,n)}else if("object"==typeof t)for(o in t)r(e+"["+o+"]",t[o],n);else n(e,t)}t.isId=function(e){return"string"==typeof e&&7===e.length&&/^[0-9a-zA-Z\-_]+$/.test(e)},t.parseUrl=function(e){var t=/^((([a-z]+):)?\/\/)?(([^:]*)(:([^@]*))?@)?([^:\/?#]+)?(:([0-9]+))?([^?#]+)?(\?[^#]*)?(#.*)?$/i.exec(e);return!!t&&{scheme:t[3],user:t[5],password:t[7],hostname:t[8],port:t[10],path:t[11],search:t[12],hash:t[13]}},t.getParam=function(e,t){var r=e.indexOf("?"),n=new RegExp("[\\?&]"+encodeURIComponent(t)+"=([^&#]*)"),o=-1!==r?n.exec(e.substr(r)):null;return null===o?"":decodeURIComponent(o[1])},t.getQueryString=function(e,t){var r=e.indexOf("?"),n=new RegExp("[\\?&]"+encodeURIComponent(t)+"=([^&#]*)"),o=-1!==r?n.exec(e.substr(r)):null;return null===o?"":decodeURIComponent(o[1])},t.removeParam=function(e,t){var r=e.split("?");if(r.length>=2){var n=r[1].indexOf("#"),o="";-1!==n&&(o=r[1].substr(n),r[1]=r[1].substr(0,n));for(var i=encodeURIComponent(t)+"=",s=r[1].split(/[&;]/g),a=s.length;a-- >0;)-1!==s[a].lastIndexOf(i,0)&&s.splice(a,1);return r[0]+(s.length>0?"?"+s.join("&"):"")+o}return e},t.insertParam=function(e,r,n){var o=(e=t.removeParam(e,r)).indexOf("#"),i="";-1!==o&&(i=e.substr(o),e=e.substr(0,o));var s=e.indexOf("?"),a="";return-1!==s&&(a=e.substr(s),e=e.substr(0,s)),a+=a.length?"&":"?",e+(a+=encodeURIComponent(r)+"="+encodeURIComponent(n))+i},t.param=function(e){var t,n=[],o=function(e,t){t="function"==typeof t?t():null==t?"":t,n[n.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};for(t in e)null!==e[t]&&void 0!==e[t]&&r(t,e[t],o);return n.join("&").replace(/%20/g,"+")};var n=t.pad=function(e,t,r){return r=r||"0",(e+="").length>=t?e:new Array(t-e.length+1).join(r)+e};t.sizeToString=function(e){return e=parseInt(e),isNaN(e)?"-":(e>9e8?e=Math.floor(e/1e9*100)/100+" GB":e>9e5?e=Math.floor(e/1e6*100)/100+" MB":e>900?e=Math.floor(e/1e3*100)/100+" KB":e+=" B",e)},t.dateToString=function(e){var t=new Date;if("number"==typeof e&&(e=new Date(1e3*e)),e){if(t.getTime()-e.getTime()<864e5)return n(e.getHours(),2)+":"+n(e.getMinutes(),2);var r=e.getFullYear(),o=e.getDate(),i=e.getMonth();return r==t.getFullYear()?o+" "+new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[i]+".":r+"/"+n(i+1,2)+"/"+n(o,2)}return"-"},t.dateDiffToString=function(e){if(e=parseInt(e),isNaN(e))return"-";var t,r=604800,n=0,o="";return(t=Math.floor(e/r))>=1&&n<2&&(o+=Math.floor(t)+" week"+(t>1?"s":""),e-=t*r,n++),(t=Math.floor(e/86400))>=1&&n<2&&(n&&(o+=" "),o+=Math.floor(t)+" day"+(t>1?"s":""),e-=86400*t,n++),(t=Math.floor(e/3600))>=1&&n<2&&(n&&(o+=" "),o+=Math.floor(t)+" hour"+(t>1?"s":""),e-=3600*t,n++),(t=Math.floor(e/60))>=1&&n<2&&(n&&(o+=" "),o+=Math.floor(t)+" minute"+(t>1?"s":""),e-=60*t,n++),(t=e)>=1&&n<2&&(n&&(o+=" "),o+=Math.floor(t)+" seconde"+(t>1?"s":""),n++),o};var o={},i=o.toString,s=o.hasOwnProperty;"Boolean Number String Function Array Date RegExp Object Error Symbol".split(" ").forEach((function(e){o["[object "+e+"]"]=e.toLowerCase()})),t.type=function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?o[i.call(e)]||"object":typeof e},t.isPlainObject=function(e){var r;if("object"!==t.type(e)||e.nodeType||null!=e&&e===e.window)return!1;try{if(e.constructor&&!s.call(e,"constructor")&&!s.call(e.constructor.prototype||{},"isPrototypeOf"))return!1}catch(e){return!1}for(r in e);return void 0===r||s.call(e,r)},t.extend=function(){var e,r,n,o,i,s,a=arguments[0]||{},u=1,c=arguments.length,f=!1;for("boolean"==typeof a&&(f=a,a=arguments[1]||{},u=2),"object"!=typeof a&&"function"!=typeof a&&(a={}),c===u&&(a=this,--u);u